Web development have always interested me and I keep on looking for more and more technologies which are being used in this domain to create better and efficient servers to tackle the real life situations. So I have decided to come up with blog series on the topic — “Microservices” which are really popular nowadays and are being used by famous web giants like Amazon , Netflix , Twitter etc. So we are going to explore as to what is so special about it?
In my first blog, I am going to answer a very simple question “What is a microservice ?”
To answer that, we will first have to do a quick review of how we probably build servers. We all are pretty much familiar with conventional monolithic architecture.
This is how probably one builds servers right now in a monolithic server.
We have all of our code needed to implement our application inside of one single code base. We deploy that code base as one discrete unit, so we might imagine that with a monolithic server, we have some requests coming from a user’s browser or mobile device that will flow into our application and go through maybe some pre-processing middleware then perhaps it goes off to some router that router might then inspect the request and decide to send it off to some particular feature to be further processed.
So if we had to characterize a monolithic server, we might say the following We might summarize it with this diagram below.
Now, We’re going to make one or two changes to the above diagram and that will then summarize or characterize what microservices are all about.
So here’s how we would characterize micro services.
We would say that a single micros service contains all of the routing ,all the middleware , all the business logic and database access required to implement one feature of our application.
That is the big difference.
So a monolith has all the code needed to implement every feature of our application. A micro service has all the code needed to implement just one feature.
So with this microservice architecture, we’ve now split off all these different features and wrap them up inside of their little personalized services.
The crucial thing to understand is that each of these services is entirely self-contained, so the service right here has all of the code required to make a feature work correctly.
It has its own middleware, it’s got its own router, and it even over here kind of surprisingly will have its own database as well.
The nice thing about this approach is that if, for some reason, if every other feature or every other service inside the application crashes or just mysteriously disappears, a portion of our app is still going to work just fine.
As service say is 100 percent standalone, it doesn’t necessarily require any other service to work correctly.
So that is a very basic kind of introduction to answering this question of what is a Micro Service. In short “A micro service contains all of the code required to make one feature work correctly.”
I hope this blog helped you gain an insight about what microservices is all about in a basic sense. In my next blogs I would come up with certain challenges we face while working with Microservices and what strategies we can employ to tackle them which would give us knowledge about some other important concepts in Microservices after which we would be able to build up our own application using Microservices.
Thanks for reading this blog!!
This is a blogpost which is in association with Programming Club IIT Kanpur blog series.