# Redis Proxy¶

Redis Proxy configuration overview.

## config.filter.network.redis_proxy.v2.RedisProxy¶

[config.filter.network.redis_proxy.v2.RedisProxy proto]

{
"stat_prefix": "...",
"cluster": "...",
"settings": "{...}",
"latency_in_micros": "...",
"prefix_routes": "{...}"
}

stat_prefix
(string, REQUIRED) The prefix to use when emitting statistics.
cluster

(string) Name of cluster from cluster manager. See the configuration section of the architecture overview for recommendations on configuring the backing cluster.

Attention

This field is deprecated. Use a catch-all cluster instead.

settings
(config.filter.network.redis_proxy.v2.RedisProxy.ConnPoolSettings, REQUIRED) Network settings for the connection pool to the upstream clusters.
latency_in_micros
(bool) Indicates that latency stat should be computed in microseconds. By default it is computed in milliseconds.
prefix_routes

(config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes) List of unique prefixes used to separate keys from different workloads to different clusters. Envoy will always favor the longest match first in case of overlap. A catch-all cluster can be used to forward commands when there is no match. Time complexity of the lookups are in O(min(longest key prefix, key length)).

Example:

prefix_routes:
routes:
- prefix: "ab"
cluster: "cluster_a"
- prefix: "abc"
cluster: "cluster_b"


When using the above routes, the following prefixes would be sent to:

• ‘get abc:users’ would retrive the key ‘abc:users’ from cluster_b.
• ‘get ab:users’ would retrive the key ‘ab:users’ from cluster_a.
• ‘get z:users’ would return a NoUpstreamHost error. A catch-all cluster would have retrieved the key from that cluster instead.

See the configuration section of the architecture overview for recommendations on configuring the backing clusters.

## config.filter.network.redis_proxy.v2.RedisProxy.ConnPoolSettings¶

[config.filter.network.redis_proxy.v2.RedisProxy.ConnPoolSettings proto]

Redis connection pool settings.

{
"op_timeout": "{...}",
"enable_hashtagging": "...",
"enable_redirection": "...",
"max_buffer_size_before_flush": "...",
"buffer_flush_timeout": "{...}"
}

op_timeout
(Duration) Per-operation timeout in milliseconds. The timer starts when the first command of a pipeline is written to the backend connection. Each response received from Redis resets the timer since it signifies that the next command is being processed by the backend. The only exception to this behavior is when a connection to a backend is not yet established. In that case, the connect timeout on the cluster will govern the timeout until the connection is ready.
enable_hashtagging

(bool) Use hash tagging on every redis key to guarantee that keys with the same hash tag will be forwarded to the same upstream. The hash key used for determining the upstream in a consistent hash ring configuration will be computed from the hash tagged key instead of the whole key. The algorithm used to compute the hash tag is identical to the redis-cluster implementation.

Examples:

• ‘{user1000}.following’ and ‘{user1000}.followers’ will be sent to the same upstream
• ‘{user1000}.following’ and ‘{user1001}.following’ might be sent to the same upstream
enable_redirection
(bool) Accept moved and ask redirection errors from upstream redis servers, and retry commands to the specified target server. The target server does not need to be known to the cluster manager. If the command cannot be redirected, then the original error is passed downstream unchanged. By default, this support is not enabled.
max_buffer_size_before_flush
(uint32) Maximum size of encoded request buffer before flush is triggered and encoded requests are sent upstream. If this is unset, the buffer flushes whenever it receives data and performs no batching. This feature makes it possible for multiple clients to send requests to Envoy and have them batched- for example if one is running several worker processes, each with its own Redis connection. There is no benefit to using this with a single downstream process. Recommended size (if enabled) is 1024 bytes.
buffer_flush_timeout
(Duration) The encoded request buffer is flushed N milliseconds after the first request has been encoded, unless the buffer size has already exceeded max_buffer_size_before_flush. If max_buffer_size_before_flush is not set, this flush timer is not used. Otherwise, the timer should be set according to the number of clients, overall request rate and desired maximum latency for a single command. For example, if there are many requests being batched together at a high rate, the buffer will likely be filled before the timer fires. Alternatively, if the request rate is lower the buffer will not be filled as often before the timer fires. If max_buffer_size_before_flush is set, but buffer_flush_timeout is not, the latter defaults to 3ms.

## config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes¶

[config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes proto]

{
"routes": [],
"case_insensitive": "...",
"catch_all_cluster": "..."
}

routes
(config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes.Route) List of prefix routes.
case_insensitive
(bool) Indicates that prefix matching should be case insensitive.
catch_all_cluster
(string) Optional catch-all route to forward commands that doesn’t match any of the routes. The catch-all route becomes required when no routes are specified.

## config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes.Route¶

[config.filter.network.redis_proxy.v2.RedisProxy.PrefixRoutes.Route proto]

{
"prefix": "...",
"remove_prefix": "...",
"cluster": "..."
}

prefix
(string, REQUIRED) String prefix that must match the beginning of the keys. Envoy will always favor the longest match.
remove_prefix
(bool) Indicates if the prefix needs to be removed from the key when forwarded.
cluster
(string, REQUIRED) Upstream cluster to forward the command to.