0
0
LLDsystem_design~10 mins

Pricing strategy (discounts, coupons) in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Pricing strategy (discounts, coupons)
Growth Table: Pricing Strategy (Discounts, Coupons)
UsersCoupon Requests/SecondDatabase Reads/WritesCache UsageSystem Complexity
100 users~10 req/sLow (few DB queries)Minimal or noneSimple validation logic
10,000 users~1,000 req/sModerate (more reads, some writes)Basic caching for couponsIntroduce cache, rate limiting
1,000,000 users~100,000 req/sHigh (heavy DB load)Distributed cache (e.g., Redis cluster)Sharding, load balancing, async processing
100,000,000 users~10,000,000 req/sVery high (DB bottleneck)Multi-region caches, CDN for static coupon dataMicroservices, event-driven, global distribution
First Bottleneck

At small to medium scale, the database is the first bottleneck. Coupon validation requires frequent reads and writes (e.g., usage count, expiration). As traffic grows, DB query volume and write contention increase, causing latency and failures.

Scaling Solutions
  • Caching: Use in-memory caches (Redis) to store coupon data and validation rules to reduce DB reads.
  • Read Replicas: Add DB replicas to distribute read load.
  • Sharding: Partition coupon data by user or coupon ID to spread writes and reads across multiple DB instances.
  • Async Processing: Use message queues to handle coupon usage updates asynchronously to reduce write contention.
  • Rate Limiting: Prevent abuse by limiting coupon validation requests per user/IP.
  • Microservices: Separate pricing and coupon logic into dedicated services for independent scaling.
  • CDN: Cache static coupon metadata globally to reduce origin load.
Back-of-Envelope Cost Analysis

Assuming 1M users with 10% using coupons, each making 1 validation request per minute:

  • Requests per second: (1,000,000 * 0.1) / 60 ≈ 1,667 req/s
  • Database QPS: ~1,667 (mostly reads, some writes)
  • Cache size: Coupon data ~100B per coupon * 10,000 active coupons = ~1MB RAM
  • Bandwidth: Each request ~1KB, total ~1.6MB/s (13Mbps)

At 100M users, scale these numbers by 100x, requiring distributed caching, sharded DB, and load balancing.

Interview Tip

Start by clarifying traffic patterns and coupon usage frequency. Identify the main bottleneck (usually DB). Discuss caching and async updates to reduce load. Explain how sharding and microservices help at large scale. Mention rate limiting to prevent abuse. Always justify your choices with traffic and data estimates.

Self Check

Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?

Answer: Introduce caching to reduce DB reads and add read replicas to distribute load. Also consider async processing for writes to reduce contention.

Key Result
The database is the first bottleneck as coupon validation grows. Caching, read replicas, and sharding are key to scaling pricing strategies with discounts and coupons.