Running apps
Processes & scaling
Run more instances, bigger instances, and more kinds of process, with zero-downtime rollouts.
Scale out and up#
Each instance is its own Firecracker microVM. On a cluster, instances are spread across your servers. ps:scale with no counts shows the current scale.
Process types#
To run more than one kind of process, add a Procfile to your repo:
Only web runs at first. Scale the others to start them:
Only web gets HTTP traffic. For a Procfile somewhere else: jokku builder:set myapp procfile Procfile.prod.
Instance sizes#
Each instance starts with 1 vCPU and 256 MiB of memory. Set sizes per process type:
resource:report shows the size each process type runs at, a compose file's cpus and mem_limit included, and jokku top shows it on its Apps view. Memory takes 512, 512m or 1g; plain numbers are megabytes. In a microVM, the limit is also the reservation: memory is never overcommitted, so an instance only starts on a server with that much free. vCPUs may be shared.
Start, stop and restart#
Crashed instances restart on their own. The policy is on-failure:10 by default:
Sleep when idle#
An app few people visit doesn't need its microVMs running all day. Give it a sleep-after, and once it goes that long without a request, its instances stop:
The next request wakes it. The proxy holds the request while the instances boot where they were, then passes it on, so the visitor just waits a moment: about as long as the app takes to start listening, a second or two for a small one. Requests that arrive meanwhile wait with it, for up to a minute.
- The whole app sleeps and wakes together, every process type. Its volumes stay where they are.
- Its memory still counts against its servers, so it always has room to wake.
- Only requests through the proxy keep it awake, and only they wake it. Anything that requests it counts, a monitoring check included. Apps calling it at
myapp.internaldon't count and can't wake it, so leave apps that others call awake. - A request that stays open, such as a websocket, keeps it awake.
- With a login in front, only requests that get past the login wake it: the login page is served without it.
ps:reportsays whether it's asleep, andps:startwakes it. Deploys, restarts and config changes wake it too.- Databases don't sleep.
Zero-downtime deploys#
Every deploy, scale or settings change rolls out the same way:
- Jokku boots the new release's instances to the target scale.
- It waits for them to pass checks: the process stays up and, for
web, accepts TCP connections on$PORT. - It switches traffic to the new instances.
- After the
wait-to-retireperiod, 60 seconds by default, it stops the old ones.
If checks fail, the deploy fails, the new instances are torn down, the old release keeps serving, and you see the failing instance's output.
Only what changes restarts. A process type the new release would run exactly as before (same image, command, environment, port, size and volumes) is left running. Scaling worker leaves web alone, and the deploy says so:
Releases#
Each deploy and config change creates a numbered, immutable release: the build, process types, config vars and sizes.
releases:rollback is planned.