Why microservices?

People tend to relate microservices with newer style of building applications. Many people tend to decide microservices is only way to go since they are building new application. However, microservices is nor new architectural patterns nor is it only (or best) way for building application.

Is microservices not new pattern? Why are people not building applications monolith any more?

Microservices is pattern of breaking application logic in independent servicable components that can then be independently built, developed and deployed independent of other services.

As noted earlier, microservices is not new pattern. Microservices always existed as pattern along with monolith. Many of OS kernels(core of Operating System) were developed as microkernel in past based on this architecture pattern. Windows NT and above versions still use this architecture pattern for its kernel.

Ok, if microservices existed in past, why are so many applications being built with this architectural pattern in recent times?

Or Why was this pattern not so common in past but only now?

Business applications have always been more about delivering value to business over technical classification. Businesses now have gone global. With advent of cloud, your application is used by millions of users across globe. In past, on premise infrastructure was too restrictive to enable scalability or reliability across geographies.

Microservices provides following benefit over monoliths:

  1. Scalability : With microservices, you break your business application logic into sublogics that are then wrapped into their own services. For example, if you are running a ecommerce application system with microservices, you may want to run multiple instances of ecommerce portal to facilitate growing demand of users but may choose to run only portal service but not payment service. Such scaling of logic also saves operational cost of infrastructure.
  2. Limit blast radius of failure : Consider an ecommerce application, you have user added products to buy in cart and your payment service fails. What do you expect your application to behave? Is it fair to pull entire ecommerce app down because your payments failed because of issue in payment gateway? This can be addressed by microservices by pulling payment logic out of ecommerce app as a separate service.
  3. Division of responsibilities : In larger organizations, management want teams to take responsibility of specific components. Such division of responsibilities of components can very well be addressed by separating logic of component into new service. Remember, services are independently developed and deployed, so team can build, develop and deploy their part of service and ensure service is tested independent of other services.

So is monolith dead?

No. Monolith still is better way to build business application in certain scenarios. Following are reasons when to choose monolith over microservices architecture pattern:

  1. If you are just starting to build new application, do not worry about scalability, focus on executing business goal. Going monolith way helps keep complexity to minimum and focus on usability by business.
  2. If team is small, it is better to opt for monolith architecture as small team should be able to communicate better and maintain small source code as against multiple microservices.
  3. If your team lacks understanding of automation and deployment of microservices, it is better to opt for monolithic pattern and then gradually migrate application to microservices over period of time. This eases initial period and helps team get time to learn tools and concepts required for microservices pattern.

So to answer in short, monoliths are not dead. In fact, monoliths is better architectural pattern when you are not serving millions of customers simultaneously and are not worried about uptime of application globally.

Conclusion:

Microservices or monoliths are architectural patterns and any application built in certain architectural pattern need not be superior to one over another. It entirely depends on usecase you are serving with business application.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *