--- title: Fly description: Run a Rivet control plane on Fly Machines and pools of nodes on a Fly Service. --- Host your Durable Objects on Fly.io, and the control plane runs on Fly Machines with a volume each, behind the App's `fly.dev` address. Each pool is a private Fly Service, and any Fly Service calls the rooms by name. ```typescript title="src/cluster.ts" import * as RivetFly from "@alchemy.run/rivet/Fly"; import * as Layer from "effect/Layer"; export const Cluster = RivetFly.MachineControlPlane("Rivet"); export const Default = RivetFly.MachinePool("Default").pipe(Layer.provide(Cluster)); ``` Install `@alchemy.run/fly` and finish [Fly setup](/fly/setup). ## The control plane You get three engine Machines, each with a volume, sharing a Tigris bucket. The App's `fly.dev` address is the endpoint. ```typescript title="src/cluster.ts" export const Cluster = RivetFly.MachineControlPlane("Rivet", { region: "fra", guest: { cpus: 4, memoryMb: 8192 }, diskSize: 50, }); ``` ## The pool ```typescript title="src/cluster.ts" export const Default = RivetFly.MachinePool("Default", { replicas: 2, region: "fra" }).pipe( Layer.provide(Cluster), ); ``` The pool has no public address. ## Rivet Services `ServicesPool` runs [Rivet Services](/rivet/durable-streams) on Fly Machines that take no traffic from Fly's proxy: ```typescript title="src/cluster.ts" export const Services = RivetFly.ServicesPool("Services").pipe(Layer.provide(Cluster)); ``` ## Call it from a Fly Service ```typescript title="src/api.ts" export default class Api extends Fly.Service()( "Api", { main: import.meta.url }, Effect.gen(function* () { const rooms = yield* Room; return { fetch: Effect.gen(function* () { const visitors = yield* rooms.getByName("lobby").join(); return yield* HttpServerResponse.json({ visitors }); }), }; }), ) {} ``` Every option, with its default, is in the reference: [MachineControlPlane](/providers/rivet/fly#machinecontrolplane), [MachinePool](/providers/rivet/fly#machinepool) and [ServicesPool](/providers/rivet/fly#servicespool).