Magento 2.0: Site Performance and Scalability Optimizations
Magento 2.0: Site Performance and Scalability Optimizations
0
Site Performance and
Scalability Optimizations
Table of Contents
1 Introduction
2 Recommended Magento Configurations
4 Layered Architecture
5 Performance and Scalability Improvements
5 Client-side Improvements
6 Page Caching
7 Application Enhancements
7 Asynchronous Order and Product Updates
7 Job Queue Mechanism
8 PHP Interpreters
8 Database Improvements
8 Multiple Database Masters
10 MySQL Cluster Support
10 Performance Toolkit
10 Performance Results
10 Test Configuration
10 Software
11 Scenarios
11 Testing Methodology
12 Small Merchant Deployment
12 Throughput Results
13 Server Response Time Results
14 Large Merchant Deployment
14 Throughput Results
15 Server Response Time Results
17 Conclusion
17 Small Merchant Deployment
18 Large Merchant Deployment
19 Appendix
19 Merchant Profile Details
19 Small Merchant Deployment (4 web node cores)
20 Larger Merchant Deployment (20 web node cores)
Magento 2.0 also offers new functionality to help you create powerful shopping experiences. An all-
new, streamlined checkout and enhanced responsive designs provide you with an improved toolset
for differentiating your site and growing sales across devices. Redesigned administrative controls and
merchandising tools enable more efficient business operations and faster onboarding of new team
members so you can deliver better service to your customers. And, with easier upgrades enabled by
Magento 2.0’s modular architecture, you can immediately take advantage of new functionality as it
becomes available.
On top of this flexible and feature-rich new platform, Magento 2.0 also includes comprehensive changes
that set a new standard for performance and scalability. Out-of-the-box, Magento 2.0 can now:
This paper explores the Magento 2.0 performance and scalability enhancements in depth to help you
understand how the new platform can benefit your business and support your long-term growth plans. It
also provides configuration recommendations and benchmark testing results that you can use to optimize
your Magento 2.0 site performance.
IMPORTANT NOTE: All tests referenced in this paper are based on recommended and supported
configurations for Magento platforms. Deviation from these configurations may results in varied results,
which may not accurately reflect the nature in which the product was designed and architected.
Core Configuration
Magento 2.0 is optimized to run using PHP7 and Varnish. Although it is possible to run with PHP5.6 and
without Varnish, it is not recommended. It is advised that sites use both PHP7 and Varnish to support
the operation of their business and to achieve optimal performance results.
• Stores->Configuration->Advanced->Developer:
- Grid Settings: Asynchronous indexing: Enable
- CSS Settings: Minify CSS Files: Yes
- JS Settings: Minify JS Files: Yes
- Merge JavaScript Files: No
- Template Settings: Minify HTML: Yes
- JavaScript Settings: Enable JavaScript Bundling: Yes
Page Cache
The page cache setting controls which version of the page cache is used. For the best performance,
enabling the Varnish cache is strongly recommended. Note that this requires the deployment and
configuration of Varnish.
• Stores->Configuration->Sales->Sales Emails:
- General settings: Asynchronous sending: Enable
Index Settings
• System->Index Management:
- All indexers should be in “Update on schedule” mode
Application Cache
• Configure the platform to use Redis in env.php
- Requires deployment and configuration of Redis
Production Mode
Production mode can either be enabled using a single command:
or can be broken into multiple steps if desired to give developers additional control over the process:
This standard web application structure allows for different components of the architecture to be scaled
independently in order to meet the requirements of different business use cases and different loads on
the system.
ADVANCED TOPOLOGY
CLIENT TIER
Client Workstation
PAGE CACHE
Varnish Reverse Proxy
and Full Page Cache
Load Balancer
APPLICATION TIER
Magento Memcache
(session + markup
Apache/Nginx + PHP + data cache)
Load Balancer
DATABASE TIER
MySQL MySQL
Search
Master R/O Replicas
The following section describes the performance and scalability improvements made in each of these tiers
in Magento 2.0.
Client-side Improvements
Page load time is a critical factor for creating a successful eCommerce site and has been shown to
directly impact consumer engagement and conversion rates. One key factor in providing a fast page load
and good customer experience is reducing the overall page weight or the amount of data that must be
loaded to render the page. The amount of data required to render a web page is both a function of the
visual design of the page and the technologies and web development strategies used.
Magento 2.0 provides a number of optimizations to reduce page weight and improve response times:
• Magento 2.0 optimizes the assets required to render the page by using minification.
Minification is a process of removing whitespace, comments, and other unnecessary characters
in order to reduce the size of files served to the browser. With Magento 2.0, all HTML, CSS, and
JavaScript served by the application are minified to reduce their size. This minification is carried
out in advance of requests and is cached so the minified files are available for all website requests.
Magento uses industry-standard minification engines such as jShrink for Javascript and cssmin for
CSS, as well as an internally-developed engine for HTML. These engines were selected to maximize
compression, but merchants can choose to use others if they desire. To further reduce page
weight, image files used by Magento websites are compressed using the PHP gd2 library to provide
high quality images in the smallest file size.
• Magento 2.0 maximizes the usage of the browser cache for storing assets. All JavaScript
and CSS are loaded to the browser and cached on the initial web page visited. This minimizes
the amount of content that needs to be downloaded to render any subsequent page. To further
improve the ability of the cache to service page requests and allow the browser to begin rendering
the page, private data (such as consumers’ names) are no longer provided as HTML blocks. Now
they are returned to the browser as JSON and are inserted into the rendered page when available.
• Magento 2.0 improves response time by using asynchronous processing during checkout
and cart operations. Items are added to the cart asynchronously to improve response times for
the browsing experience. Many checkout operations are also done asynchronously to improve
response time, such as address validation and cart updates.
Collectively, these optimizations reduce the amount of data that must be passed to the browser in order
to render the webpage. These approaches help ensure that nearly any page design can be efficiently
rendered for speed.
With Magento 2.0, the application now directly integrates with Varnish page caching out-of-the-box.
Varnish is a reverse-HTTP proxy or web accelerator. The Varnish application stores HTML and other files or
fragments so that they can be returned extremely quickly.
Varnish provides a very fast and efficient mechanism for serving content that is highly scalable. The
requests that are served by the Varnish cache never need to reach the Magento application servers,
which reduces the load on the web nodes while dramatically improving the response time. One or more
Varnish servers can be used in front of the Magento server(s), an approach that provides a much faster
and more efficient system.
Cached content can be composed of different elements with different lifespans or times-to-live using
Edge Side Includes (ESI). Edge Side Includes allow for different cached elements to be combined
dynamically before being served from the cache. Page elements that cannot be cached, such as cart
contents, customer name, or other private data, are provided separately. These page elements are passed
to the browser as JSON that can be rendered asynchronously in the browser rather than on the server.
This approach allows the page to begin rendering as quickly as possible with the other content added in
when it is available, creating a superior user experience. Magento 2.0 handles invalidation of content in
the page cache to ensure the right content is served to the website.
Magento 2.0 opens the benefits of Varnish caching to a much broader set of merchants by fully
supporting and providing configuration files (.vcl files) for Varnish 3.X and 4.X. These configurations must
be updated to reflect the deployment topology, but provide a starting point that makes it significantly
easier and less expensive to implement Varnish to improve performance and scalability.
There can be a number of different ways to architect Varnish in the application. The simplest option is to
deploy Varnish on the same server that is running Magento. More sophisticated deployment architectures
can be used to scale out multiple Varnish servers using a load balancer to distribute traffic between
multiple Varnish instances on multiple servers. These deployments can improve scalability and provide
redundancy as part of a high availability system.
To use Varnish with secure pages or sites (i.e., served using HTTPS), another application (such as Nginx)
must be placed in front of the Varnish server(s) to handle SSL termination.
Magento 2.0 does provide an alternative Page Cache in addition to Varnish. This cache is intended
for use in development or in single web node situations where Varnish cannot be used. However, the
Page Cache uses a PHP implementation that requires the Magento application to process the caching
requests, which causes it to be less efficient and to not yield the same performance benefits. Due to
the superior performance and scalability characteristics of Varnish, it is strongly recommended for
use in production deployments.
For example, when a server is operating at full capacity, an Admin making updates to product descriptions
or pick, pack and ship orders is still able to quickly interact with Magento, as the actual processing is queued
for later. This means backend Application performance is dramatically improved for situations where there
are over 50+ Admin users simultaneously making order updates and over 25+ Admin users simultaneously
making product updates.
WEB SERVERS
An example of the job queue’s ability to improve efficiency and throughput in operations is deferred stock
updates, an optional configuration in Magento Enterprise Edition 2.0. Deferred stock updates allow for
inventory levels to update asynchronously as orders are placed to increases checkout throughput. It helps
ensure that orders will be captured when checkout transactions are high. This functionality is best suited for
high inventory items or products that can easily be backordered. Deferred stock updates can be enabled on
either a per-product or per-website scope, giving merchants the flexibility to use where ideal.
PHP Interpreters
Beyond the updates made in the Magento application, there are significant performance advancements
that have come from the larger PHP community. One such improvement is PHP7, a radically enhanced PHP
interpreter recently released by Zend that has been demonstrated to boost the performance of nearly all
PHP applications. Magento recommends and supports the use of PHP7 to achieve optimal performance
with the Magento 2.0 platform. Earlier versions of PHP may be used, but may not yield the same
performance benefits and are not recommended.
Database Improvements
To further improve scalability in our commercial product, Magento Enterprise Edition 2.0, we made a
number of improvements to the database tier of the application. These options allow for tuning and
optimization of the databases to better handle high traffic and transaction volumes.
FRAMEWORK
DIGITAL COMMERCE
The division helps ensure that the load from merchandising and order management activities can be
isolated from users browsing and purchasing on the website. This separation allows different functional
areas to be scaled independently depending on the system load and unique needs of the business, such
as high order volume in checkout or a very high SKU count.
Magento uses the Command Query Responsibility Segregation (CQRS) database pattern to seamlessly
support the routing of queries to the appropriate database. Because of this, developers do not need
to know which database configuration is being used, which simplifies customization. CQRS assumes
a Create Read Update Delete (CRUD) database access pattern is in use. Our framework uses that
assumption to route the generated queries to read (slave) or write (master) databases. Developers
customizing Magento do not need to incorporate code to support different database configurations
as the framework will handle this automatically.
These database improvements represent a major advancement for Magento Enterprise Edition and provide
considerable flexibility in how the database tier can be scaled. Now each area of the application can be
tuned independently for its expected load. In addition, one can isolate the critical customer facing database
interactions from lower priority administrative tasks to achieve comprehensive scale for large and growing
enterprise customers.
Performance Toolkit
The Magento Performance Toolkit is a script and a set of JMeter tests that allow for consistent and
repeatable performance testing for Magento applications. The script allows the generation of four distinct
customer profiles that are intended to represent different eCommerce business sizes. The data from the
script populates a Magento instance. The Performance Toolkit is bundled with the Magento distribution
(in the setup/performance-toolkit directory).
Performance Results
To show the impact of Magento 2.0’s more flexible architecture and performance enhancements, a series
of benchmark tests were performed comparing the recommended configurations of Magento Enterprise
Edition 2.0 and Magento Enterprise Edition 1.14.2. These tests revealed that Magento Enterprise Edition
2.0, with its performance enhancements, tight integration with Varnish, and support for PHP7,
delivers higher throughput (orders/hour) and faster server response times across the board for
both small and large merchant deployments.
Test Configuration
Software
We tested the recommended and fully-supported out-of-the-box configurations for both products:
Testing of other scenarios is not valid as they do not provide data on recommended or supported
configurations. Additional software details are available in the Appendix.
• Small merchant with $1-$5M in online sales deployed on a single 4-core web node and a single
database node. 25 simultaneous JMeter threads (representing 25 concurrent requests) were used to
show site performance during a period of peak traffic, such as a sale.
• Large merchant with $50-$100M in online sales deployed on five 4-core web nodes and a single
database node. 25 to 100 simultaneous JMeter threads (representing 25 to 100 concurrent requests)
were used to show site performance under increasing traffic loads.
Testing Methodology
The tests emulated typical eCommerce site usage scenarios, such as:
• Catalog browsing, including visiting the home page, a catalog page, a configurable product page,
and a simple product page
• Adding both a simple and configurable product to the cart
• Completing the full checkout process (all steps) as a guest and a registered customer
All tests were conducted using the Magento Performance Toolkit and JMeter was used to measure and
report server response times in milliseconds.
The small merchant test scenario shows that Magento Enterprise Edition 2.0 successfully runs on a small
4-core server, even when handling high loads associated with 25 concurrent users during a sales event.
Magento Enterprise Edition 2.0 delivers better performance than Magento Enterprise Edition 1.14.2 across all
use cases:
• Processes 28% more order per hour, reaching 597 orders per hour
• Delivers nearly instant response times for catalog pages
• Enables up to 66% faster add-to-cart server response times
• Provides 48% faster guest checkout response times and 36% faster customer checkout response
times when all checkout steps are combined
Throughput Results
597
600
500 467
Orders per Hour
400
300
200
100
Catalog Browsing
50
Median Server Response Time (ms.)
41
40 37
35 35
30
20
10
1 1 1 1
0
Home Category Configurable Simple
Page Page Product Product
2000 10000
8677
Median Server Response Time (ms.) - All Steps
1662
1533
Median Server Response Time (ms.)
8000
1500
6325
6000 5558
1000
656 4000
3303
523
500
2000
0 0
Simple Product Configurable Product Guest Checkout Customer Checkout
FIGURE 6: Server response times for adding products to FIGURE 7: Consolidated server response times for all steps of
the shopping cart are sub-700 milliseconds and up to 66% the checkout process show that Guest Checkouts are 48% faster
faster for Magento Enterprise Edition 2.0 when compared to and Customer Checkouts are 36% faster on Magento Enterprise
Magento Enterprise Edition 1.14.2. Edition 2.0 when compared to Magento Enterprise Edition 1.14.2.
• Processes 39% more order per hour, reaching up to 2,558 orders per hour
• Delivers nearly instant response times for catalog pages
• Enables up to 66% faster add-to-cart server response times that are under 500 milliseconds
• Provides 51% faster guest checkout response times and 36% faster customer checkout response
times for all checkout steps combined
Throughput Results
3000 3000
2558
2500 2500
Orders / Hour
1500 1500
1000 1000
500 500
0 0
25 Threads 50 Threads 75 Threads 100 Threads
Magento EE 1.14.2 Magento EE 2.0
FIGURE 8: Throughput results for 100 JMeter threads show FIGURE 9: Throughput data for a range of JMeter thread
that Magento Enterprise Edition 2.0 can process 2,558 counts show Magento Enterprise Edition 2.0 consistently
orders per hour, or 39% more orders per hour than Magento processes more orders per hour than Magento Enterprise
Enterprise Edition 1.14.2. Edition 1.14.2 across different load profiles, and is particularly
strong at the highest load level.
Catalog Browsing
40 38 50
35 44
35 41
Median Server Response Time (ms.)
25 22 30
26
20
20
15
10
10
5
1 1 1 1 1 1 1 1
0 0
25 Threads 50 Threads 75 Threads 100 Threads 25 Threads 50 Threads 75 Threads 100 Threads
35 34 35 33
31 31
30 30
Median Server Response Time (ms.)
26 26
25 25
21
20
20 20
15 15
10 10
5 5
1 1 1 1 1 1 1 1
0 0
25 Threads 50 Threads 75 Threads 100 Threads 25 Threads 50 Threads 75 Threads 100 Threads
FIGURE 10: Benchmark data for catalog browsing pages show Magento Enterprise Edition 2.0 outperforms Magento Enterprise Edition
1.14.2 and delivers nearly instant server response times across all load profiles.
1189
1200 1137 1500
1380
994 1236
Median Server Response Time (ms.)
600
600
397 402 486 497
400 345 418
303 366
300
200
0 0
25 Threads 50 Threads 75 Threads 100 Threads 25 Threads 50 Threads 75 Threads 100 Threads
FIGURE 11: Server response times for adding products to the cart on Magento Enterprise Edition 2.0 are up to 66% faster when compared
to Magento Enterprise Edition 1.14.2.
4979
5000 4805 8000
7086
4253 7000
6432
Median Server Response Time (ms.)
4000
3651 5933
6000
5141
5000 4696
3000 4516
2384 2434 3833
4000
2068 3336
2000 1850
3000
2000
1000
1000
0 0
25 Threads 50 Threads 75 Threads 100 Threads 25 Threads 50 Threads 75 Threads 100 Threads
FIGURE 12: Consolidated server response times for all steps of the checkout process show that Guest Checkouts are up to 51% faster and
Customer Checkouts are up to 35% faster on Magento Enterprise Edition 2.0 when compared to Magento Enterprise Edition 1.14.2.
Powering Magento 2.0’s performance and scalability gains are a comprehensive set of enhancements that
optimize the client side to reduce page weight, tightly integrate Varnish caching to accelerate page load
times, and optimize the application itself to support more efficient job processing and additional concurrent
Admin users. It also incorporates new technologies, like PHP7, to boost performance and includes a re-
architected database tier with support for multiple master databases to offer a better ability to scale and
manage unique system load and business requirements.
Together, these enhancements result in a solution that sets a new standard for performance and scalability.
Benchmark tests show that Magento Enterprise Edition 2.0 delivers across-the-board improvements in
server response times for both small and large merchants. Catalog browsing, add-to-cart operations, and
checkouts are significantly faster and Magento Enterprise Edition 2.0 can process up to 39% more orders
per hour, enabling you to get more from your hardware investment. The chart below summarizes all key
benchmark test results so you can see for yourself the power of the Magento 2.0 platform.
467 597
Catalog Browsing
Home Page 37 1
Category Page 41 1
Configurable Product 35 1
Simple Product 35 1
Add to Cart
Simple Product 1,533 523
Configurable Product 1,662 656
25 Threads 50 Threads 75 Threads 100 Threads 25 Threads 50 Threads 75 Threads 100 Threads
25 50 75 100 25 50 75 100
Threads Threads Threads Threads Threads Threads Threads Threads
Catalog Browsing
Home Page 22 28 35 38 1 1 1 1
Category Page 26 34 41 44 1 1 1 1
Configurable Product 21 26 31 34 1 1 1 1
Simple Product 20 26 31 33 1 1 1 1
Add to Cart
Simple Product 844 994 1,137 1,189 303 345 397 402
Configurable Product 896 1,076 1,236 1,380 366 418 486 497
Definitions
• Software
- PhP 5.6.13 with Zend Opcache v7.0.6-dev (for Magento Enterprise Edition 1.14.2)
- PhP 7.0.3-1 with Opcache (for Magento Enterprise Edition 2.0)
- Nginx 1.6.2
- MySQL 5.6.28
- Varnish 4.0.2 (for Magento Enterprise Edition 2.0)
- Redis 3.0.5
- CentOS 6.4, CentOS 7.0 and Debian (on core 3.16.7)
• 1 Database Node
- 4 CPUs Core i7 with hyper threading
- 8GB of memory
- 500 GB 7200 RPM SSHD and RAID 1, 5, or 10 disks
- Running Software
- MySQL
- Redis (FPC Cache for Magento Enterprise Edition 1.14.2, Session Storage)
• All performance tests leverage real cores. Virtual can bring unexpectedly high deviation.
• Software
- PhP 5.6.13 with Zend Opcache v7.0.6-dev (for Magento Enterprise Edition 1.14.2)
- PhP 7.0.3-1 with Opcache (for Magento Enterprise Edition 2.0)
- Nginx 1.6.2
- MySQL 5.6.28
- Varnish 4.0.2 (for Magento Enterprise Edition 2.0)
- Redis 3.0.5
- Memcache 1.4.21
- CentOS 6.4, CentOS 7.0 and Debian (on core 3.16.7)
• 1 Database Node
- 4 CPUs Core i7 with hyper threading
- 8GB of memory
- 500 GB 7200 RPM SSHD and RAID 1, 5, or 10 disks
- Running Software
- MySQL
- Redis (Session Storage, FPC storage for Magento Enterprise Edition 1.14.2)
• All performance tests leverage real cores. Virtual can bring unexpectedly high deviation.