rate_limit function

Modern rate limiting implementation