You want to scale your microservice, when the load exceeds the available resources. Resources can be CPU, RAM, database throughput, workers pool. I will describe two common patterns how to scale your microservices.
Vertical Scaling
"Vertical scaling" is a simple option, which can be considered as a go to, when performance issues arises. With this pattern you need to update your hardware, using more RAM or CPU. If your service is spinning on a virtual machine, then it is a matter of configuration.
- ✔️ simple implementation
- ❌ has physical limitations
- ❌ can become very expensive
Horizontal duplication Scaling
With "Horizontal duplication" pattern you need to copy your microservices (and possibly database) and control load via load balancer or message broker. This is a big advantage of microservices architecture, to have possibility to scale the "hot-spot" microservice. Where in the monolith you will copy the whole application.
If you need to scale your database horizontally, one of the options is to make "read replica" which will be used only for reads. Writes will be sent to the primary database.
- ✔️ cheaper to scale
- ❌ complex implementation
- ❌ the database need to be synced