Skip to content

Add Go ucloud-gatewayd fast-path front door and cap store chunk-index RAM (Phase 2) - #72

Merged
rlrs merged 2 commits into
mainfrom
phase2-gateway-scale
Dec 2, 2026
Merged

rlrs merged 2 commits into
mainfrom
phase2-gateway-scale

Conversation

@rlrs

@rlrs rlrs commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Summary

Enables smaller/cheaper permanent Gateway and Store VMs to scale beyond 1,000+ concurrent sandboxes without Gateway GIL or Store RAM bottlenecks:

  • runtime/gatewayd/ (pure Go stdlib, CGO_ENABLED=0, zero external deps):
    • Front-door HTTP proxy in front of Python control_plane that offloads all high-QPS/long-poll/streaming data-plane routes directly to ucloud-noded:
      • Stateless /v1/exec/<session>[/events|/stdin|/close-stdin|/signal] via byte-for-byte compatible HMAC verification (xr1.<b64>.<mac>) + in-memory worker freshness table seeded from /v1/nodes and updated on POST /v1/nodes/heartbeat.
      • Route-cached POST /v1/sandboxes/<id>/exec, GET /jobs/*, GET/PUT /files, PUT /archive with zero-copy streaming uploads (constant memory, no 256 MiB Python buffer) and Go-side X-UCloud-Exec-Session-Prefix signing.
      • Strict consistency: evicts cached routes before forwarding DELETE, park, wake, detach, migration, or batch delete, evicts worker routes on node_epoch reboot, bounds route TTL (30s), strips internal X-UCloud-Gateway-Route headers, and transparently falls back to Python on miss / 404 / 409 / 503 / stale worker.
  • Python Gateway & Store improvements:
    • Emit X-UCloud-Gateway-Route only when fronted by X-UCloud-Gateway-Front-Door: 1 (sandboxes/gateway/create.py, sandboxes/gateway/sandbox_proxy.py).
    • Cap sandboxes/chunk_index.py memory caches (META_CACHE_BYTES 256→64 MiB, TAIL_CACHE_IDS 2M→250k, locator_cache 64→16, SQLite PRAGMA cache_size=-8000) to prevent multi-GB RSS bloat starving Linux page cache on the Store Node.
    • Fix sandboxes/systemd.py require_registry_mount to recognize Linux bind mounts via /proc/self/mountinfo (enabling local NVMe registry bind mounts).
    • Fix standalone runtime/noded/src/exec_front.rs to return 400 instead of 404 on malformed/partial exec payloads.
    • Update stale worker diagram in docs/architecture.md and wire runtime/gatewayd into scripts/check.sh.

Verification

  • runtime/gatewayd: go vet + go test -race (including Python/Go HMAC parity vector and 1,500-concurrent-request fast-path stress test: 0.31s, 0 upstream hits).
  • tests/test_gatewayd_contract.py: end-to-end test running compiled ucloud-gatewayd in front of real LocalFleet + standalone Rust ucloud-noded.
  • Full scripts/check.sh (with PostgreSQL): PASSED — all 202 Python modules, Go (managed_process, chunk_serve, gatewayd), Rust ucloud-noded, wheel build, and all 133 SDK tests.

rlrs added 2 commits December 2, 2026 07:36
… RAM (Phase 2)

1. Add runtime/gatewayd (pure Go stdlib, CGO_ENABLED=0): fast-path HTTP front
   door in front of Python control_plane that handles /v1/exec/* statelessly
   via HMAC + fresh worker map, proxies running-sandbox POST /exec, GET /jobs,
   GET/PUT /files, and PUT /archive directly to ucloud-noded with zero-copy
   streaming, evicts cached routes immediately on park/wake/delete/migration/
   worker-reboot, and falls back transparently to Python on miss/parked/stale.
2. Emit internal X-UCloud-Gateway-Route hint from control_plane/create and
   sandbox_proxy only when fronted by X-UCloud-Gateway-Front-Door: 1.
3. Bound chunk_index.py caches (META_CACHE_BYTES, TAIL_CACHE_IDS,
   locator_cache, PRAGMA cache_size=-8000) to eliminate multi-GB RSS growth
   on the store node.
4. Fix standalone exec_front.rs to return 400 directly on malformed/partial
   exec payloads instead of falling through to 404.
5. Support Linux bind mounts in systemd.py require_registry_mount via
   /proc/self/mountinfo, update stale diagram in docs/architecture.md, and
   wire runtime/gatewayd into scripts/check.sh.
@rlrs
rlrs merged commit 268dc54 into main Dec 2, 2026
4 checks passed
@rlrs
rlrs deleted the phase2-gateway-scale branch December 2, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant