A ride-hailing backend must notify a billing service and a fraud service whenever a trip ends, without either service slowing down the trip flow. Which option fits best?
Show answer and explanation
Answer: C
Pub/Sub decouples producers from consumers. The trip service publishes an event to a topic and returns immediately, while billing and fraud each receive it through their own subscription and process it at their own pace. Adding a consumer later requires no change to the publisher. Polling a database or chaining synchronous calls would couple the services and add latency to the trip flow.
Why the other options are wrong
- A. Polling a shared table couples both services to database load and adds latency. It also lacks built-in delivery retries and fan-out to multiple independent consumers.
- B. Proxying requests one after another makes the trip flow wait for each downstream call. A failure in one service would block the other, which the design is meant to avoid.
- D. Running both services in one pod ties their lifecycle and scaling together. It does not provide asynchronous event delivery between them.