mirror of https://github.com/hashicorp/consul
Update enterprise banner
parent
b9249e25d8
commit
93341a6e52
|
@ -8,17 +8,19 @@ description: Learn how to limit the rate of requests to services in a Consul ser
|
|||
|
||||
This topic describes how to configure Consul to limit the request rate to services in the mesh.
|
||||
|
||||
<EnterpriseAlert> This feature is available in Consul Enterprise. </EnterpriseAlert>
|
||||
|
||||
## Introduction
|
||||
|
||||
Consul allows you to configure settings to limit the rate of HTTP requests a service receives from sources in the mesh. Limiting request rates is one strategy for building a resilient and highly-available network.
|
||||
|
||||
Consul applies rate limits per service instance. As an example, if you specify a rate limit of 100 requests per second (RPS) for a service and five instances of the service are available, the service accepts a total of 500 RPS, which equals 100 RPS per instance.
|
||||
|
||||
You can limit request rates for all traffic to a service, as well as set rate limits for specific URL paths on a service. When multiple rate limits are configured on a service, Consul applies the limit configured for the first matching path. As a result, the maximum RPS for a service is equal to the number of service instances deployed for a service multiplied by either the rate limit configured for that service or the rate limit for the path.
|
||||
You can limit request rates for all traffic to a service, as well as set rate limits for specific URL paths on a service. When multiple rate limits are configured on a service, Consul applies the limit configured for the first matching path. As a result, the maximum RPS for a service is equal to the number of service instances deployed for a service multiplied by either the rate limit configured for that service or the rate limit for the path.
|
||||
|
||||
## Requirements
|
||||
|
||||
Consul v1.17.0 or later
|
||||
Consul Enterprise v1.17.0 or later
|
||||
|
||||
## Limit request rates to a service on all paths
|
||||
|
||||
|
@ -28,7 +30,7 @@ Specify request rate limits in the service defaults configuration entry. Create
|
|||
<Tab heading="VMs" group="vms">
|
||||
|
||||
1. `RateLimits.InstanceLevel.RequestPerSecond`: Set an average number of requests per second that Consul should allow to the service. The number of requests may momentarily exceed this value up to the value specified in the `RequestsMaxBurst` parameter, but Consul temporarily lowers the speed of the transactions.
|
||||
1. `RateLimits.InstanceLevel.RequestsMaxBurst`: Set the maximum number of concurrent requests that Consul momentarily allows to the service. Consul blocks any additional requests over this limit.
|
||||
1. `RateLimits.InstanceLevel.RequestsMaxBurst`: Set the maximum number of concurrent requests that Consul momentarily allows to the service. Consul blocks any additional requests over this limit.
|
||||
|
||||
</Tab>
|
||||
<Tab heading="Kubernetes" group="k8s">
|
||||
|
@ -39,7 +41,7 @@ Specify request rate limits in the service defaults configuration entry. Create
|
|||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Refer to the [service defaults configuration entry reference](/consul/docs/connect/config-entries/service-defaults) for additional specifications and example configurations.
|
||||
Refer to the [service defaults configuration entry reference](/consul/docs/connect/config-entries/service-defaults) for additional specifications and example configurations.
|
||||
|
||||
## Specify request rate limits for specific paths
|
||||
|
||||
|
@ -48,7 +50,7 @@ Specify request rate limits in the service defaults configuration entry. Create
|
|||
<Tabs>
|
||||
<Tab heading="VMs" group="vms">
|
||||
|
||||
1. Add a `RateLimits.InstanceLevel.Routes` block to the configuration entry. The block contains the limits and matching criteria for determining which paths to set limits on.
|
||||
1. Add a `RateLimits.InstanceLevel.Routes` block to the configuration entry. The block contains the limits and matching criteria for determining which paths to set limits on.
|
||||
1. In the `Routes` block, configure one of the following match criteria to determine which path to set the limits on:
|
||||
- `PathExact`: Specifies the exact path to match on the request path.
|
||||
- `PathPrefix`: Specifies the path prefix to match on the request path.
|
||||
|
@ -60,8 +62,8 @@ Specify request rate limits in the service defaults configuration entry. Create
|
|||
</Tab>
|
||||
<Tab heading="Kubernetes" group="k8s">
|
||||
|
||||
1. Add a `spec.rateLimits.instanceLevel.routes` block to the configuration entry. The block contains the limits and matching criteria for determining which paths to set limits on.
|
||||
1. In the `routes` block, configure one of the following match criteria for enabling Consul to determine which path to set the limits on:
|
||||
1. Add a `spec.rateLimits.instanceLevel.routes` block to the configuration entry. The block contains the limits and matching criteria for determining which paths to set limits on.
|
||||
1. In the `routes` block, configure one of the following match criteria for enabling Consul to determine which path to set the limits on:
|
||||
- `pathExact`: Specifies the exact path to match on the request path. When using this field.
|
||||
- `pathPrefix`: Specifies the path prefix to match on the request path.
|
||||
- `pathRegex`: Specifies a regular expression to match on the request path.
|
||||
|
|
Loading…
Reference in New Issue