It's an architectural style of software development where software is a collection of services that are distributed, loosely coupled, and highly maintainable. To understand microservice architecture first we need to understand what monolithic architecture is. It's a traditional way to build applications where every component of your code is composed in a single piece. That characteristic leads to a large, tightly coupled ( Components of the application depend on each other) code base. But this type of architecture has its drawbacks. One component can bring down the entire application. If customer service shuts down, it will affect the whole application. This means that the user who just wants to preview the product or interact with the product service is unable to do so. Complex technology adoption - using multiple tech stacks and maintaining the code is often complex and time-consuming. It's near impossible to scale components individually in a microservices architecture. Here's an example of an e-commerce app architecture. ( monolithic )
With the microservices architecture, instead of a single service that handles everything, applications are divided into multiple services. Every service runs independently so if one server shuts down, it won't collapse the entire application. For example, breaking down an E-commerce application into multiple services (user service, product service, etc.). If user service fails it won't affect product service or any other services. The services are isolated from each other, so deploying them individually is more efficient than deploying a monolithic code base. This reduces both costs and time. Since the service follows a single responsibility, developers can use any technology stack according to their requirements. For example, a service configured only for caching data that is isolated from the database with Redis or Memcache. Horizontal scaling is easier in a microservice architecture. Monitoring is easier in a microservice architecture.
This is an example of a simple E-commerce app (Microservice architecture). Microservices can be more complicated as per the use case.
Nowadays, microservices are so popular that most enterprises use them instead of a traditional monolithic architecture. It has some drawbacks. Managing a distributed system and dealing with the complexity of microservices is challenging. Communication between services can be complex, as well as having a higher chance of failure. The upfront costs can get increased due to the need for sufficient hosting infrastructure and service security.