Skip to main content

Distributed Rate Limit

Enable distributed rate limiting in Traefik Hub.


Introduction

Traefik Hub uses Redis (Remote Dictionary Server) to store rate limit information across all Traefik Hub agents.

Connection parameters to your Redis server are attached to your Traefik Hub deployment.

The following Redis modes are supported:

info

For more information about Redis, we recommend the official Redis documentation.


Available Configuration Options

The table below lists the configuration options in Traefik Hub to connect to Redis and store rate limit information.

ValueDescriptionRequired
endpointsEndpoints of the Redis instances to connect to (example: redis.traefik-hub.svc.cluster.local:6379)Yes
usernameThe username Traefik Hub will use to connect to RedisNo
passwordThe password Traefik Hub will use to connect to RedisNo
databaseThe database Traefik Hub will use to sore information (default: 0)No
clusterEnable Redis ClusterNo
tls.caBundleCustom CA bundleNo
tls.certTLS certificateNo
tls.keyTLS keyNo
tls.insecureSkipVerifyAllow skipping the TLS verificationNo
sentinel.masterSetName of the set of main nodes to use for main selection. Required when using Sentinel.No
sentinel.usernameUsername to use for sentinel authentication (can be different from username)No
sentinel.passwordPassword to use for sentinel authentication (can be different from password)No
info

If you use Redis in single instance mode or Redis Sentinel, you can configure the database field.
This value won't be taken into account if you use Redis Cluster (only database 0 is available).

In this case, a warning is displayed, and the value is ignored.

Adjust Traefik Hub's Configuration

First, save the default Traefik Hub configuration to a values.yaml file.

helm show values traefik/traefik-hub > values.yaml

Second, adjust the values.yaml file by adding the configuration for distributed rate limiting to the additionalArguments part.

additionalArguments:
# Redis single instance mode
- --hub.rateLimit.redis.endpoints=redis-headless.traefik-hub.svc.cluster.local:6379
- --hub.rateLimit.redis.password=$(PASSWORD)
additionalEnvVars:
# Redis in single instance mode
- name: PASSWORD
valueFrom:
secretKeyRef:
name: redis
key: redis-password

service:
type: LoadBalancer
All configuration settings

Please see the configuration options above for an overview about all possible values.

Deploy Your Custom Configuration

Once the configuration is adjusted, use Helm to (re)deploy the Traefik Hub agent with the new values to enable distributed rate limiting.

CLI
helm upgrade --install --namespace traefik-hub traefik-hub traefik/traefik-hub \
--values values.yaml