Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

A web application is hypothetically featured on Digg or Reddit, and the server load immediately spikes up by a couple of orders of magnitude. What kind of hosting solution will allow the website to survive through a large flux like this? (and not cost a fortune)

Hosting through AWS seems to be in fashion these days. However, many complain about the cost. Will a VPS hosting solution also be able to scale-up in a timely fashion, while costing less? Alternatives? Thanks.

share|improve this question

3 Answers 3

Optimise your application before optimising your server infrastructure
It's tempting to throw more servers at traffic spikes or overpay for resources that you may never use "just in case". A better solution is to optimise your application to withstand spikes before they arrive. Specifically:

Cache dynamic code
Your application should serve static html files instead of dynamically generated ones using a caching system. WordPress offers plugins for this (e.g. W3 Total Cache) but it's not too tricky to roll your own solution if your application is home grown. (Search for "[programming language] static cache".)

Offload static assets
Serve images, CSS, and JavaScript files from somewhere else. Amazon's Cloudfront and S3 packages are popular options, but I favour Cloudflare, which offers automatic caching of static assets and a list of other CPU and bandwidth-saving benefits for $20/month.

Use Google's Page Speed Online tool
Optimise your site further with Google's Page Speed Online tool. It will present suggestions for things you can do to improve page speed (and reduce load) without touching your server infrastructure.

When you've done all that
Only then is it worth looking at hardware and environment optimisation. Some options worth considering:

  1. VPS solutions that provide 'instant scaling', such as
  2. Application hosting solutions such as Duostack, PHP Fog, and, which optimise and load balance the infrastructure for you.
  3. Optimised environments such as Nginx with PHP-FPM, or Ruby Enterprise Edition.
  4. If you're just hosting a blog, consider a hosted platform like or tumblr. These tend to withstand traffic surges better than default home-grown setups (and they're cheaper).

If all fails...
Consider creating a static page to outline your service and collect email addresses. Put this up in place of the application itself should your site go down during a traffic spike. I use Wufoo or MailChimp for this.

If you host the emergency 'whoops! we got dugg!' form on a separate (cheap) shared hosting account, you can use DNS failover to automatically redirect traffic to the static form if your main application goes down. That way, if Digg sends you 100,000 visitors and your app chokes, at least you'll have built up your mailing list and piqued interest for a proportion of those visitors.

share|improve this answer
I am very interested in automatic scaling solutions such as AWS, where more processing power can be automatically assigned to your application if there is an overload problem. Also, sometimes dynamic HTML is a necessity, and caching is not a viable solution, I don't think. – whamsicore May 26 '11 at 23:47

This really depends heavily on how your frontend servers distribute load. If it's not designed to have extra capacity added to it at the flip of a switch (or maybe better yet, automatically when a sustained spike is detected), then planning for this sort of thing is tough.

If you design your load balancing in such a way that you can flip on extra servers in a matter of minutes (e.g. via AWS), then you'll only pay for the extra capacity while you're using it. You'll have to do some pricing research with some kind of scenario to see if the pricing works out.

HOWEVER if you have a sudden traffic spike due to popularity, there are worse things in the world than going down for a brief period, unless you're running life support systems or something.

If your app/startup/project is especially cost sensitive, then I'd suggest building what you need, and keeping it at that. If it explodes in popularity and you have to spend a couple of days adding capacity, you'd call that a good problem to have.

Furthermore, planning too far ahead for capacity you don't yet need will cause you to spend money now that you could spend on more critical resources.

As just one example, the first StackExchange Site (StackOverflow) ran on a single server until maybe last year, I believe. Jeff Atwood talks about it in his blog, and they were getting millions of pageviews/day before they added additional infrastructure to scale out for the StackExchange network.

share|improve this answer
I wonder how stackoverflow managed to maintain their site on a single server for so long (link to article?). – whamsicore May 26 '11 at 23:44

During the high traffic period your server should be able to handle all requests made by visitors to your website. But there are some limits in concurrent connections handled by the server. So it's best to serve the page requests as fast as possible.

Here are some suggestions to consider in these situations,

Application level improvements:

  1. Minimize HTTP Requests to Speed Up Page Load Times.

a) Combine all JS files together in a single combined JS file, and all CSS files in a single combined CSS file.

b) Minify JS, and CSS files, so the file size will be reduced and it will be downloaded faster.

c) Use CSS Sprites - When you combine most or all of your images into a sprite, you turn multiple images requests into just one. Then you just use the background-image CSS property to display the section of the image you need.

d) Delay image download with lazy-loading, this will be helpful to reduce the http requests.

  1. Prepare lightweight pages which are expecting more visits:

a)Exclude decorative elements like images or Flash wherever possible; use text instead of images in the site navigation and chrome, and put most of the content in HTML.

b)Use static HTML pages rather than dynamic ones; the latter place more load on your servers. You can also cache the static output of dynamic pages to reduce server load.

Server level improvements:

  1. Reduce server timeout values by consulting your hosting provider (shouldn't be too low).

When timeouts are lower the connection will be released soon, so the server will be able to handle more connections.

  1. Use third party services like CloudFlare for static data caching, and to protect your website from malicious users and attacks like DDOS.

  2. Upgrade your server hardware - Upgrade physical and Virtual memories, increase I/O and Entry processes limits, if required. Your hosting provider will be able to help you better.

  3. Cache dynamic code - Use APC to cache PHP opcode.

  4. Load Balancing - Distribute load across multiple load balancing servers.

    When all required actions are taken, now it's time to check if the website is ready for a huge traffic spike.

    There are some third party services like who provide load testing with simulated traffic. The analysis will help you to understand how much load your website can handle and what can be improved.

    Also, during the traffic spike period, avoid high CPU usage operations like website backup cronjobs etc.

share|improve this answer
Please do not use this site to promote yours – John Conde Oct 29 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.