Home > Database > Mysql Tutorial > body text

MySQL线程缓存thread_cache_size参数优化

WBOY
Release: 2016-06-07 14:59:13
Original
1776 people have browsed it

thread_cahe_size线程池,线程缓存。用来缓存空闲的线程,以至于不被销毁,如果线程缓存中的空闲线程,需要重新建立新连接,则会

thread_cahe_size线程池,线程缓存。用来缓存空闲的线程,以至于不被销毁,如果线程缓存中的空闲线程,需要重新建立新连接,则会优先调用线程池中的缓存,很快就能响应连接请求。

每建立一个连接,都需要一个线程与之匹配

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        |代表当前此时此刻线程缓存中的空闲线程

| Threads_connected                        | 11       |代表当前建立的连接数

| Threads_created                          | 11032160 |最近一次服务启动以来,,创建的线程数量

| Threads_running                          | 2        |当前激活的(非睡眠)的线程数

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

thread_cache_size最好设置成和threads_connected一样。不过很少将thread_cache_size设置成比200大。

配置:

mysql>set global thread_cache_size=30    即时生效

或者

vim /etc/my.cnf

thread_concurrency=30

重启mysql。

本文永久更新链接地址

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template