Skip to content

Commit 383859a

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 29b2b12 commit 383859a

File tree

6 files changed

+41
-29
lines changed

6 files changed

+41
-29
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 based on 429 response. 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: adaptive_concurrency
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: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
## For OpenFaaS Standard and OpenFaaS for Enterprises users, see:
22
# https://github.com/openfaas/faas-netes/blob/master/chart/openfaas/values-pro.yaml
33

4-
functionNamespace: openfaas-fn # Default namespace for functions
4+
functionNamespace: openfaas-fn # Default namespace for functions
55

66
# Contact us via https://www.openfaas.com/support to purchase a license
77
openfaasPro: false
88

99
# Contact us via https://www.openfaas.com/support to purchase a license
1010
oem: false
1111

12-
httpProbe: true # Setting to true will use HTTP for readiness and liveness probe on the OpenFaaS core components
12+
httpProbe: true # Setting to true will use HTTP for readiness and liveness probe on the OpenFaaS core components
1313

1414
# set clusterRole: true for:
1515
## CPU/RAM metrics in OpenFaaS API
1616
## Multiple-namespace support
1717
clusterRole: false
1818

19-
createCRDs: true # Creates the Function/Profile CRDs, set to false if you are managing CRDs in another way
19+
createCRDs: true # Creates the Function/Profile CRDs, set to false if you are managing CRDs in another way
2020

2121
# basic_auth must never be disabled, and is required for all OpenFaaS components.
2222
# There is no good reason to disable this, and it causes a severe security risk.
2323
# The configuration option remains for backwards-compatibility.
24-
basic_auth: true # Authentication for core components, always set to true
24+
basic_auth: true # Authentication for core components, always set to true
2525

26-
rbac: true # Kubernetes RBAC, no good reason to disable this
27-
generateBasicAuth: true # Set to false if applying credentials separately from the chart, otherwise set to true
26+
rbac: true # Kubernetes RBAC, no good reason to disable this
27+
generateBasicAuth: true # Set to false if applying credentials separately from the chart, otherwise set to true
2828

2929
# Define a securityContext for the containers deployed by this helm chart.
3030
securityContext: {}
3131

3232
exposeServices: true
33-
serviceType: NodePort # serviceType for OpenFaaS gateway
34-
async: true # No known reason to disable this, kept for legacy reasons
33+
serviceType: NodePort # serviceType for OpenFaaS gateway
34+
async: true # No known reason to disable this, kept for legacy reasons
3535

3636
# create pod security policies for OpenFaaS control plane
3737
# https://kubernetes.io/docs/concepts/policy/pod-security-policy/
@@ -45,22 +45,22 @@ openfaasImagePullPolicy: "IfNotPresent"
4545
#
4646
# kubectl create secret generic -n openfaas ca-bundle --from-file=ca.crt=./ca.crt
4747
#
48-
caBundleSecretName: "" # Name of the secret containing the CA bundle for the OpenFaaS gateway
48+
caBundleSecretName: "" # Name of the secret containing the CA bundle for the OpenFaaS gateway
4949

5050
functions:
51-
imagePullPolicy: "Always" # Image pull policy for deployed functions, for OpenFaaS Pro you can also set: IfNotPresent and Never.
52-
httpProbe: true # Setting to true will use HTTP for readiness and liveness probe on function pods
53-
setNonRootUser: false # It's recommended to set this to "true", but test your images before committing to it
51+
imagePullPolicy: "Always" # Image pull policy for deployed functions, for OpenFaaS Pro you can also set: IfNotPresent and Never.
52+
httpProbe: true # Setting to true will use HTTP for readiness and liveness probe on function pods
53+
setNonRootUser: false # It's recommended to set this to "true", but test your images before committing to it
5454
readinessProbe:
5555
initialDelaySeconds: 0
56-
timeoutSeconds: 1 # Tuned-in to run checks early and quickly to support fast cold-start from zero replicas
57-
periodSeconds: 2 # Reduce to 1 for a faster cold-start, increase higher for lower-CPU usage
56+
timeoutSeconds: 1 # Tuned-in to run checks early and quickly to support fast cold-start from zero replicas
57+
periodSeconds: 2 # Reduce to 1 for a faster cold-start, increase higher for lower-CPU usage
5858
successThreshold: 1
5959
failureThreshold: 3
6060
livenessProbe:
6161
initialDelaySeconds: 0
6262
timeoutSeconds: 1
63-
periodSeconds: 2 # Reduce to 1 for a faster cold-start, increase higher for lower-CPU usage
63+
periodSeconds: 2 # Reduce to 1 for a faster cold-start, increase higher for lower-CPU usage
6464
failureThreshold: 3
6565

6666
gatewayPro:
@@ -71,7 +71,7 @@ gateway:
7171
image: ghcr.io/openfaas/gateway:0.27.13
7272
readTimeout: "1m05s"
7373
writeTimeout: "1m05s"
74-
upstreamTimeout: "1m" # Must be smaller than read/write_timeout
74+
upstreamTimeout: "1m" # Must be smaller than read/write_timeout
7575
replicas: 1
7676
scaleFromZero: true
7777
# change the port when creating multiple releases in the same baremetal cluster
@@ -222,6 +222,9 @@ faasnetes:
222222
jetstreamQueueWorker:
223223
image: ghcr.io/openfaasltd/jetstream-queue-worker:0.4.7
224224
mode: "static"
225+
# Enable adaptive concurrency limiting for functions based on 429 response.
226+
# This setting only takes effect when jetstreamQueueWorker.mode is set to "function".
227+
adaptiveConcurrency: true
225228
consumer:
226229
inactiveThreshold: "30s"
227230

@@ -474,20 +477,20 @@ ingress:
474477

475478
# Used to create Ingress record (should be used with exposeServices: false).
476479
hosts:
477-
- host: gateway.openfaas.local # Replace with gateway.example.com if public-facing
478-
http:
479-
paths:
480-
- path: /
481-
pathType: Prefix
482-
backend:
483-
service:
484-
name: gateway
485-
port:
486-
number: 8080
480+
- host: gateway.openfaas.local # Replace with gateway.example.com if public-facing
481+
http:
482+
paths:
483+
- path: /
484+
pathType: Prefix
485+
backend:
486+
service:
487+
name: gateway
488+
port:
489+
number: 8080
487490

488491
# annotations:
489-
# This annotation is deprecated, use IngressClass in the spec instead
490-
# kubernetes.io/ingress.class: nginx
492+
# This annotation is deprecated, use IngressClass in the spec instead
493+
# kubernetes.io/ingress.class: nginx
491494
tls:
492495
# Secrets must be manually created in the namespace.
493496

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 based on 429 response. 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: "adaptive_concurrency"
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 based on 429 response.
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)