Đang mở hậu trường...
4 câu hỏi kỹ thuật chủ đề Thiết kế hệ thống, song ngữ Anh-Việt, có đáp án và giải thích.
An order service must (1) persist a new order row in its PostgreSQL database and (2) publish an OrderCreated event so downstream inventory and notification services react. The team notices that after DB commit, the process sometimes crashes before the broker ack, so events are silently lost. They consider replacing the direct publish with the Transactional Outbox pattern (write the event into an outbox table in the same DB transaction, then a relay polls the table and publishes to Kafka). What is the most accurate trade-off of adopting this pattern here?
In an e-commerce platform, when a customer places an order, the Order Service must notify the Notification Service to send an email and the Analytics Service to record the purchase. To minimize latency for the customer and prevent failures in downstream services from blocking the checkout response, which communication pattern should be used?
An Order service commits orders to its database and then publishes OrderCreated events to a message broker used by inventory, billing, and analytics teams. Production incidents show both missing events when the service crashes after the database commit and duplicate deliveries during broker retries. Without introducing distributed two-phase commit, which design best preserves business consistency at scale?
An order service must publish an OrderCreated event after committing an order to its database. The current implementation writes to the database and then sends directly to a message broker, occasionally losing events when the broker call fails after the commit. Which design best improves reliability while keeping the service scalable?