InterviewVault
Welcome back, Sujit Kumar Mishra
Admin
SK Mishra
Revision Mode
Document technical questions and best-practice answers.
Microservices Communication
- Can you explain synchronous vs asynchronous communication between microservices?
- When should each approach be used, and how have you implemented them?
Synchronous vs Asynchronous Communication in Microservices
Synchronous Communication:
1: One service calls another and waits for a response (like a phone call).
2: Example: REST API calls.
3: Use when you need immediate feedback or real-time processing.
Asynchronous Communication:
1: One service sends a message and continues without waiting (like sending an email).
2: Example: Message queues (Kafka, RabbitMQ).
3: Use when you want better performance, reliability, or do not need instant response.
When to Use Each:
1: Use synchronous for quick, direct interactions (e.g., user login).
2: Use asynchronous for tasks that take time or can happen in the background (e.g., sending notifications).
Implementation Experience:
1: I have used synchronous REST APIs for real-time data exchange.
2: I have implemented asynchronous messaging for processing orders and sending emails, using Kafka and RabbitMQ.
Easy to Remember:
Phone call = synchronous (wait for reply)
Email = asynchronous (send and move on)