Skip to content

Auto Suspend and Wake-up

Use --idle-timeout when creating a runtime to suspend it after a period without observed activity. The value is in seconds. This example includes a --publish rule because HTTP ingress traffic can wake a suspended runtime when traffic returns.

Create the smallest useful example with a 30 second idle timeout:

Terminal window
runta run \
--name idle-demo \
--cpus 1 \
--memory 512 \
--publish 8080/https \
--idle-timeout 30

Start a simple HTTP server in the runtime:

Terminal window
runta exec idle-demo -- sh -lc 'nohup python3 -m http.server 8080 >/tmp/http.log 2>&1 &'

Find the runtime ID and make one request:

Terminal window
runta ps -a
curl https://<runtime-id>.runta.sh

After the runtime has received no inbound HTTP traffic for the configured idle timeout, the coordinator will suspend it on a later idle scan. The default scan interval is 60 seconds, so a 30 second timeout can take roughly 90 seconds or more to show up as suspended:

Terminal window
sleep 100
runta inspect idle-demo

Send another request to wake the runtime. The wakeup path restores the runtime and then proxies the original request:

Terminal window
curl https://<runtime-id>.runta.sh