Mystery Performance Variance with MySQL Restarts

Based on a lot of surprising comments about my MySQL 5.5 vs 5.6 performance post I decided to perform deeper investigation to see where my results could go possibly wrong. I had set up everything to be as simple as possible to get maximally repeatable results. I did Read Only ran which is typically a lot more repeatable (though also less relevant for production like workload). I had done number of iterations for benchmark run and I used dedicated physical hardware box so external environment impact often causing problems in Virtualized environments can be eliminated. Still I found there could be large variance between the runs.

I set up the benchmarks run to go over night in the loop, doing the benchmark run for 5 runs when restarting MySQL server and repeating the run. I did it on 2 identical boxes to eliminate faulty hardware as possible suspect. In both cases I’ve spotted something along those ways:

Running Socket /tmp/mysql_sandbox5610.sock with 1 threads
    transactions:                        99210  (330.70 per sec.)
    transactions:                        99733  (332.44 per sec.)
    transactions:                        99766  (332.55 per sec.)
    transactions:                        99838  (332.79 per sec.)
    transactions:                        100035 (333.45 per sec.)

These would be very stable results repeatable in most cases, but sometimes you would see something like this instead:

Running Socket /tmp/mysql_sandbox5610.sock with 1 threads
    transactions:                        90816  (302.72 per sec.)
    transactions:                        90748  (302.49 per sec.)
    transactions:                        90941  (303.13 per sec.)
    transactions:                        90934  (303.11 per sec.)
    transactions:                        90689  (302.29 per sec.)

As you can see the variance between individual (5 minute) run iteration is expectedly rather small – less than 1% especially if you remove the first run, which can be seen as warmup. However the difference between different starts of MySQL is staggering. It looks like sometimes you can just get MySQL server started a wrong way and you will get 10% worse performance which will be very stable at that lower level.

I can repeat it for both MySQL 5.5 and MySQL 5.6 both with single thread and 64 threads run, though the difference in performance can vary from 5% to 10%.

This does not seems to be the plan difference which could be one common cause of performance differences based on server restart it seems to be something else. For now I do not have a good answer what it could be. Why I’m writing about it ? Well there are two outcomes for me.

First – I now can see the confirmation for “magical slowdowns” some our customers reported when upon restart MySQL works significantly slower with no changes to the query load or query plans, which can be solved by MySQL restart. My previous approach have been – there must be some external changes in environment which we’re just not tracking.

Second – I understand we need to be a lot more careful with benchmarks. We need to do multiple runs with MySQL restarts in the end to get meaningful data.

I also can still confirm there is a significant performance difference between MySQL 5.5 and MySQL 5.6 in this workload with MySQL 5.6 being slower, yet the worse case performance difference looks lower than 26% I wrote about. I will update with corrected numbers as I will be able to look more into it.

The post Mystery Performance Variance with MySQL Restarts appeared first on MySQL Performance Blog.