SCUA

Backend servers

A backend in one script and one binary.

An HTTP server, actors that run on several cores, and sessions that sleep in storage are part of SCUA. The service behind a game or an app is a script, with no runtime or framework to install on the machine beside it.

serve.scua
import http

fn handle(req)
  if req.method == "GET" and req.path == "/health" then
    return { status = 200, body = b"ok" }
  end
  return { status = 404, body = b"not found" }
end

http.serve(handle, { bind = "127.0.0.1:8080" })?
$ scua --allow-serve=127.0.0.1:8080 serve.scua
scua: serving on http://127.0.0.1:8080/ — 1 worker (8 with SCUA_SCHEDULER=threaded), up to 10000 connections …

HTTP

Serve HTTP from one plain function

http.serve accepts connections, parses requests and frames responses. Your script supplies the handler. Opening a port is its own permission, and the grant names the exact address the script may bind.

Each request runs with its own state, as if in a partition of its own. A handler can wait on a database, another service or a file, and the server answers other requests meanwhile. There is no async and no await, so a function that waits looks like any other function.

  • Streamed responses, for server-sent events and long downloads
  • Streamed uploads, with body limits the server reports
  • A graceful stop that finishes the requests in flight
  • Routing with typed path parameters, from the @scua/web package
Serve HTTP requests →
requests time → 1GET /profile waiting on the database 2GET /health 3POST /score waiting on a service the thread 1 2 3 1 3 A handler that waits steps aside, and the next request runs. Each request has its own state, so they cannot see each other half-way through.
Three requests on one thread. While one waits on a database, the others are answered.

Throughput

Ahead of Bun when the handler does work

HTTP requests answered per second, one threadlonger is better; each group is scaled to its longest bar
A handler that does work (a 20,000-step loop per request)SCUA 0.3546,804 req/sBun 1.4.234,020 req/suWebSockets.js 20.7133,921 req/sNode 2422,382 req/sA fixed 13-byte replyuWebSockets.js 20.71131,080 req/sSCUA 0.35118,631 req/sBun 1.4.2102,729 req/sNode 2440,048 req/s
One sitting on an Intel i7-10700 running Linux, October 2026: wrk over 256 connections from four other cores, the median of three 10-second runs. uWebSockets.js ran on Node 24.

We measured SCUA against the fast JavaScript servers on one machine. The chart is one thread each, which is SCUA's default. Where the handler does real work, a 20,000-step loop per request, SCUA answered the most requests a second, because the JIT compiles the handler from end to end. On a fixed plaintext reply, which measures the server more than the language, SCUA was ahead of Bun and behind uWebSockets.js.

On four threads SCUA was again first on the working handler: 146,210 requests a second, against 113,396 for uWebSockets.js and 106,494 for Bun. The full table is in the 0.35.0 release post.

Concurrency

State lives in actors, so nothing needs a lock

Anything that must last from one request to the next lives in a partition: a counter, a cache, a matchmaking queue, a connection pool. A partition handles one message at a time and its state is private, so two requests cannot corrupt it between them.

Partitions run on several cores by default.

For a batch of independent work, wait_all and map_all run ordinary function calls and give the results back in order, with one failure never cancelling the rest. Under --io=async their waits overlap.

Concurrency in the manual →
reply Cache Request 1 Metrics Match queue Request 2 Session, idle Session, idle ask cache.Get("ana") tell queue.Join("ana") tell metrics.Hit Each partition owns its state and handles one message at a time. Nothing is shared, so nothing is locked.
Two requests and the long-lived partitions they talk to. Each partition owns its state and takes one message at a time.

Idle cost

Idle sessions hold no memory

Most sessions spend most of their life waiting: for the player's next move, the user's next message, a webhook. Keeping a process or a container warm for each one costs memory around the clock.

A SCUA session can be frozen to a blob, dropped from memory and stored as one object. When something arrives for it, the host loads the blob and the session carries on. A thousand idle sessions are a thousand stored objects.

A frozen session wakes into the same script that froze it. State that must survive a code change goes in a typed save, which carries a version and is upgraded by the migrate hooks you write.

Hibernate a session →
One session, over an afternoon time → messages in memory awake awake awake in storage asleep: one stored object asleep: one stored object While it sleeps there is no process and no memory held for it. The script never learns it was frozen, and carries on from where it was.
One session over an afternoon: three short bursts in memory, and the rest of the time asleep as a stored object.

Operations

One file lists everything a service may touch

A service starts with no access. You grant what it needs on the command line or in a permissions file you can review and keep in version control: which folder, which hosts, which environment variables, which address to bind.

A value set to false in that file is a refusal that holds even when somebody runs the program with --allow-all.

  • Secrets print as <secret>, in logs and in error messages
  • --max-mem caps the whole program, actors included
  • --max-ops bounds the work a single turn may do
Handle secrets →
permissions.toml
[capabilities]
fs    = "./data"
net   = ["api.internal", "cdn.example"]
env   = ["PORT", "HOME"]
serve = "127.0.0.1:8080"
$ scua --allow-file=permissions.toml app.scua

What you build it from

The usual parts of a service, already written

Databases

Packages for PostgreSQL and Redis speak the wire protocols over TCP or TLS, with a connection pool. SQLite is bound through the experimental FFI.

Database packages →

Calling other services

An HTTP client and TLS are built in. Packages add OAuth 2.0, JWT, AWS request signing and an OpenAPI client driven by the spec.

Fetch over HTTP →

Money that adds up

decimal values and money literals such as 19.99 USD keep totals exact, in code and in data tables.

Handle money →

An append-only log

A durable log with an optional hash chain, which recovers from a write torn by a crash.

Keep an append-only log →

Config for a fleet

A small table of settings replicated between machines by gossip, so a flag changed on one reaches the rest.

Share config across a cluster →

One file to deploy

The runtime is a single binary. A program, its locked dependencies and its data can be bundled into one .scuapp file.

Ship a tool as one file →

Packages for services

Read how a handler is written

The serving guide starts from the ten-line server above and goes as far as streaming and uploads.