How to Scale a Web Solution (Part 2)
How to scale past a single web server?
If you haven’t checked it out, make sure you read the previous article on Scaling a Web Solution, you may not need to scale (yet) and it could save you thousands!!
Upwards and onwards…
“Lets just buy a bigger server…..”
Ah yes, the old way of thinking. There’s a time and place for simply buying a bigger/better server but you’ll eventually reach a point where that doesn’t work anymore, and you’ll be painted into a corner with nowhere to go.
What can you you do to ensure that doesn’t happen?
Outwards, not upwards…
There are two types of scaling; horizontal and vertical.
Buying a bigger server is called vertical scaling. It’s the “old” way of doing things, but still has a very valid place in the world. It’s VERY simple, and can give you a very significant boost in performance, but has a hard limit when things get really busy. You’re basically throwing money at the problem to make it faster.
Adding another server to share the load is called horizontal scaling. It’s the “new” way of doing things, and is the better way to approach scaling. It’s more complicated to get right, BUT can be cheaper and gives you unlimited options for future expansion.
If you’re still confused take the following example.
Problem: You have a 100Kg weight to carry to the top of the hill.
Vertical Scaling: Get a gym membership, train hard, build muscles and use brute force to move the weight.
Horizontal Scaling: Ask a friend (or two) to help you move the weight and do it together.
BUT there comes a point with vertical scaling where you can only lift so much weight with one person. That’s why you need to consider horizontal scaling.
Horizontal it is….
Hang on, horizontal scaling won’t solve all your problems overnight. There’s planning to do, and more elements to plan for.
The idea behind horizontal scaling is sharing the load across many servers. This means you need a way to share the load out, which is conveniently called a load balancer. This takes requests from your customers, and send that request to one of the servers.
All your servers sit behind the load balancer, so where you had 1 server, you now have a load balancer, and multiple servers. It’s more complicated, and needs a bit of forward planning.
Cheaper, faster…
Vertical scaling can get very expensive, very quickly. It works, but it’s not the smart or cost effective way to go about scaling your web solution. You also get to a point where you cannot scale it anymore to serve your customers.
Amazon doesn’t have 1 massive web server running their website, they have tens of thousands of servers (if not hundreds). You cannot use vertical scaling forever, at some point you will need to scale horizontally.
Final Thoughts…
What else does horizontal scaling offer you?
- You cannot outgrow a well designed horizontally scaled solution, for all purposes horizontal scaling is unlimited
- Add/remove servers to deal with busy periods (i.e. Black Friday) or when you need some extra grunt for reports
- Cheaper. It’s generally cheaper to run a small cluster of servers than a massive single server
Horizontal scaling is not the final answer to scaling, but it is the more logical choice for a business that needs to grow.