---
title: "Discussion on \"One Window, N Requests: Building a Rate Limiter from Scratch in Go\" | Hashnode"
description: "Discussion on \"One Window, N Requests: Building a Rate Limiter from Scratch in Go\". Building an in-memory Fixed Window rate limiter in Go, covering concurrency, per-client rate limits, cleanup, and integrating it with HTTP middleware."
url: "https://hashnode.com/posts/one-window-n-requests-building-a-rate-limiter-from-scratch-in-go/6ac69aa870f3f5d264eaee1c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [One Window, N Requests: Building a Rate Limiter from Scratch in Go](https://utkarshkrsingh.hashnode.dev/one-window-n-requests-building-a-rate-limiter-from-scratch-in-go?utm_source=hashnode&utm_medium=feed)

Building an in-memory Fixed Window rate limiter in Go, covering concurrency, per-client rate limits, cleanup, and integrating it with HTTP middleware.

Oct 7 · 7 min read · utkarshkrsingh.hashnode.dev  
Updated 3d ago  
Read the article

-   [#golang](https://hashnode.com/tag/golang)
-   [#backend](https://hashnode.com/tag/backend)

## Written by

[Utkarsh Kumar Singh](https://hashnode.com/@utkarshkrsingh)

@utkarshkrsingh · Mysore, IND

  
[View profile](https://hashnode.com/@utkarshkrsingh)

My compiler and I have a love-hate relationship. It mostly involves coffee.

Backend developer passionate about Go and system design. Building things, learning continuously, and sharing my journey.

## Responses 3

Markdown supported · ⌘↵ to post

[Parsa Aftabi](https://hashnode.com/@parsaaftabi)

[Oct 9](https://hashnode.com/posts/one-window-n-requests-building-a-rate-limiter-from-scratch-in-go/6ac69aa870f3f5d264eaee1c/comment/6ac96474954062902cbd3110)

Nice walkthrough. Two things worth adding for anyone taking this to production. Fixed-window counters have a boundary stampede problem: a burst at the end of one window plus a burst at the start of the next can double the intended rate. Sliding-window log or token bucket fixes it. The in-memory approach breaks the moment you run more than one replica, each instance gets its own budget. The standard production answer is a Redis-backed token bucket (a small Lua script keeps the check-and-decrement atomic). Happy to sketch it if useful.

[Utkarsh Kumar Singh](https://hashnode.com/@utkarshkrsingh)

[Oct 14](https://hashnode.com/posts/one-window-n-requests-building-a-rate-limiter-from-scratch-in-go/6ac69aa870f3f5d264eaee1c/comment/6ac96474954062902cbd3110#reply-6acfd0911bd63c6bf23bf1bc)

Thank you for pointing these out! I'm still learning about rate limiting, so this was mainly an exercise to understand the basics and implement it from scratch. I hadn't thought much about the boundary issue. Redis-backed token bucket sounds like a good next step to explore. Appreciate the suggestions!

[Parsa Aftabi](https://hashnode.com/@parsaaftabi)

[Oct 16](https://hashnode.com/posts/one-window-n-requests-building-a-rate-limiter-from-scratch-in-go/6ac69aa870f3f5d264eaee1c/comment/6ac96474954062902cbd3110#reply-6ad17b050bf62d3523e37f26)

anytime. when you get to the redis bucket, the refill side is where it gets interesting. happy to look at your sketch.
