Read more about this book |
(For more resources on Magento, see here.)
The reader can benefit from the previous article on How to Overcome the Pitfalls of Magento.
Users really respond to speed.—Marissa Mayer, Google vice president of the research section and user experience.
We will explain why this quote is true throughout this article. Her key insight for the crowd at the Web 2.0 Summit is that “slow and steady doesn’t win the race”. Today people want fast and furious. Not convinced? Okay, let’s have a look at some arguments:
This is the era of milliseconds and terabytes, so we have to pay a big price if we can’t keep up. This article will describe how to ensure the optimum performance of your Magento store.
The very first task of any website’s performance optimization is to know its pitfalls. In other words, know why it is taking too much time. Who are the culprits? Fortunately, we have some amicable friends who will guide us through. Let’s list them:
Okay, we are introduced to our new friends. In this recipe, we will work with them and find the pitfalls of our Magento store.
Before starting the work, we have to make sure that every required tool is in place. Let’s check it.
ab: This Apache benchmarking tool is bundled with every Apache installation. If you are on a Linux-based distribution, you can give it a go by issuing the following command in the terminal:
ab -h
Siege: We will use this tool in the same box as our server. So make sure you have it installed. You can see it by typing this command (note that the option is capital V):
siege -V
If it’s installed, you should see the installed version information of Siege. If it’s not, you can install it with the following command in any Debian-based Distro:
sudo apt-get install siege
You can also install it from source. To do so, grab the latest source from here: ftp://ftp.joedog.org/pub/siege/siege-latest.tar.gz, then issue the following steps sequentially:
# go the location where you downloaded siege
tar xvzf siege-latest.tar.gz
# go to the siege folder. You should read it with something like
siege-2.70
./configure
make
make install
If you are on a Windows-based box, you would find it as:
apache/bin/ab.exe
Magento Profile: This is also a built-in tool with Magento.
YSlow: This firebug add-on from Firefox could be installed via the Internet from here: http://developer.yahoo.com/yslow/. Firebug add-on is a dependency for YSlow.
Page Speed: This is also a firebug add-on that can be downloaded and installed from: http://code.google.com/speed/page-speed/download.html.
For using GTmetrix and WebPagetest, we will need an active Internet connection. Make sure you have these.
Using the simple tool ab:
ab -c 10 -n 50 -g mage.tsv http://magento.local.com/
Using Siege:
http://magento.local.com/
http://magento.local.com/skin/frontend/default/default/favicon.ico
http://magento.local.com/js/index.php?c=auto&f=,prototype/
prototype.js,prototype/validation.js,scriptaculous/builder.
js,scriptaculous/effects.js,scriptaculous/dragdrop.
js,scriptaculous/controls.js,scriptaculous/slider.js,varien/
js.js,varien/form.js,varien/menu.js,mage/translate.js,mage/cookies.jshttp://magento.local.com/skin/frontend/default/default/css/print.css
http://magento.local.com/skin/frontend/default/default/css/stylesie.css
http://magento.local.com/skin/frontend/default/default/css/styles.css
http://magento.local.com/skin/frontend/default/default/images/np_
cart_thumb.gifhttp://magento.local.com/skin/frontend/default/default/images/np_
product_main.gifhttp://magento.local.com/skin/frontend/default/default/images/
np_thumb.gifhttp://magento.local.com/skin/frontend/default/default/images/
slider_btn_zoom_in.gifhttp://magento.local.com/skin/frontend/default/default/images/
slider_btn_zoom_out.gifhttp://magento.local.com/skin/frontend/default/default/images/
spacer.gifhttp://magento.local.com/skin/frontend/default/default/images/
media/404_callout1.jpghttp://magento.local.com/electronics/cameras.html
http://magento.local.com/skin/frontend/default/default/images/
media/furniture_callout_spot.jpghttp://magento.local.com/skin/adminhtml/default/default/boxes.css
http://magento.local.com/skin/adminhtml/default/default/ie7.css
http://magento.local.com/skin/adminhtml/default/default/reset.css
http://magento.local.com/skin/adminhtml/default/default/menu.css
http://magento.local.com/skin/adminhtml/default/default/print.css
http://magento.local.com/nine-west-women-s-lucero-pump.html
siege -c 50 -i -t 1M -d 3 -f mage_urls.txt
Lifting the server siege.. done.
Transactions: 603 hits
Availability: 96.33 %
Elapsed time: 59.06 secs
Data transferred: 10.59 MB
Response time: 1.24 secs
Transaction rate: 10.21 trans/sec
Throughput: 0.18 MB/sec
Concurrency: 12.69
Successful transactions: 603
Failed transactions: 23
Longest transaction: 29.46
Shortest transaction: 0.00
siege -h
Magento profiler:
line 65: #Varien_Profiler::enable(); // delete #
line 71: #ini_set(<display_errors>, 1); // delete #
(Move the mouse over the image to enlarge.)
Yslow:
Page Speed:
Using GTmetrix:
This is an online tool to benchmark a page with a combination of YSlow and Page Speed. Visit http://gtmetrix.com/ and DIY (Do It Yourself).
Using WebPagetest:
This is a similar tool as GTmetrix, which can be accessed from here: http://www.webpagetest.org/.
ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.
The analysis that Siege leaves you with can tell you a lot about the sustainability of your code and server under duress. Obviously, availability is the most critical factor. Anything less than 100 percent means there’s a user who may not be able to access your site. So, in the above case, there’s some issue to be looked at, given that availability was only 96.33 percent on a sustained 50 concurrent, one minute user Siege.
Concurrency is measured as the time of each transaction (defined as the number of server hits including any possible authentication challenges) divided by the elapsed time. It tells us the average number of simultaneous connections. High concurrency can be a leading indicator that the server is struggling. The longer it takes the server to complete a transaction while it’s still opening sockets to deal with new traffic, the higher the concurrent traffic and the worse the server performance will be.
Yahoo!’s exceptional performance team has identified 34 rules that affect web page performance. YSlow’s web page analysis is based on the 22 of these 34 rules that are testable. We used one of their predefined ruleset. You can modify and create your own as well. When analyzing a web page, YSlow deducts points for each infraction of a rule and then applies a grade to each rule. An overall grade and score for the web page is computed by summing up the values of the score for each rule weighted by the rule’s importance. Note that the rules are weighted for an average page. For various reasons, there may be some rules that are less important for your particular page.
In YSlow 2.0, you can create your own custom rulesets in addition to the following three predefined rulesets:
Page Speed generates its results based on the state of the page at the time you run the tool. To ensure the most accurate results, you should wait until the page finishes loading before running Page Speed. Otherwise, Page Speed may not be able to fully analyze resources that haven’t finished downloading.
Windows users can use Fiddler as an alternative to Siege. You can download it from http://www.fiddler2.com/fiddler2/, which is developed by Microsoft.
At Packt, we are always on the lookout for innovative startups that are not only…
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…