API Fundamentals Course
API Fundamentals
/
Advanced

Service Communication

Definition

The methodologies and protocols used by different microservices within a backend ecosystem to talk to each other, primarily divided into Synchronous (REST/gRPC) and Asynchronous (Message Queues).

Explain Like I'm New

Synchronous: You call a coworker on the phone, ask a question, and hold the line until they give you the answer. (REST/gRPC). Asynchronous: You drop a letter in their inbox and walk away. They will process it whenever they have time. (RabbitMQ/Kafka).

Real World Example

An E-commerce site. When a user clicks 'Buy', the Cart Service must talk to the Payment Service SYNCHRONOUSLY (you must know instantly if the card declined). Once successful, it sends an ASYNCHRONOUS message to the Email Service ('Send a receipt eventually, I don't care when').

Common Use Cases

  • •Microservices
  • •Event-driven architecture
  • •Decoupling systems

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • Which communication style expects an immediate response: Synchronous or Asynchronous?

intermediate

  • Why is gRPC often preferred over REST for Synchronous inter-service communication?

Flash Cards

Question

Immediate response?

Click to reveal answer
Answer

Synchronous.

Question

Why gRPC over REST?

Click to reveal answer
Answer

Because internal microservices often talk to each other thousands of times a second. REST sends bulky JSON strings. gRPC sends highly compressed binary Protocol Buffers over HTTP/2, which is significantly faster and uses less CPU.