ratelimit

package
v0.10.286 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: Apache-2.0, MIT Imports: 6 Imported by: 4

Documentation

Overview

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

Constants

View Source
const RetryAfterKey = "#ratelimitretryafter"

RetryAfterKey is used as key in the context state bag

View Source
const RouteSettingsKey = "#ratelimitsettings"

RouteSettingsKey is used as key in the context state bag

Variables

This section is empty.

Functions

func NewClientRatelimit added in v0.10.168

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 added in v0.10.153

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 added in v0.10.113

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

func NewDisableRatelimit() filters.Spec

NewDisableRatelimit disables rate limiting

Example:

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

func NewLocalRatelimit

func NewLocalRatelimit() filters.Spec

NewLocalRatelimit is *DEPRECATED*, use NewClientRatelimit, instead

func NewRatelimit

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";

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL