What’s worse than having NO website visitors? Having TOO MANY! You might dream of getting 100,000’s of visitors but large traffic spikes can be a real problem for websites hosted on underpowered servers. In this blog post, I’ll show you how we handled 1.2 million visitors without breaking the bank.
It’s worth noting that a typical ‘off the peg’ shared hosting package from GoDaddy or Hostgator won’t withstand a sudden surge in visitor numbers. In fact, many hosting companies specifically forbid websites hogging server resources. If your site becomes popular and starts hogging CPU resources don’t be surprised if your hosting company pulls the plug on the offending website without warning. However, if you follow the tips here you’ll be able to utilise a budget hosting plan and still accommodate big visitor numbers.
So what happens when a site suddenly experiences an explosion in traffic? It’s a problem we know all too well because for the last ten years we’ve operated a horse racing portal which generates insane levels of traffic. I’m talking about 40,000+ active users on the site at any given time. To complicate matters further the traffic increase only lasts for a few days per year. Making the situation more like a classic ‘Hug Of Death‘ or ‘Slashdot‘ effect. Of course, we could spend big bucks on a server which could accommodate the traffic, but most of the time we’d only use a fraction of its power, potentially wasting thousands of pounds in hosting costs.
[av_image src=’https://www.eddison-media.com/wp-content/uploads/2015/06/visitors.jpg’ attachment=’2651′ attachment_size=’full’ align=’left’ animation=’no-animation’ styling=” hover=’av-hover-grow’ link=” target=” caption=’Visitors’ font_size=” appearance=” overlay_opacity=’0.4′ overlay_color=’#000000′ overlay_text_color=’#ffffff’ av_uid=’av-621f2y’][/av_image]
We could place the site on a cheaper server for 11 months of the year and move it to a more powerful one just before the traffic volumes increase. However, that runs the risk of something going wrong during the move and anyone who’s ever migrated a server will tell you they rarely run smoothly, plus you still have the hassle of moving the site back once the traffic levels return to normal. It goes without saying that this approach also won’t help those people with websites that suddenly become popular overnight.
So how can you make sure your website is capable of handling millions of visitors without spending a fortune?
Imagine your website server is acting like the automatic door at shopping mall entrance. A shopper walks up to the door and the sensor detects them approaching, in response the door swings open. If two people walk up to the door they can enter the shopping mall without any problems. However, if five hundred people attempt to enter simultaneously the doorway will become clogged and each shopper will take longer to gain access to the mall.
This is what happens when your website server becomes stressed with too many visitors. The volume of people trying to access the site will have a negative effect on the load time. Eventually, the server will crash under the stress.
By optimising your website and pushing server requests away from your hosting account you will be able to handle traffic spikes more effectively.
A quick word before I start… I have used this method for managing traffic spikes on many different hosting plans, ranging from $8 per month shared servers to $50 per month cloud server. I’ve never suffered from a crash or seen a negative impact on load times, even using the cheapest hosting plan.
Even if your site never suffers from the dreaded ‘Hug Of Death’, optimising it will still pay dividends. The majority of our sites run on WordPress, which is a brilliant CMS platform, but it has a reputation for causing high server CPU usage. Excessive and poorly coded WordPress plugins can exacerbate the problem further.
Before you do anything else, get rid of any unused or unnecessary plugins – do you really need that snow effect? Test your WordPress site with P3 Plugin Profiler to find out which plugins are negatively affecting load times and get rid of them!
The next step is to find a theme that loads super fast. StudioPress produce the quickest loading themes I’ve ever used and they’re also optimised for SEO which means you’ll need one less plugin (Yoast SEO). Having said that Studiopress themes can be a little basic for some people’s needs. If you want a fast loading theme with all the bells and whistles then look no further than Kriesi themes. So now you’ve addressed the basics by swapping to a fast loading theme and restricting the number of plugins to a bare minimum – what else should you do?
What the hell does this mean? Well, have you noticed that when you return to a website it loads quicker the second time round? That’s caching, your browser is storing elements of the website within its own memory. It’s much quicker than requesting the information again from the server – this is known as browser caching, but you can speed up this process more by adding server side caching.
Serving a copy of your web pages is much faster and uses fewer resources than requesting the original. This is especially true if you’re using WordPress because it stores information in a database and each visitor to the site will trigger a complicated database retrieval process which places a server under stress. You can drastically reduce this burden by using a WordPress caching plugin and the plugin will store copies of recently accessed pages and deliver those instead of querying the database.
Over the years we’ve used all the leading caching plugins available; W3 Total Cache, WP Super Cache and QuickCache. Of that trio my personal favourite was QuickCache, mainly because until now it was the easiest to set-up. W3 Total Cache is by far the most powerful but it is also the most difficult to configure. Recently I started using WP Rocket, a plugin with the power of W3 Total Cache and the usability of QuickCache. The only downside to WP Rocket is that it costs $39 to use it on your site. However, it’s worth every cent and I couldn’t recommend it highly enough. Check out the video review of WPRocket below.
[av_video src=’https://www.youtube.com/watch?v=jFKEv2kLijQ’ format=’16-9′ width=’16’ height=’9′ av_uid=’av-fc6gq’]
Before implementing the tweaks mentioned above, test the current load time of your site using Pingdom Tools or GTmetrix. Once you’ve made some changes you can retest and compare the before and after load times – you should start see a big improvement.
2. Image Optimisation
One of the quickest way to speed up a website is by reducing the image file size. No one will thank you for forcing them to render a 2meg photo! The only exception to this rule is photography websites, where the need for quality outweighs the need for speed. Everyone else should be compressing images to the bone. I usually do my image optimising in Fireworks or Photoshop before upload. However, If you don’t have access to these software programmes then try the excellent and free WP.Smush.it, a nifty little WordPress plugin which will automatically optimise images as you upload them.
By now you should have a fast loading theme, optimised images and have WPRocket installed, the next step is to add the Cloudflare service to your site. I could try to explain the concept of Cloudflare, but It would take ages and bore you to death – so why not watch this short entertaining video which explains the benefits…
[av_video src=’https://www.youtube.com/watch?v=0XZOecsbnKo’ format=’16-9′ width=’16’ height=’9′ av_uid=’av-2kwyl6′]
CloudFlare can be used by anyone with a website and their own domain, regardless of your choice in platform. From start to finish, setup takes most website owners less than 5 minutes. Adding your website requires only a simple change to your domain’s DNS settings. There is no hardware or software to install or maintain and you do not need to change any of your site’s existing code.
During our traffic spike, Cloudflare was able to handle 96% of requests! Only a fraction of people who viewed our website hit OUR server and the remaining 4% viewed a cached page generated by the WPRocket plugin. That means our site never came close to crashing or slowing down and we maintained a healthy 2 second load time for the duration of the spike.
So you’re probably thinking this Cloudflare service is expensive? Well, the basic features are FREE. If you want to aggressively cache everything as we did and get access to enhanced features such as page rules and real time stats then you’ll need Pro Plan ($20 a month) bargain! Nevertheless, the free plan is more than capable of handling high traffic situations.
It was my intention to detail the settings we use for Cloudflare in this post, but I eventually decided against it, mainly as it would require a lengthy explanation and this post is already too long. I will write a post which deals solely with Cloudflare settings at a later date – I will post a link here when it’s finished. However, don’t let that put you off using Cloudflare right now. The default settings will turbo charge your website like nothing else can. In my experience just adding the basic (free) plan offered by Cloudflare will cut your load time in half.
I would expect all of the above tweaks to reduce an average websites load time to under 2 seconds. I’ve even managed to get some sites loading in under 1 second using this method. It might seem daunting to take on these changes but don’t be frighten by the techy stuff, the majority of these tweaks are simple to implement and easy to undo if something goes wrong. Plus you’ll glad you made those changes when the traffic spikes!