Compute

Run a WebAssembly program as a device on your VPC.

Compute is for the small network services you would otherwise park on a spare box. You register a WebAssembly program, give it Ethernet interfaces on your VPCs, and it handles the frames that reach it. Between events it does not run at all.

Programs and processes

There are two resources. A Program is a WebAssembly module you register once, through the console's file picker or the API. We check it at registration, and when it passes it becomes Ready. A Process is one program plus Ethernet interfaces on your VPCs and its own allowance of memory and processor time.

kind: Program
metadata: {name: reflector}
spec: {module: <the .wasm file, base64>}   # or pick the file in the console
---
kind: Process
metadata: {name: echo}
spec:
  programRef: {name: reflector}
  interfaces: [{name: eth0, vpcRef: {name: lan}}]

Every interface gets a MAC and the addresses of its VPC, and shows up as a device of that VPC, so the rest of the network sees the process like any other member. It answers frames from the members of its VPC, and it reaches only its VPCs. Memory comes in powers of two from 64 KiB upwards, and processor time is a share of a core.

A process sees raw frames, which means it can be any network service on its VPC and speak any protocol it likes. It also means the program brings the stack it needs, TCP and TLS included. Our Rust SDK has TCP, and a program built with it answers ping6 and TCP. The developer docs have a guide to writing a program.

A program never changes after registration. Its digest is its identity, so a new version is a new Program. To roll it out you point the process at the new one, and the process begins a new life with only its saved state carried over.

What happens between events

An event wakes a process, it runs one activation, and it stops again. Most of the time the event is a frame on one of its interfaces. How much of the process survives until the next event depends on its residency.

ResidencyBetween events
Ephemeral (default)No instance exists. Each activation starts a fresh instance and loads the saved state.
ResidentThe instance and its memory are kept between activations on its node, so a program can hold connections and protocol state in memory.

Ephemeral is the default because an idle ephemeral process has no instance and no memory, so it uses no processor. Nothing stays in memory, though. Whatever has to last goes into the saved state, which can be up to 1 MiB, and it is saved only when an activation succeeds. A failed activation changes nothing. If your program needs to keep connection state between activations, run it as resident.

Letting a resident process sleep

A resident process can hibernate. We write its memory as a snapshot into a Storage bucket of the same project and release the instance. When it resumes, it comes back with the same MAC and addresses. Set desiredState: Hibernated to park it yourself, or set hibernation.idleAfterSeconds and it goes to sleep on its own once no unicast frame has been addressed to it for that long.

An open TCP connection survives this. Hibernate a process in the middle of one, restore it, and the same connection carries on. The peer just sees a pause.

What wakes a process that sleeps by itselfDetail
A Wake-on-LAN frameEtherType 0x0842, from a member of the same VPC.
A UDP magic packetOver IPv6, port 7 or 9.
An ordinary connectionTo the address of the process. The first packets are held (16 frames, 2 s) and the first SYN may be retransmitted after about a second.
A request through the APIspec.wake.requestedAt. The process wakes about 30 s after the request.

With wake.mode: none, a sleeping process ignores wake frames and neighbour solicitations.

Limits

PropertyValue
ProgramA core WebAssembly module, up to 256 KiB. It imports only Etorm's host interface: no files, no sockets, no wall clock, no threads.
Memory per process64 KiB × 2 to the power memoryPower, 0 to 12, default 4 (1 MiB). 256 MiB is the cap for every process.
Processor per processcpuMillicores 1 to 1000, default 100: thousandths of a core on average.
Interfaces, buckets8 and 4 per process.
config64 entries, 16 KiB of keys and values together. It is visible to everyone who can read the Process, so it is not for secrets.
Saved stateUp to 1 MiB, default 64 KiB.
FramesA queue of 256 frames per interface; frames beyond it are dropped and counted. Sending is limited to 2 000 frames a second sustained per interface.
One activationAt most 1 000 slices of work, about a second of processor time. Beyond that it is ended with reason ActivationTooLong.
HibernationResident processes only. idleAfterSeconds is 0 (off) or 30 to 86 400. A snapshot is taken between activations.
PlacementA process runs on one machine and stays there.
NetworkA process reaches only its VPCs.

When an activation or a node fails

An activation can end badly: the program traps, or it runs into its memory or processor limit. The activation ends and its state changes are thrown away. The process stays Ready, with the condition LastActivationFailed so you can see it happened. A resident process also loses its instance, and its next activation is a new life.

If the node restarts, a resident process's memory is gone and it begins a new life with its saved state only. The events of an activation that was in progress are lost, the same way a frame gets lost on a wire. Since a process stays on the machine it was placed on, write your program so that anything it cannot afford to lose is in the saved state.

The architecture page covers Compute in more depth.

Request access