MySQL thread cache thread_cache_size parameter optimization

Source: Internet
Author: User

Thread_cahe_size thread pool, threading cache. Used to cache idle threads so that they are not destroyed, and if idle threads in the thread cache need to reestablish a new connection, the cache in the thread pool is prioritized and the connection request can be answered very quickly.

For each connection, a thread is required to match it.


MariaDB [(None)]> show global status like '%thread% ';

+------------------------------------------+----------+

| variable_name | Value |

+------------------------------------------+----------+

| Delayed_insert_threads | 0 |

| Innodb_master_thread_1_second_loops | 4338823 |

| Innodb_master_thread_10_second_loops | 432031 |

| Innodb_master_thread_background_loops | 18974 |

| Innodb_master_thread_main_flush_loops | 18974 |

| Innodb_master_thread_sleeps | 4338819 |

| Performance_schema_thread_classes_lost | 0 |

| Performance_schema_thread_instances_lost | 0 |

| Slow_launch_threads | 0 |

| Threadpool_idle_threads | 0 |

| Threadpool_threads | 0 |

| threads_cached | 0 | Represents the current idle thread in the thread cache at this moment

| threads_connected | 11 | Represents the number of connections currently established

| threads_created | 11032160 | The number of threads created since the last service startup

| threads_running | 2 | Number of currently active (non-sleep) threads

+------------------------------------------+----------+


Thread_cache_size is best set to be the same as threads_connected. However, Thread_cache_size is rarely set to be larger than 200.


Configuration:

Mysql>set Global thread_cache_size=30 Immediate effect

Or

Vim/etc/my.cnf

Thread_concurrency=30

Restart MySQL.



MySQL thread cache thread_cache_size parameter optimization

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.