Jennifer Academy

Code: Dynamic workloads: autoscaling Resque workers with Jennifer

Code for "Dynamic workloads: autoscaling Resque workers with Jennifer"

Every program behind the slides, for Jennifer 0.27.0. Run everything from this folder. The decks come from the registry: jvc install reads deck.toml and copies them into vendor/.

Setup

jvc install          # @deckyard/docker 0.2.0, proxmox 0.2.0, virtualbox 0.1.0, vmware 0.3.0
./setup.sh           # network academy-scale-net, Redis on 127.0.0.1:16390,
                     # the Docker API on 127.0.0.1:12375 (socat), the worker image

setup.sh runs these three containers and one pull:

docker network create --label academy-scale=1 academy-scale-net
docker run -d --name academy-scale-redis --label academy-scale=1 --network academy-scale-net -p 127.0.0.1:16390:6379 redis:7
docker run -d --name academy-scale-sock --label academy-scale=1 -p 127.0.0.1:12375:2375 -v /var/run/docker.sock:/var/run/docker.sock alpine/socat tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock
docker pull ghcr.io/jennifer-language/jennifer:0.26.0

Anyone on this machine who can reach 127.0.0.1:12375 is root on it while the socat container runs. ./teardown.sh removes every academy-scale-* container and the network.

Programs

FileShows (slides)Run
controller.jthe autoscaler: measuring, the rule, up fast and down slowly, limits, retries, reconciliation, logging (4 to 7, 16 to 18, 20 to 23)BACKEND=docker REDIS_PORT=16390 DOCKER_URL=tcp://127.0.0.1:12375 WORKER_DIR=$PWD/worker jennifer run controller.j
backend.jthe Backend enum and the match dispatch for all four decks (10 to 15)imported by controller.j
worker/worker.jthe worker: drains on SIGTERM, exits after 30 s idle (8, 9)runs in the containers, mounted at /app
enqueue.ja burst of jobs, each stamped with its enqueue time (5, 22)REDIS_PORT=16390 jennifer run enqueue.j --count 60 --queue thumbs
errors.jwhat each deck throws (19)start both stand-ins, then VBOXMANAGE=$PWD/standin/vboxmanage.sh jennifer run errors.j
standin/pve.ja stand-in for the Proxmox VE API calls the controller makes (14)jennifer run standin/pve.j --listen 127.0.0.1:18006
standin/vcenter.ja stand-in for the vCenter REST calls (15)jennifer run standin/vcenter.j --listen 127.0.0.1:18443
standin/vboxmanage.sha stand-in VBoxManage, machines kept as files in standin/vbox-state/ (13)used through VBOXMANAGE
run.shthe full Docker run: burst, controller killed and replaced, Docker API lost for 7 s, second burst (12, 16, 20 to 23)./run.sh, then read events.log, runA.log, runB.log, decisions.log
run_orphan.shthe controller stays dead; workers exit idle, a new controller reaps them (17)./run_orphan.sh
run_vm.shthe same controller against a stand-in; the jobs are deleted by hand, no worker runs (13 to 15)WARM=0 ./run_vm.sh proxmox, WARM=0 ./run_vm.sh vbox, WARM=1 ./run_vm.sh vmware

The controller reads its settings from the environment: BACKEND (docker, proxmox, vbox, vmware), REDIS_PORT, WARM (stopped clones to keep), STOP_IDLE_AFTER (seconds; stop once nothing runs or waits, for the demos), and per backend DOCKER_URL and WORKER_DIR; PVE_URL, PVE_TOKEN_ID, PVE_SECRET; VBOXMANAGE; VCENTER_URL, VCENTER_USER, VCENTER_PASSWORD. The scripts set placeholder values that only the stand-ins accept. redis-cli SET autoscale:hold 1 freezes the pool.

The runs write their logs and standin/vbox-state/ into this folder; delete them afterwards.

FileSize
LICENSE899 Braw
README.md3.5 KiBraw
backend.j7.3 KiBraw
controller.j12.4 KiBraw
deck.toml497 Braw
enqueue.j823 Braw
errors.j2.4 KiBraw
run.sh1.3 KiBraw
run_orphan.sh893 Braw
run_vm.sh1.4 KiBraw
setup.sh691 Braw
standin/pve.j4.7 KiBraw
standin/vboxmanage.sh2.0 KiBraw
standin/vcenter.j3.8 KiBraw
teardown.sh227 Braw
worker/worker.j1.6 KiBraw