Configure Redis Cluster
Our Gateway, Dashboard and Pump all support integration with Redis Cluster. Redis Cluster allows data to be automatically sharded across multiple Redis Nodes. To setup Redis Cluster correctly, we recommend you read the Redis Cluster Tutorial. You must use the same settings across the Gateway, Dashboard and Pump.Redis Cluster operates differently from a Redis setup where one instance serves as the primary and others as replicas.
Supported Versions
- Tyk 5.3 supports Redis 6.2.x, 7.0.x, and 7.2.x
- Tyk 5.2.x and earlier supports Redis 6.0.x and Redis 6.2.x only.
Redis Cluster and Tyk Gateway
To configure the Tyk Gateway to work with your Redis Cluster, setenable_cluster
to true
and list your servers under addrs
in your tyk.conf
file.
addrs
is new in v2.9.3, and replaces hosts
which is now deprecated.use_ssl
to true
.
Redis Cluster and Tyk Dashboard
redis_addrs
is new in v1.9.3 for the Dashboard, and replaces hosts
which is now deprecated.tyk_analytics.conf
file:
Redis Cluster and Tyk Pump
To configure the Tyk Pump to work with your Redis Cluster, setenable_cluster
to true
and list your servers under addrs
in your pump.conf
file.
addrs
is new in v2.9.3, and replaces hosts
which is now deprecated.Redis Cluster with Docker
For Redis clustered mode to work with Tyk using Docker and Amazon ElastiCache, follow these two steps:- Make sure cluster mode is enabled
TYK_GW_STORAGE_ENABLECLUSTER
to true
.
- Add all cluster endpoints to the config
These are suggested settings, please verify them by load testing.
Redis Cluster with TLS
If you are using TLS for Redis connections, setuse_ssl
to true
for Gateway and Pump, and redis_use_ssl
to true
for the dashboard.
Redis supports SSL/TLS encryption from version 6 as an optional feature, enhancing the security of data in transit. Similarly, Amazon ElastiCache offers encryption in transit and at rest. To configure TLS or mTLS connections between an application and Redis, consider the following settings in Tyk’s configuration files:
-
storage.use_ssl
: Set this to true to enable TLS encryption for the connection. -
storage.ssl_insecure_skip_verify
: A flag that, when set to true, instructs the application not to verify the Redis server’s TLS certificate. This is not recommended for production due to the risk ofman-in-the-middle
attacks.
-
storage.ca_file
: Path to the Certificate Authority (CA) file for verifying the Redis server’s certificate. -
storage.cert_file
andstorage.key_file
: Paths to your application’s certificate and private key files, necessary for mTLS where both parties verify each other’s identity. -
storage.max_version
andstorage.min_version
: Define the acceptable range of TLS versions, enhancing security by restricting connections to secure TLS protocols (1.2 or 1.3).
- Enable TLS: By setting
"use_ssl": true
, you encrypt the connection. - Skip Certificate Verification: Setting
"ssl_insecure_skip_verify": true
bypasses the server’s certificate verification, suitable only for non-production environments.
- Ensure
use_ssl
is set totrue
. - Set
ssl_insecure_skip_verify
tofalse
to enforce certificate verification against the CA specified inca_file
. - Specify the path to the CA file in
ca_file
for server certificate verification. - Adjust
min_version
andmax_version
to secure TLS versions, ideally 1.2 and 1.3.
- Follow the steps for a secure TLS connection.
- Provide paths for
cert_file
andkey_file
for your application’s TLS certificate and private key, enabling Redis server to verify your application’s identity.
Troubleshooting Redis Cluster
If you find that Tyk components fail to initialise when using Redis clustering, for example the application does not start and the last log file entry shows a message such asUsing clustered mode
, try setting the environment variable REDIGOCLUSTER_SHARDCOUNT
to 128
on all hosts which connect to the Redis Cluster i.e. Gateway, Dashboard, Pump, MDCB. E.g.
REDIGOCLUSTER_SHARDCOUNT=128
If setting to 128
does not resolve the issue, try 256
instead.
Configure Redis Sentinel
From v2.9.3 Redis Sentinel is supported. Similar to Redis Cluster, our Gateway, Dashboard and Pump all support integration with Redis Sentinel. To configure Tyk to work with Redis Sentinel, list your servers underaddrs
and set the master name in your Gateway, Dashboard, Pump and MDCB config. Unlike Redis Cluster, enable_cluster
should not be set. Indicative config snippets as follows:
Supported Versions
- Tyk 5.3 supports Redis 6.2.x, 7.0.x, and 7.2.x
- Tyk 5.2.x and earlier supports Redis 6.0.x and Redis 6.2.x only.
Redis Sentinel and Gateway
Redis Sentinel and Dashboard
Redis Sentinel and Pump
When using Bitnami charts to install Redis Sentinel in k8s, a Redis service is exposed, which means that standard Redis config is required instead of the above setup, i.e. a single server in
addrs
and master_name
is not required.Support for Redis Sentinel AUTH
To support the use of Redis Sentinel AUTH (introduced in Redis 5.0.1) we have added the following global config settings in Tyk v3.0.2:- In the Tyk Gateway config file -
sentinel_password
- In the Tyk Dashboard config file -
redis_sentinel_password
- In the Tyk Pump config file -
sentinel_password
- In the Tyk Identity Broker config file -
SentinelPassword
- In the Tyk Synk config file -
sentinel_password
Configure Redis TLS Encryption
Redis supports SSL/TLS encryption from version 6 as an optional feature, enhancing the security of data in transit. To configure TLS or mTLS connections between an application and Redis, consider the following settings in Tyk’s configuration files:-
storage.use_ssl
: Set this to true to enable TLS encryption for the connection. -
storage.ssl_insecure_skip_verify
: A flag that, when set to true, instructs the application not to verify the Redis server’s TLS certificate. This is not recommended for production due to the risk ofman-in-the-middle
attacks.
-
storage.ca_file
: Path to the Certificate Authority (CA) file for verifying the Redis server’s certificate. -
storage.cert_file
andstorage.key_file
: Paths to your application’s certificate and private key files, necessary for mTLS where both parties verify each other’s identity. -
storage.max_version
andstorage.min_version
: Define the acceptable range of TLS versions, enhancing security by restricting connections to secure TLS protocols (1.2 or 1.3).
- Enable TLS: By setting
"use_ssl": true
, you encrypt the connection. - Skip Certificate Verification: Setting
"ssl_insecure_skip_verify": true
bypasses the server’s certificate verification, suitable only for non-production environments.
- Ensure
use_ssl
is set totrue
. - Set
ssl_insecure_skip_verify
tofalse
to enforce certificate verification against the CA specified inca_file
. - Specify the path to the CA file in
ca_file
for server certificate verification. - Adjust
min_version
andmax_version
to secure TLS versions, ideally 1.2 and 1.3.
- Follow the steps for a secure TLS connection.
- Provide paths for
cert_file
andkey_file
for your application’s TLS certificate and private key, enabling Redis server to verify your application’s identity.