A Story of Microservices

One day Minnie was going to the Supermarket when she heard Mickey calling her out

Mickey – Hey! Minnie

Minnie – Hi Mickey, How are you

Mickey – I am fine, Have been searching for you

Minnie – What happened, tell me

Mickey – I keep hearing this word Microservices but have never understood, what it actually means. Need your help

Minnie – Oh-kay! I know you need a story to understand everything

Mickey – You know me

Minnie – Okay, how about you come along to the Supermarket and I will tell you the story of Microservices

Mickey – Sure Minnie, let’s go


(Mickey and Minnie at the Supermarket)

Minnie – Okay Mickey, tell me how do you find this supermarket

Mickey – It is like any supermarket. Why are you asking me useless questions?

Minnie – Do you like going to the Supermarket

Mickey – Yes

Minnie – What do you find good here?

Mickey – Nothing much, it’s just that I can get all my stuff in one place and it is quick and easy. Everything is arranged and placed in its location. It’s easy to find and get things.

Minnie – Exactly! Now just imagine, if all the things are put together and it’s on you to figure out, find what you need and then get it.

Mickey – What! NO! It will be a nightmare. It will be a lot of chaos. I won’t come here

Minnie – So the Supermarket works efficiently because there are sections for each product or each type of product, nicely placed and arranged

There is a section for groceries, which can have further subsections, there is a separate section for fruits and vegetables, a section for books, for furniture, for stationery items, etc.

And together they form the Supermarket and is organized and together it works so well

Mickey – Yes I know and that is the reason it works so efficiently

Minnie – Yes, now, in the same way, Microservices are smaller component or services that work together to form the complete application or service

Mickey – Wow! I need to know more

Minnie – Let’s suppose, there is an e-commerce application. It can have sections or module like:

Users
Products
Orders
Inventory
Marketing
Shipping
Payments
Notifications
Currency Management
Accounts
Reports

Here some sections or modules can have further sub-sections like Products can have categories like

Apparels
Toys
Electronics
Kitchen
Furniture
etc.

Mickey – I am getting it so far

Minnie – Now imagine each of these modules is independent of each other in a way that they have a separate code base and repository, are hosted on a separate server, have its own Database and management systems

And all of them can integrate with each other to make the complete application or service function efficiently

Mickey – Okay so it is like complete independent smaller services within a large service

Minnie – Yes and that is why these are called microservices

Mickey – Tell me more

Minnie – Sure, but do you want to grab some snacks first

Mickey – Yes, let’s go to the snacks section. Err… I mean Snacks Microservices
(Both laughing)

 

Minnie – You are getting it

Mickey – I am smart

Minnie – Okay Mickey, so you see earlier we had Monolithic services where all the services were housed together in the single code base, using the same server and Database and all resources

Here it will be very difficult if there is some issue in one particular module, the whole application will stop functioning

However, with the Microservices architecture, we can manage, update, fix, upgrade an isolated service or module, without impacting any other module or service

Mickey – Yes, that’s so awesome. It’s like in the Supermarket, every section has its own inventory, transport, and management. If anything goes wrong or needs any change or upgrade, we do not have to touch any other service or process, It can all be done at the microservice level

Minnie – You got it exactly

Mickey – I told you I am smart

Minnie – Yeah!

Mickey – Hey Minnie, this is getting exciting, Tell me more

Minnie – Now just imagine, let’s say a particular microservice like Products is getting huge traffic and we need to add more servers, It can be done easily and the isolated service can be scaled up without touching any other service

Mickey – Yeah

Minnie – So here are the main advantages of using Microservices architecture

  1. Scalability – Isolated services can be scaled up or down as per the need
  2. Maintenance – Every service can be updated or maintained separately without impacting the other services
  3. Addition and Deletion – With Microservices architecture adding new services or removing old services is very easy and efficient
  4. Technology Stack – Different microservices can use different technology in terms of language, server, DB, etc
  5. Cost – It is a very cost-efficient system
  6. Time – Time for every operation reduces considerably
  7. Testing & Deployment – It is very difficult to test a complete Monolithic Service, but with isolated microservices, it’s very easy to test and deploy

Mickey – I see

Minnie – Are you able to get it now

Mickey – Yes I do Ma’am

Minnie – But you look lost in thoughts

Mickey – Just thinking why did I not meet you earlier. This is so great to know

Minnie – How do you feel now

Mickey – I feel much better and intelligent now 🙂

Minnie – Good to know Mickey

Mickey – Just one more question, these are separate isolated services, which have their own separate management system, But ultimately they have to work together for the entire application to work

Minnie – Yes, you are right

Mickey – So basically they must interact with each other. Am I right!

Minnie – Yes you are absolutely right, The microservices interact with each other and can use API calls for that

Mickey – And how do we test them

Minnie – We can test a microservice in isolation and then can also test its interaction with other services using the request-response process.

One of the process to test microservices is call Contract Testing

Contract Testing is mostly used in Microservices Architecture where we have multiple isolated services and to check the interaction and communication between these services Contract Testing is an efficient process.

Mickey – I got it exactly

Minnie – Happy to know

Mickey – Just one more question

Minnie – Bring it on Mickey

Mickey – Can there be any drawbacks of microservices

Minnie – Yes there are some like

  1. Developing distributed systems can be a little complex. As everything is now a separate module, it is important to carefully handle the requests and response coming in and going out of the service
  2. Need to maintain multiple Databases and Management systems
  3. Testing has to be done separately for each Microservice and then for the complete application working together

But you see with all this, it still becomes easier and efficient to manage a distributed system. So the advantages are much more than the drawbacks

Mickey – Yes, I see that

Minnie – Anything else you need to know Mickey

Mickey – Yes, so is it always good to have a Microservice Architecture

Minnie – It depends, For a large application with multiple functional components like an e-commerce application, microservice architecture is the best bet.

If there is some small application that does not require many distinct modules or services, monolith architecture should work fine.

Mickey – I got it

Minnie – So can you now explain Microservices in your class

Mickey – Yes, not just in my class, but to anyone in this world

Minnie – I hope now you will never forget what are microservices

Mickey – Never, till the end of my life

Minnie – Wow! That’s deep

Mickey – Thanks Minnie, you are truly my best friend

Minnie – I am always here for you 🙂

about the author more stories

187