packages/server/worker/docs/adr/0001-gcp-cloud-run-is-the-pool-at-concurrency-1.md
We want Activepieces to scale elastically by running the engine on autoscaled GCP Cloud Run instances. The tempting framing is "serverless = a new Runtime with its own cache, its own materializer (download bundles from S3), and the engine talking direct-to-API with no loopback peer." That framing means a second execution code path to build and test forever — the thing we most wanted to avoid.
There is one execution path, packaged as @activepieces/sandbox-pool (sandbox pool + Execution
Cache + materialize + engine spawn, extracted from packages/server/worker). RuntimeKind is LOCAL
or GCP_CLOUD_RUN, and the two modes are the same pool differing only in two injected inputs:
basePath — the cache root, a library parameter. LOCAL passes cwd-relative cache;
GCP_CLOUD_RUN passes its ephemeral-disk mount.concurrency — LOCAL runs N; GCP_CLOUD_RUN runs 1, so Cloud Run autoscales instances
1:1 with concurrent jobs and the instance is itself the tenant-isolation boundary.GCP_CLOUD_RUN is a thin Docker image: an HTTP server that drives the pool's
createExecution → init → run → dispose per pushed job. A warm, pull-based dispatcher stays on our
side and pushes one job per request (Cloud Run autoscales on inbound HTTP, so the puller cannot be the
autoscaled unit).
pieceInstaller ARCHIVE path already does pure
download-and-extract and, for bundleDeps pieces, skips bun install entirely — so feeding the
pool self-contained bundleDeps ARCHIVE bundles from a co-located bucket needs zero new
materializer code.SandboxStrategy seam if cold boot proves to be the bottleneck.socket.io peer even on Cloud Run (localhost); we point apiClient
at the real API rather than rewriting the engine transport. The "direct-to-API, no loopback peer"
ambition in the old types.ts comment is dropped.@activepieces/sandbox-pool; lift the hardcoded cache literal into a
basePath param; the gcp Docker + HTTP wrapper; a publish-time pipeline emitting bundleDeps
ARCHIVE bundles to the co-located bucket (seeded by the #13838 piece-bundle migration CLI); and
the enum rename LOCAL_POOL → LOCAL, GCP_CLOUD_FUNCTION → GCP_CLOUD_RUN.