Tencent Cloud Enterprise MySQL Dynamic Thread‑Pool Feature Overview
The article explains Tencent Cloud's enterprise‑level MySQL dynamic thread‑pool capability, describing the one‑thread‑per‑connection and thread‑pool modes, the new thread_handling_switch_mode parameter with its four options, status‑monitoring commands, and added columns for process‑list visibility, enabling seamless mode switching without server restarts.
This article, delivered via video and text, introduces Tencent Cloud's enterprise‑level MySQL dynamic thread‑pool feature.
Background
MySQL has two commonly used work modes: one‑thread‑per‑connection and thread‑pool .
The one‑thread‑per‑connection mode is the default MySQL mode, creating a dedicated handle_connection thread for each client connection. The thread‑pool mode, originally supported by Percona and later improved by CDB, uses a relatively fixed number of worker threads to serve connections, which is better for handling many short‑lived queries and avoids frequent thread creation and resource contention. Its drawback is that when queries are long‑running, worker threads can become blocked, slowing the response to new requests.
Both modes have advantages and disadvantages, and the system should switch between them based on business needs. Previously, switching required a server restart, which is disruptive during peak traffic.
To solve this, CDB adds a dynamic thread‑pool switching capability that allows mode changes without restarting the server.
Dynamic Thread‑Pool Feature
Introduced Parameter
The new parameter thread_handling_switch_mode controls dynamic switching and can take the following values: disabled: prohibit dynamic migration. stable: only new connections are migrated. fast: new requests are migrated; existing connections migrate after receiving a new request (default). sharp: kill active connections to force reconnection, achieving rapid switching (aggressive).
Status Monitoring
To monitor the state of each thread‑pool work group, a new command show threadpool status is added. It displays the following metrics for each thread group: connections_moved_from_per_thread: number of connections moved from Per‑thread to Thread‑pool. connections_moved_to_per_thread: number of connections moved from Thread‑pool back to Per‑thread. events_consumed: total events consumed by the worker thread group; stops increasing after migration to Per‑thread. average_wait_usecs_in_queue: average wait time of each event in the queue, useful for judging thread‑group load; a high value suggests a mode switch may be needed.
The above four items are directly related to the dynamic thread‑pool feature; other status fields are described in the accompanying diagram.
Corresponding status description
In addition, the show full processlist command now includes two new columns: Moved_to_per_thread: number of times a connection has migrated to Per‑thread. Moved_to_thread_pool: number of times a connection has migrated to Thread‑pool.
With the dynamic thread‑pool feature, businesses can flexibly configure MySQL work modes according to their needs, eliminating concerns about thread‑pool stalls.
Tencent Database Technology Team supports internal services such as QQ Space, WeChat Red Packets, Tencent Ads, Tencent Music, and Tencent News, and external products on Tencent Cloud like CynosDB, CDB, CTSDB, MongoDB, and CES. The team focuses on continuous kernel and architecture optimization to improve performance and stability, providing reliable database services for both internal and cloud customers.
Tencent Database Technology
Tencent's Database R&D team supports internal services such as WeChat Pay, WeChat Red Packets, Tencent Advertising, and Tencent Music, and provides external support on Tencent Cloud for TencentDB products like CynosDB, CDB, and TDSQL. This public account aims to promote and share professional database knowledge, growing together with database enthusiasts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
