“Our services are backed by a scalable microservice architecture”, “We are planning to switch to microservices architecture”. If you are a developer, then you must have come across these phrases very often and would have definitely tried to understand — WTF is a microservice? Don’t worry! This guide will give you a solid understanding of microservice architecture using real world example. Wait! Did I mention that there isn’t any code snippet in this article?
For a moment, let’s forget about microservices and consider an ice cream machine which has four parts — ice cream scooper, nuts shredder, chocolate funnel, and strawberry syrup funnel. Ice cream scooper adds one scoop of vanilla/mango ice cream to the cup, and as the name indicates, nuts shredder sprinkles shredded nuts over the ice cream scoop. Chocolate or strawberry funnel pour desired liquid syrups on the ice cream scoop. Except ice cream scoop (from scooper part) , all the toppings are optional for the customer.
Big Ice Cream Machine — Monolith Application
You being the owner of the ice cream shop start with a small ice cream machine which has all these parts embedded in a single machine. Fortunately, people start loving your ice cream and your business grows. What will you do? You will buy a bigger machine that can complete more ice cream orders in the given time. Following this procedure, there would be a time when you will run out of options as the machine manufacturer company will not have any bigger machine than you current machine.
No more big machines — Scalability limit reached
This is what is known as a monolith architecture in development world. You start with a single app which has all different parts amalgamated in a single code base. As the resource requirement increases, you rent bigger machines but after certain point of time, a limit is reached when you already have the biggest possible machine.
You must be thinking that you could bypass this scenario by buying multiple ice cream machines. You are correct! So, you decided that instead of buying the most powerful ice cream machine, you will buy multiple smaller ones.
This is what is known as cloning, where you use multiple instances of an application to cater your user requests.
Now, with God’s grace and your hard work, people became addicted to your ice cream flavors. To meet the demand you will eventually have to upgrade all your ice cream machines to the most powerful versions.
Multiple Instances of Monolith Application — Cloning
When you started your business, you hired one technician who was responsible for fixing any issues with the machine or for upgrading the machine. Everything was running smoothly. But when you bought multiple machines, you felt the need of hiring more technicians because you never want to be ‘unavailable’ to your customers.
Now, upon customer requests, you decided to sell a new ice cream flavor. You decided to add chocolate ice cream to your ice cream scooper. But since, all the four parts of each machine are dependent on each other, your technicians had hard time adding the new ice cream flavor. But somehow they achieved their goal, and as soon as they completed the integration of new flavor, the strawberry funnel stopped working because the parts of the machine are interdependent and modifying one broke the other.
One Update Breaks Other Parts — Yellow represents chocolate scooper
Due to the limit of scalability, you decided to set up a new infrastructure. You requested machine manufacturer company to provide you separate part machines for each of the four parts. One ice cream scooper part machine, one nut shredder part machine, two funnel part machines for chocolate & strawberry syrups respectively. Now, you distributed your technicians into separate independent teams with each team taking care of a single separate part machine.
Separating big machine & big team into separate independent part machines & their respective technician teams — Microservices
This is known as a microservice architecture, where a big monolith application is divided in to separate independent modules and each module serves as an application on its own, dedicated to perform specific tasks.
Short answer to this question is No! Most experts recommend that if you don’t need microservice architecture then you shouldn’t do it. Why not keep serving your customers with a monolithic ice cream machine until it reaches the point where it becomes hard to maintain or scale it. At that point break your monolith machine in to separate independent microservice part machines.
You might feel that if you reach the stage of having microservice part machines for your ice cream parlor, then these would be small part machines. Nope! Each microservice part machine could be a big machine in itself, or it may have several clones running parallely to cater the user needs. For example, your scooper part machine might have 20 scoopers running parallely considering majority of your customers prefer only ice cream and no toppings.
Similarly, microservices could be separate applications in themselves, making them not so “micro”, and requiring good amount of effort to maintain and scale them.
Several big software companies who are currently using microservice architecture, started with a monolith application. Once they reached the limits of scalability and maintainability, they broke that monolith in to separate independent components/services.
No doubt, microservice architecture allows you to use different technologies for different services, and allows to scale and maintain better, but all this comes with an overhead complexity and requires good expertise. Therefore, it’s never bad to start with a well structured monolith ice cream machine, instead of starting directly with microservice architecture and landing yourself in “accidental complexity”.
If you enjoyed reading this, please don’t forget to show your love by giving “50 claps” and by clicking on “follow” button :). It motivates me to write more stories like this, and do help your friends to find this by sharing this with them. Thank You! :)