Scalability is the ability of your web application (or any system!) to grow and shrink to fulfill demand cost-effectively. Properly scaling can allow you to build applications that can handle more data, users, and interactions with your servers without the degradation of your app’s user experience. Don’t think about how fast your server handles any particular task or request, but rather ask yourself: does my application work for 10,000 users as well as it does for 10?
So, how would I go about making my application scalable?
The first approach you might consider is making your application more scalable is to give it more hardware resources. Instead of deploying your application for free on Heroku, you instead pay for a server equipped with a powerful processor and a decent amount of memory. When your app’s audience grows you simply upgrade the server by changing the CPU for one with faster clock speeds and adding more RAM. This is known as scaling vertically.
Scaling vertically is about upgrading your hardware and not changing how your application works. This works great. Your application is not that big and you’re making enough money to afford the hardware upgrades.
This approach is not without its limitations, however (I mean why else would I list more than one approach, right?). The bottleneck for scalability here is cost and application design. Firstly, getting set up with consumer-grade CPU with 18 cores from Intel for $999, but you need a quote for an enterprise-grade CPU with 28 cores (as early 2020). More cores won’t always solve the problem either, software often has to be designed to take advantage of them and software your application relies on might not be yours or even open-sourced. Eventually, you will reach a limit to the upgrades you can make.
Another approach you might consider is adding more servers instead of having one a couple of really powerful servers. Can you avoid hitting a ceiling with this strategy? The answer is yes! As you add servers to the system they don’t need to be all that powerful since the benefit comes from your application’s ability to leverage many of them meaning cost grows more reasonably.
Horizontal scalability is hard and will probably require your application to change. Think of the individual roles of different services in your application, like the web server, caches, and databases. True horizontal scalability means being able to add more servers to fulfill each role. Pulling this off without major rewrites means thinking a lot about your application as a system of services.
There are different ways to architect your system but generally, they all encourage you to separate your system into smaller, independent units. A system made of more independent units lets you work to develop and scale them independently as well.
Thanks for reading! If you’re feeling generous with your knowledge and experience be sure to leave a comment. Feeling curious? Questions are welcomed too!
If you’re looking to learn more about system design I would highly recommend Web Scalability for Startup Engineers by Artur Ejsmont. This is also my main source of knowledge for this post.