Skip to content

Rivet.AWS reference

Source: packages/rivet/src/AWS/Ec2ControlPlane.ts

A Rivet control plane on EC2, as a Rivet.Cluster Layer: instances across Availability Zones, each running the engine container from its user data with a data disk of its own, an S3 bucket for the durable copy of every actor’s data, and an internal Application Load Balancer in front. Callers reach it over HTTPS at a CloudFront address, through a VPC origin, so it needs no domain of your own; nodes in its VPC skip CloudFront. 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 EBS volume, so it outlives the instance it is attached to: a replaced instance mounts the same disk again. Changing the engine image replaces the instances; RivetAWS.EcsControlPlane rolls a new image onto the same instances instead.

Ec2ControlPlane: Running a control plane on EC2

Section titled “Ec2ControlPlane: Running a control plane on EC2”

Three instances

export const Cluster = RivetAWS.Ec2ControlPlane("Rivet");

Larger instances and disks

export const Cluster = RivetAWS.Ec2ControlPlane("Rivet", {
instances: 5,
instanceType: "m7i.large",
diskSize: 100,
});

Source: packages/rivet/src/AWS/Ec2Pool.ts

Run a pool’s nodes on EC2 instances: a pool on the control plane, and one instance per node running a program that hosts every Rivet.DurableObject given this pool. Nodes only connect out to the control plane, so they run in public subnets with no inbound rules: the control plane’s VPC with RivetAWS.Ec2ControlPlane or RivetAWS.EcsControlPlane, and a VPC of the pool’s own with any other control plane.

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

A pool of two instances

export const Cluster = RivetAWS.EcsControlPlane("Rivet");
export const Default = RivetAWS.Ec2Pool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Larger instances

export const Default = RivetAWS.Ec2Pool("Default", { instanceType: "m7i.large" }).pipe(
Layer.provide(Cluster),
);

Source: packages/rivet/src/AWS/EcsControlPlane.ts

A Rivet control plane on ECS, as a Rivet.Cluster Layer, the topology of Rivet’s own AWS guide: EC2 instances across Availability Zones register with an ECS cluster, each with a data disk of its own, and each runs one engine as an ECS service pinned to it with host networking. An S3 bucket holds the durable copy of every actor’s data and an internal Application Load Balancer sits in front. Callers reach it over HTTPS at a CloudFront address, through a VPC origin, so it needs no domain of your own; nodes in its VPC skip CloudFront. A namespace is created for the stage.

Each data disk is its own EBS volume, so it outlives the instance it is attached to. A new engine image rolls out as an ECS deployment onto the same instances, one engine at a time per service.

EcsControlPlane: Running a control plane on ECS

Section titled “EcsControlPlane: Running a control plane on ECS”

Three instances

export const Cluster = RivetAWS.EcsControlPlane("Rivet");

Larger engines

export const Cluster = RivetAWS.EcsControlPlane("Rivet", {
instanceType: "m7i.xlarge",
cpu: 3072,
memory: 12288,
});

Source: packages/rivet/src/AWS/EcsPool.ts

Run a pool’s nodes on ECS Fargate: a pool on the control plane, and an ECS service whose tasks host every Rivet.DurableObject given this pool. Nodes only connect out to the control plane, so they run in public subnets with no load balancer and no inbound rules: the control plane’s VPC with RivetAWS.Ec2ControlPlane, and a VPC of the pool’s own with any other control plane (RivetCloud.ControlPlane, Rivet.ControlPlane).

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

A pool of two nodes

export const Cluster = RivetAWS.Ec2ControlPlane("Rivet");
export const Default = RivetAWS.EcsPool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Larger Graviton nodes

export const Default = RivetAWS.EcsPool("Default", {
cpu: 2048,
memory: 4096,
architecture: "ARM64",
}).pipe(Layer.provide(Cluster));

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

Run Rivet Services on ECS Fargate: the services pool on the control plane, and an ECS service running Rivet’s prebuilt Services node, which hosts Durable Streams and agentOS. Nodes run in the control plane’s VPC with RivetAWS.Ec2ControlPlane, and in a VPC of their own otherwise. They take no inbound traffic: callers reach every stream through the control plane’s gateway, with its token.

ServicesPool: Running Rivet Services on AWS

Section titled “ServicesPool: Running Rivet Services on AWS”
export const Cluster = RivetAWS.Ec2ControlPlane("Rivet");
export const Services = RivetAWS.ServicesPool("Services").pipe(Layer.provide(Cluster));