How to scale up for a temporary traffic spike?

Posted January 11, 2014 10.7k views
Let say you have a low traffic $5 droplet running Ubuntu MEAN stack which is serving up static content with minimal database use which suddenly gets featured on the front page of a popular site e.g. NYT, Techcrunch, Hackernews etc. How can you best handle this traffic spike and then return to your cheap lower traffic state? Should you resize your droplet, spin up/down a cluster of droplets or ...?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers

The best way to handle traffic spikes (for static content)? Using a Content Delivery Network (CDN).
Leveraging traffic among several Droplets can be tricky (especially within a short time).

A CDN like KeyCDN is affordable and makes it easy to scale.

You could always replicate it (create a snapshot and create new droplets off that snapshot) and set up Round Robin DNS, that would be the easiest way to do it. Scaling vertically (resizing your droplet) is also an option.

Also check out
by Jesin A
This article runs through how to use HAProxy to setup HTTP load balancing on an Ubuntu VPS.
Thanks Kamal.

If horizontal scaling it sounds like I have to:
- setup 1 load balancer droplet with HAProxy
- setup a mongo master
- setup 2+ node droplets with mongo shards
- setup DNS round robin

Whereas with vertical scaling, I can resize droplet with only a 1 minutes of downtime and only be charged the extra for the number of hours I keep the larger size.

The vertical solution sounds like a low effort strategy to have in the bag. Are there any disadvantages?
by Bulat Khamitov
MongoDB is a NoSQL database with great features like replication and sharding built in. This allows you to scale your database to as many servers as you would like by distributing content among them. Use this tutorial to help get everything up and running.
Vertical scaling is fine however you might reach a point where horizontal scaling is more performant and more cost-effective that horizontal scaling.
As long as disk space is not an issue it's better to go with MongoDB replication instead of sharding for stability and redundancy.

If you decide to use a load balancer you wouldn't need round robin DNS records as there's only one server that is actually going to serve the requests.