Explain Pub/Sub vs RPC.
Pub/Sub (publish-subscribe) is an asynchronous one-to-many messaging model, while RPC (remote procedure call) is a synchronous one-to-one request-response communication method.
When to Use
Use Pub/Sub when multiple services need to react to an event independently — ideal for microservices, analytics, or notifications. Choose RPC when a service needs an immediate response — perfect for APIs or user data retrieval.
Example
A “new user signup” triggers Pub/Sub to notify email, billing, and analytics systems. The login flow, however, uses RPC to fetch user credentials in real time.
Want to master these concepts?
Explore Grokking System Design Fundamentals, Grokking the System Design Interview, Grokking Database Fundamentals for Tech Interviews, Grokking the Coding Interview, or Mock Interviews with ex-FAANG engineers.
Why Is It Important
Choosing between Pub/Sub and RPC impacts scalability, latency, and reliability. Pub/Sub scales better with loose coupling; RPC offers simplicity for direct, quick interactions.
Interview Tips
Explain the difference using coupling and timing: Pub/Sub = asynchronous and loosely coupled; RPC = synchronous and tightly coupled. Back your answer with real-world examples.
Trade-offs
Pub/Sub trades immediacy for scalability and decoupling, while RPC provides speed but risks tight coupling and failures cascading across services.
Pitfalls
Don’t force Pub/Sub into request-response patterns.
Overusing RPC can over-tighten dependencies and hurt fault tolerance.
GET YOUR FREE
Coding Questions Catalog
$197

$78
$78