Microservices: more parts, but each one simpler
Microservices are often described as good for large companies and overkill for smaller ones. My projects suggest otherwise: in the long run, a system made of specialised services almost always beats a monolith. Here is why, and what you need to know before you commit.
How it works
In a monolith the whole system is one application: login, orders, payments and reports live in one codebase and are deployed together. In a microservice architecture each of these areas is a separate service. The services talk to each other through APIs or event queues, but they can be developed, deployed and scaled independently.
What it gives you in practice
- Independent releases. A change in payments does not require redeploying the whole system or retesting everything.
- Scaling where it is needed. If load grows in one place, e.g. communication with field devices, you scale only that service.
- A failure does not take everything down. When one service has a problem, the rest of the system can keep running.
- The right tool for the job. Each service can use the technology and database suited to its task.
- Ready-made components. Some services can be built on proven solutions, e.g. login and user management on Keycloak, instead of writing them from scratch.
This is how the urban traffic management platform used by operators in several cities is built, as is the car wash network system that supervises about 1,000 devices and serves more than 20,000 users.
The price: more complexity
To be fair: a microservice system has more moving parts. You need to take care of communication between services, monitoring of the whole, automated deployments and tracing errors that pass through several services. Without that, instead of flexibility you get chaos.
In my experience this complexity pays off, because each individual service is simpler than a large monolith and the system can grow without a rebuild. There is one condition: the architecture has to be thought through from the start, not created by cutting existing code into pieces.
Where to start
- Split the system by business area, not by technical layer. A “payments” service makes sense; a “database” service does not.
- Start with a few services, not dozens. You can split out more when you need them.
- Automate deployment and monitoring from day one. Deploying several services by hand quickly becomes a bottleneck.
- Already have a monolith? Do not rewrite it all at once. Extract services gradually, starting with the area that blocks development most.