Rivet - Stateful Backends. Finally Solved.
Rivet - Stateful Backends. Finally Solved. 图标

Rivet - Stateful Backends. Finally Solved.

rivet.gg

Rivet is a library for long-lived processes with durable state, realtime, and scalability. Easily self-hostable and works with your infrastructure.

收录于 1 年前更新于 1 年前正常收录
Rivet - Stateful Backends. Finally Solved. 网站预览

详细内容

Introducing Live WebSocket Migration and Hibernation

Stateful Backends. Finally Solved.

Rivet is open-source infrastructure for long-lived, in-memory processes called Actors. It's what you reach for when you hit the limitations of HTTP, databases, or queues.

Start Building npm install rivetkit

actor.ts

1import { actor } from "rivetkit";
2
3export const chatRoom = actor({
4  // In-memory, persisted state
5  state: { messages: [] },
6
7  // Type-safe RPC
8  actions: {
9    sendMessage: (c, user, text) => {
10      // High performance writes
11      c.state.messages.push({ user, text });
12
13      // Realtime built-in
14      c.broadcast("newMessage", { user, text });
15    },
16  },
17});

< 1msRead/Write Latency

∞Horizontal Scale

100%Self-Hostable

Apache 2.0Permissive Open-Source

Think in Actors, not just Functions.

What is an Actor?

An Actor is a tiny, isolated server that holds its own data in memory. Unlike a stateless function that forgets everything after it runs, an Actor remembers.

Why use them?

When you need to manage state — like a chat room, user session, or multiplayer document — fetching that data frequently from a database is slow and expensive. Actors combine state and compute, keeping your data in memory in the same place as your application code.

Traditional Serverless

Client

Lambda

External DB

State must be fetched from a remote DB for every request.

High Latency • Connection Limits

Rivet Actor Model

Client

Actor

Compute

In-Mem State

State lives with the compute in memory.

Zero Latency • Realtime • Persistent

How it works

Rivet makes backend development feel like frontend development. Define your state, write your logic, and let Rivet handle the rest.

chat-room.ts

1import{actor}from"rivetkit";

2

3exportconstchatRoom=actor({

4state:{messages:[]},

5

6actions:{

7postMessage:(c,text)=>{

8constmsg={text,at:Date.now()};

9c.state.messages.push(msg);

10

11c.broadcast("newMessage",msg);

12return"sent";

13}

14}

15});

1

Define the Actor

Start by writing an actor template. This will be used to create actors with their own isolated state.

import { actor } from "rivetkit";

export const chatRoom = actor({

});

2

Declare State

Define the shape of your data. This state object is automatically persisted to disk and loaded into memory when the actor wakes up. No database queries needed.

state: { messages: [] },

3

Write Actions

Actions are logic that runs on your actor. They run directly in the actor's memory space with zero network latency to access the state.

actions: {

postMessage: (c, text) => {

}

}

4

Mutate State Directly

Just modify the state variable. Rivet detects the changes and handles the persistence and replication for you.

const msg = { text, at: Date.now() };

c.state.messages.push(msg);

5

Broadcast Realtime Events

Push updates to all connected clients instantly using WebSockets. It's built right into the context object.

c.broadcast("newMessage", msg);

Everything you need for stateful workloads.

Rivet handles the hard parts of distributed systems: scaling, fault tolerance, and realtime. You just write the logic.

01

stateless

stateful

Compute Without Timeouts

Like Lambda, but memory and no timeouts. Your code can run for as long as it needs for use cases like realtime, batch jobs, and so much more.

02

Actor

Compute

State

DB

In-Memory Speed

State lives in the same place as your compute. Reads and writes are in-memory. No cache invalidation, no round-trips.

03

Realtime, Built-in

WebSockets out of the box. Broadcast updates with one line—no extra infrastructure, no pub/sub layer.

04

Zzz

Sleeps When Idle

Actors automatically sleep to save costs and wake instantly on demand. WebSockets stay connected even while sleeping.

05

Resilient by Design

Automatic failover maintain 100% fault tolerance. Your actors survive crashes and upgrades.

06

OR

VA

FRA

SG

Multi-Region

Deploy actors across regions worldwide. Compute and state live together at the edge, delivering ultra-low latency responses — something stateless edge runtimes can't match.

Stack Agnostic.

Rivet actors are just standard TypeScript. They run in Docker, connect via WebSockets, and integrate effortlessly with your existing stack.

Infrastructure

Vercel Cloudflare Railway Kubernetes AWS GCP Hetzner VM

Frameworks

React Next.js Svelte Hono Express Elysia tRPC

Runtimes

Node.js Bun Deno Cloudflare Workers

Tools

Vitest Pino AI SDK OpenAPI AsyncAPI TypeDoc

Rivet Inspector Dashboard

Built-In Observability

Powerful debugging and monitoring tools that work seamlessly from local development to production at scale.

Visit The Inspector Watch Demo

Live State Inspection

View and edit your actor state in real-time as messages are sent and processed

Network Inspector

Monitor active connections with state and parameters for each client

Event Monitoring

See all events happening in your actor in real-time and track every state change and action as it happens

REPL

Debug your actor in real-time by calling actions, subscribing to events, and interacting directly with your code

Build anything stateful.

If it needs to remember something, it belongs in an Actor.

AI Agent\
\
Build AI assistants with persistent conversation history and tool calling
Chat Room\
\
Real-time messaging with automatic state persistence and broadcasting
Collaborative Canvas\
\
Real-time cursor tracking and collaborative text placement across users
Stream Processing\
\
Track top values from streaming data with real-time updates
Background Jobs\
\
Scheduled reminders and recurring tasks with automatic state persistence
Multi-Region\
\
Multi-region game rooms with player tracking and regional deployment
Realtime Events\
\
Real-time cursor synchronization with connection state and broadcasting
Native WebSockets\
\
Raw WebSocket handling with low-level connection management
Cross-Actor Actions\
\
Coordinate multiple actors for inventory management and checkout workflows

Deploy your way.

Start with the open-source binary on your laptop. Scale with Rivet Cloud. Go hybrid when you need total control over data residency.

Self-Host

Deploy as a single Rust binary or Docker container. Works with your existing Postgres, file system, or FoundationDB. Easy-to-use dashboard included.

$docker run -p 6420:6420 rivetkit/engine

View Self-Hosting Docs

Rivet Cloud

The fully managed actor platform. We handle the orchestration, monitoring, and edge routing. You just connect your compute and go.

  • Global Edge Network
  • Scales Seamlessly
  • Connects To Your Cloud

Sign Up

Open Source

Built in Rust for performance and safety. Fully open source under Apache 2.0. Audit the code, contribute features, and hack it as you'd like.

$git clone https://github.com/rivet-dev/rivet

$cd rivet

$cargo run -p rivet-engine

View on GitHub

Performance in every act — thanks to Rivet Actors.

Stateful backends, zero infrastructure.

Deploy globally. Scale on demand.

Start Building Talk to an Engineer


网站信息

官网地址
https://rivet.gg/
域名
rivet.gg
收录路径
rivet