-
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.
Merge pull request #5773 from hashicorp/docs/rate-limiting-from-ip-ad…
…dresses-1.16 updated docs for rate limiting for IP addresses - 1.16
- Loading branch information
1 parent
b1d3ec0
commit 755bd95
Showing
7 changed files
with
448 additions
and
93 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
66 changes: 66 additions & 0 deletions
66
website/content/docs/agent/limits/usage/limit-request-rates-from-ips.mdx
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,66 @@ | ||
--- | ||
layout: docs | ||
page_title: Limit traffic rates for a source IP address | ||
description: Learn how to set read and request rate limits on RPC and gRPC traffic from all source IP addresses to a Consul resource. | ||
--- | ||
|
||
# Limit traffic rates from source IP addresses | ||
|
||
This topic describes how to configure RPC and gRPC traffic rate limits for source IP addresses. This enables you to specify a budget for read and write requests to prevent any single source IP from overwhelming the Consul server and negatively affecting the network. For information about setting global traffic rate limits, refer to [Set a global limit on traffic rates](/consul/docs/agent/limits/usage/set-glogal-traffic-rate-limits). For an overview of Consul's server rate limiting capabilities, refer to [Limit traffic rates overview](/consul/docs/agent/limits/overview). | ||
|
||
## Overview | ||
|
||
You can set limits on the rate of read and write requests from source IP addresses to specific resources, which mitigates the risks to Consul servers when consul clients send excessive requests to a specific resource type. Before configuring traffic rate limits, you should complete the initialization process to understand normal traffic loads in your network. Refer to [Initialize rate limit settings](/consul/docs/agent/limits/init-rate-limits) for additional information. | ||
|
||
Complete the following steps to configure traffic rate limits from a source IP address: | ||
|
||
1. Define rate limits in a control plan request limit configuration entry. You can set limits for different types of resources calls. | ||
|
||
1. Apply the configuration entry to enact the limits. | ||
|
||
You should also monitor read and write rate activity and make any necessary adjustments. Refer to [Monitor rate limit data](/consul/docs/agent/limits/usage/monitor-rate-limits) for additional information. | ||
|
||
## Define rate limits | ||
|
||
Create a control plane request limit configuration entry in the `default` partition. The configuration entry applies to all client requests targeting any partition. Refer to the [control plane request limit configuration entry](/consul/docs/connect/config-entries/control-plan-request-limit) reference documentation for details about the available configuration parameters. | ||
|
||
Specify the following parameters: | ||
|
||
- `kind`: This must be set to `control-plane-request-limit`. | ||
- `name`: Specify the name of the service that you want to limit read and write operations to. | ||
- `read_rate`: Specify overall number of read operations per second allowed from the service. | ||
- `write_rate`: Specify overall number of write operations per second allowed from the service. | ||
|
||
You can also configure limits on calls to the key-value store, ACL system, and Consul catalog. | ||
|
||
## Apply the configuration entry | ||
|
||
If your network is deployed to virtual machines, use the `consul config write` command and specify the control plane request limit configuration entry to apply the configuration. For Kubernetes-orchestrated networks, use the `kubectl apply` command. | ||
|
||
<Tabs> | ||
<Tab heading="HCL" group="hcl"> | ||
|
||
```shell-session | ||
$ consul config write control-plane-request-limit.hcl | ||
``` | ||
|
||
</Tab> | ||
<Tab heading="JSON" group="json"> | ||
|
||
```shell-session | ||
$ consul config write control-plane-request-limit.json | ||
``` | ||
|
||
</Tab> | ||
<Tab heading="Kubernetes" group="kubernetes"> | ||
|
||
```shell-session | ||
$ kubectl apply control-plane-request-limit.yaml | ||
``` | ||
|
||
</Tab> | ||
</Tabs> | ||
|
||
## Disable request rate limits | ||
|
||
Set the [limits.request_limits.mode](/consul/docs/agent/config/config-files#mode-1) in the agent configuration to `disabled` to allow services to exceed the specified read and write requests limits. The `disabled` mode applies to all request rate limits, even limits specifed in the [control plane request limits configuration entry](/consul/docs/connect/config-entries/control-plane-request-limits). Note that any other mode specified in the agent configuration only applies to global traffic rate limits. |
77 changes: 77 additions & 0 deletions
77
website/content/docs/agent/limits/usage/monitor-rate-limits.mdx
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,77 @@ | ||
--- | ||
layout: docs | ||
page_title: Monitor traffic rate limit data | ||
description: Learn about the metrics and logs you can use to monitor server rate limiting activity, include rate limits for read operations and writer operations | ||
--- | ||
|
||
# Monitor traffic rate limit data | ||
|
||
This topic describes Consul functionality that enables you to monitor read and write request operations taking place in your network. Use the functionality to help you understand normal workloads and set safe limits on the number of requests Consul client agents and services can make to Consul servers. | ||
|
||
## Access rate limit logs | ||
|
||
Consul prints a log line for each rate limit request. The log provides the necessary information for identifying the source of the request and the configured limit. The log provides the information necessary for identifying the source of the request and the configured limit. Consul prints the log `DEBUG` log level and can drop the log to avoid affecting the server health. Dropping a log line increments the `rpc.rate_limit.log_dropped` metric. | ||
|
||
The following example log shows that RPC request from `127.0.0.1:53562` to `KVS.Apply` exceeded the limit: | ||
|
||
```text | ||
2023-02-17T10:01:15.565-0500 [DEBUG] agent.server.rpc-rate-limit: RPC | ||
exceeded allowed rate limit: rpc=KVS.Apply source_addr=127.0.0.1:53562 | ||
limit_type=global/write limit_enforced=false | ||
``` | ||
|
||
Refer to [`log_file`](/consul/docs/agent/config/config-files#log_file) for information about where to retrieve log files. | ||
|
||
## Review rate limit metrics | ||
|
||
Consul captures the following metrics associated with rate limits: | ||
|
||
- Type of limit | ||
- Operation | ||
- Rate limit mode | ||
|
||
Call the `/agent/metrics` API endpoint to view the metrics associated with rate limits. Refer to [View Metrics](/consul/api-docs/agent#view-metrics) for API usage information. In the following example, Consul dropped a call to the consul service because it exceeded the limit by one call: | ||
|
||
```shell-session | ||
$ curl http://127.0.0.1:8500/v1/agent/metrics | ||
{ | ||
. . . | ||
"Counters": [ | ||
{ | ||
"Name": "consul.rpc.rate_limit.exceeded", | ||
"Count": 1, | ||
"Sum": 1, | ||
"Min": 1, | ||
"Max": 1, | ||
"Mean": 1, | ||
"Stddev": 0, | ||
"Labels": { | ||
"service": "consul" | ||
} | ||
}, | ||
{ | ||
"Name": "consul.rpc.rate_limit.log_dropped", | ||
"Count": 1, | ||
"Sum": 1, | ||
"Min": 1, | ||
"Max": 1, | ||
"Mean": 1, | ||
"Stddev": 0, | ||
"Labels": {} | ||
} | ||
], | ||
. . . | ||
} | ||
``` | ||
|
||
Refer to [Telemetry](/consul/docs/telemetry) for additional 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 stale 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
Oops, something went wrong.