How to scale up for a temporary traffic spike?

January 11, 2014 7.1k 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 ...?
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 https://www.digitalocean.com/community/articles/how-to-use-haproxy-to-set-up-http-load-balancing-on-an-ubuntu-vps.
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

https://www.digitalocean.com/community/questions/round-robin-dns
https://www.digitalocean.com/community/articles/how-to-set-up-a-scalable-mongodb-database
https://www.digitalocean.com/community/articles/how-to-create-a-sharded-cluster-in-mongodb-using-an-ubuntu-12-04-vps

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.
Have another answer? Share your knowledge.