Why Microservice Over Traditional Monolithic !!!
Let me start with a simple example!
Sometimes we all must have faced issues while posting a post in LinkedIn or Facebook, Basically an error message appeared after clicking on that submit button, that some error occurred!
Have You ever wondered as a engineer if this functionality is failing then how entire product is working??? if this thought hits to your mind then buddy i am sure you belong to Monolithic architecture!
In Monolithic, entire application build as a one single process!
We follow n-tier architecture or Spring MVC , where different layers maintained such as Controller layer which is exposed to client, then service layer which used by controller layer to perform some entity type operations, then comes Data access object layer where it operates on database. This is pretty common design to build application in a monolithic or in a microservice architecture.
For an example we have one application where user can post their thoughts! So here lets consider two modules such as User module and Post module. In Monolithic we just build these modules in a single environment . Hence we will be limited to technology which we can use for building even different modules, we will limited to database as all the interaction can happen to a single database. As it scales managing would be difficult even scalability issue.
Finally if anything goes wrong entire application will be down!
领英推荐
Now answering the above How Facebook / LinkedIn providing other services works fine even one service down?
Here comes Microservice architecture! Let's consider that example only, so following this architecture we will build different process for different module/services , for user module we will build one microservice(i.e. a new project completely) and for post module another microservice(again a new project itself). This will give us flexibility to choose technology database and all, we can decide to build one microservice which techs we should go for and like so!
Now as we will have different projects for different services so even if one project referring microservice goes down other won't be impacted and also if any change required in any module we need to manipulate respective microservice without changing other services.
For different microservice we will have different server where they got deployed! One server down won't impact other. For data communication between microservices we have protocols like we use to do data transfer in client-server while building applications. Hence coupling will be low as each microservice independent of each other.
However it comes with certain costs! we can face connectivity issue while communicating between services. We have to configure a central package which will be common gateway for every client requests. We will have multiple compiled files to deploy on multiple servers.
Now we have the answer i.e. because of this architecture usage even if one user post service failed other services works fine in LinkedIn or in Facebook.
To implement this architecture in any language we have different methodologies. For an example in JAVA, we have Spring Cloud Gateway for common API gateway, then we have Eureka server to register all microservices, config server to access config files, Load Balancer to evenly manage requests, registry for fault tolerant, etc.
That's all about Monolithic VS Microservice !
Thank You