fastify / fastify-rate-limit

A low overhead rate limiter for your routes
MIT License
477 stars 66 forks source link

perf: use map for the in-memory store #353

Closed gurgunday closed 8 months ago

gurgunday commented 8 months ago

Reference: https://github.com/kibertoad/toad-cache/issues/40 Benchmark: https://github.com/kibertoad/nodejs-benchmark-tournament/pull/12

TLDR, I've discovered a 50%+ improvement in the lookup performance of non-numeric keys when a map is used instead of an object

In rate-limit, the key of a request is by default its IP address, so we should benefit directly from the change