Easily Improve Magento Performance

magento-standard-configuration-apache-mysql-varnish

Determine Optimal Magento Configuration for Peak Performance

The following configurations were compared during the performance tests to determine the optimal hardware and software configuration for a standard 2+1 (two nodes plus one database) setup:

  • Standard: Apache + MySQL — The most widely used configuration, combining the Web’s most popular HTTP server and open-source database.
  • Cache Optimized with Varnish: Varnish + Apache + Percona MySQL — An optimized configuration using Varnish (an open-source reverse proxy server), Apache, and Percona’s enhanced version of MySQL.
  • Cache Optimized with Nginx: Nginx + PHP-FPM + Percona MySQL — An optimized configuration of Nginx (a combined web server, caching proxy, and load balancing solution), PHP-FPM (the PHP FastCGI process manager), and Percona’s enhanced version of MySQL.

According to Magento engineers optimization of the caching configuration and tools dramatically improved Magento performance by offloading the application servers. So the main goal of the performance experiment was to offload back-end servers by serving as many pages as possible using third-party caching software in addition to native Magento full page caching. So the engineers added Cached Optimized with Varnish and Cache Optimized with Nginx configurations to the standard and the most popular Apache + MySQL infrastructure.

Testing Parameters

The following eCommerce parameters were set in each test scenario:

  • Number of websites: 1
  • Number of stores and store views: 1
  • Number of categories and products: 50 categories/100,000 products
  • Users per simulation: 2,800
  • Conversion rate ranging from 3% – 6%
  • Concurrency rate: 100 catalog page views/sec

The following testing tools were used:

  • A load testing and benchmarking utility Siege v. 2.72
  • An open source stress tool Gatling v. 1.1.0

Hardware used while the performance testing:

  • CPU: 2 x Intel® Xeon® CPU E5645 @ 2.40GHz
  • HDD: RAID1 – LSI MegaRAID SAS 9260-4i; 2 x SAS 164GB 15,000rpm
  • RAM: 24GB ECC
  • Network Interface Card: Intel 1GB 82576

 

The following software was installed on the performance testing servers:

  • Magento Enterprise Edition 1.11.2.0
  • Apache 2.2.15, mpm_prefork, mod_php
  • PHP 5.3.10
  • MySQL 5.5
  • Pecl memcache 3.0.6
  • Varnish 2.1.5
  • Nginx 1.0.15
  • PHP-FPM 5.3.10
  • Percona MySQL 5.5
  • Memcached 1.4.4
  • Operating system: Red Hat Enterprise Linux version 6.2 (Santiago) x86_64

magento-standard-configuration-apache-mysql-chart

  • Number of orders (clients): 2,800
  • Time required to process all orders: 900 seconds
  • Orders/per sec (average): 3.11
  • Response time (average): 2.11 sec
  • Web server load: 100%
  • Concurrent visitors: 100 page views/sec
With the Standard configuration, the system was able to serve approximately 268,700 orders and 79,500,000 catalog views per day.
  • Number of orders (clients): 2,800
  • Time required to process all orders: 496 sec
  • Orders/per sec (average): 5.65
  • Response time (average): 1.052 sec
  • CPU load: 100%
  • Concurrent visitors: 100 page views/sec
magento-configuration-apache-mysql-varnish-chart-s 
Click to enlarge

The system was able to serve approximately 487,300 orders or 79,500,000 catalog views per 24-hour period. The CPU load on web servers during the orders scenario test was as high as it was in the Standard Apache + MySQL architecture (close to 100%). However, due to the aggressive caching of static files as well as catalog pages, the bar was raised to handle 1.8 times additional orders. This architecture can easily serve more than 4,000 catalog page views per second from a single server with Varnish — whereby the only limiting factor is the network interface (1Gbit in these tests). To increase the number of catalog pages served to a client, you can add extra network cards or set up a 10Gbit network. For scaling dynamic content, you must add extra application servers.

Cache Optimized with Nginx

magento-configuration-apache-mysql-nginx 

  • Number of orders (clients): 2,800
  • Time required to process all orders: 460 sec
  • Orders/per sec (average): 6.09
  • Response time (average): 1.237 sec
  • CPU load: 100%
  • Concurrent visitors: 100 page views/sec
magento-configuration-apache-mysql-nginx-chart-b 
Click to enlarge

With a configuration optimized by implementing caching inside the FastCGI module of the Nginx server, the system was able to serve approximately 525,300 orders or 373,200,000 catalog views per 24-hour period. During an order scenario test, the CPU load on the web servers was as high as it was on the Standard configuration. However, this configuration managed to offload the system by serving static files to Nginx and aggressively caching catalog pages. This resulted in almost doubling the number of orders created. This architecture can easily serve more than 4,000 catalog page views per second from a single server with Nginx — the only limiting factor is the network connectivity (1Gbit in these tests). To increase the number of catalog pages served to the client, you can add extra network cards or set up a 10Gbit network. For scaling dynamic content, you must add extra application servers.

Comparison of Optimized Architectures (Chart)

 magento-configuration-apache-mysql-varnish-chart-s
Click to enlarge

Conclusion

Proper configuration of Magento Enterprise Edition is the right way to improve performance of your eCommerce business, speed up your online store and boost your bottom line due to a more efficient service offered to site visitors and customers. If your Magento-powered online business is constantly growing you’ll have to scale up your online store capacities, so you might need to offload your standard Apache+MySQL server architecture from serving static content by means of additional cache servers in order to double the number of orders and increase the number of catalog views which the system can handle.

To optimize hardware/software configuration with an ideal caching scheme, the following components are recommended:

  • Cache server — a caching layer; in this case, either Varnish or Nginx
  • Application server — one or more servers capable of serving dynamic requests; in this case, the Apache web server or the PHP FastCGI process manager
  • Cache storage — storage in RAM or on the disk in which cached documents are stored

The results of Magento engineers’ testing demonstrate that optimizing 2+1 configurations using Varnish or Nginx can lead to significant increases in performance. Optimizing the hardware/software configuration with Varnish or Nginx produces impressive results. However, due to differences in their designs, each configuration improves performance in different areas. While Nginx produces better server response times, Varnish does better when it comes to the amount of data being processed. When deciding between Varnish and Nginx, consider these points: Nginx can be a point of SSL termination; it provides flexible virtual hosting; and preserves cache between restarts. On the other hand, Varnish supports more flexible cache rule definitions due to the Varnish Configuration Language. According to the testers using Nginx with PHP-FPM slightly outperforms Varnish with Apache (by 8%). The main bottleneck is the application server CPU bandwidth. With more servers dedicated to handling dynamic requests, more orders can be processed.

Leave a comment