Đang mở hậu trường...
2 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 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?