|
|
+++
|
|
|
title = "Verify API worker gzipped binary size is within CF Workers free tier (3 MB limit)"
|
|
|
priority = 5
|
|
|
status = "todo"
|
|
|
ticket_type = "task"
|
|
|
dependencies = ["1f5bb5"]
|
|
|
+++
|
|
|
|
|
|
<context>
|
|
|
Resolved from TRIAGE ticket 182210. The original concern (1 MB Workers free tier limit) was based on
|
|
|
outdated information. The actual current limit is **3 MB after gzip** for the free tier (10 MB paid).
|
|
|
|
|
|
This ticket verifies that the API worker stays within that limit once all Cargo.toml dependencies
|
|
|
are pinned (ticket 1f5bb5). No structural changes are expected — the release profile and architecture
|
|
|
already make this highly likely.
|
|
|
|
|
|
Key facts:
|
|
|
- Worker size limit: Free = 3 MB (gzipped), Paid = 10 MB (gzipped)
|
|
|
- `Cargo.toml` release profile already has `opt-level = "z"`, `lto = true`, `strip = true`, `codegen-units = 1`
|
|
|
- `wrangler` applies `wasm-opt -Oz` automatically during build
|
|
|
- The API Worker contains only API code (no Yew/UI); UI runs on Cloudflare Pages
|
|
|
- Database layer uses `workers-rs` D1 bindings (not SQLx) — avoids a heavy dep
|
|
|
</context>
|
|
|
|
|
|
<implementation-plan>
|
|
|
|
|
|
## Step 1 — Build the release worker bundle
|
|
|
|
|
|
From the `quotesdb/` directory, after ticket 1f5bb5 has added all Cargo.toml dependencies:
|
|
|
|
|
|
```sh
|
|
|
wrangler deploy --outdir bundled/ --dry-run
|
|
|
```
|
|
|
|
|
|
This produces output like:
|
|
|
|
|
|
```
|
|
|
Total Upload: 523.41 KiB / gzip: 147.23 KiB
|
|
|
```
|
|
|
|
|
|
The `gzip:` figure is the size that counts against the 3 MB free tier limit.
|
|
|
|
|
|
## Step 2 — Evaluate the result
|
|
|
|
|
|
| Gzip size | Action |
|
|
|
|-----------|--------|
|
|
|
| < 2 MB | No action needed. Note the size in this ticket. |
|
|
|
| 2–3 MB | Note the size. Add a comment to track future dep additions carefully. |
|
|
|
| > 3 MB | See remediation steps below. |
|
|
|
|
|
|
## Step 3 (conditional) — Remediation if > 3 MB
|
|
|
|
|
|
Try in order:
|
|
|
|
|
|
1. **Audit dependencies** — run `cargo bloat --release --crates` to identify the largest contributors.
|
|
|
Remove or replace heavy crates (e.g., swap `chrono` for `time`, avoid full `tokio` features).
|
|
|
|
|
|
2. **Explicit `wasm-opt` pass** — if `wrangler` is not applying `wasm-opt` for some reason:
|
|
|
```sh
|
|
|
wasm-opt -Oz -o output.wasm input.wasm
|
|
|
```
|
|
|
|
|
|
3. **Workers Paid plan** — if the binary genuinely cannot be reduced below 3 MB, upgrade to the
|
|
|
Workers Paid plan ($5/month, 10 MB limit). Update `infra/` resources accordingly and document
|
|
|
the decision in `docs/ARCHITECTURE.md`.
|
|
|
|
|
|
## Step 4 — Document outcome
|
|
|
|
|
|
Record the final gzipped size in `docs/ARCHITECTURE.md` under the API section, and close this ticket.
|
|
|
|
|
|
</implementation-plan>
|
|
|
|
|
|
<validation>
|
|
|
|
|
|
```sh
|
|
|
# From quotesdb/ directory:
|
|
|
wrangler deploy --outdir bundled/ --dry-run
|
|
|
# Confirm "gzip: X KiB" is < 3 MB (3072 KiB)
|
|
|
```
|
|
|
|
|
|
</validation>
|
|
|
|
|
|
<commit>
|
|
|
`chore(quotesdb): verify api worker binary size within cf workers 3mb free tier limit`
|
|
|
</commit>
|