Skip to content

Commit 70687f5

Browse files
committed
Add adaptive concurrency parameter for queue-worker
Allow users to disable the new adaptive concurrency feature for the queue-worker. Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent fa68ddd commit 70687f5

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

chart/openfaas/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ See [values.yaml](./values.yaml) for detailed configuration.
581581
| `jetstreamQueueWorker.consumer.pullMaxMessages` | PullMaxMessages limits the number of messages to be buffered per consumer. Leave empty to use optimized default for the selected queue mode | `` |
582582
| `jetstreamQueueWorker.logs.debug` | Log debug messages | `false` |
583583
| `jetstreamQueueWorker.logs.format` | Set the log format, supports `console` or `json` | `console` |
584+
| `jetstreamQueueWorker.adaptiveConcurrency` | Enable adaptive concurrency limiting for functions. This setting only takes effect when `jetstreamQueueWorker.mode` is set to `function`. | `true` |
584585
| `nats.channel` | The name of the NATS Streaming channel or NATS JetStream stream to use for asynchronous function invocations | `faas-request` |
585586
| `nats.external.clusterName` | The name of the externally-managed NATS Streaming server | `""` |
586587
| `nats.external.enabled` | Whether to use an externally-managed NATS Streaming server | `false` |

chart/openfaas/templates/queueworker-dep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ spec:
9999
- name: ack_wait
100100
value: "{{ .Values.queueWorker.ackWait }}"
101101

102+
- name: limiter_enabled
103+
value: "{{ .Values.jetstreamQueueWorker.adaptiveConcurrency }}"
102104
- name: upstream_timeout
103105
value: "{{ .Values.gateway.upstreamTimeout }}"
104106
- name: "max_retry_attempts"

chart/openfaas/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ faasnetes:
222222
jetstreamQueueWorker:
223223
image: ghcr.io/openfaasltd/jetstream-queue-worker:0.4.12
224224
mode: "static"
225+
# Enable adaptive concurrency limiting for functions.
226+
# This setting only takes effect when jetstreamQueueWorker.mode is set to "function".
227+
adaptiveConcurrency: true
225228
consumer:
226229
inactiveThreshold: "30s"
227230

chart/queue-worker/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ nats:
3838
name: slow-fns
3939
consumer:
4040
durableName: slow-fns-workers
41-
upstreamTimeout: 15m
41+
upstreamTimeout: 15m
4242
```
4343
4444
Then pass `-f ./values-slow-fns.yaml` to the `helm upgrade --install` command instead of the `--set` flags.
@@ -101,6 +101,7 @@ helm upgrade --install \
101101
| `queueName` | Name of the queue if you want it to be different to the stream name | `""` - when empty, defaults to `nats.stream.name` |
102102
| `mode` | Queue operation mode: `static` (OpenFaaS Standard) or `function` (requires OpenFaaS for Enterprises) | `static` |
103103
| `maxInflight` | Control the concurrent invocations | `1` |
104+
| `adaptiveConcurrency` | Enable adaptive concurrency limiting for functions. This setting only takes effect when `mode` is set to `function`. | `true` |
104105
| `queuePartitions` | Number of queue partitions | `1` |
105106
| `partition` | Queue partition number this queue should subscribe to | `0` |
106107
| `consumer.inactiveThreshold` | If a function is inactive (has no invocations) for longer than this threshold its consumer will be removed to save resources | `30s` |

chart/queue-worker/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ spec:
8282
- name: "ack_wait"
8383
value: "{{ .Values.nats.consumer.ackWait }}"
8484

85+
- name: "limiter_enabled"
86+
value: "{{ .Values.adaptiveConcurrency }}"
8587
- name: "upstream_timeout"
8688
value: "{{ .Values.upstreamTimeout }}"
8789
- name: "max_retry_attempts"

chart/queue-worker/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ replicas: 1
1313
queueName: ""
1414
mode: static
1515
maxInflight: 1
16+
# Enable adaptive concurrency limiting for functions.
17+
# This setting only takes effect when mode is set to "function".
18+
adaptiveConcurrency: true
1619

1720
queuePartitions: 1
1821
partition: 0

0 commit comments

Comments
 (0)