Practice/Amazon/Design a Subscribe and Save Feature for an E-commerce Website
Design a Subscribe and Save Feature for an E-commerce Website
System DesignOptional
Problem Statement
Design a subscribe-and-save feature for an e-commerce platform with 100M daily active users that allows customers to set up recurring deliveries for products and receive discounts. Users pick items, set a delivery cadence (weekly, monthly), and automatically receive shipments at a discounted price without manually reordering.
This system blends scheduling, payments, inventory, and pricing into a workflow-heavy platform. Interviewers ask this to assess your ability to design reliable job orchestration at massive scale, handle idempotency across multi-step processes, reason about eventual consistency, and manage failure handling across multiple services while keeping the experience simple and trustworthy.
Key Requirements
Functional
- Subscription creation -- users create subscriptions for eligible products by choosing quantity, cadence, start date, and delivery address with payment method
- Subscription management -- users edit frequency and quantity, skip a cycle, pause, or cancel subscriptions at any time through a self-service interface
- Automated fulfillment -- scheduled deliveries trigger reliably with payment authorization/capture, order creation, and clear notifications for each cycle
- Subscription benefits -- users automatically receive and see discounts on product pages, in cart, and at checkout for subscribed items
Non-Functional
- Scalability -- support 100M+ DAU with millions of active subscriptions, handling synchronized delivery spikes (monthly renewals) without overwhelming downstream services
- Reliability -- guarantee at-least-once delivery processing with idempotent execution; no double-charges or missed deliveries after outages
- Latency -- subscription creation and modification under 500ms; scheduled processing completed within a delivery window with retry budgets
- Consistency -- strong consistency at order calculation and payment capture; eventual consistency acceptable for discount display and subscription status propagation
What Interviewers Focus On
Based on real interview experiences, these are the areas interviewers probe most deeply:
1. Reliable Recurring Job Scheduling
Subscriptions fire far in the future and must reliably trigger delivery workflows even after outages, deployments, or infrastructure changes.
Hints to consider:
- Store subscription definitions with next-fire timestamps in a durable database, using secondary indexes for time-range queries
- Use a multi-tier scheduling approach: a scanner finds subscriptions due in the next window, enqueues them to a work queue, and workers process each subscription independently
- Implement catch-up logic so missed windows (due to outages) are detected and processed when the system recovers
- Distribute scheduling load by partitioning subscriptions across time buckets to prevent thundering herds at common renewal times
2. Multi-Step Delivery Workflow
Each delivery cycle is a saga spanning price calculation, inventory reservation, payment authorization, order creation, and notification, with each step potentially failing independently.
Hints to consider:
- Model the delivery workflow as a state machine with explicit states (scheduled, pricing, reserving, charging, ordered, notified) and compensating actions for each failure
- Use idempotency keys for every external call (payment gateway, inventory service) so retries are safe and never produce duplicate effects
- Implement dead-letter queues for cycles that exhaust retry budgets, with alerting and manual resolution workflows
- Lock in subscription prices at the moment of cycle processing to prevent price changes mid-workflow
3. Traffic Spike Management
Many subscriptions share common renewal dates (first of the month, weekly cadences), creating synchronized demand spikes on pricing, payments, and inventory services.
Hints to consider:
- Jitter delivery processing times within a configurable window (e.g., process "monthly" subscriptions across a 4-hour window rather than all at midnight)
- Use rate limiting and backpressure at the work queue level to protect downstream services from sudden load
- Pre-warm caches for product pricing and availability data ahead of known spike windows
- Design circuit breakers so payment gateway failures degrade gracefully with automatic retry scheduling
4. Subscription Lifecycle Edge Cases
Users modify subscriptions between scheduling and processing, products go out of stock, payment methods expire, and prices change, all requiring careful handling.
Hints to consider:
- Use versioning on subscription records so the processing workflow operates on a consistent snapshot even if the user modifies settings concurrently
- Handle payment method failures with automatic retry schedules and user notifications, pausing the subscription after configurable failed attempts
- Design substitution or skip logic for out-of-stock items, with user preference settings for automatic alternatives vs cancellation
- Support prorated billing adjustments when users change quantity or cadence mid-cycle
Suggested Approach
Step 1: Clarify Requirements
Confirm scope and constraints with the interviewer. Ask about the number of active subscriptions, supported cadences (weekly, biweekly, monthly), whether bundled subscriptions (multiple products in one delivery) are required, and if the discount model is fixed or tiered based on subscription count. Clarify whether out-of-stock handling should substitute automatically or skip the delivery. Confirm payment retry policies and how long to attempt before pausing. Establish whether international shipping and multi-currency support are in scope.