Optimizing MySQL InnoDB Buffer Pool: From Size to Instances
Increase MySQL query speed by tuning the InnoDB buffer pool: choose the right size, add instances, verify hit ratios, and recover if swapping occurs. Follow our step‑by‑step guide for a dedicated server.
02 Jan 2026, 05:34 UTC

Desired Outcome
Improve query latency and throughput on a dedicated MySQL server by tuning the InnoDB buffer pool so that most data and index pages are served from memory rather than disk. A properly sized buffer pool with an adequate number of instances will raise the hit ratio above 95% and reduce OS swapping.
Prerequisites
- MySQL 5.7 or 8.0 running on a dedicated database host.
- Root or sudo access to the operating system and the MySQL configuration directory (
/etc/mysql/or/etc/my.cnf). - At least 2 GB of free RAM beyond what the operating system and other services need.
- A maintenance window, because changing
innodb_buffer_pool_sizerequires a server restart.
Focused Procedure
- Determine available RAM
# free -m | awk '/^Mem:/ {print $2}';Note the total memory reported (e.g., 8192 MB). Reserve 10‑15 % for OS buffers, page cache, and other services.
- Calculate buffer pool size
For a dedicated server, aim for 70‑80 % of usable RAM. Example: with 8 GB total and 1 GB reserved, allocate 5.6 GB.
- Edit the MySQL configuration
Open
/etc/mysql/my.cnf(or the appropriate file) and add or modify the following lines under the[mysqld]section:[mysqld] innodb_buffer_pool_size=5G innodb_buffer_pool_instances=8In MySQL 8.0 the default number of instances is 1. Setting too many can hurt small deployments; 8 is a good starting point for servers with >4 GB RAM.
- Restart MySQL
# systemctl restart mysqlUse the service manager that matches your distribution. Verify the service is running:
systemctl status mysql. - Confirm the new settings
# mysql -uroot -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';" # mysql -uroot -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_instances';"Both should reflect the values you set.
Expected Checks
- Buffer pool hit ratio
Run:
# mysql -uroot -p -e "SELECT * FROM performance_schema.innodb_buffer_pool_stats;"Look for
hit_ratio> 95.0. If using older MySQL,SHOW ENGINE INNODB STATUSwill show aBuffer pool read requestssection; calculate hit ratio manually. - System RAM usage
After restart, monitor free memory:
# free -mFree memory should stay above 1 GB. If it drops below, consider reducing the buffer pool size or increasing total RAM.
- OS swapping
Check swap usage:
# swapon --showNo active swap indicates the buffer pool is not starving the OS.
Recovery Options
- Rollback size change
If performance degrades or the system starts swapping, revert to the previous
innodb_buffer_pool_sizevalue inmy.cnfand restart MySQL again. - Adjust instances
Too many instances can increase context switching. If you observe a drop in performance, reduce
innodb_buffer_pool_instancesto 4 or 2 and restart. - Monitor continuously
Set up a cron job that logs
performance_schema.innodb_buffer_pool_statsor uses Percona Toolkit’spt-query-digestto keep an eye on hit ratios over time.
By following this guide, you can systematically increase the InnoDB buffer pool size, add instances for concurrency, and verify that your server’s memory usage remains healthy while improving query performance.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.