Code Room
System designHard
Question
A microservices system has an Orders service (its own Postgres) that must, on every order change, both commit the DB change AND publish an event to Kafka for downstream services (inventory, notifications, analytics). Today it writes to the DB and then publishes to Kafka in app code; sometimes the DB commits but the Kafka publish fails (or vice versa), so downstream state diverges from the DB and inventory drifts. ~5k order changes/sec. Design how to make the DB change and the event publish atomic and exactly-once-effective downstream.
What a strong answer looks like
Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.
Learn the concepts
Loading whiteboard…
Run or narrate your approach, then ask the coach.