← Back to Napkin Math

problem 10

https://sirupsen.com/napkin/problem-10

Is MySQL’s maximum transactions per second equivalent to fsyncs per second?

fsync background

ref:

Maximum theoretical writes per second:

Attempt

Where does a transaction “end”? If it ends when MySQL inserts a new record into WAL and successfully calls fsync, then isn’t the answer 1000?

Or do we also need to estimate the time to insert the records into the page? That would be B+ tree insertion.

The page we write to is now in the buffer pool, but we mark it as dirty: we don’t flush it to disk right away, since we’ve flushed the WAL and so can recovery from a crash.

Solution

When we benchmark against MySQL, we are able to get 5300 insertions per second. That’s significantly faster than the expected fsync time!

The reason why we have more fsyncs than expected is because there’s a group commit scheme to binlog and wal.

But it’s unclear why fsync is faster than 1ms. Perhaps due to file system batching together writes.