Backend Development 9 min read

Scalable Discount System Design with Crowd Synchronization

The article proposes a three‑step, crowd‑based discount system that decomposes discount elements, pre‑computes fan group membership in Redis, and combines offline batch with real‑time event synchronization, achieving tens of thousands QPS, millisecond latency, and both eventual and strong data consistency.

Xianyu Technology
Xianyu Technology
Xianyu Technology
Scalable Discount System Design with Crowd Synchronization

This article presents a practical solution for designing and implementing a discount system that can scale under high traffic while ensuring data consistency.

Problems and challenges include describing, storing, and computing discounts with good scalability, maintaining real‑time performance under large traffic, and achieving consistent data synchronization for discount queries.

Background describes a scenario on the Xianyu platform where sellers set targeted fixed‑price discounts for all fans, old fans, or purchased fans, and buyers can see the lowest applicable price in real time.

Technical implementation is divided into three steps: (1) decompose discount elements into object, product, and price; (2) abstract and accelerate the discount‑object determination process for high‑traffic scalability; (3) synchronize data offline + online to guarantee consistency.

The discount is expressed as [SellerA_all_fans] + [Product1234] + [18.88 RMB] . When a buyer requests the product, the system checks the rule, interprets the object symbol, and verifies the buyer’s membership in the crowd.

Crowd abstraction and acceleration replace runtime semantic parsing with pre‑computed crowd membership stored in Redis using keys like ${user}_${crowd} . Two implementation options are discussed: marking users directly or creating crowd objects; the latter is chosen for large groups.

Data‑sync consistency combines offline T+1 batch sync with real‑time event sync. Offline sync provides eventual consistency, while real‑time sync ensures freshness. To handle unfollow deletions missing from batch data, a TTL is added to crowd entries. To avoid conflicts where batch sync re‑writes stale follow relations, unfollow events are recorded temporarily in Redis and checked during batch processing.

The resulting architecture supports tens of thousands of QPS with millisecond latency for discount queries, while guaranteeing eventual consistency for search and recommendation scenarios and strong consistency for order‑placement checks.

In conclusion, the three‑part approach—discount element decomposition, crowd pre‑preparation, and hybrid offline/online synchronization—delivers scalable, high‑performance discount functionality with reliable data consistency.

backend architectureRedisData SynchronizationHigh Performancecrowd managementdiscount system
Xianyu Technology
Written by

Xianyu Technology

Official account of the Xianyu technology team

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.