(How Powerful Microservice Architecture is?)
Have you ever wondered how big applications i.e. Amazon, Netflix update and deploy the new functionality within seconds? Have you ever realized Netflix undergoes maintenance for adding your latest favorite movies? Have you ever noticed Amazon update it’s services by continuously serving us?
Rock and Pebbles Analogy
You are wondering how this image suits Microservice architecture, but this is the way how service architecture is— “Rock and Pebble Analogy”. Consider rock as a big monolithic application where all components(UI, Back-end Logic and Databases) tightly packed and assembled together similar to Big containers. But when this big complex application can be divided into small and independent services(Pebbles) where each individual component can be developed and deployed independently termed as microservice.
Why not Monolithic?
In Monolithic Architecture (UI, Business Logic , Data Access Layers) are tightly combined, interconnected and interdependent with each other, as described in above image. If any client’s requirement needs to get embed in this architecture, first we need to communicate and integrate with teams accessing the three above stated layers. After completion of request, we need to deploy the whole service which is also a time consuming process. The major problem with monolithic architecture can be best explained as “Monolithic Application is like a house. Once built, it can’t be moved.”
On the other hand, Microservice Architecture provides us a flexibility to decompose a big and complex monolithic application into individual services. These individual services can be developed, test and deployed autonomously in a team comprises of 5–10 members. It essentially follows “Do one thing and do it well”. It also transforms Industry standards by supporting different languages, databases for different services i.e. we can develop one service in Java-Spring and other in Node.js which helps developers to develop applications in their comfort frameworks. It should be noted that within each service, implementation language should be uniform.
Let’s understand with an example of an Online Store that serves different functions:
Catalog: Responsible for keeping track of all items in store.
Orders: Process customer orders
Shipping: After order, responsible for shipping related processes
UI: A web UI which enables users to browse items in a store.
Previously in monolithic application we need to develop this entire online store using single UI framework(say Angular JS) , single Backend Framework(say Node JS) and one Database(say MongoDB). But not now, in this era we can develop Catalog in Node.js, can implement Orders in Java and Shipping in some other framework. We can use multiple databases for individual services i.e. SQL DB for Orders, MongoDB for Catalog. Not only this but also we can deploy Catalog on IBM Cloud, Orders on Amazon AWS and Shipping on Microsoft Azure.
Catalog, Orders, Shipping, UI all are treated as individual and autonomous services which can be developed in parallel using multiple Tech Stacks. The main beauty of microservice is, we can containerize different services and can deploy on multiple clouds. With containerization, we can update a service instantly by up an instance of updated container and down the instance of previously deployed container.
When No to Microservice
No need of Expansion: When there is no need for expansion and it is clear that the application won’t expand further than it currently is.
Tech Stack is Fixed and no need for Frequent Deployments: When entire application is built on same Tech Stack and won’t change in near future. Also when there is no frequent deployment of new releases.
Productivity of Monolithic application is very high as compared to microservices when application size is small, since small applications can be managed easily as a whole rather being distributed. But as we grow, number of customers increases, monolithic application becomes very slow and it’s productivity declined with a huge rate. Comparatively productivity of microservices also declined but the rate is quite low as compared to monolithic.
Drawbacks of Microservices
Distributed System: Distributed system is very complex to design. Testing is more complicated.
Cost: Cost of designing and building distributed system is high.
Enterprise Readiness: Conversion from Monolithic Architecture is extremely tough.
It is always be the best practice to start with monolithic architecture because in the beginning, application is small in size and can be handled easily. But with the growth of application, there is a requirement for transformation to Microservice Architecture which comprises of loosely coupled services that operates through lightweight protocols which enables Continuous Delivery and Deployment.