Set a global limit on traffic rates

This topic describes how to configure rate limits for RPC and gRPC traffic to the Consul server.

Introduction

Rate limits apply to each Consul server separately and limit the number of read requests or write requests to the server on the RPC and internal gRPC endpoints.

Because all requests coming to a Consul server eventually perform an RPC or an internal gRPC request, global rate limits apply to Consul’s user interfaces, such as the HTTP API interface, the CLI, and the external gRPC endpoint for services in the service mesh.

Refer to Initialize Rate Limit Settings for additional information about right-sizing your gRPC request configurations.

Set a global rate limit for a Consul server

Configure the following settings in your Consul server configuration to limit the RPC and gRPC traffic rates.

In the following example, the Consul server is configured to prevent more than 500 read and 200 write RPC calls:

Consul server agent

Consul server agent

  1. limits = {
  2. rate_limit = {
  3. mode = "enforcing"
  4. read_rate = 500
  5. write_rate = 200
  6. }
  7. }
  1. {
  2. "limits" : {
  3. "rate_limit" : {
  4. "mode" : "enforcing",
  5. "read_rate" : 500,
  6. "write_rate" : 200
  7. }
  8. }
  9. }

Monitor request rate traffic

You should continue to mmonitor request traffic to ensure that request rates remain within the threshold you defined. Refer to Monitor traffic rate limit data for instructions about checking metrics and log entries, as well as troubleshooting informaiton.

Disable request rate limits

Set the limits.request_limits.mode to disabled to allow services to exceed the specified read and write requests limits, even limits specifed in the control plane request limits configuration entry. Note that any other mode specified in the agent configuration only applies to global traffic rate limits.