The Number One Reason Your Website Will Crash

Written by Adam Weiss on 2016-09-28

Are you preparing to go on the air? Rolling out a huge sale? Holding an event that will attract hundreds of thousands of people?

If you answered "yes" to any of the above, can your website withstand the traffic? If you're not sure, the answer is probably no, and the last thing you want is for your website to crash right when people want to look at you the most.

Your online reputation is just as important as the one we see offline, which is why it's so important to prepare for a media blitz properly. But how?

The average website attracts only about 1,000 pageviews per hour. That's about one page view every three seconds, and most servers are able to easily handle that without breaking a sweat.

But what if you send out an email marketing blast, have a big sale, go on TV, or even go viral? We're talking 1,000,000 visits a second. Wow, that's a lot. Is your website ready to take all that on?

Preparing for a deluge of traffic is not as easy as flipping a switch. Configuration changes, testing, tuning, and even the addition of hardware can stand between your site working beautifully or crashing at the worst moment. Unless you have an (often expensive) auto-scaling setup, it's critical to setup and test your website.

But, how do you actually prepare? Here's an inside look at what we do. Warning, we're about to get nerdy:

Caching

Most Content Management Systems have the ability to "cache" the contents of a static webpage. That means the system won't have to go back and forth to a database to generate a page; it will simply pull the cached version much faster. Faster = less time = ready for the next request.

Memcached/Redis

Your database can often be the bottleneck for performance, and it can only handle so many connections simultaneously. Storing the cached pages within a super-speedy volatile memory makes serving that information up extremely fast.

Static File Caching

If your content does not change regularly (every 5 minutes), you can implement static file caching. This will allow your server to avoid hitting the database or caching system at all, and if implemented properly, radically increases both performance and the amount of traffic your site can support.

CDN

Store your static assets (JS, CSS, images, files) in a Content Delivery Network. Rather than pulling those assets directly from your webserver, a CDN provides those files from their own servers, freeing yours to server the main document only. Not only does this speed up delivery, it also effectively increases the capacity of your server. If your site is made up of 100 files, a CDN can reduce the load to your server by 99%. If you have absolutely NO dynamic content on your site, you can even get away with putting your main pages on a CDN and calling it a day.

Static File Aggregation

Most sites are made of many CSS and JS files; if you can aggregate them into one file each, you can speed the delivery of your site.

Tuning

Make sure your configuration files are set to appropriately deal with your server's resources. If you allocate too much memory to the webserver software, you could easily crash the server. Too little, and you're not making the best use of it.

Load Balanced Webheads

At some point, caching and tuning can only do so much. You'll have to throw more webheads into the mix behind a load balancer. This will allow you to distribute traffic amongst multiple systems. If you have an 8GB webhead that can handle 2,000 visits a second, just increase your webheads appropriately to handle the increase. Keep an eye on the traffic, and if you need to add more servers, you can. (Cloud servers are really great for this, and Docker is spectacularly fast if you have it set up.)

Analytics/Monitoring

Make sure you're always monitoring your site during high-traffic events. If it goes down for you, it's probably down for others as well.

Want to learn more or getting ready for a big media blitz? Connect with us.