Durable serverless Cloud Run workers
Run a background worker on Google Cloud Run that survives cold starts and instance restarts by leaning on Resonate's durable runtime.
Python example coming soon.
Problem
Cloud Run gives you automatic scale-to-zero and rapid horizontal scaling, but stateless containers make it hard to run long-lived business logic without relying on external schedulers or compensating transactions.
You also have to handle retries yourself when the platform stops a container mid-workflow or when an upstream dependency hiccups.
Solution
Resonate keeps the workflow state outside of the Cloud Run container so every invocation can pick up where the last one left off. That means you can embrace Cloud Run's serverless model without giving up durability or idempotency.
Each container instance becomes a lightweight worker that reacts to events, resumes pending work, and fans out new tasks as needed.
Quick example
- TypeScript
import { Context, resonate } from "@resonatehq/server";
export function* cloudRunWorker(ctx: Context, jobId: string) {
const result = yield ctx.run(processJob, jobId);
yield ctx.run(writeResult, jobId, result);
}
resonate.register("cloudRunWorker", cloudRunWorker);