Microservices = micro + services
And, that's just about it :)
When an application is designed in such a way that it is made up of different services that are:-
loosely coupled
caters to a specific cause (like cart service, checkout service, shipping service,..)
deployed and scaled independentely
highly resilient, maintainable and testable
and, yes managed by small teams
can be written in different language (one can be a spring boot app and another can be a nodejs app)
Let's now understand this with a very basic and familiar use case. I believe that most of us must have purchased something or other online. So, let's try to design an online retail application using microservices architecture. The application will allow user to login/signup and browse products and make a purchase.
The first thing that we should be doing is to try and identify the different user flows that may be broken down into separate services. In case of our retail application these will be:
SignIn/SignUp - We can have a separate account service which will ensure that user can signin or signup in the application
Search and see Products - This can be divided into a product service (will store product details), a search service (will ensure to send results based on user search term) and a recommendation service (show recommended prodcts based on user search and purchase)
Add products in the cart - A cart service which will store information about items that user have added into his/her cart.
Checkout - It can be further divided into inventory (keeps info about the item in stocks), shipping (make sure that the product gets delivered to the location), and payment services (processes the payment)
See Order Details - An Order service which stores all the info about user orders.
Return - This will take care of the return process
The above is just an example to help you understand the concept of microservices. In real online retail application, there will be a lot more services based on the product requirements.
And with this, we have done the first part of identifying the different services needed for the application. All of these services expose the API endpoints or listen to the events sent by different systems and work together towards the same goal. There are different ways that you can design services to work together in a microservice architecture. We will learn about these, commonly called design patterns, in the upcoming posts.