mysql線程緩衝thread_cache_size參數最佳化

來源:互聯網
上載者:User

標籤:mysql   線程池   thread_cache_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。



mysql線程緩衝thread_cache_size參數最佳化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.