Innodb_buffer_pool_size

Tuning Innodb_buffer_pool_size variable

Basic Details

The InnoDB buffer pool stores MySQL database indexes and data in memory. The innodb_buffer_pool_size variable sets the InnoDB buffer pool size in bytes.

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

innodb_buffer_pool_size – Usage

Innodb_buffer_pool_size may be the most important variable for any MySQL database using InnoDB tables. Configuration of innodb_buffer_pool_size is highly recommended to reduce excessive I/O usage. I/O usage is the primary bottleneck for MySQL servers because it's slow, and high usage indicates that the disk subsystems are being overworked. This may markedly affect performance during peak usage and maintenance.

InnoDB buffer pool works by caching the most recently accessed data. By caching on memory, data can be retried from the cache instead of the disk. The buffer pool is designed to keep the most frequently-used data available in the cache, by managing two sublists.
  • When new data is accessed, it is stored at the top of the 'older' list. The oldest item in this list is removed and will need to be retrieved from the disk if queried again.
  • This data is moved to the top of the 'newer' list when it is queried again.

When the buffer pool is set correctly, data that is accessed often can be quickly retrieved from memory, as needed.

Releem collects information on your MySQL server and will automatically select the best configuration for innodb_buffer_pool_size, tailored to your database.

innodb_buffer_pool_size – Configuration

Innodb_buffer_pool_size can be configured offline or online, when the server is running. Configuration may be preferred online, to allow for testing. When the server is restarted the innodb_buffer_pool_size will revert.

Command Line Configuration:
 mysqld> set global innodb_buffer_pool_size = XX
Replace XX with value to suit your database needs. To verify that the variable has been changed:
mysqld> show global variables like 'innodb_buffer_pool_size'
Configuration File:
[mysqld] 
Innodb_buffer_pool_size = XX 
Replace XX with value to suit your database needs. Restart MySQL server. Refer to considerations below if you get any errors concerning instances or chunk size.

innodb_buffer_pool_size Considerations

There are a lot of factors and considerations to remember when setting innodb_buffer_pool_size. Since innodb_buffer_pool_size is the number one variable to configure to improve MySQL server performance, you want to get it right. Let Releem do all the work for you. Releem will automatically configure your MySQL settings, including innodb_buffer_pool_size, to maximize performance and stability.

The recommendation for years in setting innodb_buffer_pool_size has been 80% of RAM. This rule of thumb should not be followed, except for small servers under 1GB. As the server size gets larger, RAM is more inefficiently used if innodby_buffer_pool_size is set to 80%. Below is a list of factors you should consider when setting or assessing innodb_buffer_pool_size:

  1. InnoDB also reserves additional memory for control structures or buffers, so the total space allocated to memory is roughly 10% greater than what the pool size is set to.
  2. If innodb_buffer_pool_size is set too low or not set (default value maybe 8MB) expect extremely high input/output usage.
  3. If innodb_buffer_pool is set to high, the OS may experience paging and regular swapping which will negative the performance benefits. No real need to set larger than the database itself.
  4. To determine if innodb_buffer_pool_size is large enough, check status variable innodb_buffer_pool_wait_free. If this is continually increasing, you did not allocate enough memory for your buffer pool.
  5. Account for the operating system and MySQL memory needs such as system processes, socket buffers, query cache, MySQL threads, and more
Configuring innodb_buffer_pool_size Dynamically
Innodb_buffer_pool_size has been able to be configured dynamically since MySQL 5.7.5 and MariaDB 10.2.2. To change innodb_buffer_pool_size while the server is online, innodb_buffer_pool_chunk_size and innodb_buffer_pool_instances must be considered.

The buffer pool is broken down into instances and the instances are divided into chunks.

Resizing of innodb_buffer_pool_size is achieved using chunks set by the innodb_buffer_pool_size_chunk_size variable. Errors will arise if innodb_buffer_pool_size is not set to a value that is compatible with the number of instances and chunk size.

You can determine the currently set value of innodb_buffer_pool_chunk_size by entering:
SELECT @innodb_buffer_pool_chunk_size
(if previously configured variable yourself)
OR
show variables like %innodb_buffer_pool_chunk_size%
(for MySQL system variables)
Innodb_buffer_pool_instances can be determined in the same manner.

The relationship between these three variables can be seen in this calculation:

innodb_buffer_pool_size = innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances * N

innodb_buffer_pool_size related Health Checks

  1. InnoDB Cache Hit Rate - indicates the percentage of read requests that are satisfied by the buffer pool instead of having to be read from disk.
  2. InnoDB Dirty Pages Ratio - reflecting the proportion of "dirty" pages in the InnoDB buffer pool.

innodb_buffer_pool_size related Variables

FAQ on innodb_buffer_pool_size

1. How do I tune innodb_buffer_pool_size based on the database size?

To tune innodb_buffer_pool_size, consider the total size of your InnoDB tables and indexes:
Tuning for Small Databases:
• If your database is smaller than the available RAM, set innodb_buffer_pool_size to match the database size.
• Example: If your InnoDB data size is 1GB and your server has 8GB RAM, set innodb_buffer_pool_size=1G.
Tuning for Large Databases:
• For databases larger than available memory, allocate as much memory as possible without causing OS swapping.
• Example: On a server with 16GB RAM, allocate 12GB for the buffer pool: innodb_buffer_pool_size=12G.

2. What happens if innodb_buffer_pool_size is too small?

If the buffer pool is too small:
• MySQL cannot cache all frequently accessed data and indexes.
• Increased disk I/O occurs, slowing down query performance.
• The server may experience higher latency for read and write operations.

3. Can I dynamically change innodb_buffer_pool_size?

Yes, starting from MySQL 5.7, you can dynamically change innodb_buffer_pool_size without restarting the server:

SET GLOBAL innodb_buffer_pool_size = 1073741824;

Note: This change is temporary and will be reset after a restart unless updated in the MySQL configuration file (my.cnf).

4. How does Aurora handle innodb_buffer_pool_size?

Amazon Aurora automatically manages innodb_buffer_pool_size based on the instance class and workload. Aurora typically allocates around 70-80% of the instance memory to the buffer pool. Manual can be done for specific workloads.

5. How do I monitor buffer pool efficiency?

Use the following SQL command to check buffer pool efficiency:

SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool%';

Key metrics:
• Innodb_buffer_pool_read_requests: Total read requests served from the buffer pool.
• Innodb_buffer_pool_reads: Read requests served from disk (lower is better).
• If Innodb_buffer_pool_reads is high, increase the buffer pool size.

6. What is the difference between innodb_buffer_pool_size in MySQL and MariaDB?

In both MySQL and MariaDB, innodb_buffer_pool_size serves the same purpose.

7. What is the maximum value for innodb_buffer_pool_size?

The maximum value depends on:
• The architecture of your MySQL server:
• 32-bit systems: ~4GB.
• 64-bit systems: Limited only by the available memory.
• In most cases, ensure the buffer pool does not exceed 75-80% of total system RAM.
Releem automatically identifies MySQL performance issues, tunes configuration and optimizes SQL queries