In today's article I want to benchmark various Magento 2 full page cache setups: built-in, redis and varnish. We will find out if there is a noticeable difference between these options.
I will be using Magento 2 on AWS setup.
I will be using JMeter test plan:
- A user visits homepage
- A user clicks on a category
- A user clicks on a product
- A user adds a product to cart
- A user goes to cart
- A user proceeds to checkout
I will be using 50 concurrent connections ie 50 concurrent visitors.
Disclaimer: I will be using default options for Redis and Varnish. I understand that I might get difference results if I fine tune these caching servers.
1. Magento 2 Built-in full page cache
This is the default Magento 2 setup. If you just installed Magento 2 and didn't change any configuration settings that is the setup you got.
The Time to first byte (TTFB) over time graph is displayed below:
2. Redis for session and full page cache
Now we will use Redis for session and full page cache storage.
Setup is simple.
First install redis server (I will use Debian 8):
apt-get install redis-server
Then edit app/etc/env.php file to set redis for session:
'session' => array ( 'save' => 'redis', 'redis' => array ( 'host' => '127.0.0.1', 'port' => '6379', 'password' => '', 'timeout' => '2.5', 'persistent_identifier' => '', 'database' => '0', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'log_level' => '1', 'max_concurrency' => '6', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '0', 'min_lifetime' => '60', 'max_lifetime' => '2592000' ) ),
and for full page cache:
'cache' => array( 'frontend' => array( 'default' => array( 'backend' => 'Cm_Cache_Backend_Redis', 'backend_options' => array( 'server' => '127.0.0.1', 'port' => '6379' ), ), 'page_cache' => array( 'backend' => 'Cm_Cache_Backend_Redis', 'backend_options' => array( 'server' => '127.0.0.1', 'port' => '6379', 'database' => '1', 'compress_data' => '0' ) ) ) ),
I run the same JMeter test and here is the results:
I don't see any real difference between built-in option and redis. Do you?
3. Varnish for Magento 2 Full Page Cache
I have used Magento 2 official guide to setup varnish.
I am using Varnish 4.0.2 installed on Debian 8.
I don't really see any noticeable difference between Redis, Varnish and built-in magento full page caches.
Out of the box configurations for redis and varnish are no better than the built-in Magento 2 caching solution.
Do you disagree? Share your points in comment section.
In the next articles I will try and optimize Redis and Varnish for optimal performance and will run benchmarks again. Stay tuned.
If you find this post interesting do not hesitate to sign up for our newsletter and join the 650 people who receive Magento news, tips and tricks regularly.