MySQL optimization parameter thread_cache_size

Source: Internet
Author: User

Thread_cache_size

Query process Usage

The code is as follows Copy Code
Mysql> show global status like ' thread% ';
+ ——————-+ ———-+
| variable_name | Value |
+ ——————-+ ———-+
| threads_cached | 26 |
| threads_connected | 510 |
| threads_created | 35168165 |
| threads_running | 459 |
+ ——————-+ ———-+
4 rows in Set (0.01 sec)
Query Server Thread_cache_size Configuration
The code is as follows Copy Code
Mysql> Show variables like ' thread_cache_size ';
+ ——————-+ ——-+
| variable_name | Value |
+ ——————-+ ——-+
| Thread_cache_size | 32 |
+ ——————-+ ——-+
1 row in Set (0.00 sec)
If we set the thread_cache_size in the MySQL server configuration file, when the client disconnects,
The thread that the server handles this client will be cached in response to the next customer rather than destroyed (provided the cache count is not up to the upper limit).
Threads_created indicates the number of threads created, and if the threads_created value is found to be too large,
Indicates that the MySQL server has been creating threads, which is also a resource consuming and can appropriately increase the thread_cache_size value in the configuration file.

According to the investigation, the above server thread cache Thread_cache_size is not set, or is set too small, this value indicates that the number of stored threads in the cache can be recycled, and if there is room in the cache when disconnected, the client's thread will be placed in the cache if the thread is requested again , the request is read from the cache, and if the cache is empty or a new request, the thread will be recreated, and if there are many new threads, adding this value can improve system performance. By comparing the variables of connections and threads_created states, You can see the effect of this variable. (?> represents the value to be adjusted) set the rules according to physical memory as follows:

1G?> 8
2G?> 16
3G?> 32
>3G?> 64

Related Article

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.