What are Microservices?

What are Microservices?

In recent times one word you won't miss hearing around technology and developer spaces is microservices. For a long time, I kept pondering and deeply curious about what these microservices really were.

With seasoned experience in building applications as one package which one may call monolithic architecture, I grew a burning curiosity to adventure if there existed any other approaches.

Monolithic Servers are a scenario where we have one single codebase which is deployed as one discrete unit. This server contains all the routing, middleware, business logic, and database access needed to implement all features of the entire application.

Monolithic Architecture

The above image depicts a typical monolithic architecture where the middleware and router serve all features that interact with a common database.

On the other hand, microservice architecture is quite different from that approach to build servers.

A single microservice contains all the routing, middleware, business logic, and database access needed to implement one single feature of the application.

Microservice Architecture

In the above image, features are broken down into service that run independent of one another. Each service contains all middleware, router and database to enable it to function.

Microservices architecture eliminates single points of failure in an application by preventing tight coupling and dependency between features of an application.

For instance, in a blog app, posts and comments could be considered separate but independent services. The goal would be to prevent the dependency of the comments on posts as would they often appear with monolithic apps. Given that the posts service is broken, the comments service should be able to add comments to existing posts. In a deep dive, we would perhaps require a query service as an intermediary which would keep track of created posts and their respective comments.

Microservices have many pros and of course, as it is with any technology, there are downsides. The biggest challenge with microservices is data management between the different services. The question we always have to ask is how are we going to access existing data in the app since there is no interaction across service databases.

References;

Microservices with Node JS and React | Udemy

microservices.io