-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of Docs/rate limiting 1.15 into release/1.15.x (#16384)
* backport of commit 5042d8d * backport of commit c6b83c4 * backport of commit b12a569 * backport of commit 16d81dd * backport of commit 48ff8f7 * backport of commit e677bc7 * backport of commit 74924a2 * backport of commit fe9bca7 --------- Co-authored-by: trujillo-adam <[email protected]>
- Loading branch information
1 parent
7cd0eff
commit 926d480
Showing
8 changed files
with
212 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
layout: docs | ||
page_title: Limit Traffic Rates Overview | ||
description: Rate limiting is a set of Consul server agent configurations that you can use to mitigate the risks to Consul servers when clients send excessive requests to Consul resources. | ||
|
||
--- | ||
|
||
# Limit Traffic Rates Overview | ||
This topic provides overview information about the traffic rates limits you can configure for Consul servers. | ||
|
||
## Introduction | ||
You can configure global RPC rate limits to mitigate the risks to Consul servers when clients send excessive read or write requests to Consul resources. A read request is defined as any request that does not modify Consul internal state. A write request is defined as any request that modifies Consul internal state. Read and write requests are limited separately. | ||
|
||
## Rate limit modes | ||
You can set one of the following modes, which determine how Consul servers react when the request limits are exceeded. | ||
|
||
- **Enforcing mode**: In this mode, the rate limiter denies requests to a server beyond a configurable rate. Consul generates metrics and logs to help operators understand their Consul load and configure limits accordingly. | ||
- **Permissive mode**: The rate limiter allows requests if the limits are reached and produces metrics and logs to help operators understand their Consul load and configure limits accordingly. This mode is intended to help you configure limits and debug specific issues. | ||
- **Disabled mode**: Disables the rate limiter. All requests are allowed and no logs or metrics are produced. This is the default mode. | ||
|
||
Refer to [`rate_limits`](/consul/docs/agent/config/config-files#request_limits) for additional configuration information. | ||
|
||
## Request denials | ||
When an HTTP request is denied for rate limiting reason, Consul returns one of the following errors: | ||
|
||
- **429 Resource Exhausted**: Indicates that a server is not able to perform the request but that another server could potentially fulfill it. This error is most common on stale reads because any server may fulfill state read requests. To resolve this type of error, we recommend immediately retrying the request to another server. If the request came from a Consul client agent, the agent automatically retries the request up to the limit set in the [`rpc_hold_timeout`](/consul/docs/agent/config/config-files#rpc_hold_timeout) configuration . | ||
|
||
- **503 Service Unavailable**: Indicates that server is unable to perform the request and that no other server can fulfill the request, either. This usually occurs on consistent reads or for writes. In this case we recommend retrying according to an exponential backoff schedule. If the request came from a Consul client agent, the agent automatically retries the request according to the [`rpc_hold_timeout`](/consul/docs/agent/config/config-files#rpc_hold_timeout) configuration. | ||
|
||
Refer to [Rate limit reached on the server](/consul/docs/troubleshoot/common-errors#rate-limit-reached-on-the-server) for additional information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
layout: docs | ||
page_title: Initialize Rate Limit Settings | ||
description: Learn how to determins regular and peak loads in your network so that you can set the initial global rate limit configurations. | ||
--- | ||
|
||
# Initialize Rate Limit Settings | ||
|
||
In order to set limits for traffic, you must first understand regular and peak loads in your network. We recommend completing the following steps to benchmark request rates in your environment so that you can implement limits appropriate for your applications. | ||
|
||
1. Specify a global rate limit with arbitrary values in the agent configuration file based on the following conditions: | ||
|
||
- Environment where Consul servers are running | ||
- Number of servers and the projected load | ||
- Existing metrics expressing requests per second | ||
|
||
1. Set the `mode` to `permissive`. In the following example, Consul agents are allowed up to 1000 reads and 500 writes per second: | ||
|
||
```hcl | ||
request_limits { | ||
mode = "permissive" | ||
read_rate = 1000.0 | ||
write_rate =500.0 | ||
} | ||
``` | ||
|
||
1. Observe the logs and metrics for your application's typical cycle, such as a 24 hour period. Refer to [`log_file`](/consul/docs/agent/config/config-files#log_file) for information about where to retrieve logs. Call the [`/agent/metrics`](/consul/api-docs/agent#view-metrics) HTTP API endpoint and check the data for the following metrics: | ||
|
||
- `rpc.rate_limit.exceeded.read` | ||
- `rpc.rate_limit.exceeded.write` | ||
|
||
1. If the limits are not reached, set the `mode` configuration to `enforcing`. Otherwise adjust and iterate limits. |
Oops, something went wrong.