What is the Outbox Pattern?
Outbox Pattern is a microservice design technique where events are first stored in a local outbox table during a database transaction and then forwarded asynchronously to a message broker, ensuring reliable delivery without data loss.
When to Use
Use the Outbox Pattern when you need to update a database and publish an event together. It’s ideal in order-processing, payment, or user-signup workflows where losing events can cause inconsistencies.
Example
In an e-commerce app, placing an order writes to the database and also logs an “Order Placed” event into an outbox table. A dispatcher later sends that event to a broker so inventory and email services are updated reliably.
Want to sharpen your interview prep?
Explore Grokking System Design Fundamentals, Grokking the System Design Interview, Grokking Database Fundamentals for Tech Interviews, or try Mock Interviews with ex-FAANG engineers.
Why Is It Important
It guarantees eventual consistency without distributed transactions. If the DB update succeeds, the event is guaranteed to be delivered—even after crashes.
Interview Tips
Explain how it solves the dual write problem. Mention the transactional insert + background dispatcher, stress idempotent consumers, and note that the outbox must be cleaned regularly.
Trade-offs
Pros: strong reliability, avoids two-phase commit. Cons: adds dispatcher complexity, introduces slight delivery delay, and requires duplicate handling.
Pitfalls
Mistakes include not cleaning the outbox (leading to bloat), running too many dispatcher threads, or ignoring idempotency.
GET YOUR FREE
Coding Questions Catalog
$197

$78
$78