The setup: I have installed Wordpress and some fake content, and also a static copy of it without dynamic content into two different locations.
http://localhost/~shnigi/wordpress/
http://localhost/~shnigi/wpstatic/static.html
Open Linux terminal and type ab to find out all the functions of Apache Benchmark. With that we are going to see how much faster it is serve a static web page.
Round 1
Lets use parameters -n100, which means 100 connections at the same time and -c100 multiple requests to make. First I'm testing the dynamic page.
ab -n100 -c100 http://localhost/~shnigi/wordpress/
First thing is to look that it completed all the requests. If it would fail it wouldn't matter which page to stress.
Longest request took 11179 (last line) and time per request was mean. Lets see how the static page does.
And as you can see static page served a way faster than the dynamic... Both pages contain four blog articles but static is definitely an advantage. Lets try only one post. Both my pages are identical. The one in the left is dynamic and the one in the right is static.
Same test parameters again. First dynamic page
ab -n100 -c100 http://localhost/~shnigi/wordpress/2013/10/01/test-post-3/
Then static page.
ab -n100 -c100 http://localhost/~shnigi/wpstatic/staticpost3.html
Dynamic content: Time per request 9990 and 9983 for longest request.
Static content: time per request 31 and longest request 30 Static is definitely faster. In the next post I'm going to install Varnish which is a web application accelerator. It loads the web site into ram memory and updates only once in a second which is not very much. It creates a static copy of the page to serve faster.
With AB user can check performance of any page, for example google.com. To create logfiles automatically use commands below with crontab:
ab -n 100 -c 20 http://localhost/ > benchmarklog-$(date +\%d\%m\%y).txt
ab -n 100 -c 20 http://localhost/ > /home/username/public_html/ablogs/log-$(date +\%d\%m\%y).txt
Ei kommentteja:
Lähetä kommentti