Definition
In this lesson, we'll introduce asynchronous microservices.
We'll cover the following
Asynchronous microservices are different from synchronous microservices, which are covered in depth in Chapter 9.
A microservice is synchronous if it makes a request to other microservices while processing requests and waits for the result.
The logic to handle a request in the microservice might therefore not depend on the result of a request to a different microservice.
So, a definition of asynchronous microservices would be:
A microservice is asynchronous if:
(a) It does not make a request to other microservices while processing requests. OR
(b) It makes a request to other microservices while processing requests and does not wait for the result.
There are two cases here, let’s discuss each.
No communication #
The microservice does not communicate at all with other systems while processing a request. In that case, the microservice will typically communicate with the other systems at a different time, see the drawing below.
For example, the microservice can replicate data that is used when processing a request. In this way, customer data can be replicated so that when processing an order, the microservice can access the locally available customer data instead of having to load the necessary customer data for each request via a request to another system.
Get hands-on with 1200+ tech skills courses.