Skip to content

Cluster.GCP reference

Source: packages/effect-cluster/src/GCP/ComputeEnginePool.ts

Run a pool of Effect Cluster runners on Compute Engine: instances in the database’s VPC, spread across zones, each running every class given these runners from a Cloud Storage bucket, behind a regional load balancer on a static address that serves their gateway to callers anywhere. Runners reach each other and the database through the cluster’s network tag.

The database URL, the gateway token, and every other secret bound into the runners’ environment are kept in Secret Manager secrets of the pool’s own, which only the runners’ service account can read. Instance metadata names their versions, never their values. With a database on no GCP network (Cluster.Database.fromUrl), give the pool its network.

Cloud Run can’t host runners: runners take connections from each other.

ComputeEnginePool: Running on Compute Engine

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

Source: packages/effect-cluster/src/GCP/Database.ts

The database an Effect Cluster coordinates through, on Compute Engine, as a Cluster.Database Layer: Postgres on an instance with a persistent disk, in a VPC of its own that the pool’s runners join. Only the runners reach it; runners reach each other on the runner port.

The Postgres password is kept in a Secret Manager secret of the database’s own, which only its instance’s service account can read. Instance metadata names its version, never its value.

export const Database = ClusterGCP.Database("Cluster");