MySQLThreadPool: ProblemDefinition

Source: Internet
Author: User
MySQLThreadPool: ProblemDefinition 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

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

Or some abbreviation of thread is actually representing a connection.

Obviusly 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.

MySQL Server also have scalability bottlenecks where performance suffers

When too required connections execute in parallel.

So far tively there are two reasons that can make performance suffer in

The original MySQL Server model.

The first is that your connections executing in parallel means that

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

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 cocould at times

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

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

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 scheded.

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 publish 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

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

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

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.

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

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.

Refer:

Http://mikaelronstrom.blogspot. AE /2011/10/mysql-thread-pool-problem-definition.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.