|
| 1 | +# Expanded timeouts |
| 2 | + |
| 3 | +In this tutorial you'll learn how to expand the default timeouts of OpenFaaS to run your functions for longer. |
| 4 | + |
| 5 | +## Part 1 - the core components |
| 6 | + |
| 7 | +When installing with Kubernetes, you need to set various timeout values for the distributed components of the OpenFaaS control plane. |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +We will set: |
| 12 | + |
| 13 | +* `gateway.upstreamTimeout` |
| 14 | +* `gateway.writeTimeout` |
| 15 | +* `gateway.readTimeout` |
| 16 | +* `faasnetes.writeTimeout` |
| 17 | +* `faasnetes.readTimeout` |
| 18 | + |
| 19 | +For async tasks, also set: |
| 20 | + |
| 21 | +* `queueWorker.ackWait` |
| 22 | + |
| 23 | +All timeouts are to be specified in Golang duration format i.e. `1m` or `12s`, or `1m12s`. |
| 24 | + |
| 25 | +```bash |
| 26 | +export TIMEOUT=2m |
| 27 | + |
| 28 | +arkade install openfaas \ |
| 29 | + --set gateway.upstreamTimeout=$TIMEOUT \ |
| 30 | + --set gateway.writeTimeout=$TIMEOUT \ |
| 31 | + --set gateway.readTimeout=$TIMEOUT \ |
| 32 | + --set faasnetes.writeTimeout=$TIMEOUT \ |
| 33 | + --set faasnetes.readTimeout=$TIMEOUT \ |
| 34 | + --set queueWorker.ackWait=$TIMEOUT |
| 35 | +``` |
| 36 | + |
| 37 | +One installed with these settings, you can invoke functions for up to `2m` synchronously and asynchronously. |
| 38 | + |
| 39 | +## Part 2 - Your function's timeout |
| 40 | + |
| 41 | +Now that OpenFaaS will allow a longer timeout, configure your function. |
| 42 | + |
| 43 | +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) |
| 44 | + |
| 45 | +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) |
| 46 | + |
| 47 | +## Further support |
| 48 | + |
| 49 | +Check the [troubleshooting guide](https://docs.openfaas.com/deployment/troubleshooting/) and work through the exercises above. |
| 50 | + |
| 51 | +For Docker Swarm, simply edit `docker-compose.yml` and redeploy the stack. |
0 commit comments