Practice/Meta/Design an Ads Campaign for a 5-Minute Availability with Coupon
Design an Ads Campaign for a 5-Minute Availability with Coupon
Product DesignOptional
Problem Statement
Design a system that powers flash sale advertising campaigns where promotional offers become available for exactly 5 minutes at scheduled times throughout the day. During each availability window, users can claim digital coupons that they later redeem for discounts. The system must handle multiple concurrent campaigns across different products or services, support millions of users attempting to claim coupons simultaneously, and prevent fraud or over-claiming. Consider that a major e-commerce platform might run 20-30 such campaigns daily, with each campaign attracting 500K-2M concurrent users during peak seconds. The system needs to handle both the real-time claim process and the subsequent redemption flow at checkout.
Key Requirements
Functional
- Campaign scheduling -- Allow marketers to create campaigns with precise start times, duration (5 minutes), inventory limits, and coupon rules
- Real-time availability tracking -- Display live countdown timers and remaining coupon inventory to users as campaigns go live
- Coupon claiming -- Enable users to claim coupons during the 5-minute window with proper inventory management
- Redemption validation -- Verify coupon validity, expiration, and single-use constraints at checkout
- Anti-fraud measures -- Prevent bots, duplicate claims, and abuse through rate limiting and user verification
Non-Functional
- Scalability -- Handle 2M+ concurrent users per campaign with 50K+ claim requests per second during peak
- Reliability -- Maintain 99.9% uptime with no double-claiming or inventory over-allocation
- Latency -- Return claim success/failure within 200ms; show real-time updates with sub-second delays
- Consistency -- Guarantee strong consistency for inventory management; eventual consistency acceptable for counters
What Interviewers Focus On
Based on real interview experiences, these are the areas interviewers probe most deeply:
1. Handling Thundering Herd at Campaign Start
The most critical challenge is managing the massive spike in traffic when a campaign goes live, with millions of users clicking simultaneously.
Hints to consider:
- Use a queuing system to buffer and rate-limit incoming claim requests
- Consider pre-warming caches and connection pools before campaign start time
- Implement client-side jitter and retry logic to spread the load
- Design a waiting room or lottery system for extremely popular campaigns
2. Inventory Management Without Over-Claiming
Ensuring coupon inventory is accurately tracked while serving high request volumes is crucial to avoid disappointing customers or losing revenue.
Hints to consider:
- Evaluate distributed locking versus optimistic concurrency control for inventory decrements
- Consider pre-allocating inventory batches to different service instances
- Implement a two-phase commit for claim validation then fulfillment
- Use counters in Redis or similar fast data stores with atomic operations
3. Real-Time Updates and Countdown Synchronization
Users expect accurate countdown timers and live inventory updates, which creates interesting technical challenges at scale.
Hints to consider:
- Use WebSockets or Server-Sent Events for pushing live updates to clients
- Implement a pub-sub system for broadcasting inventory changes
- Consider update frequency tradeoffs (showing exact count vs bucketed ranges)
- Batch and throttle updates to reduce backend load while maintaining user experience
4. Fraud Prevention and Fair Access
Preventing bot attacks and ensuring legitimate users can claim coupons requires multiple layers of protection.
Hints to consider:
- Implement CAPTCHA or device fingerprinting before high-value claims
- Use rate limiting per user, IP address, and device
- Design progressive delays or account verification for suspicious patterns
- Consider requiring pre-registration or authenticated sessions for claim eligibility
Suggested Approach
Step 1: Clarify Requirements
Begin by understanding the business context and constraints. Ask about expected campaign volumes, average coupon inventory per campaign (100 coupons vs 100K coupons), user authentication requirements, redemption timeframe (same-day vs 30-day expiration), and whether campaigns are global or region-specific. Clarify if users can claim multiple coupons from different campaigns simultaneously and what constitutes a valid redemption event.