How to design a scalable web application
Episode #17: What are the best practices to keep in mind when designing your first web application so that you can later scale to millions of users?
This article will cover:
(free section) Minimum viable product: web app + database
(💰 paid) Think big, but start small: Vertical scaling -> Horizontal scaling
(💰 paid) Non-functional requirements: Observability and Infrastructure as Code.
(💰 paid) Horizontal scaling: Load Balancers and HTTP protocol
(💰 paid) Monolith vs Microservices: which pattern is better to start with
(💰 paid) Scaling the state: Federation, Sharding, Read replicas
As in previous articles, what you learn here is not limited to system design interviews but can be used in your daily job.
This article explicitly targets junior developers as it sets a foundation for future advanced articles. There are still quite a few lessons that a more experienced developer can learn from it.
Minimum viable product
We are going to start by designing the most simplistic web application.
The pattern described here is the foundation of most of the web application these days. Think Netflix, Spotify, and LinkedIn scale. Even if some of those services have native apps, behind the scenes, they still communicate with a web application similar to the pattern described in this article.
Most of the web applications are composed of two distinct layers:
a stateless web layer
a storage layer for the state
There is quite a lot to talk about in designing a web application, so we need to discuss what is in scope and what is out of scope for this article.
What is out of scope:
How to implement this architecture in the cloud
Computer Networking
SQL vs NoSQL database
Containers, Kubernetes, Serverless, or any other way to run your application
Components in the design:
We will use a simple relational database.
Two or more web servers running a REST API that returns a JSON object.
A Load Balancer to distribute the request load between the web servers.
This is it.
Most of the complexity is in scaling and optimising the storage layer. We could write multiple articles about that alone. We will only mention a few techniques here since we won't have time to go deeper.
Keep reading with a 7-day free trial
Subscribe to Cloud Native Engineer to keep reading this post and get 7 days of free access to the full post archives.