InnoDB Page Flushing

Learn about the background processes that flush dirty pages from the buffer pool to disk, including adaptive flushing algorithms to optimize I/O.

InnoDB uses a single buf_flush_page_cleaner thread to flush dirty pages—modified pages that have not yet been written to data files—from the InnoDB buffer pool to disk. This thread handles page flushing regardless of the number of buffer pool instances. These dirty pages are flushed using a least-recently used (LRU) algorithm, which manages memory efficiently by prioritizing the eviction of older, less frequently accessed pages.

innodb_max_dirty_pages_pct

The innodb_max_dirty_pages_pct variable specifies the target maximum percentage of unwritten (dirty) pages in the buffer pool. If this percentage is exceeded, flushing will take place.

innodb_max_dirty_pages_pct_lwm

The innodb_max_dirty_pages_pct_lwm variable determines the low-water mark percentage of dirty pages that will enable preflushing to lower the dirty page ratio. The default value is 0.

circle-check

Configuring the InnoDB I/O Capacity

increasing the amount of I/O capacity available to InnoDB can help increase the performance of page flushing. The unit of innodb_io_capacity is the number of data pages (of the size defined by innodb_page_size) that can be written per second.

Scope of Throttling

It is critical to understand the restricted scope of this variable in modern versions of MariaDB:

  • Checkpoint Flushing Only: innodb_io_capacity only throttles checkpoint flushing (background or idle flushing). It does not throttle LRU eviction flushing, which handles the removal of pages when the buffer pool is at capacity.

  • Interaction with innodb_flush_sync: The innodb_io_capacity limit is only effective when innodb_flush_sync is set to OFF. When innodb_flush_sync=ON (the default), InnoDB may ignore this limit during aggressive "furious flushing" if a log checkpoint is urgently required to prevent the redo log from filling up.

  • No Throttling for Buffer Pool Loading: As of MariaDB 10.5.19, 10.6.12, 10.11.2, and later, this parameter no longer throttles the loading of buffer pool dumps at startup (MDEV-25417arrow-up-right). Startup loads are now performed at best-effort speed.

  • Interaction with innodb_flush_sync: The innodb_io_capacity limit is only effective when innodb_flush_sync is set to OFF. When innodb_flush_sync=ON (the default), InnoDB may ignore this limit during aggressive "furious flushing" if a log checkpoint is urgently required to prevent the redo log from filling up.

  • Shared Storage Consideration: If the InnoDB redo log resides on the same physical storage as the data files, ensure you leave some spare capacity for log writes so they are not blocked by background page flushing.

Adjusting I/O Capacity

The amount of I/O capacity available to InnoDB can be configured by setting the innodb_io_capacity system variable. This system variable can be changed dynamically with SET GLOBAL:

The maximum amount of I/O capacity available to InnoDB in an emergency defaults to either 2000 or twice innodb_io_capacity, whichever is higher, or can be directly configured by setting the innodb_io_capacity_maxarrow-up-right system variable.

Device-Specific Recommendations

When setting these variables, consider the physical limits of your storage hardware:

Storage Device Type
Typical IOPS Capability
Recommended innodb_io_capacity

SATA HDD

~100 – 200

100 – 200

SATA SSD

~50,000 – 100,000

2,000 – 20,000

NVMe SSD

500,000+

20,000 – 80,000+

For high-speed NVMe storage, a sensible value for innodb_io_capacity may be as high as 80,000.

Page Flushing Before MariaDB Server 10.5

InnoDB supported multiple partitions and threads to reduce internal mutex contention. These features were rendered unnecessary by architectural improvements—such as splitting the buffer pool mutex and implementing read-write locks for the page hash—and were removed to reduce context-switching overhead:

See Also

This page is licensed: CC BY-SA / Gnu FDL

spinner

Last updated

Was this helpful?