In this article, we will learn how microservices interact with each other using the gRPC framework. gRPC is a modern RPC that enables microservices to interact with each other.

What is a microservice?

A microservice is an architecture that splits the server application into loosely coupled services. for example:

  1. A microservice that is dedicated to user authentication and authorization.
  2. A microservice for handling customers’ details (getting, updating, inserting Etc.)
  3. A microservice for handling products.
  4. A microservice for handling orders.
  5. The list goes on.

These microservices often need to interact with each other. For example, The orders microservice often needs to have product details and some customer’s details.

The products and the orders microservices often need to interact with the user’s microservice to know whether the users are authorized to perform certain actions like Adding products or confirming orders.

There are several methods that define how Microservices interact with each other. The most commonly used are:

  1. SOAP
  2. HTTP REST architecture
  3. GraphQL

In this article, we will focus on a newer protocol which is known as gRPC. Unlike older protocols, this protocol is based on the HTTP 2.0 protocol.

Some of the advantages of this new protocol are:

  1. Binary data instead of textual data. Ensures lower latency and greater speed because binary data is more compressed than textual data.
  2. HTTP 2.0 is fully multiplexed. HTTP 1.1 transfers one resource (such as images, JavaScript files, and so forth) so if one resource is blocked for some reason then all of the resources after this blocked resource are also blocked. this is not a problem in HTTP 2.0 since it can send multiple streams of data in a single TCP connection so that no resource can block other resources.
  3. Server push: The server pushes more than one resource in response to one request.
  4. Header compression ensures an even faster loading time.

#nodejs #angular #programming #javascript

Upload and Retrieve Images by Integrating MinIO With NestJS
5.50 GEEK