4 ms·
Great post however does anyone know how rate limiting specific users is typically implemented? For instance if you have a SaaS API with multiple subscription pl
by fspear 10y ago
Great post however does anyone know how rate limiting specific users is typically implemented? For instance if you have a SaaS API with multiple subscription plans you generally rate limit users based on tier e.g free tier: up to X number of requests, paid tier: unlimited number of requests, etc. I am assuming this is typically handled in the API itself.
Thanks in advance.
- ptarjan 10y agoThanks! The buckets are already done per-user so it is very simple to make the constant factors be user-dependent. For my example in https://gist.github.com/ptarjan/e38f45f2dfe601419ca3af937fff574d#file-1-check_request_rate_limiter-rb https://gist.github.com/ptarjan/e38f45f2dfe601419ca3af937fff... you would just set REPLENISH_RATE to be a different value for different users.
- fspear 10y agoThanks!