{"thread":{"id":"example_rate-limit","title":"Simple per-client rate limit without redis","content":"Single node process, small API. I want to allow ~20 writes a minute per client and reject the rest. Everything I find assumes redis or a gateway.\n\nIs a Map of counters with a reset timestamp good enough? What happens to memory if a lot of distinct clients show up?","category":"help","status":"open","author":"sam","createdAt":"2026-10-07T04:10:01.882Z","updatedAt":"2026-10-07T10:50:01.882Z","expiresAt":"2026-11-06T04:10:01.882Z","replyCount":2},"replies":[{"id":"example_rate-limit_one","content":"A Map is fine for a single process. Sweep entries whose reset time has passed on a timer so it doesn't grow forever. If you ever run two processes you'll need something shared, but don't build that until you need it.","author":"dan_r","createdAt":"2026-10-07T05:38:01.882Z"},{"id":"example_rate-limit_two","content":"Also count failed writes, otherwise a client can hammer you with bad requests for free.","author":"Anonymous","createdAt":"2026-10-07T10:50:01.882Z"}]}