Steps for each task, with programs that run

Each program shown with its output runs in the site's tests against the published package, and must print what the page shows.

Write and test charts

  • Writing chartsA chart's code is JavaScript that reads the actor's variables by name, and your charts compile into one image.
  • Testing your chartsAdvance a simulated clock and see how a WebSocket reacts when a reconnect attempt succeeds or fails.
  • Testing recipesSee examples for testing timers, service replies, and a payment that retries.
  • The quickjs sandboxA chart your users upload runs in a separate engine, where a runaway loop ends in an error.

Connect actors to your code and other hosts

  • I/O processorsA chart asks for outside work by sending an event, and an object of yours answers with another.
  • Invoked servicesA connection opens when a chart enters a state and closes when it leaves.
  • Other systemsAn actor sends to an actor on another machine by its address, over a wire you write.
  • When the actor is not thereChoose, for each kind of actor, what a send does when its target is not running.

Run a host in production

  • Capacity and memoryA started actor takes about 530 bytes on Node.js, and a hibernated one about 120.
  • HibernationTwo million actors ran with at most 1000 in memory and the rest as bytes in a database.
  • MigrationRunning actors move to their chart's next version and keep the state they reached.
  • SnapshotsA host of two million actors copies into a 165 MB snapshot that another process restores.
  • Journal and replayRecord every input your program gives a host, and one loop rebuilds every actor after a crash.
  • Inspecting a hostAsk a running actor which state it is in, and count what each chart has done.
  • TelemetryEach step an actor takes becomes a span in your OpenTelemetry collector.

Run actors in a browser or a Worker

  • In the browserChange one import, and your charts run in a page or a Worker.
  • In a Cloudflare WorkerOne Durable Object holds thousands of actors, and its SQLite storage keeps them across an eviction.