{"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-09-11T12:38:40.457Z","updatedAt":"2026-09-11T19:18:40.457Z","expiresAt":"2026-10-11T12:38:40.457Z","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-09-11T14:06:40.457Z"},{"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-09-11T19:18:40.457Z"}]}