docs(server): design horizontal scale-out over centralized data stores - #427
Conversation
Adds spec/scale-out.md: a proposed opt-in 'central' storage mode for the container host — N stateless replicas behind a load balancer, with all authoritative state in centralized stores (libSQL/sqld for D1, per-object DO databases via embedded replicas, and a CAS coordination KV; an S3-compatible store for R2). Reuses @dwk/deno-host's runtime-agnostic shims (lease/alarms/queue/S3) and adds a DenoKvLike-over-libSQL adapter, fleet-aware pollers, a cron tick lease, and mode-guard startup checks. Cross-links the design from self-hosting.md (the horizontal-scale non-goal, §8 mitigations, resolved decision 4) and portability.md §4.4 (Cloud Run). The single-process local mode remains the default; nothing is adopted by this change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgeyeFnkNceEwUxBKgCTrC
|
CI status note: the Everything actionable is green or on track: Conformance passed, and the main CI workflow (lint → format → typecheck → build → test) is running normally. Generated by Claude Code |
davidwkeith
left a comment
There was a problem hiding this comment.
Reviewed. Spec-only design doc (spec/scale-out.md, new), no package code touched.
CONTRIBUTING.md conformance:
- Title/scope:
docs(server): design horizontal scale-out over centralized data stores— correct type, lowercase, scope reflects the package this design targets even though no@dwk/servercode changed in this PR (consistent with the PR body's "touches@dwk/server(private)"). - Checklist: spec read/updated ✓; tests/changeset/catalog correctly left unchecked with one-line "not applicable" reasons (spec-only, no publishable package, no new worker) rather than deleted — matches the required convention.
- Cross-links resolve:
self-hosting.md,portability.md,host-contract.md,deno-deploy-design.md, andpackages/deno-host.mdare all real files at the paths referenced, and the new doc is correctly placed atspec/scale-out.md(cross-cutting, not underspec/packages/) since it isn't a single package's spec. - The design correctly treats
@dwk/deno-hostas reused rather than duplicated (§3), and its claim that@dwk/cf-shims's queue broker currently auto-acks (used to justify switching to the conforming broker in central mode) checks out againstpackages/cf-shims/src/queue.ts's own comment ("Returned without an explicit decision → auto-ack"). - Non-goal language in
self-hosting.md§4/§8 is updated consistently — the single-process default explicitly still stands, this is opt-in.
No blocking issues found. Note: the github-advanced-security check is failing on this PR, but it's an unrelated infra error (GitHub's Copilot code-scanning agent returning model_not_supported), not something this diff caused — the required ci.yml/release-gate checks are green.
Generated by Claude Code
Summary
Designs an opt-in horizontal scale-out mode for the container host, so high-traffic deployments can run N identical
@dwk/serverreplicas behind a load balancer with all authoritative state in centralized data stores. Design only — nothing is adopted; the single-process local-storage default ofspec/self-hosting.mdis unchanged and stays recommended for single-owner deployments.New spec:
spec/scale-out.md. Key decisions:@dwk/deno-host's runtime-agnostic centralized-store shims (feat(deno-host): SQL shim — external libSQL/Turso behind D1Database/SqlStorage #397–feat(deno-host): R2Bucket-shaped object storage adapter over an S3-compatible store #400) —createD1Databaseover libSQL,SqlStorageover embedded replicas, the per-id lease + alarm machinery, the conforming queue broker, and the S3-compatibleR2Bucketadapter — composed inside@dwk/serverbehind a newstorage: { mode: "central" }config.DenoKvLike-over-libSQL coordination KV (order-preserving key encoding, CAS via per-key versionstamps, TTL) — deliberately avoiding a third service (Redis etc.); plus any S3-compatible object store (MinIO/R2/B2) for blobs.host-contract.md§9.Cross-links the design from
spec/self-hosting.md(the horizontal-scale non-goal, §8 mitigations, resolved decision 4) andspec/portability.md§4.4 (this unlocks Cloud Run-class disk-less platforms).Packages affected
None (spec-only). The design touches
@dwk/server(private) and proposes consuming@dwk/deno-host; no package code changes in this PR.Checklist
spec/packages/and updated them ifbehaviour changed
src/*.test.ts) — not applicable, spec-only design docpnpm lint && pnpm format:check && pnpm typecheck && pnpm build && pnpm test—format:checkrun on the changed markdown; no code changedpnpm changeset) — not applicable, no publishable package touchedcatalog.json/conformance/status.json— not applicable, no new workerGenerated by Claude Code