How Magento Can Easily Handle 8 Orders Per Second on a Budget
One of our Magento hosting clients was recently featured on NBC’s Today Show in the Steals and Deals segment highlighting discounted items for the holidays. It is always an exciting event that generates tens of thousands of visitors in a short period of time, and results in thousands of orders in a few short hours.
At the peak, we saw up to 8 orders per second being placed on their site. Everything worked as planned, no slowdowns or issues with people being able to place orders.
You might think this would take thousands of dollars in infrastructure and consulting fees to set up properly. Working with us, our client was able to spend less than $700 to be fully prepared for the onslaught of traffic and orders.
Here’s how we did it…
Cleanliness is paramount
Before embarking on a major live event, you want to be 100% sure your site is fully patched and free of any malware or compromised files. This means having your host or yourself verify all security patches are deployed, a malware scan is completed, a core file audit is conducted, CMS block review, etc…
For our hosted Magento clients, this is part of the services we provide for their stores to make sure they are safe. You cannot afford to have any card data being compromised during a large event.
Proper hardware is in place
The client already had a dedicated server with us. The only hardware addition we made was to use a second server just for the MySQL database. This allows PHP and MySQL to be separate and not compete for CPU resources. Each server had 32 GB of RAM, which was more than enough to handle an event such as this.
The servers were connected via a Gigabit private network. That’s all we did in terms of hardware to prepare for the segment.
Tuning, tuning, tuning
Making sure everything is properly configured and “tuned” optimally is the key to having a successful outcome. We broke it down as follows:
Magento Caching
Besides the general Magento cache being enabled, we also made sure a Full Page Cache (FPC) extension was in place (for Magento 1), and properly configured to cache as much as possible, both primary and secondary caches. We went with standard file based storage, as the client did not have thousands of pages/products, so it was quite efficient and easier to manage.
PHP
Using PHP’s built-in OpCode caching is very important to lower CPU usage during high traffic events. Not only enabling it, but tuning the memory usage, files allowed to be cached, and production settings to not verify timestamps is necessary to reduce resource usage to the absolute minimum.
MySQL
Looking at items such as InnoDB memory buffer space, maximum number of connections, and the query cache can really help eliminate any bottlenecks. The entire InnoDB data space should reside in memory. The MySQL query cache, always a contentious point for many server admins, can actually boost things quite a bit if it is sized correctly. You want it to be small enough so that query flushes do not impede performance, yet large enough to cache the most used queries during the order process.
Web Server
Besides the obvious setting to make sure enough resources can be used to accommodate the traffic by the web server, other important settings include client side caching rules, and setting the KeepAlive timeout to a small number of seconds (we opted for 2 seconds for this client) to free up unused resources.
Content Delivery Network (CDN)
We used a CDN in two ways to really help with handling the surge in visitors:
1. CDN Splash Page
The client created a 100% static splash page that was placed on the CDN on a separate sub-domain. This is what was linked to by NBC and where all the visitors first land. Think of this as a large shock absorber. It creates a buffer to minimize impact by a sudden increase in visitors.
The splash page has all of its assets (images, CSS, JS files) called via the CDN as well, so no hits to the servers occur when people land on the page.
2. CDN in use throughout the site
All static assets throughout the site (images, CSS, JS) are also called via the CDN, both regular and secure calls. This reduces the work the webserver must do under heavy traffic.
Warm everything up
Before the event, we made sure the Full Page Cache (FPC) was properly warmed. This means having a script that can spider the entire site making sure all pages are fully cached as much as possible. This includes the primary and secondary cache. OpCode cache should also be fully warmed so all code is as cached as possible.
Warming the CDN is also a good idea. You want to make sure the CDN has all of its files already cached to speed up page loads and offload traffic from the servers.
Pro tip: You can use a service like webpagetest.org to force the CDN to cache assets at CDN locations across the country and/or globe.
During the event
One of the biggest mistakes you can make during a high traffic event is to be using functions in the admin panel. Looking at orders, running reports, updating pages/products, etc… can put a strain on things, trigger automatic reindexing, and slow down the order process for customers. We informed our client to avoid the admin panel until traffic started to level off. This can make a big difference.
Your host should be on-hand monitoring resources, loads, overall flow of the site, etc… to make sure everything is running as expected. The homework we did prior to the event paid off, as we did not have to adjust any parameters during the airing of the segment or during the high traffic that resulted.
The process worked as planned, with no slowdowns encountered when orders started piling up. We saw a peak rate of 8 orders per second, and thousands of orders were successfully placed in just a few hours.
…
This is what fully managed hand-on hosting looks like. A web hosting company that is involved, knowledgeable, and able to respond to issues in real-time. This can make all the difference for a large event such as this one, or during your busy season.
Having a web host that understands Magento, takes a proactive approach to security patches, malware detection, site / performance monitoring, and personalized service when it’s needed, can make the difference between a successful online store, and one where your scrambling to put out fire after fire.
If this is the type of hosting you’d like for your ecommerce store, get in touch with us.
Looking for a web host that understands ecommerce and business hosting?
Check us out today!