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
real_page_modes.sh · 2.9 KB · 45 lines
1#!/bin/bash
2# A REAL page (app-notes /notes, rendered by site_view_render) under each object-execution mode.
3# One page view = one object execution (the HTML shell) + the browser's follow-up API calls
4# (list + schema), which are NOT object executions. Measures all three, per mode.
5# usage: real_page_modes.sh [PYTHON] -- needs oha, jq, curl. Everything lives in a temp dir.
6set -u
7REPO="$(cd "$(dirname "$0")/../../.." && pwd)"
8PY="${1:-$REPO/.venv-jit/bin/python}"
9run_mode() { # label, shell-requests, conns, env...
10 local label="$1" n="$2" c="$3"; shift 3
11 local tmp port base; tmp=$(mktemp -d); port=$((20000 + RANDOM % 20000)); base="http://127.0.0.1:$port"
12 mkdir -p "$tmp/objects" "$tmp/data"
13 (cd "$REPO" && DBBASIC_DATA_DIR="$tmp/data" "$PY" - "$tmp" <<'PYEOF'
14import sys
15from pathlib import Path
16import object_packages
17tmp = Path(sys.argv[1])
18for name in ("app-projects", "app-views", "app-notes"):
19 object_packages.install_package(name, root=Path("packages"), base_dir=tmp / "data", object_roots=[tmp / "objects"])
20PYEOF
21 ) || { echo "install failed"; return; }
22 (cd "$REPO" && exec env DBBASIC_OBJECTS_DIR="$tmp/objects" DBBASIC_DATA_DIR="$tmp/data" DBBASIC_ADMIN_TOKEN=t DBBASIC_ENABLE_SITE_ROUTES=true \
23 DBBASIC_MAX_CONCURRENT_EXECUTIONS=0 DBBASIC_MAX_CONCURRENT_REQUESTS=0 "$@" \
24 "$PY" -m uvicorn object_server:app --host 127.0.0.1 --port "$port" --log-level warning --no-access-log >"$tmp/log" 2>&1) &
25 echo $! >"$tmp/pid"
26 for _ in $(seq 40); do curl -sf "$base/health" >/dev/null && break; sleep 0.5; done
27 for i in $(seq 200); do curl -s -o /dev/null -X POST -H 'Authorization: Token t' -H 'Content-Type: application/json' \
28 -d "{\"content\":\"note $i about something moderately long to look real\"}" "$base/collections/notes/records"; done
29 local code; code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Authorization: Token t' "$base/notes")
30 [ "$code" = 200 ] || { echo "$label: /notes returned $code"; head -c 300 "$tmp/log"; kill "$(cat "$tmp/pid")"; return; }
31 one() { # name, n, conns, path
32 oha -n "$2" -c "$3" --no-tui --output-format json -H 'Authorization: Token t' "$base$4" |
33 jq -r --arg l "$label" --arg w "$1" --arg c "$3" \
34 '"\($l) \($w|.+" "|.[0:14]) c=\($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)"'
35 }
36 one "page shell" "$n" "$c" /notes
37 one "list API" 1000 "$c" "/collections/notes?limit=50"
38 one "schema API" 1000 "$c" /api/schema/notes
39 kill "$(cat "$tmp/pid")" 2>/dev/null; wait 2>/dev/null; rm -rf "$tmp"
40}
41for c in 1 8; do
42 run_mode "in-process " 1500 $c
43 run_mode "timeout=5 spawn " $((c == 1 ? 40 : 80)) $c DBBASIC_OBJECT_TIMEOUT_SECONDS=5
44 run_mode "timeout=5 + pool 4" 1500 $c DBBASIC_OBJECT_TIMEOUT_SECONDS=5 DBBASIC_WORKER_POOL_SIZE=4
45done