skipper: github.com/zalando/skipper/filters/ratelimit Index | Files

package ratelimit

import "github.com/zalando/skipper/filters/ratelimit"

Package ratelimit provides filters to control the rate limitter settings on the route level.

For detailed documentation of the ratelimit, see https://godoc.org/github.com/zalando/skipper/ratelimit.

Index

Package Files

ratelimit.go

Constants

const RetryAfterKey = "#ratelimitretryafter"

RetryAfterKey is used as key in the context state bag

const RouteSettingsKey = "#ratelimitsettings"

RouteSettingsKey is used as key in the context state bag

func NewClientRatelimit Uses

func NewClientRatelimit() filters.Spec

NewClientRatelimit creates a instance based client rate limit. If you have 5 instances with 20 req/s, then it would allow 100 req/s to the backend from the same client. A third argument can be used to set which HTTP header of the request should be used to find the same user. Third argument defaults to XForwardedForLookuper, meaning X-Forwarded-For Header.

Example:

backendHealthcheck: Path("/healthcheck")
-> clientRatelimit(20, "1m")
-> "https://foo.backend.net";

Example rate limit per Authorization Header:

login: Path("/login")
-> clientRatelimit(3, "1m", "Authorization")
-> "https://login.backend.net";

func NewClusterClientRateLimit Uses

func NewClusterClientRateLimit() filters.Spec

NewClusterClientRatelimit creates a rate limiting that is aware of the other instances. The value given here should be the combined rate of all instances. The ratelimit group parameter can be used to select the same ratelimit group across one or more routes.

Example:

backendHealthcheck: Path("/login")
-> clusterClientRatelimit("groupB", 20, "1h")
-> "https://foo.backend.net";

The above example would limit access to "/login" if, the client did more than 20 requests within the last hour to this route across all running skippers in the cluster. A single client can be detected by different data from the http request and defaults to client IP or X-Forwarded-For header, if exists. The optional third parameter chooses the HTTP header to choose a client is counted as the same.

Example:

backendHealthcheck: Path("/login")
-> clusterClientRatelimit("groupC", 20, "1h", "Authorization")
-> "https://foo.backend.net";

func NewClusterRateLimit Uses

func NewClusterRateLimit() filters.Spec

NewClusterRatelimit creates a rate limiting that is aware of the other instances. The value given here should be the combined rate of all instances. The ratelimit group parameter can be used to select the same ratelimit group across one or more routes.

Example:

backendHealthcheck: Path("/healthcheck")
-> clusterRatelimit("groupA", 200, "1m")
-> "https://foo.backend.net";

func NewDisableRatelimit Uses

func NewDisableRatelimit() filters.Spec

NewDisableRatelimit disables rate limiting

Example:

backendHealthcheck: Path("/healthcheck")
-> disableRatelimit()
-> "https://foo.backend.net";

func NewLocalRatelimit Uses

func NewLocalRatelimit() filters.Spec

NewLocalRatelimit is *DEPRECATED*, use NewClientRatelimit, instead

func NewRatelimit Uses

func NewRatelimit() filters.Spec

NewRatelimit creates a service rate limiting, that is only aware of itself. If you have 5 instances with 20 req/s, then it would at max allow 100 req/s to the backend.

Example:

backendHealthcheck: Path("/healthcheck")
-> ratelimit(20, "1s")
-> "https://foo.backend.net";

Package ratelimit imports 6 packages (graph) and is imported by 4 packages. Updated 2019-06-04. Refresh now. Tools for package owners.