Skip to content

perf(fleet): 60 s cello lease and rebalance intervals for idle fleets - #211

Merged
ryuzdev merged 1 commit into
mainfrom
perf/cello-idle-lease
Dec 1, 2026
Merged

ryuzdev merged 1 commit into
mainfrom
perf/cello-idle-lease

Conversation

@ryuzdev

@ryuzdev ryuzdev commented Dec 1, 2026

Copy link
Copy Markdown
Member

Idle cost: an awake-but-idle app fleet (CELLO_DURABILITY=bucket) issues 1.81M R2 Class A ops/month ($8) doing nothing. This sets CELLO_TTL_MS=60000 and CELLO_REBALANCE_INTERVAL_MS=60000 (what Noite runs) in the fleet env, cutting that to ~0.3-0.45M/month. Crash-recovery worst case grows 10 s -> ~60 s; every graceful path is unaffected (evidence below).

Evidence (all at the pinned Cello v0.3.2, docker/Dockerfile CELLO_VERSION=0.3.2)

Setting Cello source Effect Before After
CELLO_TTL_MS (default 10000) crates/cello/main/cli.rs:387, read at crates/cello/actor.rs:2561 Node-lease lifetime; renewal cadence is TTL/3 (crates/logic/lib.rs hold_node_lease: renew_after = (spec.ttl_ms / 3).max(1); fence timer at anchor+TTL) lease PUT ~every 3.3 s (~778k/mo) lease PUT every 20 s (~130k/mo)
CELLO_REBALANCE_INTERVAL_MS (default 5000, 0 disables) crates/cello/main.rs:4072 (DEFAULT_REBALANCE_INTERVAL_MS), read at main.rs:4434; also sets the shared fleet-sample interval (main.rs:4439) Balancing tick: GET fleet/capacity-v1.json every tick, and when stale claim-PUT + LIST nodes/ + lease GETs + sample PUT (ownership_store.rs:read_or_claim_capacity_sample) GET+PUT every 5 s, LIST every ~5-7.5 s same per 60 s tick (~130k Class A/mo)
Deploy pickup generation.rs:91-94 (CELLO_DEPLOY_POLL_S, default 30; Outer sets 30), plus Outer POSTs /reload after every deploy Independent of the rebalance tick unchanged unchanged
Format gate on 1-node fleet balancing tick judges fleet_reads(&peers…) per sample (main.rs:5254+); single peer is always current Gate stays open; 60 s sample still fresh by its own interval unchanged unchanged

Failure modes (single-node-per-app fleets)

  • Graceful stop / sleep / deploy / rename / host release: SIGTERM and SIGINT default to ShutdownMode::Handoff (main.rs:5604-5605; /shutdown defaults to Handoff, main.rs:3518-3526); Handoff means "release every owner record so another node can take over without waiting for the node lease to expire" (actor.rs:606-607). Node-lease records are never deleted, only ownership records — and those release at once. No wake-latency or deploy-downtime impact. Residual edge (pre-existing): releases are bounded by the drain deadline, so a wedged store at shutdown can still leave the successor waiting out the lease — now up to ~60 s instead of ~10 s.
  • Same-node restart (wake): state dir persists per app (manager.rs:376), so the node id is stable; a restart replaces its own lease immediately — "a configured node id is a singleton key: restarting that node replaces its prior process generation immediately" (logic/lib.rs initial-acquire path). No wait.
  • Crash (no release): a peer treats the lease dead the instant now_ms reaches expires_ms (logic/lib.rs:1028+); the successor then takes over (with the dead-owner log-recovery interlock, apply_node_lease_result). Worst case grows 10 s -> ~60 s, plus log recovery (1 s backoff base).

Ops estimate (30-day month = 2,592,000 s, Class A)

  • Before: lease PUT 2.592M/3.33 ≈ 778k + capacity 2 PUTs + 1 LIST per ~5 s tick (Delay-stretched to ~6.4 s effective) ≈ 1.0M ≈ ~1.81M measured.
  • After: lease PUT 2.592M/20 = 129.6k + capacity 3 ops per 60 s tick = 129.6k ≈ ~0.26M modeled (~0.45M measured on Noite incl. unmodeled fixed traffic) — ≈-75% or better.

Checks

  • cargo fmt --all --check: clean
  • cargo clippy --all-targets --locked -- -D warnings: clean (one pre-existing unused-dep warning)
  • cargo test --locked -p outer --lib -- fleet::: 74 passed, 0 failed
  • Docs: web/docs/agents/platform/* and web/docs/deploy/* state no lease/failover timing — no doc change needed.

- Awake-but-idle fleets cost ~1.81M R2 Class A ops/month (~$8) doing nothing: node-lease PUT every TTL/3 (~3.3s at the 10s default) plus a capacity-sample GET+PUT every rebalance interval (5s default) with a LIST nodes/ scan on each refresh.
- Set CELLO_TTL_MS=60000 and CELLO_REBALANCE_INTERVAL_MS=60000 (what Noite runs): renew every 20s, sample every 60s, cutting idle ops to ~0.3-0.45M/month.
- Safe for single-node fleets: SIGTERM defaults to Handoff, which releases every ownership record at once (no TTL wait); same-node restarts replace their own lease immediately (singleton key); deploy pickup is POST /reload + CELLO_DEPLOY_POLL_S, not the rebalance tick. Crash-recovery worst case grows 10s -> ~60s (successor waits out the dead lease).
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dc115b40-d2de-4286-8345-450812beb21f
Commits

Reviewing files that changed from the base of the PR and between 4633f4d and 8d14071.

Files selected for processing: 1

  • crates/outer/src/fleet/supervisor.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ryuzdev
ryuzdev merged commit d0c2cc8 into main Dec 1, 2026
8 of 9 checks passed
@ryuzdev
ryuzdev deleted the perf/cello-idle-lease branch December 1, 2026 07:19
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