Thread_cache and table_cache for MySQL Performance Optimization configuration parameters _ MySQL

Source: Internet
Author: User
Thread_cache and table_cache for MySQL Performance Optimization configuration parameters I. THREAD_CACHE

To improve the performance of the connection process created by client requests, MySQL provides a connection pool, namely the Thread_Cache pool, which stores idle connection threads in the connection pool instead of destroying them immediately. the advantage is that when there is another new request, mysql will not immediately create a connection thread, but will first go to Thread_Cache to find idle connection threads. if so, it will be used directly, A new connection thread is created if it does not exist.

Thread_Cache has several important parameters in MySQL, which are described as follows:

Thread_cache_size

The maximum number of connection threads in Thread_Cache. thread_Cache is very effective in applications with transient connections, because the connection and creation of databases in applications are very frequent. if Thread_Cache is not used, the resources consumed are very considerable! Although the improvement brought by persistent connections is not as obvious as short connections, the benefits are obvious. but it is not as big as the better, but a waste of resources. this is generally considered to be related to the physical memory, as shown below:
The code is as follows:
1 GB-> 8
2 GB-> 16
3G-> 32
> 3 GB-> 64

You can increase the number of transient connections.

Thread_stack

The memory allocated to mysql when a connection is created. this value is generally considered to be applicable to most scenarios by default, unless necessary.

Thread_handing

Use Thread_Cache to process connections. new features added in 5.1.19. there are two optional values: [no-threads | one-thread-per-connection]. you should have guessed points. haha, the no-threads server uses one thread, the one-thread-per-connection Server uses one thread for each client request. as mentioned in the original manual, no-threads has been downgraded for trial use in Linux.
The code is as follows:
Mysql> show variables like 'thread % ';
+---+
| Variable_name | Value |
+---+
| Thread_cache_size | 32 |
| Thread_handling | one-thread-per-connection |
| Thread_stack | 196608 |
+---+
3 rows in set (0.01 sec)

Mysql> show status like '% connections % ';
+---+ ――

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.