Databases 2 min read

Boost MySQL Performance by Tuning Thread Cache Size

This guide explains how the thread_cache_size setting in MySQL caches idle threads, how to monitor thread creation with Thread_created, and why increasing the cache size can reduce resource consumption and improve response times.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Boost MySQL Performance by Tuning Thread Cache Size

If the MySQL configuration file sets thread_cache_size, the thread that handled a client request is kept in a cache after the client disconnects, ready to serve the next client instead of being destroyed, provided the cache limit is not reached.

The status variable Thread_created shows the total number of threads that have been created. You can view it with: show global status like 'Thread%'; If Thread_created is unusually high, it indicates that MySQL is constantly creating new threads, which consumes resources. Increasing thread_cache_size can reduce this overhead.

You can check the current thread_cache_size setting with:

show variables like 'thread_cache_size';

To change the cache size, execute for example:

set global thread_cache_size=32;
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceConfigurationmysqlDatabase Tuning
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.