8/09/2012

Compute a good InnoDB log file size

Run these queries during your server’s peak usage time: The log sequence number is the total number of bytes written to the transaction log. Now you can see how many MB have been written to the log in one minute. (This technique works on all versions of MySQL, in 5.0 and newer, you can just watch Innodb_os_log_written from SHOW GLOBAL STATUS, too.) Say we want our logfile to hold at most an hour or so of logs, which is generally plenty of data for InnoDB to work with. For good measure we can round this up to 32MB, and considering the fact that there are two logfiles, divide by half: 16MB per logfile. This seems like a surprisingly small number, but you can monitor this easily enough. Word of advice though: be sure to run the above queries at your server's peak time, or your results might be seriously skewed. Consider running the above multiple times a day over a course of a couple days, and use the average value, so you are on the safe side. That being said, in this particular case, memory being so cheap, I would simply set the log file size to 64MB and be done ;-)

Update: To run this multiple times using a script: https://github.com/datune/innodb_log_file_size

No comments:

Post a Comment