Why use microservices:
Companies develop their websites with two methods. One method is by creating one database and one code base is known as monolithic architecture. In monolithic architecture, if you update any code then you have to redeploy whole application i.e. test code of whole application if it is working fine. There is one more method to make application and that is microservices architecture. In microservices, your application/website is divided into small services/components/microservices/modules and each of these services is given one database and code set. Now if any microservice is changed then you only need to redeploy and test that service. Another feature of using microservices is that you can code each service with the language you like and all the services communicate with each other through common language i.e. REST.
There may be 1 developer working on multiple microservices or more than one developer working on single microservices, it all depends upon how complex the microservice is.
Types of microservices:
There are two main types of microservice.
In stateless microservices, we don’t need to save the state of the user. For example, the user visits our website and reads the article and get information so we don’t need to save user identity and don’t need to save the session.
If stateful microservices, we save the state of the user. For example, if we have an e-commerce website and user add any product to the cart and then browse through other products then we save cart information of the user. Shopping cart information includes a number of products in the cart, the price of products and some other session information.
Examples of microservices:
Below are the websites using microservices