There are 3 different dimensions your app can scale, namely:
- X-axis: replicate the service multiple times
- commonly referred to as “horizontal scaling”
- Y-axis: split a monolith into multiple microservices
- imagine a monolith of a retail app with an API that handles the following:
- products
- customers
- payments
- deliveries
- each into its own microservices (more on that later)
- imagine a monolith of a retail app with an API that handles the following:
- Z-axis: partition microservices’ clients
- similar to the X-axis, here you partition the access of specific clients to different instances of your microservice
Each in detail
X-axis: Replication
Run N instances of your service running in parallel, and the workload is distributed between them.
π Advantages
You can easily scale on the go. Just spin another instance.
π Disadvantages
Your service must be synchronized with the rest of the instances, and implemented in a way that all can work together.
Cost is increased.
Y-axis: Split
Apply the microservice pattern, by splitting a big service/monolith into several ones, each with its own responsibility.
π Advantages
In case one piece of the system fails, the rest of the system isn’t affected.
It’s easier to pinpoint which service handles what.
If you’re also splitting the database itself, its schemas, or even the table, transactions scale as well.
If you have a cache implemented, it gets more hits, thus further improving performance.
π Disadvantages
Makes the architecture more complex.
Z-axis: Partition
Run N instances of your service, but route different customers to each one, with some logic.
Cloud platforms make use of this when providing SLAs, you can have the “Standard” tier go to a cluster of 5 microservices, while the “Premium” tier lands on a cluster of 20 microservices.
The same holds true for regions.
π Advantages
Get more cache hits, if a cache is implemented.
An issue in one region or tier will not affect another.
π Disadvantages
Can be difficult to implement.
Tracing an issue becomes harder.
Conclusion
These are 3 different ways you can scale your application.
You aren’t restrained to using only one of them, you can apply one, two, or all of them.