Microservices are the state-of the art software development technique that structures the backend of an application into loosely coupled services that can be reused by other applications. Each service is self-contained and will implement a single business capability.
Mobile and cloud applications typically start with two repositories in source control; one repository for the front-end and another repository for the backend. There are some initial benefits to this type of architecture. For example, by splitting your application into 2 repositories, you enable two different sets of engineers to work on the UI and backend simultaneously.
Unfortunately, there are some significant drawbacks with having a monolithic backend that encompasses your business logic and data access layer. These drawbacks include:
- The sole responsibility of the backend is to serve data to the front end. The backend can’t be used for anything else.
- The components within the monolithic backend are interconnected and interdependent.
- If the developer wants to make changes to the backend, they have to build and deploy the entire stack at once.
- If the developers want to address scalability issues, the entire system must scale together.
- If the developers want to adopt a new technology stack, you may have to rewrite the entire solution.
There’s a better way. By splitting our monolithic backend into business specific services, we can address a number of the shortcomings of the monolithic backend.
A good example of a self-contained microservice is Authentication. Every application requires the user to signup, sign in, reset password, perform email validation, etc. By building an Authentication microservice that is solely responsible for handling the user’s authenticity, we’re able to solve many of the issues we face with the monolithic backend.
- The authentication microservice can be used for multiple applications.
- The authentication microservice can be flexibly designed to make use of a REST API.
- If the developer wants to make changes to the backend of the authentication microservice, changes can be made without modifying the rest of the application.
- If the developers want to address scalability issues with the authentication service, the rest of the application outside of the authentication does not have to change.
- If you want to adopt a new technology stack for the authentication microservice, you only have to rewrite the single authentication service.
In subsequent blog posts, we will explore the role that Kubernetes plays with microservices, and the different types of microservices that will exist in a cloud SaaS application.