lyft/ratelimit config question

206 views
Skip to first unread message

Jason Ragsdale

unread,
May 30, 2018, 11:19:57 AM5/30/18
to envoy-users
Hello all, 

Hopefully this is the right place to to ask a config question about https://github.com/lyft/ratelimit? If so, i'm looking to use ratelimit in my stack, i'm looking for examples or guidance on how i can set up different rate limits for the same request bucketing by either IP or user_id i.e. 1500 requests per hour, 500 requests per minute, 50 requests per second. I'm thinking if it can be done in ratelimit i would have to use nested descriptors but it's not making sense to me how.

Anyone out there implemented this before with lyft/ratelimit or envoy?

-Jason

Jose Nino

unread,
May 30, 2018, 6:44:51 PM5/30/18
to Jason Ragsdale, envoy-users
Hi Jason,
Yes this is the right place for your question. 

If I understand your question correctly you want some guidance on how to set up multiple limits for a request, and have the ratelimit service return an OVER_LIMIT if any of the limits are hit.
This is possible you would send several descriptor sets per request so that you hit all the N limits you have setup. To use your example:

Ratelimit Config:

domain: requests_per_time_unit
descriptors:
  - key: generic_key
    value: req_per_second
    descriptors:
      - key: remote_address
        rate_limit:
          unit: second
          requests_per_unit: 50
  - key: generic_key
    value: req_per_minute
    descriptors:
      - key: remote_address
        rate_limit:
          unit: minute
          requests_per_unit: 500
  - key: generic_key
    value: req_per_hour
    descriptors:
      - key: remote_address
        rate_limit:
          unit: hour
          requests_per_unit: 1500

And then for every request you would send:

RateLimitRequest:
  domain: requests_per_time_unit
  descriptor: ("generic_key", "req_per_second"),("remote_address", "<address>")
  descriptor: ("generic_key", "req_per_minute"),("remote_address", "<address>")
  descriptor: ("generic_key", "req_per_hour"),("remote_address", "<address>")
Which you can do by setting up the ratelimit actions on your ratelimit filter in envoy. More docs on that here.

Then every request you send will be matched against all three limits, and the Ratelimit Response will come OVER_LIMIT if any of the three limits is over the limit.

Hope that helps,
Jose


--
You received this message because you are subscribed to the Google Groups "envoy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to envoy-users+unsubscribe@googlegroups.com.
To post to this group, send email to envoy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/envoy-users/d655afa0-26c3-4820-a214-170e434d31d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Ragsdale

unread,
Jun 6, 2018, 10:51:14 AM6/6/18
to Jose Nino, envoy-users
Thanks Jose, 

This looks like what i am wanting to do!

-Jason

To unsubscribe from this group and stop receiving emails from it, send an email to envoy-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages