Design and Implementation of QQ Reminder Subscription Push System
Tencent’s QQ reminder subscription push system combines push‑pull prefetching, heterogeneous MySQL/Redis storage, delayed‑queue triggers, Redis‑based rate‑limiting, task scattering, message‑queue decoupling, at‑least‑once delivery, and dual‑replica disaster recovery within a dispatcher‑worker architecture to ensure reliable, controllable, low‑latency mass notifications.
Tencent engineer Xu Yang presents the technical key points and implementation ideas of a subscription push system derived from QQ reminder business scenarios.
Business background and requirements : QQ serves massive mobile internet users, and its subscription reminder function is critical for both users and business. Requirements include push reliability (every configured task must be triggered and every subscribed user must receive the message), push controllability (overall push rate must stay within the capacity of the message service), and push efficiency (high concurrency with low latency).
Implementation方案 includes eight major techniques:
Push‑pull combination (mixed mode): pre‑fetch tasks to clients at 0:00 of the reminder day, while remaining users receive push notifications.
Heterogeneous storage: task data stored in MySQL for reliability; subscription lists stored in Redis set for fast access.
Multi‑trigger: use delayed queues such as Redis sorted set or RabbitMQ dead‑letter queue; QQ uses a mobile‑side timer based on Redis sorted set.
Controllable scheduling: a distributed rate‑limiting scheduler uses Redis INCR to count per‑second requests and only dispatch tasks when the limit is not exceeded.
Scattered execution: large tasks are split into small blocks (e.g., 5,000 uin per block) to enable fine‑grained rate control and parallel execution.
Message queue integration: decouple scheduling from execution, achieve peak‑shaving and asynchronous processing, and guarantee at‑least‑once consumption.
At‑least‑once delivery: after popping a batch of uin from a Redis set, the IDs are atomically moved to a task set via a Lua script to ensure reliability.
Disaster recovery: task data is duplicated in a proprietary KV store (CKV) and Redis cluster (2 replicas, 3 shards) for mutual backup.
Key code examples:
CREATE TABLE table_xxx(
ds BIGINT COMMENT '数据日期',
label_name STRING COMMENT '标签名称',
label_id BIGINT COMMENT '标签id',
appid STRING COMMENT '小程序appid',
useruin BIGINT COMMENT 'useruin',
tag_name STRING COMMENT 'tag名称',
tag_id BIGINT COMMENT 'tag id',
tag_value BIGINT COMMENT 'tag权重值'
)
PARTITION BY LIST(ds)
SUBPARTITION BY LIST(label_name)(
SUBPARTITION sp_xxx VALUES IN ('xxx'),
SUBPARTITION sp_xxxx VALUES IN ('xxxx')
) redis.replicate_commands()
local set_key, task_key = KEYS[1], KEYS[2]
local num = tonumber(ARGV[1])
local array
array = redis.call('SPOP', set_key, num)
if #array > 0 then
redis.call('SADD', task_key, unpack(array))
end
return redis.call('SCARD', task_key)The overall workflow follows a Dispatcher + Worker model: the dispatcher partitions tasks, controls rate, and enqueues sub‑tasks; workers fetch user IDs from Redis sets, push notifications, and report results. This design achieves high reliability, controllability, and efficiency for massive concurrent push scenarios.
In summary, the QQ reminder subscription push system demonstrates a scalable backend architecture that can be abstracted as a generic service for various B‑side applications.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.