innodb_thread_concurrency

Tuning innodb_thread_concurrency

Basic Details

The innodb_thread_concurrency variable in MySQL and its forks, such as Percona and MariaDB, controls the level of concurrency for InnoDB threads. It manages the number of threads that can execute concurrently within the InnoDB storage engine, which is used for managing databases and handling transactions.

Releem automatically tunes innodb_thread_concurrency and 44 other variables to improve MySQL performance. Try Releem for Free, or deepen your understanding by reading our detailed article.

innodb_thread_concurrency – Usage

Concurrency refers to the execution of multiple threads or processes simultaneously. In the context of InnoDB, threads are responsible for performing various database operations such as reads, writes, and updates. By controlling the level of concurrency, you can optimize the performance of the InnoDB storage engine, ensuring efficient use of system resources and preventing contention among threads.

The default value of innodb_thread_concurrency is 0, which means there is no limit on the number of threads that can operate concurrently. The system automatically manages thread concurrency, and this default setting often works well for most systems.

However, in cases where there is high concurrency and contention for resources, setting a specific limit on the number of threads that can execute simultaneously may be beneficial.

By setting the innodb_thread_concurrency parameter, you can define the maximum number of threads that are allowed to execute simultaneously. When this limit is reached:

  • A new incoming request will sleep (wait) for a short period if the number of currently executing threads has reached the innodb_thread_concurrency limit.
  • If the request cannot be rescheduled after sleeping, it will be placed in a first-in/first-out (FIFO) queue and processed when resources become available.
  • Threads that are waiting for locks (e.g., due to resource contention) are not counted towards the innodb_thread_concurrency limit.

innodb_thread_concurrency – Configuration

The innodb_thread_concurrency variable can be configured using the command line or configuration file:
Command Line Configuration:
mysqld> set global innodb_thread_concurrency = XX

Replace XX with value to suit your database needs. To verify that the variable has been changed:

mysqld> show global variables like ‘innodb_thread_concurrency

Configuration File:
[mysqld]
innodb_thread_concurreny = XX

Replace XX with value to suit your database needs. Must restart MySQL server to see changes applied.

innodb_thread_concurrency – Considerations

When making adjustments to the innodb_thread_concurrency variable, you will want to consider a few different aspects of your server, including hardware and workload. All changes should be tested to ensure that the change is optimal and not causing more issues than it helped.

  • Hardware capabilities – When setting the innodb_thread_concurrency value, consider the server's hardware capabilities, such as the number of CPU cores and the available memory.

A higher level of concurrency may benefit from a system with more CPU cores and memory, while a lower concurrency level may be more suitable for systems with fewer resources.

  • Workload – Consider the type of workload your database is handling. If your workload involves a lot of read and write operations with high contention, setting a specific limit on innodb_thread_concurrency may help prevent resource contention and improve performance.

  • Monitoring and testing – It's essential to monitor your system's performance after adjusting the innodb_thread_concurrency value. Perform tests to determine the optimal value for your specific use case.

Remember that setting the value too low may lead to underutilization of resources, while setting it too high could cause contention and performance degradation.

  • Adjusting related variables – Keep in mind that innodb_thread_concurrency works in conjunction with other InnoDB-related configuration variables, such as innodb_read_io_threads, innodb_write_io_threads, and innodb_buffer_pool_size. Make sure to optimize these settings as well to achieve the best performance for your system.

By carefully considering your server's hardware capabilities and workload, and adjusting innodb_thread_concurrency accordingly, you can effectively optimize the performance of the InnoDB storage engine and ensure efficient resource utilization on your system.
If you are concerned or unsure that the innodb_thready_concurrency variable is optimized for your servers, let Releem help you with that. Releem will assess MySQL performance and determine if any of your variables need to be adjusted. With Releem’s automatically applied recommended configuration, you can rest easy knowing every variable is optimized for peak performance and stability.
Releem automatically identifies MySQL performance issues, tunes configuration and optimizes SQL queries