Microservices have gone through a complete hype cycle. From being hailed as the one true way to build systems, to a backlash where they are often cons

4 Things I Like About Microservices

submited by
Style Pass
2021-05-24 05:30:04

Microservices have gone through a complete hype cycle. From being hailed as the one true way to build systems, to a backlash where they are often considered too difficult and complex. In a way though, they are like most technology – there are trade-offs. You get some benefits and some drawbacks. Here are four features specific to microservices that I have come to appreciate.

True separation. A typical microservice has its own database, and the microservice is only accessible via an API. This means that the microservice internals are not accessible outside it. As long as the API stays the same, the code in the microservice can be changed without any effects to the system outside of that service. You get perfect encapsulation.

In a monolith, you also strive for encapsulation. However, it is more work to enforce it there. You can easily end up with a system where the interfaces between modules start to blur. One module can call a supposedly internal function from another module, and soon there are many more cross dependencies than intended between the modules. Another way you can break encapsulation is through the database. If all modules have access to all the tables in the database, there is a risk that the separation between the modules breaks down because tables intended for one module are read and written to by other modules as well.

Independent scaling. Once the system is separated in different microservices, you can run more instances of services that require more capacity. This is something we have made use of at work, and it is quite convenient. It works in reverse too – you can temporarily scale down a service to no instances. This can be good if you want to make sure there is no traffic in a part of the system while for example doing a database migration.

Leave a Comment