How to Scale Monolith Service Based

Imagine your eCommerce business is growing well since started 3 years ago and expected will grow more about 50% at the end of this year on monthly active user based and transaction. Now, you are at the stage on how to scale your application that can serve million users and keep your customer be happy.

Strategy to Scale the Monolith Service Based

When you app with monolith based means that all your components such as user-interface, payment, order, and user management is built as a single unified code based. Monolith based is good for the early stage app or for simple app. Ok, let’s back to the topic on to how to scale monolith service based.

First, Let’s Optimize the Entire App

  1. Optimize your code based logic such as implement asynchronous function
  2. Database Optimization ( database indexing, optimize query)
  3. Implement Caching

Second, Vertical Scaling

Vertical scaling means you need to upgrade your hardware where the entire app is deployed. This can be done by increase storage, RAM, upgrade to the faster machines etc. It’s safe for your app because no code changes. But, this technique has limitation on hardware capacity and very expensive cost.

Third, Horizontal Scaling

Horizontal scaling means you may create several instances (assume from 1 server to 5 server) and you may containerized your app and create into several instances. Store sessions externally so every instance can handle any request such as using Redis. To distribute request to every instance you may use load balancer such as Nginx, AWS ELB.

Load balancer

But, on this technique you have to be aware of expensive cost, means that you need you set the expensive instance even though is not used optimal.

Database Scaling

At this strategy, you can create replicas database for read scenarios on heavy workload and you may shard your database (partition data across multiple DB instances) for write scenarios.

Database sharding

Advanced Technique

Using Content Delivery Network (CDN) such as Cloudflare, AWS Cloud front for static assets to reduce workload. Another one is by setup auto-scaling cloud rules.

In practice, start with vertical scaling for quick wins, then move to horizontal as load grows. If the monolith becomes too unwieldy, consider gradual migration to micro-services.

Do you have another suggestion to scale the monolith based?