Today I wondered how my newly purchased Virtual Server performs under load. I am currently using lighttpd as a webserver and MySQL as the database for WordPress. I already knew that MySQL features the Query Cache, which stores the result of issued queries in memory (Oracle’s equivalent of this would be the Result Cache in Oracle 11g). I wondered how much this feature could improve performance on a normal WordPress blog.
I quickly wrote a small Java program to query my website (source code available here: TestWebPerfo.java) and retrieve the performance metrics from the HTML source code. I then ran it 500 times to get my metrics without the Query Cache turned on. Average time for building the website: 0.115 seconds.
I then turned the Query Cache of the server on by specifying the following parameters in my
# # * Query Cache Configuration # query_cache_type = 1 query_cache_limit = 2M query_cache_size = 128M
I then ran my Java program again and got only a small improvement: Average time: 0.110 seconds. That is ‘only’ 5 milliseconds faster than without the Query Cache.
No significant change, since this difference could come from network latency or delay on my local machine.
You can see the marginal difference in the graphical representation of the results:
Sadly, the only thing I noticed were the missing ‘spikes’ (remember, these spikes represent only a few milliseconds in difference) and the lower average.
Having the Query Cache in MySQL turned on can surely improve performance and keep MySQL query results in memory. Note that the Query Cache only works with static queries where the result does not change. I am not familiar with the WordPress SQL schema and don’t know if the queries of WP are optimized for Query Cache usage.
The higher performance comes at the price of memory. But as I am only using my Virtual Server as a web server and backup storage, I don’t care if the memory usage from MySQL is a little bit higher.
I would love to know if someone can improve their web blog performance using the Query Cache. I am sure there are better results out there :)