Skip to content

Commit

Permalink
docs: Add redis-streams streamLength documentation (#1094)
Browse files Browse the repository at this point in the history
Co-authored-by: jmadajczak <[email protected]>
  • Loading branch information
jkbmdk and jmadajczak authored Mar 28, 2023
1 parent 50fde80 commit 13def06
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 9 deletions.
38 changes: 35 additions & 3 deletions content/docs/2.11/scalers/redis-cluster-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Redis 5.0 introduced [Redis Streams](https://redis.io/topics/streams-intro) whic

One of its features includes [`Consumer Groups`](https://redis.io/topics/streams-intro#consumer-groups), that allows a group of clients to co-operate consuming a different portion of the same stream of messages.

This specification describes the `redis-cluster-streams` trigger that scales based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream and supports Redis Cluster topology.
There are two ways to configure `redis-streams` trigger:
1. Based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream
2. Based on the *Stream Length* (see [`XLEN`](https://redis.io/commands/xlen))


```yaml
Expand All @@ -25,8 +27,9 @@ triggers:
usernameFromEnv: REDIS_USERNAME # optional (can also use authenticationRef)
passwordFromEnv: REDIS_PASSWORD # optional (can also use authenticationRef)
stream: my-stream # Required - name of the Redis Stream
consumerGroup: my-consumer-group # Required - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # Required - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
consumerGroup: my-consumer-group # optional - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # optional - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
streamLength: "50" # optional - Redis stream length, alternative to pendingEntriesCount scaler trigger
enableTLS: "false" # optional
unsafeSsl: "false" # optional
# Alternatively, you can use existing environment variables to read configuration from:
Expand Down Expand Up @@ -55,7 +58,9 @@ triggers:

- `stream` - Name of the Redis Stream.
- `consumerGroup` - Name of the Consumer group associated with Redis Stream.
> Setting the `consumerGroup` causes the scaler to operate on `pendingEntriesCount`. Lack of `consumerGroup` will cause the scaler to be based on `streamLength`
- `pendingEntriesCount` - Threshold for the number of `Pending Entries List`. This is the average target value to scale the workload. (Default: `5`, Optional)
- `streamLength` - Threshold for stream length, alternative average target value to scale workload. (Default: `5`, Optional)
- `enableTLS` - Allow a connection to Redis using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)

Expand Down Expand Up @@ -150,3 +155,30 @@ spec:
authenticationRef:
name: keda-redis-stream-triggerauth # name of the TriggerAuthentication resource
```

#### Using `streamLength`

To scale based on redis stream `XLEN` don't set `consumerGroup`. Example:

```yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-streams-scaledobject
namespace: default
spec:
scaleTargetRef:
name: redis-streams-consumer
pollingInterval: 20
cooldownPeriod: 200
maxReplicaCount: 10
minReplicaCount: 1
triggers:
- type: redis-cluster-streams
metadata:
addressesFromEnv: REDIS_ADDRESSES
usernameFromEnv: REDIS_USERNAME # name of the environment variable in the Deployment
passwordFromEnv: REDIS_PASSWORD # name of the environment variable in the Deployment
stream: my-stream
streamLength: "50"
```
39 changes: 36 additions & 3 deletions content/docs/2.11/scalers/redis-sentinel-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Redis 5.0 introduced [Redis Streams](https://redis.io/topics/streams-intro) whic

One of its features includes [`Consumer Groups`](https://redis.io/topics/streams-intro#consumer-groups), that allows a group of clients to co-operate consuming a different portion of the same stream of messages.

This specification describes the `redis-sentinel-streams` trigger that scales based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream and supports a Redis Sentinel setup.
There are two ways to configure `redis-streams` trigger:
1. Based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream
2. Based on the *Stream Length* (see [`XLEN`](https://redis.io/commands/xlen))


```yaml
Expand All @@ -25,8 +27,9 @@ triggers:
usernameFromEnv: REDIS_USERNAME # optional (can also use authenticationRef)
passwordFromEnv: REDIS_PASSWORD # optional (can also use authenticationRef)
stream: my-stream # Required - name of the Redis Stream
consumerGroup: my-consumer-group # Required - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # Required - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
consumerGroup: my-consumer-group # optional - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # optional - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
streamLength: "50" # optional - Redis stream length, alternative to pendingEntriesCount scaler trigger
enableTLS: "false" # optional
unsafeSsl: "false" # optional
# Alternatively, you can use existing environment variables to read configuration from:
Expand Down Expand Up @@ -59,7 +62,9 @@ triggers:
- `sentinelMaster` - The name of the master in Sentinel to get the Redis server address for.
- `stream` - Name of the Redis Stream.
- `consumerGroup` - Name of the Consumer group associated with Redis Stream.
> Setting the `consumerGroup` causes the scaler to operate on `pendingEntriesCount`. Lack of `consumerGroup` will cause the scaler to be based on `streamLength`
- `pendingEntriesCount` - Threshold for the number of `Pending Entries List`. This is the average target value to scale the workload. (Default: `5`, Optional)
- `streamLength` - Threshold for stream length, alternative average target value to scale workload. (Default: `5`, Optional)
- `enableTLS` - Allow a connection to Redis using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)

Expand Down Expand Up @@ -157,3 +162,31 @@ spec:
authenticationRef:
name: keda-redis-stream-triggerauth # name of the TriggerAuthentication resource
```

#### Using `streamLength`

To scale based on redis stream `XLEN` don't set `consumerGroup`. Example:

```yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-streams-scaledobject
namespace: default
spec:
scaleTargetRef:
name: redis-streams-consumer
pollingInterval: 20
cooldownPeriod: 200
maxReplicaCount: 10
minReplicaCount: 1
triggers:
- type: redis-sentinel-streams
metadata:
addressesFromEnv: REDIS_ADDRESSES
usernameFromEnv: REDIS_USERNAME # name of the environment variable in the Deployment
passwordFromEnv: REDIS_PASSWORD # name of the environment variable in the Deployment
stream: my-stream
streamLength: "50"
sentinelMaster: "mymaster"
```
38 changes: 35 additions & 3 deletions content/docs/2.11/scalers/redis-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Redis 5.0 introduced [Redis Streams](https://redis.io/topics/streams-intro) whic

One of its features includes [`Consumer Groups`](https://redis.io/topics/streams-intro#consumer-groups), that allows a group of clients to co-operate consuming a different portion of the same stream of messages.

This specification describes the `redis-streams` trigger that scales based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream.
There are two ways to configure `redis-streams` trigger:
1. Based on the *Pending Entries List* (see [`XPENDING`](https://redis.io/commands/xpending)) for a specific Consumer Group of a Redis Stream
2. Based on the *Stream Length* (see [`XLEN`](https://redis.io/commands/xlen))


```yaml
Expand All @@ -25,8 +27,9 @@ triggers:
usernameFromEnv: REDIS_USERNAME # optional (can also use authenticationRef)
passwordFromEnv: REDIS_PASSWORD # optional (can also use authenticationRef)
stream: my-stream # Required - name of the Redis Stream
consumerGroup: my-consumer-group # Required - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # Required - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
consumerGroup: my-consumer-group # optional - name of consumer group associated with Redis Stream
pendingEntriesCount: "10" # optional - number of entries in the Pending Entries List for the specified consumer group in the Redis Stream
streamLength: "50" # optional - Redis stream length, alternative to pendingEntriesCount scaler trigger
enableTLS: "false" # optional
unsafeSsl: "false" # optional
databaseIndex: "0" # optional
Expand Down Expand Up @@ -56,7 +59,9 @@ triggers:

- `stream` - Name of the Redis Stream.
- `consumerGroup` - Name of the Consumer group associated with Redis Stream.
> Setting the `consumerGroup` causes the scaler to operate on `pendingEntriesCount`. Lack of `consumerGroup` will cause the scaler to be based on `streamLength`
- `pendingEntriesCount` - Threshold for the number of `Pending Entries List`. This is the average target value to scale the workload. (Default: `5`, Optional)
- `streamLength` - Threshold for stream length, alternative average target value to scale workload. (Default: `5`, Optional)
- `databaseIndex` - The Redis database index. Defaults to `0` if not specified.
- `enableTLS` - Allow a connection to Redis using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)
Expand Down Expand Up @@ -152,3 +157,30 @@ spec:
authenticationRef:
name: keda-redis-stream-triggerauth # name of the TriggerAuthentication resource
```

#### Using `streamLength`

To scale based on redis stream `XLEN` don't set `consumerGroup`. Example:

```yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-streams-scaledobject
namespace: default
spec:
scaleTargetRef:
name: redis-streams-consumer
pollingInterval: 20
cooldownPeriod: 200
maxReplicaCount: 10
minReplicaCount: 1
triggers:
- type: redis-streams
metadata:
addressFromEnv: REDIS_HOST
usernameFromEnv: REDIS_USERNAME # name of the environment variable in the Deployment
passwordFromEnv: REDIS_PASSWORD # name of the environment variable in the Deployment
stream: my-stream
streamLength: "50"
```

0 comments on commit 13def06

Please sign in to comment.