Closed conorbros closed 2 years ago
Good question - I'm pretty sure a real authoritative answer will involve benchmarks of your specific code base, but I imagine the following factors will play a role in how easy each method will be to execute:
With those in mind, it should be easier to find a representation that'll work for you - if there's a limit per connection (not per user) and you can easily associate a limiter with a connection - make it direct. Otherwise, if you limit per-user, I'd say go with the keyed variant.
Hope that helps - I'll close this issue, but feel free to re-open it you have follow-up questions.
Performance wise, is it preferable to construct a direct
RateLimiter
for each new connection or use a keyed one?