<#557 Add RateLimit middleware using TokenBucket a...
# flyte-github
a
#557 Add RateLimit middleware using TokenBucket algorithm Pull request opened by LaPetiteSouris TL;DR Solve flyteorg/flyte#327 Type ☐ Bug Fix ☑︎ Feature ☐ Plugin Are all requirements met? ☐ Code completed ☐ Smoke tested ☑︎ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description Main changes • Add a simple rate limiter middleware. • The RateLimiter components rely on an in-memory map storage to store
userID
and
rate
per user ID.
rate
is a native Golang package to track total count of requests. • The in-memory storage is cleaned periodically to reduce memory footprint. • The component, which is considered as part of the security scope, relies on the identity of the user provided by
auth
package. In fact, the best way to uniquely identify requests to rate limit is to track usage per authenticated user. Tradeoff • To keep it simple, an in-memory map storage is used to track rate per user. This becomes inaccurate if multiple instances of
flyteadmin
is deployed. If this is the case and we are serious about rate limit, another improvement is needed, like introduction of Redis for example, which is out of scopes for this PR. Tracking Issue _Remove the '_fixes_' keyword if there will be multiple PRs to fix the linked issue_ fixes flyteorg/flyte#327 Follow-up issue NA flyteorg/flyteadmin All checks have passed 2/2 successful checks