How does hardware queue depth correlate with log file sync wait?
In a 1M TPS architecture, the Log File Sync (LFS) wait is often the ultimate "choke point." It represents the moment the CPU stops and waits for the physical world (the SSD/NVMe) to acknowledge that a transaction is safely on disk.
The relationship between Hardware Queue Depth (QD) and Log File Sync is a classic optimization trade-off: Throughput vs. Latency.
Log File Sync: The time between a user session issuing a COMMIT and receiving the "Success" signal. This includes the time to gather the log buffer, send it to the OS, and wait for the hardware to write it.
Hardware Queue Depth (QD): The number of I/O requests that the storage controller (NVMe/SATA) can hold in its "waiting room" simultaneously before it actually executes them on the NAND flash.
The correlation isn't linear; it follows a specific curve based on utilization.
If your QD is 1 (synchronous writes), your Log File Sync wait is purely the hardware's raw latency.
Result: Low latency per sync, but your total TPS is capped by the speed of light (or electrons in the controller). At 1M TPS, a QD of 1 is impossible—you’d need a disk that responds in nanoseconds.
Modern NVMe drives thrive at high queue depths (often QD32 or QD64). By sending multiple log writes at once, the controller can parallelize the writing across multiple NAND channels.
Result: High throughput. You can batch 1,000 commits into a single I/O request. The Log File Sync wait stays stable because the hardware is efficiently "digesting" the work.
Once the hardware queue is full (e.g., QD > 128 on many consumer drives), the "Queueing Delay" begins.
The Math: Total Wait = Service Time + Queueing Time.
Result: Your Log File Sync wait skyrockets. Even if the disk is fast, your request is sitting in the "waiting room" (the hardware queue) before it even starts being written.
At 1M TPS, you cannot do 1M individual disk writes. You use Group Commits.
How it works: The database waits a few microseconds to collect 500 transactions, then sends one large write to the hardware.
Impact on QD: This actually reduces the hardware queue depth (fewer, larger requests) but increases the Log File Sync wait for the first transaction in the batch.
The Trade-off: You are trading a small amount of "artificial" latency in the software to prevent a massive "queueing" latency in the hardware.
Hardware queue depth correlates with LFS wait through Write Amplification (WA). When the queue is consistently deep:
The SSD controller gets "stressed."
It triggers background Garbage Collection (GC) to clear blocks for the incoming flood.
GC competes for the same hardware queue as your Log File Sync.
The Result: A "Stochastic Spike." Your LFS wait jumps from 20$\mu$s to 10ms for a single frame, causing a backup in the CPU’s transaction logs.
| Strategy | Queue Depth | Log File Sync Wait | Use Case |
| Synchronous | Low (1-4) | Lowest Latency | Low-volume, ultra-fast trading |
| Asynchronous | High (32-128) | High Throughput | 1M TPS Mainstream |
| Saturated | Overloaded (>256) | Exponential Spikes | System Failure / Bottleneck |
To model this, you must find the Saturation Point of your storage bus. If your NVMe maxes out at QD64, you should aim to keep your software-level batching tight enough that the hardware queue stays around QD16–32. This leaves "headroom" for the stochastic spikes we discussed earlier.