MCP Fusion/Operate and integrate/Performance and scaling
Performance and scaling
Understand the real performance mechanics: compiled middleware, cached Zod schemas, O(1) maps, optional AOT serialization, bounded concurrency and stateless horizontal scaling without invented benchmarks.
MCP Fusion optimizes the work it can know before the request and leaves your database and upstream latency visible. This page separates source-backed mechanics from benchmark claims: the repository has no benchmark suite or measured operations-per-second number.
Build-time work
When a builder is registered, the framework compiles and caches:
- the merged JSON Schema and a strict Zod validation schema per action
- the middleware chain, with global middleware outermost and action middleware innermost
- the action map and the flat exposition routing map
- the Presenter serializer when the optional AOT serializer is installed
- state-sync policy matches and contract digests
The request path then resolves maps and invokes closures. It does not assemble a middleware array, regenerate a schema or scan builders.
Zero cost when disabled
The execution code checks optional subsystems before constructing their hooks:
- no concurrency guard object without
.concurrency() - no mutation FIFO serializer unless an action is destructive
- no debug hooks without
debug - no tracing branch without
tracing - no telemetry work when there are no clients on the telemetry bus
- no progress sink without a client
progressToken
This is a code path property, not a promise of a fixed latency.
Serialization
createSerializer() lazy-loads optional fast-json-stringify, turns Zod schemas into JSON Schema and caches compiled functions in a WeakMap. If the dependency is absent or compilation fails, it falls back to JSON.stringify. Install the optional peer when response serialization is a measured bottleneck, then profile the result on your own data.
Load shedding and ordering
concurrency({ maxActive, maxQueue }) is a bounded semaphore. A full queue returns SERVER_BUSY with recovery guidance instead of allowing unbounded memory growth. Destructive actions receive a per-action FIFO MutationSerializer, so two writes to the same action do not race. Cancellation removes queued waiters through the same AbortSignal.
Stateless horizontal scaling
transport: 'stateless' creates a fresh MCP Server for each request and has no session affinity. Vercel and Cloudflare adapters cache the compiled registry at module scope but use JSON responses with no SSE and no shared session memory. Any instance behind a load balancer can process any request. Durable state belongs in your database, an external store or an explicit request state handle, not in a module variable.
Scale the context before the CPU
Most agent cost is context, not JavaScript execution. Before adding infrastructure:
- group related actions behind a discriminator
- tag-filter the surface by deployment or role
- use
.agentLimit()on collections - expose
_selectfor wide entities - use TOON for uniform arrays and descriptions
- profile token inflation in the lockfile
See Token economics and Tool exposition.
What we do not claim
The framework repository contains no benchmark directory and no measured ops-per-second table. Claims such as 2x faster serialization or a percentage cost reduction are documentation heuristics, not a guarantee. Measure your handler, database, upstream and payload shape with Observability.
Deployment choices
- Deploy for Vinkius Cloud's free managed Edge path
- Vercel via
@mcpfusion/vercel - Cloudflare Workers via
@mcpfusion/cloudflare - Self hosting when your perimeter must stay in your account
The tools, Presenters and middleware do not change between these targets.
Next steps
- Runtime architecture: the compiled request path
- Observability: profile your real workload
- Governance: keep performance regressions reviewable
