Choose between http/1.1 and gRPC. TL; DR: Use gRPC

Communicate effectively

How microservices communicate with each other can affect performance and scalability of the application. Communication between services can be synchronous or asynchronous. For this blog post, we will focus on synchronous. We have 2 common protocols at our disposal

HTTP/1.1 : The “default” http call

: The “default” http call gRPC: High performance remote procedure call (RPC framework). gRPC.io has a comprehensive documentation and how it works.

Let’s look at some sample code and run some performance test to pick our choices.

Non-cluster mode

Let’s start small and try to get one microservice talk to another one.

Simple application architecture diagram

Our application has following components

Load Testing tool: jMeter

jMeter Service A: Makes a request to serviceB and returns that response.

Makes a request to serviceB and returns that response. Service B: Replies with a static JSON after 10ms of delay for all the APIs

Replies with a static JSON after 10ms of delay for all the APIs VMs: Both the VMs are Amazon EC2 t2.xlarge machines

HTTP/1.1

This is the default request we make when we use any of the HTTP client libraries like axios, superagent.

Let’s create ServiceB to implement our APIs.

service B with HTTP/1.1 implementation

Next, we create ServiceA which calls ServiceB with HTTP/1.1

service A with HTTP/1.1 implementation