Rivet Framework Documentation

repository·main·Indexed 26 days ago

https://github.com/rivet-dev/rivet

A framework for building stateful workloads using Actors, providing lightweight processes with in-memory state, automatic persistence, and real-time communication. The ecosystem includes rivet-container-runner for hosting actors via child processes, Depot (a per-database storage engine for SQLite-on-FDB), and Epoxy (a geo-distributed, strongly consistent key-value store using Fast Paxos consensus).

Tokens
235.4K
Snippets
470
Records
1.3K
Agent score
90%

What's inside Rivet

  1. Overview of Rivet Cloud features

    main

    Rivet Cloud provides a managed environment for Rivet Actors with the following capabilities:

    • Global Edge Network: Deploy actors to a global network to reduce latency for real-time applications with automatic scaling.
    • Hybrid Cloud Integration: Works alongside your existing infrastructure on AWS, GCP, Azure, or other providers.
    • Portability: Built on open-source Rivet (Apache 2.0), ensuring no vendor lock-in and full code portability.
    • Enterprise Capabilities:
      • Organizations & Security: Team management and access control.
      • Multi-region Support: Deployment across multiple geographic locations.
      • FoundationDB Backend: Distributed systems with fault tolerance.
      • Observability: Built-in monitoring and debugging tools.
  2. Overview of Rivet Workflows

    main

    Rivet Workflows provides durable execution for TypeScript, built directly into Rivet Actors. It is designed to ensure that workflow progress persists across system crashes, deployments, and restarts.

    Key capabilities include:

    • Resilience: Automatic retries for failed steps and state persistence.
    • Control Flow: Support for sleep, join, race, rollback, human-in-the-loop, and durable loops.
    • Durable Agents: Ability to build AI agents with tool use, human-in-the-loop, and automatic checkpointing (compatible with the AI SDK).
    • Observability: Built-in workflow inspector for debugging.
    • Runtime Support: Runs on Node.js, Bun, and Cloudflare Workers under the Apache 2.0 license.
  3. Overview of rivet-container-runner

    main

    rivet-container-runner is a RivetKit (Rust) serverless app designed to host actors by spawning a child game-server process per actor and proxying Rivet's tunneled HTTP/WebSocket traffic to it.

    Key behaviors:

    • Each child process gets its own port.
    • The process exits when the last actor stops.
    • You can wrap any dedicated server (Unity, Godot, Node.js, etc.) in a container using this binary as the entrypoint to enable Rivet Compute cold-starts and routing.
    • The actor input payload (CBOR-encoded) can override the child command, arguments, and environment variables per actor.
    • WebSocket clients connect at the bare gateway path.
    • Raw HTTP reaches the child under the /request/* prefix on the actor surface.
  4. Overview of Depot storage engine

    main

    Depot is the per-database storage engine for Rivet's SQLite-on-FDB system. It manages FDB-backed durability, branch/fork metadata, restore points, Point-in-Time Recovery (PITR) interval bookkeeping, hot compaction, and FDB cleanup.

    Note on Cold Storage: The Open Source Software (OSS) version of Depot does not include S3-backed cold storage. Any configurations attempting to specify SQLite workflow cold storage are unsupported in the OSS version.

  5. Overview of Epoxy KV Store

    main

    Epoxy is a geo-distributed, strongly consistent key-value (KV) store. It uses a single-decree Fast Paxos consensus protocol that runs independently for each key.

    Key Characteristics

    • Immutability by Default: Keys are immutable by default, which enables zero-network-cost local reads, aggressive caching without invalidation, and idempotent replication.
    • Opt-in Mutability: Mutable overwrite semantics are available for specific workloads, though they require cache invalidation and version-aware changelog catch-up.
    • Single-Decree per Key: Each key has its own independent Paxos instance. This eliminates the need for a shared global log or leader election, allowing any replica to propose for any key at any time.
    • Performance:
      • Fresh keys: Commit in 1 RTT by skipping the Prepare phase and going straight to Accept.
      • Keys with in-flight state: Fall back to classic two-phase Paxos (Prepare + Accept) at 2 RTT.
      • Committed keys: Can be read locally with 0 RTT.
  6. Overview of Gasoline Durable Execution Engine

    main

    Gasoline is the durable execution engine used for persistent tasks in Rivet Engine. It manages long-running processes through Workflows, which can be removed from memory (sleep) when inactive and reloaded from a database when needed.

    Key components include:

    • Workflows: Durable sequences of steps that use history replay to recover state.
    • Activities: Wrappers around native functions that support automatic retries.
    • Signals: Durable communication used for inter-workflow or service-to-workflow interaction.
    • Messages: Ephemeral, "fire-and-forget" communication from workflows to other services.
    • Operations: Thin wrappers for clean interop with the Gasoline ecosystem (Note: Operations cannot be run directly in a workflow body; they must be wrapped in an Activity first).
  7. Overview of the ServerlessWorker API Proposal

    main

    The ServerlessWorker is a proposed Web API (similar to Web Workers) designed to provide stateful serverless functionality. It aims to unify patterns seen in Cloudflare Durable Objects and Rivet Actors. Key characteristics include:

    • Multi-Tenant: Can serve multiple clients simultaneously in real-time.
    • Message-Based: Uses postMessage for communication.
    • Persistent: Workers run indefinitely and can optionally sleep when inactive.
    • Storage: Provides persistent data storage located near the compute for performance.
    • Isolated Execution: Each worker runs in its own isolated environment.
  8. Understand Rivet v2.0 Architecture and Components

    main

    Rivet v2.0 is a library-first architecture designed for building stateful workloads in NodeJS or Bun environments. It is composed of two primary components:

    • RivetKit: The library used for building stateful workloads. The core primitive in RivetKit is the Rivet Actor.
    • Rivet Engine: The orchestration layer used for self-hosting and managing actors at scale.

    Because Rivet is distributed as a library, it integrates directly into your application code via standard npm installation, avoiding external service dependencies and vendor lock-in.