In the microservice architecture pattern, a distributed system runs on several different machines, and each service is a component or process of an enterprise application. The services in these multiple machines must handle requests from the clients of the enterprise application. Sometimes, all of the services involved collaborate to handle such requests; the services interact using an inter-service communication mechanism.
However, in the case of a monolithic application, all components are part of the same application and run on the same machine. This means that the monolithic application doesn't require an inter-service communication mechanism. Have a look at the following diagram, which uses the Bookshop application from before and compares the two communication methods:
As you can see in the preceding diagram, a monolithic application has all of its components combined as a single artifact and deployed to a single machine. One component calls another using language-level method calls. However, in the microservice architecture, all components of the application run on multiple machines as a process or service and they use inter-process communication to interact with each other.
In the microservice architecture, there are two approaches to inter-process communication, which are as follows:
The synchronous communication style
The asynchronous communication style