Home Database Mysql Tutorial MySQL Thread Pool: Problem Definition

MySQL Thread Pool: Problem Definition

May 31, 2016 am 08:47 AM

A new thread pool plugin is now a part of the MySQL Enterprise Edition.

In this blog we will cover the problem that the thread pool is solving

and some high-level description of how it solves this problem.

In the traditional MySQL server model there is a one-to-one mapping between

thread and connection. Even the MySQL server has lots of code where thread

or some abbreviation of thread is actually representing a connection.

Obviously this mapping has served MySQL very well over the years, but there

are some cases where this model don't work so well.

One such case is where there are much more connections executing queries

simultaneously compared to the number of CPUs available in the server. The

MySQL Server also have scalability bottlenecks where performance suffers

when too many connections execute in parallel.

So effectively there are two reasons that can make performance suffer in

the original MySQL Server model.

The first is that many connections executing in parallel means that the

amount of data that the CPUs work on increases. This will decrease the

CPU cache hit rates. Lowering the CPU cache hit rate can have a significant

negative impact on server performance. Actually in some cases the amount

of memory allocated by the connections executing in parallel could at times

even supersede the memory available in the server. In this case we enter a

state called swapping which is very detrimental to performance.

The second problem is that the number of parallel queries and transactions

can have a negative impact on the throughput through the "critical sections"

of the MySQL Server (critical section is where mutexes are applied to

ensure only one CPU changes a certain data structure at a time, when such

a critical section becomes a scalability problem we call it a hot spot).

Statements that writes are more affected since they use more critical

sections.

Neither of those problems can be solved in the operating system scheduler.

However there are some operating systems that have attempted solving this

problem for generic applications on a higher level in the operating system.

Both of those problems have the impact that performance suffers more and

more as the number of statements executed in parallel increases.

In addition there are hot spots where the mutex is held for a longer time

when many concurrent statements and/or transactions are executed in

parallel. One such example is the transaction list in InnoDB where each

transaction is listed in a linked list. Thus when the number of concurrent

transactions increases the time to scan the list increases and the time

holding the lock increases and thus the hot spot becomes even hotter

as the concurrency increases.

Current solutions to these issues exist in InnoDB through use of the

configuration parameter --innodb-thread-concurrency. When this parameter

is set to a nonzero value, this indicates how many threads are

able to run through InnoDB code concurrently. This solution have its

use cases where it works well. It does however have the drawback that

the solution itself contains a hot spot that limits the MySQL server

scalability. It does also not contain any solution to limiting the

number of concurrent transactions.

In a previous alpha version of the MySQL Server (MySQL 6.0) a thread

pool was developed. This thread pool solved the problem with limiting

the number of concurrent threads executing. It did nothing to solve

the problem with limiting the number of concurrent transactions.

It was also a scalability bottleneck in itself. Finally it didn't

solve all issues regarding long queries and blocked queries.

This made it possible for the MySQL Server to become completely

blocked.

When developing the thread pool extension now available in the MySQL

Enterprise Edition we decided to start from a clean plate with the

following requirements:

1) Limit the number of concurrently executing statements to ensure

that each statement execution has sufficient CPU and memory resources

to fulfill its task.

2) Split threads and connection into thread groups that are

independently managed. This is to ensure that the thread pool

plugin itself doesn't become a scalability bottleneck. The

aim is that each thread group has one or zero active threads

at any point in time.

3) Limit the number of concurrently executing transactions

through prioritizing queued connections dependent on if

they have started a transaction or not.

4) Avoid deadlocks when a statement execution becomes long or

when the statement is blocked for some reason for an extended

time.

If you are interested in knowing more details of how the new

thread pool solves these requirements there will be a

webinar on Thursday 20 Oct 2011 at 9.00 PDT. Check here

for details on how to access it.

If you want to try out the thread pool go here.

参考:

http://mikaelronstrom.blogspot.ae/2011/10/mysql-thread-pool-problem-definition.html

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do you represent relationships using foreign keys? How do you represent relationships using foreign keys? Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

See all articles