Introduction to microservices
To understand micro services we need to understand monolithic applications.
So suppose you want to create an online shopping application. Where users can search the products and buy it online like amazon or flipkart.
Below is the diagram which can represent our application design.
The first module is a user interface like a browser or mobile app and the second one is business logic like backend apis. While a user will search a product from the front end the request will go to the server and then the data will appear. After that if a user likes that product he will order it by making the payments and then finally flipkart will deliver the product to the user.
That is the one complete transaction and everything looks pretty good and fine.
But suppose there is a change in searching algorithm in the future to give customers more flexibility to search a product.
Then a developer needs to change the code and also take care about dependent functionality. In the testing phase testers need to test all the functionality which are dependent on search functionality.
In Deployment we need to deploy the entire code base.
So if you think about the above scenario we have a change in search functionality but our monolithic application has dependency and that is why we need to deploy the entire code base and need to do lots of testing. It will consume our time and will cost money also.
Let's think of one more scenario where we want to update our technology. Suppose our application is developed in struts but now we want to move on spring in that we need to change the entire code base. Which will take years to complete the big applications. It's a very tedious job to do in this architecture. So we can say it's highly technology dependent also.
Last point about scaling our application.
Let's scale up the application as we get more traffic. If you take an example of an e-cart application so they have more traffic on festival sessions. Searching for products every user will do but only some percentage of users will buy the product. So it means we have more traffic on searching products. But if we need to scale the application we need to scale the entire application , we cannot just scale up the search functionality. So to scale up the entire application it will consume more resources , time and money.
Above are some problems in monolithic architecture .
So how does the Microservices architecture will help us to resolve the above problems.
So in the Microservices we need to create individual services for each functionality. Suppose in your e-cart application we created product catalog service, payment service, delivery service. So basically we divided our task in different services. So know we have less dependency as compare to monolithic application. So lets discusses the advantages one by one.
Change in searching algorithm in the future to give customers more flexibility
In the future if we need to change the code of search functionality than we need to change only in product services. The rest of the applications are not depended their code base are different. So developer need not to take care about others application. The development phase will be faster and so with testing and deployment .
Want to update our technology
So now code base is different so its easy to change the technology or upgrade one services without impacting the others. We can implement the searching feature using machine learning algorithm using python.
Scale up the application as we get more traffic
Scaling up application is easier now because we can scale up one service. This scaling in called vertical scaling. So if we have more traffic on product catalog service we scale on this service without touching other application. This will save our time, cost and resources.
No comments: