Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
099af21
Add opt-in scale comparison framework
jsturtevant Nov 20, 2026
d51c187
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
3415cad
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
f5c90b7
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
df04859
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
e7a39e8
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
8cfae5f
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
113b7ba
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
82393a5
fixup! Add opt-in scale comparison framework
jsturtevant Nov 21, 2026
aff9ece
fixup! Add opt-in scale comparison framework
jsturtevant Nov 24, 2026
1b824d7
fixup! Add opt-in scale comparison framework
jsturtevant Nov 24, 2026
e628f66
Compare the Node.js workload with stock Knative
jsturtevant Nov 25, 2026
e9fbd47
fixup! Add opt-in scale comparison framework
jsturtevant Nov 25, 2026
600f273
fixup! Add opt-in scale comparison framework
jsturtevant Nov 25, 2026
3d7de81
Measure verified scale-from-zero startup latency
jsturtevant Nov 25, 2026
49e8c73
fixup! Measure verified scale-from-zero startup latency
jsturtevant Nov 25, 2026
bfedd34
fixup! Measure verified scale-from-zero startup latency
jsturtevant Nov 25, 2026
49deb15
fixup! Measure verified scale-from-zero startup latency
jsturtevant Nov 25, 2026
dd88317
fixup! Measure verified scale-from-zero startup latency
jsturtevant Nov 25, 2026
f7b9874
fixup! Add opt-in scale comparison framework
jsturtevant Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exe-suffix := if os() == "windows" { ".exe" } else { "" }
# Kind release installed by `just install-kind` in every workflow (CI, release
# gates, Copilot); providers/kind/templates/kind-config.yaml pins its node image.
kind-version := "v0.33.0"
oha-version := "1.17.0"

default:
@just --list
Expand Down Expand Up @@ -205,6 +206,20 @@ install-mm:
mkdir -p "{{repo-root}}/build/tools"; \
tar --extract --gzip --file "$dir/mm.tar.gz" --directory "{{repo-root}}/build/tools" mm

# Install the pinned oha load generator used by opt-in scale tests.
install-oha:
if [ -x "{{repo-root}}/build/tools/oha" ] && \
[ "$("{{repo-root}}/build/tools/oha" --version)" = "oha {{oha-version}}" ]; then exit 0; fi; \
[ "$(uname -sm)" = "Linux x86_64" ] || { echo "install-oha supports linux-amd64 only" >&2; exit 1; }; \
mkdir -p "{{repo-root}}/build/tools"; \
temporary=$(mktemp "{{repo-root}}/build/tools/oha.XXXXXXXX"); \
trap 'rm -f "$temporary"' EXIT; \
curl --fail --silent --show-error --location --output "$temporary" \
"https://github.com/hatoo/oha/releases/download/v{{oha-version}}/oha-linux-amd64"; \
echo "85c6eb98066b8c8bd513b2dd96fafd8f9863249ea653606bae1ca2e3a75c43d2 $temporary" | sha256sum --check; \
chmod 0755 "$temporary"; \
mv "$temporary" "{{repo-root}}/build/tools/oha"

prepare-workspace: build-ly
if [[ ! -f build/workspace/lampyr.workspace.yaml ]]; then build/ly scaffold workspace build/workspace; fi

Expand Down Expand Up @@ -265,6 +280,7 @@ check-action-versions:

# Run focused unit tests for Lampyr.
test-unit:
python3 "{{repo-root}}/scripts/tests/test_scale_test.py"
go test ./cmd/... ./internal/...
python3 "{{repo-root}}/scripts/tests/test_worker_workspace.py"

Expand Down Expand Up @@ -346,6 +362,27 @@ release-disruption-gate service url:
--service "{{service}}" \
--url "{{url}}"

# Build the container image from the same Node.js source as the Lampyr example.
[positional-arguments]
scale-baseline-image image:
docker build --tag "$1" --file scripts/fixtures/scale-workload/Dockerfile .

# Compare Lampyr with a Deployment and optionally stock Knative.
[positional-arguments]
scale-test context service lampyr-url baseline-image duration="30s" concurrency="1,4,16,64" output="build/scale-results.json" knative-context="" knative-ingress-url="" startup-runs="3" startup-timeout="180s": install-oha
python3 scripts/scale-test.py \
--context "$1" \
--service "$2" \
--lampyr-url "$3" \
--baseline-image "$4" \
--duration "$5" \
--concurrency "$6" \
--output "$7" \
--knative-context "$8" \
--knative-ingress-url "$9" \
--startup-runs "${10}" \
--startup-timeout "${11}"

# Run the repository test suites used in CI.
test: test-unit test-cli examples-check test-preview-release cli::test cli::test-intent helper::test azure::test kind::test k3d::test test-examples-local test-kind-integration test-k3d-integration test-existing-kind-integration test-knative-portability test-walkthrough

Expand Down
3 changes: 3 additions & 0 deletions docs/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Uninstall disables fiber-router trace export before it removes Jaeger.
Remove the add-on before `ly cluster uninstall` when retaining the Kubernetes
cluster; the platform uninstall does not remove optional add-ons.

The [scale framework](scale-testing.md) uses these metrics for repeatable
Lampyr and Kubernetes comparisons.

## Platform metrics

| Metric | Type | Meaning |
Expand Down
97 changes: 97 additions & 0 deletions docs/scale-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: Scale testing
description: Compare the same Node.js application on Lampyr, Kubernetes, and Knative.
---

# Scale testing

Compare the same Node.js app on Lampyr, a Kubernetes Deployment, and optionally
stock Knative.

## Before you start

**The runner does not create clusters or install Lampyr or Knative.** You need:

- A running [Lampyr cluster](cluster-kind.md) with the
[observability add-on](observability.md#install-the-optional-add-on).
- `docs/examples/hello-nodejs-standalone` [deployed through Lampyr](cli/deploy.md),
with a URL you can reach. Use this app without other traffic during the test.
- A Linux x86-64 machine with `just`, Docker, Python 3, `kubectl`, and `jq`.

Your Kubernetes access must allow test workload creation and deletion, Pod
reads, `exec` in the fiberd container, and port-forwarding.

Run the commands below from the repository root. Replace the uppercase values.

## Run Lampyr and Kubernetes

The Deployment runs in your Lampyr cluster. Build and push the container image
from the same Node.js source to a registry that the cluster can reach:

```bash
just scale-baseline-image REGISTRY/IMAGE:TAG
docker push REGISTRY/IMAGE:TAG
docker buildx imagetools inspect REGISTRY/IMAGE:TAG
```

Copy the digest from the inspect output. Use it with your Lampyr context,
Service name, and app URL:

```bash
just scale-test \
LAMPYR_CONTEXT \
SERVICE \
"https://LAMPYR_URL" \
REGISTRY/IMAGE@sha256:DIGEST
```

Use the HTTP or HTTPS URL printed by `ly deploy`. Its path and query are sent
to every target. The runner installs its pinned load generator, oha.

## Add stock Knative

Use a **separate, existing cluster** with Knative Serving and working ingress.
The `default` namespace must exist in both clusters, and both must be able to
pull the container image. Install its metrics collectors:

```bash
bash scripts/install-scale-metrics.sh KNATIVE_CONTEXT
```

Then run this command instead of `just scale-test`:

```bash
just install-oha
python3 scripts/scale-test.py \
--context LAMPYR_CONTEXT \
--service SERVICE \
--lampyr-url "https://LAMPYR_URL" \
--baseline-image REGISTRY/IMAGE@sha256:DIGEST \
--knative-context KNATIVE_CONTEXT
```

For local Knative ingress, add `--knative-ingress-url http://127.0.0.1:PORT`
if the Service URL is not reachable. Do not include a path or query.

## Read the results

The runner measures startup three times per target:

| Target | Startup measurement |
|---|---|
| Lampyr | Zero Fibers to first response, with the same home running |
| Deployment | Zero Pods to one Ready Pod; not request-triggered |
| Knative | Zero replicas to first response |

Images stay cached. The runner then tests warm traffic for 30 seconds at each
concurrency: 1, 4, 16, and 64. Lampyr's default fresh mode still creates a Fiber
per request.

Read `build/scale-results.md` for the comparison and `build/scale-results.json`
for the full data. Client results come from oha; CPU and memory come from each
cluster's Prometheus. Knative includes its queue-proxy. Shared ingress and
control-plane costs are excluded.

Network paths differ: Deployment uses a port-forward; Lampyr and Knative use
ingress. Keep cluster sizes and test settings the same when comparing runs.
The runner removes its temporary workloads, not your Lampyr app or clusters.
2 changes: 1 addition & 1 deletion k8s/observability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ spec:
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.20.0@sha256:42cfe3723a5f058171c627537fb57a3ea0f26e4380fa18555a95cb1a1b4cfc5b
args:
- --resources=deployments,namespaces,nodes,pods
- --metric-labels-allowlist=pods=[lampyr.dev/home]
- --metric-labels-allowlist=pods=[lampyr.dev/home,serving.knative.dev/revision]
ports:
- name: metrics
containerPort: 8080
Expand Down
43 changes: 39 additions & 4 deletions scripts/fiberd_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,62 @@ def home_pod(context, resource):
return running_home(pods)


def audit_records(context, home):
def audit_records(context, home, namespace="default", strict=False, timeout=60):
"""fiberd's audit records for the grant Pod `home`."""
raw = kubectl(context, "exec", f"pod/{home.name}", "--container", "fiberd", "--",
"cat", AUDIT_SPOOL)
return grant_records(raw, home.uid)
"cat", AUDIT_SPOOL, namespace=namespace, timeout=timeout)
return grant_records(raw, home.uid, strict=strict)


def grant_records(raw, pod_uid):
def grant_records(raw, pod_uid, strict=False):
"""The records of `raw` that fiberd stamped with the grant Pod's UID.
fiberd's Fence has no JSON tags, so its fields keep their Go names."""
records = []
sequence = 0
for line in raw.splitlines():
try:
record = json.loads(line)
except json.JSONDecodeError:
if strict:
raise RuntimeError("cannot verify zero Fibers: invalid audit record")
continue
if strict:
if not isinstance(record, dict) or record.get("seq") != sequence + 1:
raise RuntimeError("cannot verify zero Fibers: incomplete audit sequence")
sequence = record["seq"]
if strict and record.get("event") == "gap":
raise RuntimeError("cannot verify zero Fibers: audit records are missing")
if record.get("fence", {}).get("GrantUID") == pod_uid:
records.append(record)
return records


def live_fibers(records):
current_epoch = epoch(records)
current = [
record for record in records
if record.get("fence", {}).get("Epoch") == current_epoch
]
if not current_epoch or not any(record["event"] == "admit" for record in current):
raise RuntimeError("cannot verify zero Fibers: home admission audit is missing")
live = set()
ended = {"release", "park", "oom", "exit", "signal", "yield", "scope-revoked", "orphan"}
for record in current:
event = record["event"]
fiber = record.get("fiber_id")
if event in STARTS:
if not fiber:
raise RuntimeError("cannot verify zero Fibers: audit Fiber ID is missing")
live.add(fiber)
elif event in ended:
if not fiber:
raise RuntimeError("cannot verify zero Fibers: audit Fiber ID is missing")
live.discard(fiber)
elif fiber:
raise RuntimeError(f"cannot verify zero Fibers: unknown audit event {event}")
return live


def fibers_started(records):
return sum(1 for record in records if record.get("event") in STARTS)

Expand Down
9 changes: 9 additions & 0 deletions scripts/fixtures/scale-workload/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1
FROM node:24-alpine@sha256:116b800c3754b440ee0aa3ed2f20f5bf3d99a554bfd9adeea09ea8017f6e85f5
WORKDIR /app
COPY docs/examples/hello-nodejs-standalone/package.json docs/examples/hello-nodejs-standalone/package-lock.json ./
RUN npm ci --omit=dev
COPY docs/examples/hello-nodejs-standalone/application.js docs/examples/hello-nodejs-standalone/server.js ./
ENV PORT=8080
USER 65532:65532
ENTRYPOINT ["node", "server.js"]
37 changes: 37 additions & 0 deletions scripts/install-scale-metrics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# != 1 || -z $1 ]]; then
echo "usage: bash scripts/install-scale-metrics.sh CONTEXT" >&2
exit 1
fi
context=$1
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)

kubectl --context "$context" create --dry-run=client --validate=false \
--filename "$root/k8s/observability.yaml" --output json |
jq --slurp --exit-status '
{
apiVersion: "v1",
kind: "List",
items: [
.[] | (if .kind == "List" then .items[] else . end) |
select(.metadata.namespace != "lampyr-system") |
select(.kind != "NetworkPolicy" or .metadata.name != "prometheus") |
select(.metadata.name | IN(
"lampyr-observability",
"lampyr-observability-prometheus",
"lampyr-observability-kube-state-metrics",
"prometheus",
"kube-state-metrics"
))
]
} |
if (.items | length) == 0 then error("no scale metrics resources found") else . end
' |
kubectl --context "$context" apply --filename -

for deployment in prometheus kube-state-metrics; do
kubectl --context "$context" --namespace lampyr-observability \
rollout status "deployment/$deployment" --timeout=300s
done
Loading