# UCall | One Engine for Clients and Servers

> UCall, Unum’s client-server engine: Noise encryption instead of TLS, synchronous handlers over io_uring, epoll, kqueue and IOCP, and server-side batching behind one C ABI

UCall · Open source · Network engine · Unum

What if clients and servers shared One Engine?

One connection state machine over io_uring, epoll, kqueue and IOCP, encrypted with Noise instead of TLS.

**One C ABI** for C, C++, Python, Rust, Go and Mojo, with no OpenSSL, no async runtime and no threads of its own. **Python handlers at 3.7×** FastAPI’s rate across two Graviton4 machines.

[Open Source ](https://github.com/unum-cloud/UCall)[Use with your agent](#for-agents)

Get started

## The FastAPI handler, served from C.

Decorate a typed function, and UCall binds its parameters from the request.

[Read the UCall docs](https://www.unum.cloud/docs/ucall.md)

Python

```python
import ucall

server = ucall.Server(ucall.Interface('0.0.0.0:8000'))

@server.get('/sum')
def sum(a: int, b: int):
    return a + b

server.run()
```

`pip install ucall`; parameters bind in C and the handler answers on the polling thread.

[01 · Sync handlers](#handlers)

## Asynchronous I/O, synchronous handlers.

> No async, no await, no futures in your code.

A request often costs less to compute than to carry: the packets between an application and its network card cross several context switches and kernel calls. UCall hides that latency under `io_uring`, epoll and kqueue, and keeps the handler an ordinary function, with no `async`, `await` or futures.

UCall creates no threads. The application owns each event loop’s polling thread and runs its handlers there, so no event loop or coroutine sits between the socket and a Python handler. A first stop drains every request already held, and a second cuts what remains.

### Fig. 1.1: Python handlers at 3.7× FastAPI’s rate across two Graviton4 machines

UCall’s Python handlers serve 395,669 tool calls a second, 3.7 times FastAPI and 11 times Python gRPC. When a Rust server also acts as a client, calling 8 upstream servers for every tool call, UCall makes 854,288 upstream calls a second to actix-web’s 628,864 and axum’s 451,880. At 65,536 open connections, UCall holds 13.8 KB per connection, against 33.7 to 38.3 KB for actix-web, axum and tonic.

Two Graviton4 machines 4 server cores per card Python handlers tool calls/s, 1 KB of JSON in and 256 B out UCall Python 396K FastAPI Python · Uvicorn 108K gRPC Python 36.0K Rust servers calling 8 upstreams per tool call upstream calls/s UCall Rust 854K actix-web Rust 629K axum Rust 452K Memory at 65,536 connections KB per connection, less is better UCall Rust 13.8 actix-web Rust 38.3 axum Rust 33.7 gRPC Rust · tonic 35.5

Two c8gn.metal-48xl, one driving the other over two 300 Gbit cards each

[02 · Noise](#noise)

## TLS is a standard too large to embed.

> One handshake, one cipher suite, no certificates.

TLS is the Internet’s encryption standard, and a massive one: several versions, dozens of cipher suites, countless options and a certificate chain to manage for every service. Integrating it cleanly through OpenSSL, BoringSSL, LibreSSL and mbedTLS failed twice in two years.

UCall speaks the [Noise Protocol Framework](https://noiseprotocol.org/) beneath HTTP, addressed as `http+noise://`, with the XX, IK and KK handshakes and exactly one suite: Curve25519, AES-256-GCM and SHA-256. The cipher and hash run on [StringZilla](https://www.unum.cloud/docs/stringzilla.md)’s kernels and each CPU’s cryptographic instructions, with no OpenSSL, libsodium or third-party Noise. Static keys replace certificates, and a server admits its peers by key.

### Fig. 2.1: One round trip either way, and only TLS negotiates

TLS 1.3 offers suites and proves a certificate chain on every connection. Noise IK starts from a key the client already knows and settles a post-quantum session in one round trip.

TLS 1.3 sends ClientHello, the server answers with ServerHello, EncryptedExtensions, Certificate, CertificateVerify and Finished, and the client sends Finished with its first request. Noise IK with ML-KEM-768 sends a 1,296-byte message and a 1,152-byte answer against a server key pinned in advance, then the request.

Sources: [RFC 8446](https://www.rfc-editor.org/rfc/rfc8446#section-2) · [The Noise Protocol Framework](https://noiseprotocol.org/noise.html)

### Fig. 2.2: Noise keeps 80% of plaintext’s rate, 2.8× TLS 1.3 behind nginx

The TLS baseline is nginx terminating TLS 1.3 in front of the same plaintext server, the way deployments behind a proxy run. Across two Graviton4 machines, Noise adds 1.3 µs of server CPU to a kept-alive call, about what TLS 1.3 adds inside actix-web and axum, 1.5 and 1.3 µs.

Requests a second, 1 KiB over kept-alive connections

UCall plaintext 366,722

UCall Noise IK 292,451

UCall Noise XX 290,926

nginx plaintext proxy 141,445

nginx TLS 1.3 proxy 105,547

Measured on Intel Core i9-13950HX · one server thread · one nginx worker · two c8gn.metal-48xl, two 300 Gbit cards each, 4 server cores per card · Sources: [UCall Noise cost](https://github.com/unum-cloud/UCall/blob/main/bench/README.md#noise-cost)

[03 · Batching](#batching)

## Client-side batching is not server-side batching.

> Gather requests across clients, answer each on its own.

A client-side batch is one request from one client, which the server must split, dispatch and reassemble. GPU inference and analytical queries want the opposite: many small requests from many clients, computed together.

A batch endpoint gathers independent requests from every connection and every event loop into one queue, closed by size and latency budgets, and the endpoint’s one polling owner, a thread the application picks and the library claims, takes each batch as a counted array. Every request keeps its own reply and transaction boundary, and pipelining lets one client fill a batch while its replies still leave in request order.

### Fig. 3.1: Eleven requests, two model calls

An illustration: a model call costs 120 µs alone, and a batch endpoint takes up to 8 requests and lets none wait past 500 µs. Batched, the model runs for 460 µs instead of 1,320, and the last reply leaves 340 µs sooner.

Six clients send eleven requests. Called once per request, the model runs eleven times for 1,320 microseconds; through a batch endpoint, one batch closes at max_batch_size and one at max_latency_microseconds, so the model runs twice for 460 microseconds and the last reply leaves 340 microseconds sooner.

[04 · Every OS](#backends)

## One state machine on every operating system.

> POSIX, epoll, io_uring, kqueue, IOCP and RIO.

Shared connection automata consume completions and emit I/O requests, so POSIX, Linux epoll with AIO, `io_uring`, macOS and FreeBSD kqueue, and Windows IOCP and Registered I/O drive the same HTTP framing, routing and Noise records. Each CPU class gets its own instantiation of every engine, picked once in the configuration rather than per call.

Header normalization and searches run on [StringZilla](https://www.unum.cloud/docs/stringzilla.md), capability checks and atomics on [ForkUnion](https://www.unum.cloud/docs/forkunion.md), and containers on [SmashTable](https://www.unum.cloud/docs/smashtable.md). One event loop serves one core, and loops add up linearly: across two Graviton4 machines with two 300 Gbit cards each, 8, 16 and 32 server cores serve 1,771,397, 3,707,284 and 7,456,078 pipelined calls a second.

### Fig. 4.1: Seven backends, two ways to wait on the kernel

Readiness backends are poll on POSIX, epoll on Linux and kqueue on macOS and FreeBSD; completion backends are io_uring on Linux 6.12 and 6.18, and IOCP and RIO on Windows.

[05 · Zero copy](#zero-copy)

## Requests read in place, large replies leave without a copy.

> Borrowed views in, zero-copy sends out.

Paths, queries, headers and every multipart part arrive as views into the receive buffer, never copied, so an image or audio decoder reads a part where it landed, and a body whose length the head declares is received in place once it reaches a page. Routing is exact, as in axum and Envoy: literal segments before parameters before a trailing wildcard, a 404 for an unknown path and a 405 with an `allow` list for a wrong verb.

Files leave as byte ranges, read with `O_DIRECT` past the page cache into windows from the loop’s pool, the next window filling while the previous one sends. Replies of a page or more leave through zero-copy sends, and a reply can name the caller’s memory, pinned until the kernel releases it: across two Graviton4 machines, such memory parts cut the server CPU of a 256 KB download from 198.8 to 86.4 µs. Shorter replies and peers on the same host are copied, where a copy costs less than pinning, and under Noise each record seals in place inside its window.

[06 · Questions](#faq)

## Before you swap your web framework

### Protocols

#### Why HTTP/1.1 and not HTTP/2?

HTTP/2 multiplexes streams over one connection and compresses headers with HPACK. Its dynamic decompression tables and the nested state machine of every extended `CONNECT` stream widen the attack surface. UCall gets the throughput through pipelining and [server-side batching](#batching) instead.

#### Why TCP and not QUIC?

A QUIC-like protocol with Noise encryption is a natural fit, and building around UDP has been an ambition at Unum since 2015. TCP and HTTP/1.1 work with every load balancer, proxy and firewall already deployed, so UCall builds on them.

#### When would I prefer WebRTC?

On lossy networks. TCP holds every later packet back until a lost one is retransmitted, while WebRTC DataChannels offer message-oriented delivery with configurable reliability. On reliable networks, there is no noticeable difference.

### Coming from elsewhere

#### What will I miss from FastAPI?

Its ecosystem of plugins for authentication, database integration and OpenAPI schema generation. Typed handlers, path parameters and greedy suffixes carry over, matched [exactly](#zero-copy) as axum and Envoy match them.

#### What if I need TLS?

Deploy UCall behind a reverse proxy such as nginx or Envoy, which terminates TLS and forwards plaintext HTTP over a local interface, a common pattern in production. The [docs](https://www.unum.cloud/docs/ucall.md) carry a deployment template.

#### Which languages can call it?

C, C++, Python, Rust, Go and Mojo, all over one C ABI with the same caller-owned polling threads, on Linux, macOS, FreeBSD and Windows. The C++ SDK is header-only over the C headers.
