NewsCrawler.org

How hard is WeChat Sports' nightly 10 PM step-ranking push, technically?

WeChat Sports sends users a nightly notification around 10 PM with their day's step count and a prompt to open the friend leaderboard, with delivery times drifting by about a minute around the hour. For a hypothetical 100 million daily active users, delivering every reminder within one minute works out to about 1.67 million messages per second, or 100 million in the same second if every task fired at 22:00:00. A single machine scanning a task table and sending at 5,000 messages per second would not finish until 3:30 AM, so scheduling is separated from sending: a queue buffers the burst, consumers are rate-limited, tasks are split by sharding[1] across instances by uid, and sends are spread across 60 seconds with a hash. For friend rankings, one ZSet[2] per user would mean roughly 20 billion entries with 200x write amplification, so the trade-off between real-time sorting (about 1,500 comparisons per query, no write cost) and short-TTL[3] caching is decided by the distribution of friend counts, from dozens to a cap of about 10,000, and by access frequency. Computing a ranking only when the user opens the push means 10 million sorts instead of 100 million at a 10% open rate, leaving the 90% who never look with no computation at all, though at 10,000 users a crontab[4] plus an in-memory sort would already be enough.

Read the original juejin.cn

Discussion

Commenters report getting the push at slightly different times, one as late as 22:21, and one observes that steps seem to stop counting after 21:50. One argues the client could simply compute the ranking itself, since it involves only a few hundred friends, while others ask whether the timing spread comes from sharded scheduling or from display delay, and whether such a system runs on a single machine or a cluster.

Sources

  • CNJuejin ZH

    微信运动每天晚上 10 点推送排行榜,技术上到底有多难?

    16 likes1,288 views9 comments8 saves

Published: First seen: Читать по-русски

Open as a page