Skip to content

Per connection rate limiting of HTTP requests #15637

Closed

Description

@gokulnair

Currently, the HTTP local rate limiter's token bucket is shared across all workers, thus causing the rate limits to be applied per Envoy instance/process. This could potentially result in bad actors quickly exhausting limits on a given instance before legitimate users have had a fair chance and in extreme cases even lead to starvation. We need a way to allocate token buckets for each connection thereby allowing us to rate limit requests per connection.

One possible option would be to allow specifying a scope on the local rate limit configuration, along the lines of:

name: envoy.filters.http.local_ratelimit
typed_config:
  "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
  token_bucket:
    max_tokens: 10000
    tokens_per_fill: 1000
    fill_interval: 1s
    scope: per_connection/per_process etc ...

Following this, depending on the configured scope, we could maybe add an instance of the LocalRateLimit::LocalRateLimiterImpl to the connection object that each HTTP request belongs to, if there isn't one already (perhaps via callbacks_->connection().streamInfo().filterState()->setData?)

Activity

  1. added
    enhancement
    triage
    on Mar 24, 2021
  2. added
    help wanted
    and removed
    triage
    on Mar 24, 2021
  3. snowp commented on Mar 24, 2021

    @snowp
    Contributor

    Seems like a reasonable enhancement, marking help wanted.

    cc @rgs1

  4. mattklein123 commented on Mar 24, 2021

    @mattklein123
    Member

    +1 I would like to see this happen. I think doing it via filter data sounds like a good plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ratelimitenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions