Design a scalable coffee ordering notification system
SalesforceSoftware Engineer · OnsiteLast updated
This problem tests your ability to design a distributed, asynchronous notification system capable of handling high-throughput order status updates and ensuring reliable message delivery to end users.
Design a Scalable Coffee Ordering Notification System
Design a backend service that notifies customers about their coffee order status (e.g., 'Order Received', 'Preparing', 'Ready for Pickup').
Functional Requirements
- The system must track the state transition of an order.
- Customers must receive real-time notifications via push notifications (mobile) and email.
- The system must support at least 5,000 orders per minute during peak hours.
Non-Functional Requirements
- Reliability: Notifications should not be lost. We must ensure 'at-least-once' delivery.
- Latency: End-to-end latency from status update to user notification should be under 2 seconds.
- Scalability: The system should handle sudden bursts of traffic.
Constraints
- Assume an existing Order Service that publishes order events to a message bus.
- The notification service must handle potential downtime of third-party notification providers (e.g., Firebase, SendGrid).
Deliverables
- High-level architecture diagram (described in text).
- Data model for storing notification preferences and message logs.
- Strategy for handling message retries and idempotency.
- Design for handling high-volume traffic bursts.
Hints
Hint 1
Use an asynchronous message queue (like Kafka or RabbitMQ) between the Order Service and the Notification Service to decouple event production from processing.
Hint 2
Implement a state machine within a database to track the lifecycle of each notification and prevent duplicate deliveries using idempotency keys.
Hint 3
Consider a 'Worker' pattern where multiple instances pull messages from a queue to scale processing horizontally based on load.
Follow-up questions
- How would you handle a scenario where a third-party notification provider experiences a 30-minute outage?
- How would you ensure that a customer doesn't receive the same 'Order Ready' notification twice if the network glitches?
- What metrics would you monitor to identify bottlenecks in the notification delivery pipeline?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.