Skip to content

perf(api): benchmark service-bound route workers - #595

Open
Makisuo wants to merge 4 commits into
mainfrom
perf/api-route-workers
Open

perf(api): benchmark service-bound route workers#595
Makisuo wants to merge 4 commits into
mainfrom
perf/api-route-workers

Conversation

@Makisuo

@Makisuo Makisuo commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a reproducible local workerd benchmark for a tiny public router and private route Workers connected by Cloudflare HTTP service bindings.
  • Compare the complete Maple HTTP/service module graph with the smallest useful telemetry-route island under current module boundaries.
  • Record the implementation finding, benchmark evidence, and a phased Cloudflare-native API plan.

Scope

This is a standalone research and planning PR based on main. It is intentionally not part of the lazy-route and cold-bootstrap optimization stack (#593 and #594), and it does not change production routing.

Finding

Hono HonoBase.route() copies handlers into one in-process router; it does not create route Workers. The matching architecture is the Cloudflare API-gateway and service-binding pattern.

Across seven fresh-process runs on the detached branch:

  • monolith module evaluation: 152 ms median;
  • telemetry-island module evaluation: 102 ms median (-32.9%);
  • warm service-binding call: 0 ms median / 1 ms p95 in each 250-request local workerd run.

This supports building a functional telemetry Worker canary after #593 and #594 merge. It does not prove production response parity or deployed latency by itself.

Verification

  • Multi-Worker benchmark completed successfully across seven standalone cold runs.
  • Benchmark source passes oxlint and oxfmt.
  • API/domain typechecks and lower-layer focused tests passed when the experiment was created.

Benchmark method and results: apps/api/scripts/service-binding-bench/README.md.

Implementation and rollout plan: docs/cloudflare-native-api.md.

@Makisuo
Makisuo force-pushed the perf/api-route-workers branch from ff5ffad to 502792b Compare August 23, 2026 13:11
@Makisuo
Makisuo marked this pull request as ready for review August 23, 2026 13:18

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

await fetch(`${baseUrl}/direct`)
await fetch(`${baseUrl}/bound`)

const [direct, bound] = await Promise.all([samplePath("/direct"), samplePath("/bound")])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Concurrent sampling contaminates warm latency numbers

Promise.all([samplePath("/direct"), samplePath("/bound")]) runs both 250-request loops at once, so each stream measures latency while the other loads the same local server. Both the direct baseline and the service-binding number are inflated under doubled load, defeating the comparison the benchmark exists to make.

Suggested change
const [direct, bound] = await Promise.all([samplePath("/direct"), samplePath("/bound")])
const direct = await samplePath("/direct")
const bound = await samplePath("/bound")
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@Makisuo
Makisuo force-pushed the perf/api-route-workers branch from 502792b to 4ec17ec Compare August 23, 2026 13:32
@Makisuo
Makisuo changed the base branch from perf/api-cold-bootstrap to main August 23, 2026 13:32
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