---
title: "Concurrency and connections | wasmCloud"
description: "Size per-instance concurrency and per-workload connection quotas together so a wasmCloud component never outruns its connection budget."
canonical: "https://wasmcloud.com/docs/kubernetes-operator/operator-manual/concurrency-and-connections/"
---

Version: v2

# Concurrency and connections

wasmCloud gives you two families of controls that decide how much work a component does at once and how much of the network it may hold open while doing it:

- **Instance limits** set how many calls a single warm instance (a component the host keeps ready between calls) serves concurrently, and how many warm instances the host keeps. They live on the component, in the `Workload` (or `WorkloadDeployment`) custom resource.
- **Connection quotas** set how many outbound and inbound connections a workload may hold. They live on the host, set through Helm values or host flags, and apply to every workload the host runs.

Raising instance concurrency raises how many connections the workload needs, so they are worth tuning as a pair. This page explains how they fit together and how to size them.

For the full field reference, see [component runtime fields](https://wasmcloud.com/docs/kubernetes-operator/crds/) and [workload security](https://wasmcloud.com/docs/kubernetes-operator/workload-security/).

## Scoping

Three settings decide a component's total in-flight work, each at a different scope:

| Scope | Field | What it sets |
| --- | --- | --- |
| Instance | `maxConcurrency` | calls one warm instance serves at the same time |
| Component | `poolSize` | warm instances the host keeps for the component |
| Deployment | `replicas` | copies of the workload across the host group |

- `maxConcurrency` and `poolSize` are set on the component entry.
- `replicas` is set on the `WorkloadDeployment`.
- A single component's warm capacity is `poolSize × maxConcurrency` in-flight calls. Multiply by `replicas` for the deployment's total. Each of those calls can open its own outbound connections, so the connections a workload needs grow with the same product.

That is the interaction to keep in mind: **instance concurrency sets the demand, connection quotas set the ceiling.**

![Where each control lives: a host box sets per-workload connection quotas (maxOutboundHttpConnectionsPerWorkload 128, maxOutboundSocketConnectionsPerWorkload 256, maxInboundSocketConnectionsPerWorkload 256, and the host-wide maxConnections); inside it, a WorkloadDeployment with replicas × 2 contains two workload replicas, each holding a component with poolSize × 4 warm instances, each instance serving maxConcurrency = 3 in-flight calls; warm capacity = replicas × poolSize × maxConcurrency](https://wasmcloud.com/assets/images/concurrency-scopes-a1a783a95d84783b353a59a251a369fd.webp)

## Instance limits (per component)

These five fields sit directly on a component entry, under `spec.template.spec.components[*]` in a `WorkloadDeployment` or `spec.components[*]` in a `Workload`:

| Field | Default when unset | What it does |
| --- | --- | --- |
| `poolSize` | none kept (every call gets a fresh instance) | how many warm instances the host keeps between calls |
| `maxConcurrency` | `1` | how many calls one warm instance serves at the same time |
| `maxInvocations` | unlimited reuse | retires a warm instance after it admits this many calls, then replaces it |
| `reclaimWindowSeconds` | never reclaimed | lets an idle pool shrink: each window, instances beyond what peak load needed are drained and retired (since 2.9.0) |
| `reclaimMinInstances` | `0` | floor on reclaim; sweeps never shrink the pool below this count (since 2.9.0) |

yaml

```yaml
spec:
  template:
    spec:
      components:
        - name: api
          image: ghcr.io/example/api:1.0.0
          poolSize: 10
          maxConcurrency: 8
          maxInvocations: 1000
          reclaimWindowSeconds: 60
```

- `maxConcurrency` above `1` lets one instance overlap calls while it waits on I/O, which is what makes pooling pay off for network-bound work. It is only safe for a guest (the component's own code) that yields while it waits rather than blocking the thread.
- `maxInvocations` bounds how long a warm instance lives, which is useful when a component accumulates state you would rather reset periodically. Both are only meaningful alongside `poolSize`, since an unpooled component starts fresh on every call.
- `reclaimWindowSeconds` (since 2.9.0) lets the pool shrink back after a spike: every window the host retires idle instances beyond what the window's peak load needed, never interrupting a call in flight. `reclaimMinInstances` sets a floor. By default a pool holds its high-water mark until the workload stops. Like the limits above, reclaim is only meaningful alongside `poolSize`.
- A `reclaimMinInstances` **at or above `poolSize` turns reclaim off** rather than clamping to the pool: a sweep could never find a surplus to retire. The CRD field documentation said "capped at `poolSize`" through 2.11.0, which read as though the pair still reclaimed; it was corrected in 2.12.0. Behavior has not changed — only the description.

> **`poolSize` does nothing for a WASI 0.2 HTTP handler**
>
> A WASI 0.2 component serves one HTTP request per instance, so its instances are never reused between requests and `poolSize` has no effect on them. Since 2.11.0 the host warns when `poolSize` is set on one, rather than leaving the setting to look effective. Build the component for WASI 0.3 to keep HTTP instances warm.

The [component runtime fields reference](https://wasmcloud.com/docs/kubernetes-operator/crds/) covers the pooling semantics in full, including how linked components share a store and what a guest trap does to calls in flight.

## Connection quotas (per workload)

Every workload gets one connection quota across three surfaces. You set these on the host, either as Helm values in a host group's `networking` block (`runtime.hostGroups[].networking`; rendered by the chart since 2.9.0, so on earlier charts use `extraArgs`) or as host flags, and they apply to each workload the host runs:

| Helm value | Host flag | Default | Bounds |
| --- | --- | --- | --- |
| `maxOutboundHttpConnectionsPerWorkload` | `--max-outbound-http-connections-per-workload` | `128` | pooled outbound HTTP and gRPC connections a workload may hold (idle keep-alive connections count) |
| `maxOutboundSocketConnectionsPerWorkload` | `--max-outbound-socket-connections-per-workload` | `256` | raw `wasi:sockets` outbound connections a workload may hold |
| `maxInboundSocketConnectionsPerWorkload` | `--max-inbound-socket-connections-per-workload` | `256` | inbound socket connections a workload serves at once; since 2.10.0 every accepted connection takes a slot |
| `maxConnections` | `--max-connections` | derived from the process file-descriptor limit | host-wide ceiling across every workload |
| `maxHttpIngressConnections` | `--max-http-ingress-connections` | a quarter of the descriptor limit, floor 256 | connections the host's own HTTP listener holds open, across every workload (since 2.9.0) |

The three per-workload surfaces behave differently when a workload reaches its limit:

- **Outbound HTTP waits.** A request over the quota waits for a slot, up to `--http-connection-wait` (default `5s`), then fails. This is the surface most sensitive to instance concurrency, because the outbound pool is what warm, overlapping calls draw from.
- **Raw sockets and inbound connections are refused immediately.** They do not wait, which avoids a guest deadlocking against its own quota.
- **The host's ingress ceiling sheds.** Connections past `maxHttpIngressConnections` are accepted and immediately closed, so the host stays responsive rather than exhausting descriptors (since 2.9.0).
- **Inbound traffic is screened (since 2.10.0).** Listens, accepts, and received datagrams go through the same address policy and `--socket-egress` mode as outbound connects. That mode is `enforce` by default since 2.11.0, so screened traffic is refused rather than counted.

Four of these five values fail the host at startup if they exceed what a semaphore can hold; `maxHttpIngressConnections` instead clamps silently to that ceiling. The ceiling is platform-dependent (it derives from the pointer width), so it is far larger on 64-bit hosts than on 32-bit ones. Since 2.11.0 the three per-workload ceilings are validated at startup rather than when a workload first claims a quota: before that, an out-of-range value let the host boot, report its quotas, pass its readiness probe, and then panic on the first workload to claim one. The startup error names the setting in its internal `snake_case` form (`max_outbound_http_connections_per_workload`) rather than the flag spelling. Note that the chart cannot render any of these as `0` — a zero value is treated as unset and omitted.

A single request body also has a deadline: `WASH_HTTP_REQUEST_BODY_TIMEOUT_SECS` (default 600 seconds) bounds how long the host waits for an inbound body to keep arriving before it abandons the request. Raise it for workloads that accept large uploads over slow links. `wash dev` applies the same per-workload quotas as a Kubernetes host and raises its own descriptor limit at startup (since 2.10.0), so the dev loop hits the same ceilings production does.

The three per-workload quotas roll up into the host-wide `maxConnections` ceiling; `maxHttpIngressConnections` bounds the host's own listener separately, derived from the same descriptor budget. Since 2.9.0 the host raises its own soft file-descriptor limit toward the hard limit at startup, and an unlimited descriptor limit derives a large budget instead of a silent 512, so hosts running under `LimitNOFILE=infinity` permit far more concurrent connections after upgrading. The [workload security](https://wasmcloud.com/docs/kubernetes-operator/workload-security/) page covers these quotas alongside the raw-socket egress policy they ship with.

## Sizing them together

Take the component above: `poolSize: 10` and `maxConcurrency: 8` is up to 80 calls in flight on one replica. If each call makes one outbound HTTP request, the workload wants up to 80 outbound connections at peak, comfortably under the default `128`. Raise `maxConcurrency` to `16`, or have each call fan out to several backends, and the demand crosses the default. Past that point, outbound requests wait on `--http-connection-wait` and then fail, which shows up as latency spikes and timeouts under load rather than an obvious error.

Two separate things are at work here, and only one of them is a value you set:

- **Keep-alive pool sizing is automatic.** For reuse, the host keeps some idle connections warm to each destination, and it sizes that from the component's declared `poolSize × maxConcurrency`, so raising concurrency keeps proportionally more connections ready without a second setting to keep in sync. Idle connections above real demand close on their own after a timeout. You do not tune this.
- **The connection ceiling is the value you set.** `maxOutboundHttpConnectionsPerWorkload` (default `128`) caps how many outbound HTTP connections the workload may hold at once, across every destination. This is the limit a request waits behind, and it is what you raise when peak demand outgrows the default.

So the tuning workflow is:

1. Set `poolSize` and `maxConcurrency` for the throughput you want.
2. Estimate peak outbound connections as `poolSize × maxConcurrency ×` (outbound requests per call).
3. If that estimate approaches `maxOutboundHttpConnectionsPerWorkload` (default `128`), raise the quota, and confirm the host-wide `maxConnections` still leaves room for every other workload.

> **Note**
>
> These quotas are per host process. A workload scaled to several `replicas` gets the quota once per replica, not divided across them, so scaling out multiplies the workload's total connection budget the same way it multiplies throughput.

## Host process memory

Instance pools and connection quotas bound what one workload asks for. Since 2.11.0 a separate limit bounds the **whole host process**, so one workload's growth cannot take the pod down with it.

`--max-process-memory` (`WASH_HOST_MAX_PROCESS_MEMORY`) defaults to **90% of the cgroup memory limit**, or of physical memory where there is no cgroup; where neither can be read, nothing is enforced. Past the limit, the host refuses guest memory growth (including the initial memory of a new instance) and refuses to start new workloads. A queued start that arrives over the limit reports `Error` on the Workload with a message naming `max-process-memory`, so this surfaces as a failed start rather than a silent stall. Refusals lift once the footprint falls back under 95% of the limit, after a full minute below it without growth, or after five consecutive failed reads of the footprint, with a successful read resuming enforcement. Pass `off` (or `none`) to disable it.

Two properties to design around:

- **It is enforced even when [`guestMemoryMode`](https://wasmcloud.com/docs/kubernetes-operator/operator-manual/helm-values/#runtimeresourcesguestmemorymode) is `count`.** `count` governs the guest budget only; it is not a global observe-only switch. Disabling the process limit takes `--max-process-memory off`.
- **It is sampled admission control, not a hard cap.** It cannot stop allocations already in flight, writes into memory a guest has already committed, or arbitrary host and plugin buffers. Leave headroom and keep the container memory limit as the real boundary.

The host exports `process_memory.footprint`, `process_memory.high_water`, and `process_memory.limit` as gauges in bytes, plus a `process_memory.refused` counter that is kept separate from the guest budget's `guest_memory.refused`. What counts toward the footprint differs by platform: Linux measures anonymous resident memory plus swap, deliberately excluding shared file mappings so a shared Wasmtime memory image is not counted once per instance; macOS includes compressed pages.

## How the instance pool is sized

Since 2.12.0 the knob that sizes the engine's pool is `--max-memories` (`WASH_MAX_MEMORIES`, chart value [`runtime.resources.maxMemories`](https://wasmcloud.com/docs/kubernetes-operator/operator-manual/helm-values/#runtimeresourcesmaxmemories)): the count of guest linear memories the pooling allocator keeps room for. Multiplied by one memory's reservation it *is* the pool's address-space reservation, and the fiber-stack, component-instance, core-instance, table, and GC-heap totals are all derived from it, one of each per memory for a component of the usual shape.

Left unset, the host derives the count from the machine rather than using a fixed number: half the usable address space, and at most 90% of `vm.max_map_count` allowing six mappings per warm component. On a default Linux node that is **9,829** memories; the floor is 1000. Setting `WASMTIME_MEMORY_INIT_COW=false` in the host's environment (since 2.12.0) copies each component's data segments into its memory at instantiation instead of mapping them copy-on-write. A warm memory then needs two fewer mappings, which raises the derived count on a default Linux node to 14,744, at the cost of the copy on every instantiation.

> **`--core-instances` no longer sizes the pool**
>
> Through 2.11.0, `--core-instances` (default 1000) was both the core-instance total and the number of instances the pool held. Since 2.12.0 it is a *counter* for live core modules — several per component, four for a Rust HTTP handler, five for a Componentize-Go one, plus every member of a composition — and defaults to sixteen per memory, a number components of the usual shape never fill, so the linear memories are what a full pool runs out of first.
>
> Set alone, `--core-instances` still pins `--max-memories` to the same count, reproducing the pool it sized before, and the host warns at startup. Set beside `--max-memories`, both are installed as given, with a warning when they disagree. `WASMTIME_POOLING_TOTAL_*` overrides any one total on its own.

The per-memory layout is separately adjustable since 2.12.0. Each slot is `--memory-reservation` (wasmtime's 4 GiB by default) followed by `--memory-guard-size` (32 MiB), whatever `--default-heap-memory` is. Lowering `--default-heap-memory` caps how far a guest may grow but does not shrink the reservation; `--memory-reservation` does. A pooled memory cannot outgrow its reservation, so when `--memory-reservation` is set, a `--default-heap-memory` above it is lowered to the reservation; the startup warning about a reduced layout reports the lowered value. Shrinking the layout fits more warm instances into a node's address space, and [moves an isolation boundary](https://wasmcloud.com/docs/kubernetes-operator/operator-manual/helm-values/#runtimeresourcesmemoryreservation-and-runtimeresourcesmemoryguardsize) while it does — read that note before reaching for it. The host warns at startup when the layout is below the defaults, or when the reservation would exceed 90% of mappable address space or outgrow `vm.max_map_count` on Linux.

### When the instance pool runs out

Pool exhaustion used to surface as a bare Wasmtime message while the workload still reported healthy. Since 2.11.0 the instantiation error names the setting to raise, for example `host instance pool exhausted. Raise --core-instances (or WASMTIME_POOLING_TOTAL_CORE_INSTANCES), or give this host fewer warm instances`. These warnings are rate-limited to once every 10 seconds, with repeats at debug level.

### Hostcall fuel

Since 2.12.0, `--hostcall-fuel` (`WASH_HOSTCALL_FUEL`, chart value [`runtime.resources.hostcallFuel`](https://wasmcloud.com/docs/kubernetes-operator/operator-manual/helm-values/#runtimeresourceshostcallfuel)) bounds roughly how many bytes a guest may copy to the host in one call, and each read the host makes from a future or a stream. Past it, the call traps, and the host logs a hint naming the knob once per deploy. Unset it is wasmtime's own default of 128 MiB. These bytes are allocated outside the guest memory budget, from what the container limit leaves over after it, and the host warns at startup when the value exceeds that remainder.

It does not bound byte streams the host reads directly, such as HTTP bodies and socket writes, and it is **unrelated to fuel metering** (`--meters fuel`), which counts instructions.

### Limits above what a semaphore can hold

A concurrency ceiling larger than Tokio's `Semaphore::MAX_PERMITS` used to panic when the semaphore was constructed. Since 2.12.0 such a value is refused at startup instead, so a mistyped limit fails the host with a message rather than taking it down later.

## Messaging admission (per component)

As of wasmCloud 2.8.0, messaging-triggered components have their own in-flight limit, applied before any instance work begins (trigger services are exempt). The `max_in_flight` config key on the component (default: the host's per-component ceiling) caps concurrent deliveries across the component's replicas on a host. A delivery over the limit waits up to `admission_wait` (default `30s`) for a slot, then is dropped with a warning.

This limit is separate from `maxConcurrency`: `maxConcurrency` bounds calls on one warm instance, while `max_in_flight` bounds total messaging deliveries executing for the component. Since 2.10.0 replicas of one deployment share that gate (earlier releases opened one per replica), and `admission_group` can rekey it. Since 2.9.0, async (`0.3.0`) deliveries to a pooled component run on its warm instances under the same `poolSize` and `maxConcurrency` rules as HTTP, so for messaging workloads, size `max_in_flight` first, then the instance limits beneath it. Sync (`0.2.0`) deliveries still run in a store per message regardless of `poolSize`. See [Messaging admission control](https://wasmcloud.com/docs/kubernetes-operator/crds/#messaging-admission-control) for the config keys and host flags.

## Replicas

`replicas` is the third scaling axis: copies of the whole workload spread across the host group (the pool of hosts the operator manages). It scales throughput past what one host's instance pool can serve, and it is the axis a `HorizontalPodAutoscaler` or KEDA drives through the `/scale` subresource. See [Autoscaling](https://wasmcloud.com/docs/kubernetes-operator/operator-manual/autoscaling/) for how to scale `replicas` automatically, and why the host group is a precondition for it.

## Takeaways

- A component's warm capacity is `poolSize × maxConcurrency` calls in flight; `replicas` multiplies that across hosts. With `reclaimWindowSeconds` set, an idle pool shrinks back after a spike.
- Instance concurrency sets connection demand; the per-workload quota sets the ceiling. Size them as a pair.
- The keep-alive pool is sized automatically from declared concurrency, so you tune concurrency and the quota, not the pool directly.
- Outbound HTTP over quota waits up to `--http-connection-wait` (default `5s`) then fails; raw sockets and inbound connections are refused immediately.
- Since 2.12.0, `--max-memories` sizes the host's instance pool and is derived from the node when unset; `--core-instances` is a counter, not the pool size.
- The connection quota applies once per replica, so scaling out multiplies the total connection budget. The messaging admission gate does not: replicas of one deployment share it (since 2.10.0).
- Messaging deliveries have their own admission limit (`max_in_flight`, as of 2.8.0), applied before instance limits come into play.
- A host-process memory limit sits above all of it (since 2.11.0), refusing guest growth and new workload starts past 90% of the cgroup limit, and enforced even in `count` mode.

Last updated on **Nov 19, 2026** by **Eric Gregory**
