Course contentsShow
← Databases & SQL
Lesson 1006 of 1,9539. MySQL and MariaDB EcosystemsFree lesson

Read and Write Throughput Tuning

Balance flushing mechanisms for optimal disk write performance on SSD storage.

In this lesson, you will learn how to balance flushing mechanisms in InnoDB to achieve optimal write performance on SSD storage.

The Balancing Act of Flushing

In MySQL/MariaDB, your buffer pool acts as a cache for data pages. When you modify data, you aren't writing to the disk immediately; you are updating pages in memory (making them "dirty") and logging the transaction to the redo log. Eventually, those dirty pages must be flushed to the actual data files.

On SSD storage, the bottleneck is rarely the physical disk latency, but rather the internal contention caused by InnoDB trying to keep up with the write rate. If you flush too slowly, the buffer pool fills up and forces the engine to perform synchronous "dirty page flushing," which stalls incoming transactions. If you flush too aggressively, you waste I/O cycles and starve read operations.

Tuning the Flushing Mechanism

The goal is to keep the flushing process constant and smooth. Two variables are critical here:

  1. innodb_io_capacity: This tells InnoDB how much I/O your underlying hardware can handle per second. On modern SSDs, the default (often 200) is far too low. Setting this to match your disk's sustained IOPS (e.g., 2000–5000) prevents the engine from underutilizing the drive.
  2. innodb_flush_neighbors: On traditional spinning disks, setting this to 1 (which flushes adjacent pages together) helped reduce seek time. On SSDs, random I/O is nearly free, so you should set this to 0. Disabling neighbor flushing prevents the "extra" work of finding nearby pages to flush, which significantly improves latency for write-heavy workloads.

By aligning innodb_io_capacity with your SSD's capability and disabling neighbor flushing, you ensure that the background threads keep the buffer pool clean without interfering with your read-heavy query execution.

-- Increase flushing throughput to match SSD capabilities
SET GLOBAL innodb_io_capacity = 2000;

-- Disable neighbor flushing for optimal SSD performance
SET GLOBAL innodb_flush_neighbors = 0;

Key Takeaway: To optimize SSD write throughput, configure innodb_io_capacity to match your hardware's actual IOPS and disable innodb_flush_neighbors to eliminate unnecessary background page searches.