Skip to content

Rivet.GCP reference

Source: packages/rivet/src/GCP/CloudRunPool.ts

Run a pool’s nodes on a Cloud Run worker pool: a pool on the control plane, and a worker pool whose instances host every Rivet.DurableObject given this pool. Worker pools serve no requests and keep a fixed number of instances running, which is what a node is: it only connects out to the control plane. Works with any control plane it can reach — RivetGCP.ComputeEngineControlPlane, RivetCloud.ControlPlane, or one on another cloud.

Every Durable Object given the same pool shares its nodes: declare the pool once and provide it to each class.

CloudRunPool: Running Durable Objects on Cloud Run

Section titled “CloudRunPool: Running Durable Objects on Cloud Run”
export const Cluster = RivetGCP.ComputeEngineControlPlane("Rivet");
export const Default = RivetGCP.CloudRunPool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Source: packages/rivet/src/GCP/ComputeEngineControlPlane.ts

A Rivet control plane on Compute Engine, as a Rivet.Cluster Layer: instances across zones, each running the engine container with a persistent disk of its own, a Cloud Storage bucket for the durable copy of every actor’s data (reached as the instances’ own service account), and a Cloud Run service in front. Callers reach it over HTTPS at the service’s run.app address, so it needs no domain of your own; the service proxies to the engines through a Serverless VPC Access connector, and the engines take no traffic from outside their network. Instances find each other through the bucket and talk on a private port only they can reach. A namespace is created for the stage.

Each data disk is its own resource, so it outlives the instance it is attached to: a replaced instance mounts the same disk again.

ComputeEngineControlPlane: Running a control plane on GCP

Section titled “ComputeEngineControlPlane: Running a control plane on GCP”

Three instances

export const Cluster = RivetGCP.ComputeEngineControlPlane("Rivet");

Larger instances and disks

export const Cluster = RivetGCP.ComputeEngineControlPlane("Rivet", {
machineType: "n2-standard-4",
diskSize: 100,
});

Source: packages/rivet/src/GCP/ComputeEnginePool.ts

Run a pool’s nodes on Compute Engine: a pool on the control plane, and Container-Optimized OS instances across zones that each run every Rivet.DurableObject given this pool in a Node container. The node program sits in a Cloud Storage bucket the instances read as their own service account; a deploy that changes it, or the nodes’ env, restarts the container on every instance in place.

Nodes only connect out to the control plane, so no inbound traffic reaches them, and the pool works with any control plane it can reach — RivetGCP.ComputeEngineControlPlane, RivetCloud.ControlPlane, or one on another cloud. On a RivetGCP.ComputeEngineControlPlane the nodes join its network.

ComputeEnginePool: Running Durable Objects on Compute Engine

Section titled “ComputeEnginePool: Running Durable Objects on Compute Engine”
export const Cluster = RivetGCP.ComputeEngineControlPlane("Rivet");
export const Default = RivetGCP.ComputeEnginePool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Source: packages/rivet/src/GCP/ServicesPool.ts

Run Rivet Services on a Cloud Run worker pool: the services pool on the control plane, and a worker pool running Rivet’s prebuilt Services node, which hosts Durable Streams and agentOS. Worker pools serve no requests and only connect out to the control plane: callers reach every stream through its gateway, with its token. Works with any control plane it can reach.

ServicesPool: Running Rivet Services on GCP

Section titled “ServicesPool: Running Rivet Services on GCP”
export const Cluster = RivetGCP.ComputeEngineControlPlane("Rivet");
export const Services = RivetGCP.ServicesPool("Services").pipe(Layer.provide(Cluster));