You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/async.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ The queue-worker uses a single timeout for how long it will spend processing a m
120
120
121
121
By default there is one queue-worker replica deployed which is set up to run a single task of up to 30 seconds in duration.
122
122
123
-
You can increase the parallelism by setting the queue worker's "max_inflight" option to a value greater than one. This will cause the queue-worker to concurrently receive up to max_inflight many messages and simultaneously invoke their corresponding functions. Should you wish to restrict concurrency for certain functions, please make use of [multiple queues](#Multiple-queues) and separate these functions accordingly.
123
+
You can increase the parallelism by setting the queue worker's "max_inflight" option to a value greater than one. This will cause the queue-worker to concurrently receive up to max_inflight many messages and simultaneously invoke their corresponding functions. Should you wish to restrict concurrency for certain functions, please make use of [dedicated queues](#dedicated-queues) and separate these functions accordingly.
124
124
125
125
Additional replicas of the queue-worker can also be added, such that the total async concurrency for a cluster will be: max_inflight * (number of queue-worker replicas).
Copy file name to clipboardExpand all lines: docs/reference/tls-openfaas.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,13 @@ $ arkade install ingress-nginx
36
36
37
37
See also: [ingress-nginx installation](https://kubernetes.github.io/ingress-nginx/deploy/)
38
38
39
+
40
+
#### Timeouts for synchronous invocations
41
+
42
+
Despite configuring OpenFaaS and your functions for [extended timeouts](/tutorials/expanded-timeouts.md), you may find that your Ingress Controller, Istio Gateway, or Cloud Load Balancer implements its own timeouts on connections. If you think you have everything configured correctly for OpenFaaS, but see a timeout at a very specific number such as 30s or 60s, then check the timeouts on your Ingress Controller or Load Balancer.
43
+
44
+
For Ingress Nginx, to extend a synchronous invocation beyond one minute, add the `nginx.ingress.kubernetes.io/proxy-read-timeout` annotation to your Ingress resource. This annotation is specified in seconds - for example, to extend the timeout to 30 minutes, use `nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"`.
45
+
39
46
### Install cert-manager
40
47
41
48
cert-manager is a Kubernetes operator maintained by the Cloud Native Computing Foundation (CNCF) which automates TLS certificate management.
@@ -125,13 +132,15 @@ You can now configure the OpenFaaS gateway to use TLS by setting the following H
Copy file name to clipboardExpand all lines: docs/tutorials/expanded-timeouts.md
+44-23Lines changed: 44 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,61 +1,80 @@
1
-
# Expanded timeouts
1
+
# Extended timeouts
2
2
3
-
In this tutorial you'll learn how to expand the default timeouts of OpenFaaS to run your functions for longer.
3
+
In this tutorial you'll learn how to extend the default timeout so that your functions can run for longer.
4
+
5
+
One of the most common support questions we get is about timeouts. Users often ask why their function is timing out after 30s or 60s.
4
6
5
7
!!! note "It's not us, it's you."
6
8
7
-
We would know if there was a regression in OpenFaaS that meant timeouts stopped working as expected.
9
+
We know it's frustrating, but we would know if there was a regression in OpenFaaS that meant timeouts stopped working as expected.
10
+
11
+
## Why do functions timeout?
12
+
13
+
OpenFaaS functions can run for as long as necessary, some users have reported running executions for 48 hours or longer. The longest executions should be [run asynchronously](), so that the HTTP caller is not blocked waiting for a result.
14
+
15
+
Functions timeout due to one of the following:
8
16
9
-
Typically, every time users reach out to us for help with timeouts it's due to a misconfiguration between one of the components in their stack, or a problem with the function itself.
17
+
* Using the default timeout set in the Helm chart in values.yaml for the gateway
18
+
* Using the default timeout in the Function's stack.yaml, or not setting all of the timeout environment variables
19
+
* An error in the function's code - a blocking I/O operation, a deadlock, or a crash/premature exit of the process
20
+
* Using an Ingress Controller or Load Balancer which has a low default timeout
10
21
11
-
You will need to use our sample functions, which we know work, before reaching out for support.
22
+
Once you've followed all the instructions in this guide, make sure you've ruled out your Ingress Controller or Load Balancer before reaching out for help. For instance, [Ingress Nginx has a timeout set of 60 seconds](#load-balancers-ingress-and-service-meshes).
23
+
24
+
You can use the [following GitHub repository](https://github.com/alexellis/go-long) with three sample functions made with Go, Python and Node to confirm the issue isn't in your own function or code.
12
25
13
26
## Part 1 - the core components
14
27
15
-
When running OpenFaaS on Kubernetes, you need to set various timeout values for the distributed components of the OpenFaaS control plane. These options are explained in the [helm chart README](https://github.com/openfaas/faas-netes/tree/master/chart/openfaas). The easiest option for new users is to set them all to the same value.
28
+
When running OpenFaaS on Kubernetes, it is possible to override the timeout on various components of the OpenFaaS gateway, however it is only usually necessary to set the timeout on the gateway itself.
29
+
30
+
You can find the various options in the [helm chart README](https://github.com/openfaas/faas-netes/tree/master/chart/openfaas).
16
31
17
-
> For faasd users, you'll need to edit the equivalent fields in your `docker-compose.yaml` file, see the eBook [Serverless For Everyone Else](https://store.openfaas.com/l/serverless-for-everyone-else).
32
+
For faasd users, you'll need to edit the equivalent fields in your `docker-compose.yaml` file, see the eBook [Serverless For Everyone Else](https://store.openfaas.com/l/serverless-for-everyone-else).
18
33
19
-
We will set:
34
+
We need to set the following in the Helm chart's values.yaml file for the OpenFaaS chart:
20
35
21
36
*`gateway.upstreamTimeout`
22
37
*`gateway.writeTimeout`
23
38
*`gateway.readTimeout`
24
39
25
40
All timeouts are to be specified in Golang duration format i.e. `1m` or `60s`, or `1m30s`.
26
41
27
-
The `HARD_TIMEOUT` is set 1-2s higher than the `TIMEOUT` value since one needs to happen before the other.
42
+
If using Helm or Argo CD, then add the following to your values.yaml file:
43
+
44
+
```yaml
45
+
gateway:
46
+
writeTimeout: 5m1s
47
+
readTimeout: 5m1s
48
+
upstreamTimeout: 5m
49
+
```
50
+
51
+
Note that `upstreamTimeout` must always be lower than `writeTimeout` and `readTimeout`, to allow the gateway to handle the request before the HTTP server cancels the request.
52
+
53
+
If using arkade, you can run the following:
28
54
29
55
```bash
30
56
export TIMEOUT=5m
31
-
exportHARD_TIMEOUT=5m2s
57
+
export SERVER_TIMEOUT=5m2s
32
58
33
59
arkade install openfaas \
34
60
--set gateway.upstreamTimeout=$TIMEOUT \
35
-
--set gateway.writeTimeout=$HARD_TIMEOUT \
36
-
--set gateway.readTimeout=$HARD_TIMEOUT
61
+
--set gateway.writeTimeout=$SERVER_TIMEOUT \
62
+
--set gateway.readTimeout=$SERVER_TIMEOUT
37
63
```
38
64
39
65
Once installed with these settings, you can invoke functions for up to `5m` synchronously and asynchronously.
40
66
41
-
If using Helm or Argo CD, then add the following to your values.yaml file instead:
42
-
43
-
```yaml
44
-
gateway:
45
-
writeTimeout: 5m1s
46
-
readTimeout: 5m1s
47
-
upstreamTimeout: 5m
48
-
```
49
-
50
67
## Part 2 - Your function's timeout
51
68
52
69
Now that OpenFaaS will allow a longer timeout, configure your function.
53
70
71
+
OpenFaaS functions usually embed a component called the watchdog, which is responsible for implementing timeouts in a consistent way across different languages. Most templates use the newer of-watchdog, but a few may still be using the classic watchdog for compatibility reasons.
72
+
54
73
For the newer templates based upon HTTP which use the of-watchdog, adapt the following sample: [go-long: Golang function that runs for a long time](https://github.com/alexellis/go-long)
55
74
56
75
For classic templates using the classic watchdog, you can follow the workshop: [Lab 8 - Advanced feature - Timeouts](https://github.com/openfaas/workshop/blob/master/lab8.md)
57
76
58
-
If you're unsure which template you're using, check the source code of the Dockerfile in the `templates` folder when you build your functions.
77
+
If you're unsure which template you're using, check the source code of the Dockerfile in the `templates` folder when you build your functions, you should see a `FROM` line at the top of the file that will specify one or the other.
59
78
60
79
## Load Balancers, Ingress, and service meshes
61
80
@@ -67,7 +86,9 @@ AWS EKS is configured to use an [Elastic Load Balancer (ELB)](https://aws.amazon
67
86
68
87
Google Cloud's various Load Balancer options have their [own configuration options too](https://cloud.google.com/load-balancing/docs/https).
69
88
70
-
Finally, if you need to invoke a function for longer than one of your infrastructure components allows, then you should use an [asynchronous invocation](/reference/async), which in OpenFaaS Standard can also be retried if it fails, and scaled out to massive concurrency.
89
+
For Ingress Nginx, set the `nginx.ingress.kubernetes.io/proxy-read-timeout` annotation to extend the timeout. This annotation is specified in seconds - for example, to extend the timeout to 30 minutes, use `nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"`.
90
+
91
+
Finally, if you need to invoke a function for longer than one of your infrastructure components allows, then you should use an [asynchronous invocation](/reference/async). Asynchronous function invocations bypass these components because they are eventually invoked from the queue-worker, not the Internet. The queue-worker for OpenFaaS Standard will also retry invocations if required.
0 commit comments