Replication · Interviews · Open-sourced a rate-limiting middleware for replication-interview with token bucket and sliding window

14
REr/replication-interview·posted by tang_hao·6 hours agoAnnouncementPinned

Open-sourced a rate-limiting middleware for replication-interview with token bucket and sliding window

Some background first. Our setup is replication-interview plus three downstream services, seven figures of daily requests, peaking around nine in the evening.

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
2 comments

2 comments

M
Kkite·12 minutes ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

131
Zzhu_zong·3 minutes agoedited

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

76

This is the post detail page /en/c/replication-interview/post/p0. Posts and comments are generated deterministically from a seeded PRNG, so the same post always renders the same content and the link can be shared, reloaded and indexed. In production this page reads MySQL for the post, Redis for hot-post caching, and fetches the whole comment tree in a single query on the path column.

See the database schema →