Microservices Patterns: Inter Process Communication

Crishantha Nanayakkara
3 min readJun 7, 2023

Microservices Pattern Series — Part 01

Inter Process Communication (IPC)

A process could be explained in two different ways. (1. Independent Process. 2. Cooperating Services Process).

An independent service is not affected by the execution of other processes while a cooperating service could be affected by other executing processes. However, though an independent process runs independently, it is hard to be in isolation in a complex architecture and at some point it will need to have some interaction with other processes. This is where Inter Process Communication (IPC) comes into the picture.

The Importance

Though, in the MSA (Micro Services Architecture) theory, microservices run in isolation, there are situations that you need some sort of collaboration.

Compared to monolithic applications, microservice applications are far more complex design and have many services running at any given point. Therefore, it is essential to plan all interaction points beforehand in a typical MSA design while identifying its IPC mechanisms / interaction styles.

Microservices Interaction Styles

As explained before, it is important to decide on the IPC interaction styles within your Microservices design. Since interaction style is an important factor especially on the availability aspect, it is very important to tick the box before anything.

On Chris Richardson’s book of Microservices Design Patterns [1], the author mentions about two key dimensions of interaction styles.

  1. One-to-One / One-to-Many
  2. Synchronous / Asynchronous

Within this framework, interaction styles could be explained further in multiple ways (Figure 01).

Figure 01

Those Interaction Styles are as follows:

Synchronous Request-Response — A service client makes a request to a service and waits for a response. The client expects the response to arrive in a timely fashion. It might event block while waiting.

Asynchronous Request-Response — A service client sends a request to a service, which replies asynchronously. The client doesn’t block while waiting, because the service might not send the response for a some time.

One-way Notifications — A service client sends a request to a service, but no reply is expected or sent.

Publish-Subscribe — A client publishes a notification message, which is consumed by zero or more interested parties.

Publish/Async Responses — A client publishes a request message and then waits for a certain amount of time for responses from the interested parties.

Interaction Mechanisms

As we all know the most popular interaction messaging mechanism is REST on HTTP. However, it has benefits and drawbacks as well.

Figure 02

As you can see both GraphQL and gRPC can be better alternatives for REST in certain design situations.

The limited number of HTTP verb support in REST is a significant drawback, which can be avoided with gRPC. It is a binary message-based protocol, which does use the API-first strategy. You need to define your API contracts using Protocol-buffer based IDL. You can use the Protocol Buffer compiler to build client stubs and server side skeletons. It can generate code for various languages such as Java, C#, NodeJS and GoLang. It does exchange messages using HTTP/2.

Figure 03

In my next blog, I will be discussing on the Circuit Breaker Patter.

Thank You!

References

  1. Microservices Patterns: with Examples in Java [Book] — By Chris Richardson, Manning Publications, 2018
  2. Building Microservices — Designing Fine Grained Systems — By Sam Newman, Orielly, 2021

--

--

Crishantha Nanayakkara

Enterprise Architect, Consultant @ FAO (UN), Former CTO, ICTA Sri Lanka