Usage Model
NIE-SLA ships a fixed Cloudflare free-tier usage estimation model (usage-model) that estimates daily Workers, D1, R2 and Durable Objects consumption purely from the site's own data — no Cloudflare API access at runtime.
- Model version:
usage-model-v1.3.4(code:agent/scripts/usage-model.mjs) - Calibration:
agent/scripts/usage-model-calibration.json(nie-sla-usage-calibration-v2) - Inputs: public
/api/status, optionally the admin-only/api/debug/usage-summaryaggregate
Ledgers vs free limits
| Ledger | Metric | Free limit (day/month) | Output field |
|---|---|---|---|
| Workers Functions | invocations | 100,000 / day | workers.function_calls |
| Durable Objects | requests | 100,000 / day | do.requests |
| D1 | rows read / written | 5,000,000 / 100,000 per day | d1.rows_read / d1.rows_written |
| R2 | Class A / B operations | 1,000,000 / 10,000,000 per month | r2.class_a / r2.class_b |
D1 "query count" is not the billing metric; rows read (including index scans) and rows written are. R2 "requests distribution" is dashboard-only and never adds to Class A/B.
Usage
node scripts/usage-model.mjs --hours 24 --json
node scripts/usage-model.mjs --from 2026-09-04T00:00:00Z --to 2026-09-04T08:35:00Z --json
node scripts/usage-model.mjs --hours 24 --range-mode stressWith an admin session (NIE_SLA_ADMIN_SESSION) or a read-only token (NIE_SLA_USAGE_TOKEN, generated in Admin → Settings → Security), the model anchors route counts against the debug aggregate and raises confidence from low to medium.
Method
- Event decomposition per request path (task polling, update checks, telemetry, probe scheduling, public traffic);
- Route anchoring from the debug aggregate when available (12% uncertainty);
- Calibration multipliers fitted against a same-topology observed Cloudflare window (Workers calls ×0.73, D1 rows read ×1.28 / written ×0.45, DO requests ×2.05, refit per release);
- Point estimate + operational envelope (optionally a stress ceiling) — never a billing guarantee.
Calibration status and capacity
- 2026-09-04 first reconciliation (00:00–08:35 UTC): Workers +10%, R2 B -11% inside the envelope; D1 writes underestimated by 36%, reads overestimated by 78% — superseded by the v1.3.4 refit below.
- 2026-09-17 v1.3.4 refit (
offline-paired-fit, operational envelope): Workers calls ×0.73, R2 A ×1.43 / B ×2.06, D1 rows read ×1.28 / written ×0.45, DO requests ×2.05, including the D1 index write amplification (d1_index_write_multiplier=3); use--range-mode stressfor ceiling planning. - Plan A (live): probe cadence is carried by the R2 status state; the D1
targetsschedule mirror is now a coarse per-target flush every 30 minutes (TARGET_SCHEDULE_FLUSH_SEC). - 80-node write-side work (v1.1.62 / v1.1.64, live): probe buckets fall back to D1 only when the buffer is unavailable; the agent-state fallback writes only while buffered state is disabled; both per-minute schedulers share one target scan; every agent's live telemetry buffer now lives inside the shared WSS Durable Object, removing one extra DO call per agent report.
- Capacity: at 80 VPS + 5 TCP pings + 1 Cloudflare + 2 latency nodes the optimized path keeps D1 writes, D1 reads and DO requests well inside the free tier; exact ratios still require a full-UTC-day reconciliation — the model never replaces the billing statement.
Change discipline
Any change to report intervals, WSS/DO paths, D1 SQL profiles or public caching requires a model version bump and recalibration; pure UI/copy changes do not. The model is a reconciliation and capacity tool, not a Cloudflare billing replacement.
v1.3.3 debug-log scope: debug_logs keeps only login/account-security events and failed agent tasks; polling and admin operations are no longer logged, and every route's debugLog row writes drop to zero.
v1.3.4 output refit: Workers / DO / R2 / D1 output multipliers were refitted against observed same-topology windows, now including D1 index write amplification.