Building a Scalable Coupon Push System with Redis for Real‑Time Notifications

This article explains how to design and implement a high‑throughput, second‑level accurate coupon push notification service using Redis Sorted Sets, a distributed task cluster, dynamic queue configuration, and load‑balancing to handle millions of users within a minute.

dbaplus Community
dbaplus Community
dbaplus Community
Building a Scalable Coupon Push System with Redis for Real‑Time Notifications

Background

The coupon‑center must push a reminder to a user exactly one minute before a coupon becomes claimable. With >60 million registered users and an estimated 200 000 concurrent pushes, the system must guarantee sub‑second timeliness and high throughput.

Key Challenges

Push timeliness – delayed notifications lead to user complaints.

Massive volume – a popular coupon can generate hundreds of thousands of push messages simultaneously.

Rejected Approaches

MQ delayed delivery – Message‑queue delay granularity is coarse (seconds to minutes) and cannot guarantee precise timing. Handling cancellations and deduplication would add considerable complexity.

Single‑machine scheduled task – A cron job that scans the database for due reminders becomes a performance bottleneck, suffers from poor timeliness, and introduces a single point of failure.

Proposed Architecture: Redis‑Backed Scheduled‑Task Cluster

Each subscription reminder is stored in a Redis Sorted Set where the reminder timestamp is used as the score. Multiple backend servers run a 1‑second timer; each server pulls a configurable batch of due records from a specific queue determined by userId % queueCount. Queue count matches the number of processing servers and can be changed at runtime.

Why Redis?

High‑performance in‑memory storage, faster than MySQL, with persistence and stability.

Sorted Sets naturally support time‑based ordering, making it trivial to select records ready for push.

Implementation Details

• Key design : Use userId as the base key and hash it to one of several Sorted Set queues to spread load and allow merging of near‑identical push times.

• Dynamic configuration : Queue count and batch size are stored in Alibaba’s Diamond configuration service, allowing on‑the‑fly adjustments without redeployment.

• Batch size is also configurable at runtime, enabling the cluster to scale its throughput according to traffic.

Load Balancing

A simple algorithm uses a Redis auto‑increment key combined with the queue count to distribute work:

nextId = INCR global_counter;
queue = nextId % queueCount;

This reduces contention so that multiple servers rarely compete for the same queue.

Performance Evaluation

With 10 processing servers each pulling 2 000 records per second, the cluster can push 20 000 messages per second. Adding an asynchronous MQ step to deliver messages to the message centre adds ~0.5 s overhead, so 200 000 pushes complete in a few seconds.

Future Improvements

Add monitoring to detect task backlogs.

Provide a visual management console.

Implement priority‑aware scheduling.

Introduce resource‑aware dispatch to guarantee critical tasks when capacity is limited.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed SchedulingredisCoupon SystemScheduled Push
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

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.