System Design

Scaling your app in 3 Dimensions

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)
  • 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

  1. X-axis: Replication
    1. πŸ‘ Advantages
    2. πŸ‘Ž Disadvantages
  2. Y-axis: Split
    1. πŸ‘ Advantages
    2. πŸ‘Ž Disadvantages
  3. Z-axis: Partition
    1. πŸ‘ Advantages
    2. πŸ‘Ž Disadvantages
  4. Conclusion

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s