Florent VanDeMoortele
12/29/2025, 4:13 PMMarvin
12/29/2025, 4:13 PMMarvin
12/29/2025, 4:18 PMIfNotPresent pull policy, container startup latency is very low and predictable.
- Kubernetes (GKE) works well but pod scheduling typically adds more latency than Docker on a single VM, and cluster costs are higher than one small VM.
- Vertex AI is great for ML/gpu but has higher startup time and cost.
Recommended setup for “low-cost + no latency”
1) Provision a small GCE VM with Docker
- e2-micro/e2-small is usually enough if your flows are light.
- Authenticate Docker to Artifact Registry:
gcloud auth configure-docker us-docker.pkg.dev
docker pull us-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG>
2) Create a Docker work pool in Prefect Cloud
prefect work-pool create --type docker gce-docker-pool
- In the pool’s Job Variables (UI), set:
- image: us-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG>
- image_pull_policy: IfNotPresent
3) Start the Docker worker on the VM (with concurrency as needed)
prefect worker start --pool gce-docker-pool --limit 2
4) Deploy your flow using your Artifact Registry image
prefect deploy
Notes
- This uses your Docker image built from your Poetry project (pyproject.toml + poetry.lock). Keep doing that during image build so dependencies are deterministic in the container.
- If you ever need private Artifact Registry auth inside the worker, either keep docker logged in (via gcloud auth configure-docker) or configure a Docker registry credentials block in Prefect.
If you can tolerate a few seconds of cold start, the cheapest/most managed option
- Use the Cloud Run v2 worker with your AR image. Expect 3–15s cold start per job; no servers to manage; cost is per execution second.
- Create and start:
prefect work-pool create --type cloud-run my-cloud-run-pool
prefect worker start --pool my-cloud-run-pool
- Deploy with your AR image in prefect.yaml or flow.deploy(...).
Helpful links
- Workers overview: Workers (concepts)
- Docker worker guide: Run with Docker
- Kubernetes worker guide: Run with Kubernetes
- Serverless (Cloud Run) guide: Run serverless (Cloud Run)
- GCP integration and worker guide: Prefect GCP integration and GCP worker guide
- Docker worker reference: prefect_docker.worker
- Cloud Run v2 worker reference: prefect_gcp Cloud Run v2
Clarifying to tailor this:
- How strict is “no latency”? Are 1–2 seconds okay, or do you need sub-second starts?
- What’s your typical flow runtime and frequency? If workloads are sparse, Cloud Run may be cheapest; if frequent or latency-sensitive, the GCE + Docker worker is usually the sweet spot.Florent VanDeMoortele
12/29/2025, 4:21 PMMarvin
12/29/2025, 4:21 PMMarvin
12/29/2025, 4:25 PMprefect work-pool create --type cloud-run-v2 my-crv2-pool
prefect worker start --pool my-crv2-pool
- Push pool (no worker to start):
prefect work-pool create --type cloud-run-v2:push my-crv2-push-pool
Then set required job variables (region, service account, image, credentials) in the pool.
Helpful links
- Workers overview: Workers (concepts)
- Cloud Run v2 worker reference: prefect_gcp Cloud Run v2
- GCP worker guide: GCP worker guide
- Serverless how-to (Cloud Run): Run serverless (Cloud Run)
If your goal is “cheap and no extra latency from Prefect,” cloud-run-v2:push is usually the best fit on Prefect Cloud. It won’t remove Cloud Run’s own cold starts, but it removes the worker polling delay and any idle worker cost.