Varnish Cache tested on Magento
Lucas Liang | September 26, 2011Varnish Cache is a web application accelerator, also known as a caching HTTP reverse proxy, which is designed for content-heavy dynamic web sites. And today, we have tried Varnish on a Magento default sample shop, to see how well Varnish helps on the loading speed, compared to the bare Magento install.
1 Varnish Features for Magento
1.1 Enable full page caching using Varnish.
For a sample Magento website, Varnish is enabled to cache most of the pages, like Home Page, and other Page Categories.
1.2 Varnish servers are configurable in Admin, under System / Configuration / General – Varnish Options
You can specify which Varnish server Magento website is using. If just use one server for hosting Magento website, we can install varnish on the same server and input the blank as 127.0.0.1:80 which is by default.
1.3 Automatically clears (only) cached pages when products, categories and CMS pages are saved.
For example, if you add a new product or update the parameters of the products, when you click the save button in the admin page, the website data which stored in Varnish will be automatically purged, so that you won’t read the old data in the Varnish Cache.
In the figure below, I modified the price of HTC Touch Diamond, when I click ‘Save’, the Data in the Varnish Cache is purged, so you can see the price of the product is up-to-date.
1.4 Adds a new cache type in Magento Admin, under System / Cache Management and offers the possibility to deactivate the cache and refresh the cache.
For example, if you finish adding a new category, you click ‘Save Category’, then you click on the Home Page, you won’t see the new category in the navigation bar, you need to manually refresh the Vanish cache in Magento Admin under System / Cache Management. You can see the picture below :
1.5 Notifies Admin users when a category navigation is saved and Varnish cache needs to be refreshed so that the menu will be updated for all pages.
You can see the green lines under the navigation bar.
1.6 Turns off varnish cache automatically for users that have products in the cart or are logged in, etc.)
Products in the cart and user logged in which are user-specific parts, which needs to interact with Apache directly, which can be passed from Varnish cache.
2 Varnish Installation
2.1 Prerequisites
it’s better running on a 64bit Linux.
wget http://download.fedora.redhat.com/pub/epel/5/x86_64/jemalloc-2.1.3-2.el5.x86_64.rpm
rpm -ivh jemalloc-2.1.3-2.el5.x86_64.rpm
Hardware Configuration for Magento + Varnish Server
- Xen Server
- CPU: Quad-Core Xeon E5506 @ 2.13GHz
- Memory: 4G
2.2 Install Varnish 2.1.5
wget http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gz
tar zxf varnish-2.1.5.tar.gz
cd varnish-2.1.5
./configure
make && make install
2.3 Install Varnish Module
- Download the latest version of Magento and install it
- cd [magento root folder]
- Create folder app/code/local/Varnish
- Copy folders controllers/ etc/ Helpers/ Model/ under app/code/local/Varnish/
- Copy Magneto_Varnish.xml to app/etc/modules/
- Copy varnish.vcl to /etc/varnish/
2.4 Install Modman
curl http://module-manager.googlecode.com/files/modman-1.1.5 > modman
chmod +x modman
mv modman /usr/bin
2.5 Install git
rpm –ivh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum install git
2.6 Clone the git repository
cd [magento root folder]
modman init
env GIT_SSL_NO_VERIFY=true modman magneto-varnish clone https://github.com/madalinoprea/magneto-varnish.git
2.7 Apache Config
vim /etc/httpd/conf/httpd.conf
change Listen 80 to Listen 8080
2.8 Launch Varnish
We will use 1G for the cache storage. It depends on how much objects need to be cache, 1G is sufficient in most of the cases.
/usr/local/sbin/varnishd -f /etc/varnish/varnish.vcl -s malloc,1G -T 127.0.0.1:2000
Now Varnish is ready for Magento.
3 Varnish tests for Magento (Magento Version 1.5.1)
3.1 Bench report for bare Magento and Magento + Varnish (Load testing tool : Funkload)
For the sample Home page of Magento, Figure 1 is without Varnish and Figure 2 is with Varnish. You can make the comparison.
In Figure 1, I made the load testing with concurrent users 2, 6, 10, 14, 18, 22. You can easily read from the table below the chart, The first column CUs means concurrent users, the third column Rating which is based on the response time of Home page of Magneto. You can find the response time for 14 CUs are becoming Good, and 18 CUs are becoming FAIR, 22 CUs are becoming POOR, which indicates that if the concurrent users are larger than 22, the performance of bare Magento will be POOR or UNACCPETABLE.
In Figure 2, I made the load testing with concurrent users 20, 40, 60, 80, 100, 120. The below test is also based on the sample home page of Magento. You can see even with Maximum 120 concurrent users, The Rating is still Excellent.
4 Testing Scenarios (Load testing tool: Jmeter)
The test scenarios below are tested under three platforms. The .cvs files are exported from the test results of Jmeters :
- Magento
- Magento + Varnish
- Magento + Varnish + J2T_AJAXCART_LITE-1.1.3
Clarification of the following figures :
- Column 1 : test pages sequence.
- Column 2 : how many times the pages are being loaded.
- Column 3 : the average time for loading the page.
4.1 Scenario 1 : Navigation
- Home Page : http://192.168.0.38/magento3/
- Page category A : http://192.168.0.38/magento3/furniture.html
- Page category A_a : http://192.168.0.38/magento3/furniture/living-room.html
- Product Page A_a_1 : http://192.168.0.38/magento3/furniture/living-room/ottoman.html
- Page category B_b : http://192.168.0.38/magento3/electronics/cell-phones.html
- Product Page C_c_2 : http://192.168.0.38/magento3/apparel/shoes/mens.html
4.2 Scenario 2 : Add to cart
- Home Page : http://192.168.0.38/magento3/
- Page category A : http://192.168.0.38/magento3/furniture.html
- Page category A_a : http://192.168.0.38/magento3/furniture/living-room.html
- Product Page A_a_1 + action add to cart : http://192.168.0.38/magento3/furniture/living-room/ottoman.html
- Shopping cart page : http://192.168.0.38/magento/checkout/cart/
4.3 Scenario 3 : Customer / Checkout
- Home Page : http://192.168.0.38/magento/
- Login Page : http://192.168.0.38/magento/customer/account/login/
- Create account page :
- http://192.168.0.38/magento/customer/account/create/
- http://192.168.0.38/magento/customer/account/createpost/
- Add default adresse page :
- http://192.168.0.38/magento/customer/address/
- http://192.168.0.38/magento/customer/address/formPost/
- Product Page A_a_1 + action add to cart :
- http://192.168.0.38/magento/furniture/living-room.html
- http://192.168.0.38/magento/furniture/living-room/ottoman.html
- Shopping cart page : http://192.168.0.38/magento/checkout/onepage/saveOrder/
- Checkout steps :
- http://192.168.0.38/magento/checkout/cart/
- http://192.168.0.38/magento/checkout/onepage/
- http://192.168.0.38/magento/checkout/onepage/saveBilling/
- http://192.168.0.38/magento/checkout/onepage/getAdditional/
- http://192.168.0.38/magento/checkout/onepage/progress/
- http://192.168.0.38/magento/checkout/onepage/saveShippingMethod/
- http://192.168.0.38/magento/checkout/onepage/progress/
- http://192.168.0.38/magento/checkout/onepage/savePayment/
- http://192.168.0.38/magento/checkout/onepage/progress/
- Checkout success : http://192.168.0.38/magento/checkout/onepage/success/
4.4 Conclusion
According to the above tests, for the static pages, Varnish performs great. For the customer specific settings, like login, logout, the cart, and https pages, Varnish will not cache these data, which will need to be directly processed by Apache, so the load average time of the customer specific pages can’t be seen any difference with or without Varnish. Varnish is a good tool for basic web page navigation.
















I agree with your details , wonderful post.
Iunderstand what you are saying and I agree with you
After study a few of the weblog posts in your web site now, and I actually like your method of blogging. I bookmarked it to my bookmark website checklist and will likely be checking again soon. Pls take a look at my website online as properly and let me know what you think.
Hi Lucas,
sorry for my stupid question, I don’t have a “Varnish Options” in my admin panel.
Do you have installed some module to have this option listed in admin?
Thank you for any help.
Kind regards, Tomas
Thanks for helping out, excellent info .
I figured I would reveal some information with everyone to contribute to the community, in hopes that more folks will share some of their methods. I’ve made exactly $11,978 in the last four months just by using http://Earn-1100-Weekly.info It’s a little gem of a software that pretty much allows me to live from my site. Have you seen it yet?
Hello there! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a extraordinary job!
My spouse and I absolutely love your blog and find almost all of your post’s to be precisely what I’m looking for. Do you offer guest writers to write content for yourself? I wouldn’t mind creating a post or elaborating on a number of the subjects you write about here. Again, awesome blog!
Hey! I could have sworn I’ve been to this site before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely delighted I found it and I’ll be bookmarking and checking back often!
I think one of your commercials triggered my browser to resize, you might want to put that on your blacklist. how to pick up girls
Thank you, I’ve been seeking for details about this subject for ages and yours is the best I have discovered so far.
Hi there just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same results.
Howdy just wanted to give you a quick heads up. The text in your content seem to be running off the screen in Chrome. I’m not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I’d post to let you know. The design look great though! Hope you get the issue fixed soon. Many thanks
Great post, I do believe blog owners should acquire so much from this web blog its really user friendly .
Sweet blog! I found it while searching on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thank you
We absolutely love your blog and find nearly all of your post’s to be precisely what I’m looking for. can you offer guest writers to write content for you? I wouldn’t mind producing a post or elaborating on a few of the subjects you write in relation to here.
Youre so cool! I dont suppose Ive read anything like this before. So good to seek out any person with some authentic thoughts on this subject. realy thanks for starting this up. this web site is one thing that is needed on the net, someone with a bit originality. useful job for bringing one thing new to the internet!
Nice guide and how, to be sure to check out varnish 3.0