What are Microservices

Image for post
Image for post

Microservices are an architectural pattern that classifies and implements an application into a collection of independent services that have a high level of autonomy. Usually, each of these services would be related to a single business group. Since these services are mostly autonomous, they can be built using different tech stacks. Microservice modules can be scaled, unit tested & modified with minimal effects to other modules in the system unlike the traditional monolithic architecture which is a collection of all the functionalities/services in one place

Microservices extend the principle of Single responsibility by focussing on a single capability or business domain. Which could be department specific, a region-specific, or any other custom business requirement. By decoupling the same from other services, development teams can iterate, test, build, and deploy the same in faster development cycles. Thus it's a natural fit for the agile development process. Microservices and API gateways usually go hand in hand. The reason being Microservices can be based on different protocols and stacks and a great deal of autonomy.

Let’s take an example to see how Microservices can help design robust, scalable systems. Consider an e-Commerce application which includes several services ranging from product details, purchase, cart, payment, history, details, so on and so forth. If this system is built in a monolithic fashion, the entire code, infrastructure, and database are centralized. Among other issues with a centralized setup, The only real option to scale this during peak traffic is running multiple instances of the same server. Plus when it comes to fault tolerance, a failure in one part of the system affects the others as well. Additionally, if a particular service needs to be updated or changed, to update the same, the whole system has to be redeployed after making the change.

Image for post
Image for post

Microservices help in handling such issues by separating each module and making them independent with well defined public interfaces. Along with an API gateway, microservice can offer a single unified interface for clients by abstracting the complexity underneath. Moreover, the independent, autonomous modules offer backend developers a scalable architecture with each microservice having the freedom to use a different development stack altogether

It’s tempting to ask how does this differ from a Service Oriented Architecture(SOA). After all, SOA also stresses on distinct components interacting amongst each other. The main difference between SOA and Microservice is that Microservices aims at modularising the system by building independent, self compassed units, unlike an SOA which focusses on building components that aim to provide services to other components by means of a common communication protocol. By that virtue, Microservice can be considered a fine-grained version of SOA.

Benefits

1. Since microservices are independent units, they can be worked upon by multiple small teams. This reduces the delivery time period and increases deployment frequency

2. In the event of any service failure, it can easily be isolated and fixed without any impact on other services

3. Individual units can be easily integrated into CI/CD pipelines

4. Components can be scaled based on a need basis. This reduces the cost and time of scaling the entire system to support a few modules.

Challenges

1. Microservices comprise individual components that are distributed. So the drawbacks associated with distributed systems apply here as well like reliability, latency, bandwidth, etc

2. Determining the boundary of a component is a complex process and requires an understanding of code dependencies

3. Depending on the number of modules the complexity of a microservice might increase more than a monolithic architecture

Conclusion

Microservice architecture offers tangible benefits for an application that has different modules spread across different requirements. But the implementation of the same has to be weighed against the need and complexity of the domain. As with any architecture, one size does not fit all and hence Microservices as a solution needs to be evaluated before implementation

How can an enterprise leverage Microservices to reduce its development and deployment time? Find out more by visiting us at https://www.codecrafttech.com/

A leading mobile app development company specialising on iPhone, Android, Cloud solutions, User Experience and UI Design.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store