{
  "id": 6929258,
  "title": "Building a rate limiter, why even use Redis.",
  "url": "https://urgent.news/2026/09/12/building-a-rate-limiter-why-even-use-redis",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-12T13:24:29.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tejaswahinduja/building-a-rate-limiter-why-even-use-redis-20b4"
  },
  "original_language": "en",
  "account": "In this story, the author explains why using Redis to create a rate limiter is a better option than using a Node.js process or a standard database. When building a rate limiter from scratch, the author highlights several issues with using Node.js, such as race conditions and millisecond collisions. Race conditions occur when two requests hit within the same millisecond and read/write the same timestamps, bypassing the rate limit. Millisecond collisions happen when two requests occur simultaneously, causing them to overwrite each other's data.\n\nThe author compares the use of a ZSET in Redis to simply using a map and array. A sorted array allows for O(logN) search time using binary search, but write-heavy operations like insertion and deletion can be costly (O(N) memory-copy operations). Redis uses a combination of a hash map and a skip list to achieve both fast lookups and efficient memory usage while performing write operations.\n\nTraditional databases are not a viable solution because they suffer from concurrency bugs similar to Node.js. Most databases use Multi-Version Concurrency Control (MVCC), which allows stale reads while writes are in progress. This can cause the rate limit to be bypassed if a second request reads the uncommitted state before the first write finishes processing. The express-rate-limit library, which is often used for rate limiting, also suffers from the boundary burst problem due to its fixed-window approach. This issue allows an attacker to send requests within the reset window, bypassing the limit.",
  "summary": "Well I failed a amazon OA because of a rate limiting question, So I have built this rate limiter from first principles and haven't followed any tutorial. Through this blog, I want to answer questions like: Why even use Redis to make a rate limiter? Why not just use a Node.js process? What are the issues with using Node.js? Node.js race conditions: If we use an in-memory map, async execution…",
  "key_points": [
    "Using Redis for rate limiting avoids race conditions and millisecond collisions.",
    "Redis combines hash map and skip list for fast lookups and efficient memory usage.",
    "Traditional databases suffer from concurrency bugs, unlike Redis."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}