Skip to main content
InterviewHubPRO
Section Overview
Q34

Question 34 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

68%
Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Real-World Architecture: The Transactional Outbox Pattern with Kafka and Debezium CDC.

senior LevelCode ExampleSystem DesignDatabases & SQLApache Kafka

In Simple Words: A microservice must save an order to PostgreSQL and publish an OrderCreated event to Kafka.

  • If you save to DB first and the app crashes before publishing to Kafka -> Inconsistent state!
  • If you publish to Kafka first and DB commit fails -> Ghost event!

The Transactional Outbox Architecture:

css
[ Order Service ]
       | (Atomic Local DB Transaction)
       v
[ PostgreSQL Database ]
  ├── 'orders' table (Order details)
  └── 'outbox' table (Event payload: { id, topic: 'orders', payload: {...} })
       |
       | (PostgreSQL WAL Log)
       v
[ Debezium CDC Connector ] (Kafka Connect)
       | (Reads WAL asynchronously)
       v
[ Kafka Broker: 'orders' Topic ]

Guarantees 100% reliable, zero-loss event publication without dual-write race conditions or distributed two-phase commit (2PC) locks.