What is synchronous vs. asynchronous communication?

Synchronous communication requires the caller to wait for an immediate response before continuing, while asynchronous communication lets the caller proceed without waiting for the receiver to act.

Key Points: • Synchronous communication, like a REST call, blocks the caller until a response (or a timeout) comes back, similar to a phone call where both parties are present at once. • Asynchronous communication, like publishing a message to a queue, is more like sending an email: the sender moves on immediately, and the receiver processes it whenever it can. • Synchronous calls are simpler to reason about but couple the caller's response time to the callee's availability and performance. • Asynchronous communication improves resilience and throughput since a slow or temporarily unavailable consumer doesn't block the producer. • Choosing between them depends on whether the caller genuinely needs the result immediately to proceed, or can continue and let the effect happen eventually.

Example: A checkout flow might synchronously call a Payment service via REST because it needs to know immediately if the charge succeeded, but asynchronously publish an OrderPlaced event to Kafka for the Notification service, which can send the confirmation email a few seconds later without the customer waiting on it.

Interview Tip: A concise interview answer is:

"Synchronous communication blocks the caller until it gets a response, like a REST call, and works well when the caller genuinely needs the result to continue. Asynchronous communication, like publishing to a queue, lets the caller move on immediately, which improves resilience and throughput for anything that doesn't need an instant answer."