# Thread Pool Size tuning

**URL:** <https://forums.percona.com/t/thread-pool-size-tuning/34044>\
**Category:** Percona Server for MySQL 8.0\
**Created:** [October 1, 2024, 5:16am UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044 "2024-10-01T05:16:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senthil](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Senthil](https://forums.percona.com/u/Senthil)\
**Post date:** [October 1, 2024, 5:16am UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/1 "2024-10-01T05:16:40Z")

</div>

Hi,  
I am looking for some direction/documentation on tuning the thread pool size for the following 2 configurations which I am benchmarking.

1. 8/16 CPU (up-to 128/256 active connections)
2. 64 CPU (up-to 1000 active connections)

I have also gone through the previous posts on this topic but need more guidance: [Optimum thread\_pool\_size](https://forums.percona.com/t/optimum-thread-pool-size/11417)

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 1, 2024, 1:26pm UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/2 "2024-10-01T13:26:07Z")

</div>

Hi @Senthil,  
Neither of the two scenarios you describe warrant using the thread pool plugin. The thread pool plugin is for MySQL servers that are in excess of 20,000 connections. 🙂 Set your thread\_cache\_size to 64, then monitor this using Percona Monitoring and Management. There is a graph specifically for this. If you see too many “threads created”, then bump up this parameter. If you are still having performance problems, check CPU max utilization, disk latency, and the ‘Handler’ graphs for read\_rnd\_next activity (this is indication of poor queries not using indexes which require much more CPU to execute).

---

<div class="post-metadata">

**Author:** ![Senthil](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Senthil](https://forums.percona.com/u/Senthil)\
**Post date:** [October 10, 2024, 6:07pm UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/3 "2024-10-10T18:07:59Z")

</div>

Thanks for the reply @matthewb. I ran Sysbench benchmarks with thread pool enabled and even with 1000 connections, it gives 6X TPS compared to without thread pool. Similar TPS gains observed with thread pool for read\_only workloads as well (3X) with same number of connections (1000). Also, the performance of Thread Pool is better than ProxySQL as well in those cases.

Why does the recommendation more than 20,000 connections? Am I missing something?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 10, 2024, 6:41pm UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/4 "2024-10-10T18:41:09Z")

</div>

This is a surprising result from your benchmarks. Have you looked over this post?

> **[Is Thread Pool Plugin the Right Choice for Your Workload?](https://www.percona.com/blog/is-thread-pool-plugin-the-right-choice-for-your-workload/)**
>
> Performance can significantly decrease due to the thread pool plugin, depending on the workload. Here's what you need to know.

Also, direct from our documentation ([Thread pool - Percona Server for MySQL](https://docs.percona.com/percona-server/8.0/threadpool.html)):

> If you have fewer than 20,000 connections, using the thread pool does not provide significant benefits. It’s better to keep thread pooling disabled and use the default method.

If you could share some PMM graphs of CPUs, MySQL QPS, etc with and without thread-pool enabled, I’m sure several people over here would like to see. And also share your my.cnf for each test, and sysbench test commands.

---

<div class="post-metadata">

**Author:** ![Senthil](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Senthil](https://forums.percona.com/u/Senthil)\
**Post date:** [October 15, 2024, 3:40pm UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/5 "2024-10-15T15:40:25Z")

</div>

Here is my set-up:

MySQL version: 8.0.37-29  
MySQL configuration is the default for this release. I have not made any other change.

numCPU: 32  
Memory: 128 GB

Thread Pool Size: 32 (default)  
Sysbench OLTP Point-Select: 6X TPS over baseline  
Sysbench read-only: Up-to 2X TPS  
Sysbench read-write: 1.5X TPS (after tuning the thread pool size to 128).

I am unable to increase the thread pool size to more than 128. Is this the maximum?

---

<div class="post-metadata">

**Author:** ![Senthil](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Senthil](https://forums.percona.com/u/Senthil)\
**Post date:** [October 16, 2024, 3:33pm UTC](https://forums.percona.com/t/thread-pool-size-tuning/34044/6 "2024-10-16T15:33:44Z")

</div>

Also, I am seeing better results with thread\_pool\_size=128 (4x TPS for Sysbench read-write) compared to the default thread\_pool\_size (32 for the 32-CPU). Any idea why the recommended value (and the default) is same as the number of CPU cores?
