Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 41 minutes ago History
object_modes.sh · 2.4 KB · 32 lines
1#!/bin/bash
2# How much does an HTTP call to an object cost under each execution mode?
3# in-process (default) | DBBASIC_OBJECT_TIMEOUT_SECONDS=5 (spawn per call, the documented production setting)
4# | timeout + DBBASIC_WORKER_POOL_SIZE=N (warm pool)
5# usage: object_modes.sh [PYTHON] -- needs oha. Uses a throwaway data dir.
6set -u
7PY="${1:-$(cd "$(dirname "$0")/../../.." && pwd)/.venv-jit/bin/python}"
8REPO="$(cd "$(dirname "$0")/../../.." && pwd)"
9run_mode() { # label, N-requests, conns, env...
10 local label="$1" n="$2" c="$3"; shift 3
11 local tmp port; tmp=$(mktemp -d); port=$((20000 + RANDOM % 20000))
12 mkdir -p "$tmp/objects" "$tmp/data"
13 cat > "$tmp/objects/bench_hello.py" <<'PYEOF'
14def GET(request):
15 return {"status": "ok", "hello": "world"}
16PYEOF
17 (cd "$REPO" && exec env DBBASIC_OBJECTS_DIR="$tmp/objects" DBBASIC_DATA_DIR="$tmp/data" DBBASIC_ADMIN_TOKEN=t DBBASIC_MAX_CONCURRENT_EXECUTIONS=0 "$@" \
18 "$PY" -m uvicorn object_server:app --host 127.0.0.1 --port "$port" --log-level warning --no-access-log >"$tmp/log" 2>&1) &
19 echo $! >"$tmp/pid"
20 for _ in $(seq 40); do curl -sf "http://127.0.0.1:$port/health" >/dev/null && break; sleep 0.5; done
21 local code; code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Authorization: Token t' "http://127.0.0.1:$port/objects/bench_hello")
22 if [ "$code" != 200 ]; then echo "$label: object call returned $code"; head -c 300 "$tmp/log"; kill "$(cat "$tmp/pid")"; return; fi
23 oha -n "$n" -c "$c" --no-tui --output-format json -H 'Authorization: Token t' "http://127.0.0.1:$port/objects/bench_hello" |
24 jq -r --arg l "$label" --arg c "$c" '"\($l) conns=\($c) \(.summary.requestsPerSec|floor) req/s p50 \(.latencyPercentiles.p50*1000|.*10|floor/10) ms p99 \(.latencyPercentiles.p99*1000|.*10|floor/10) ms ok=\(.statusCodeDistribution["200"]//0)/\(.summary.total? // "?")"'
25 kill "$(cat "$tmp/pid")" 2>/dev/null; wait 2>/dev/null; rm -rf "$tmp"
26}
27run_mode "in-process (default) " 3000 1
28run_mode "in-process (default) " 3000 8
29run_mode "timeout=5, spawn per call " 40 1 DBBASIC_OBJECT_TIMEOUT_SECONDS=5
30run_mode "timeout=5, spawn per call " 80 8 DBBASIC_OBJECT_TIMEOUT_SECONDS=5
31run_mode "timeout=5 + warm pool of 4 " 3000 1 DBBASIC_OBJECT_TIMEOUT_SECONDS=5 DBBASIC_WORKER_POOL_SIZE=4
32run_mode "timeout=5 + warm pool of 4 " 3000 8 DBBASIC_OBJECT_TIMEOUT_SECONDS=5 DBBASIC_WORKER_POOL_SIZE=4