# Patterns that break on Cloud Run

> What breaks when an app moves to Cloud Run and what replaces it: workers, cron, work after the response, files, sessions, WebSockets, Redis.

<https://exodus.elim.io/blog/topic/patterns>

Code written for a server that never stops often breaks on Cloud Run, where an instance sleeps between requests and keeps nothing on disk. These guides take each pattern in turn: queue workers, timers, work after the response, files and uploads, sessions, long requests, WebSockets, health checks and Redis, and show how to find it in your code and what replaces it.

- [An AI agent backend on Cloud Run: the loop, the stream, the state, and the bill](https://exodus.elim.io/blog/an-ai-agent-backend-on-cloud-run.md): An AI agent's backend on Cloud Run: the model-and-tools loop as a streaming service, sessions in Firestore, keyless access, tools as MCP servers, and why tokens are most of the bill.
- [A SaaS architecture on Cloud Run: tenants, sign-in, data, domains, and the bill as it grows](https://exodus.elim.io/blog/a-saas-architecture-on-cloud-run.md): A SaaS product on Cloud Run: one service and one database, a tenant id on every row under Postgres row security, sign-in, customer domains, and the bill at 5, 50 and 500 customers.
- [Database migrations on Cloud Run: run them as a job, before the deploy](https://exodus.elim.io/blog/database-migrations-as-cloud-run-jobs.md): Cloud Run has no release phase. How to run migrations as a Cloud Run job with the new image before the deploy, write migrations the old revision survives, and pay about a tenth of a cent a run.
- [Do you still need Redis on Cloud Run? Each job it does, what replaces it, and what it costs if it stays](https://exodus.elim.io/blog/do-you-still-need-redis-on-cloud-run.md): A PaaS Redis collects sessions, cache, queue, rate limits and locks; on Cloud Run it is Memorystore billed every hour. How to move each job to Postgres or Cloud Tasks, and when Redis stays.
- [Health checks on Cloud Run: startup, liveness and readiness probes, and what the default one misses](https://exodus.elim.io/blog/health-checks-and-startup-probes.md): Every Cloud Run service gets one TCP check you never set. What it misses, how startup, liveness and readiness probes work, the endpoint behind them, reading results in logs, and the cost.
- [Long requests on Cloud Run: every timeout in the chain, and where long work goes](https://exodus.elim.io/blog/long-requests-and-timeouts.md): A Cloud Run request ends at 5 minutes, 60 at most, and other clocks sit on the way. Which one ends a request, how to find slow ones, and when to raise, stream, or hand the work to a task or job.
- [Node, Python, Rails and Go on Cloud Run: the container and the traps of each stack](https://exodus.elim.io/blog/node-python-rails-and-go-on-cloud-run.md): The container each of Node, Python, Rails and Go needs on Cloud Run, and the traps we reproduced: dropped requests on shutdown, one-at-a-time gunicorn, port 80, and Go's CPU count.
- [Stripe webhooks on Cloud Run: verify, record, queue, answer, and never charge twice](https://exodus.elim.io/blog/stripe-webhooks-on-cloud-run.md): Stripe webhooks on Cloud Run: verify the signature, record the event id, queue a named Cloud Task, answer 200; a private worker does each event once. The traps, catching up after an outage, the cost.
- [Background workers on Cloud Run: Cloud Tasks or a worker pool](https://exodus.elim.io/blog/background-workers-with-cloud-tasks.md): A worker waiting on a Redis queue stalls or bills all day on Cloud Run. How to turn each job into a Cloud Tasks request, with retries, rate limits, costs, and when a worker pool fits better.
- [Cron and timers on Cloud Run: Cloud Scheduler and jobs](https://exodus.elim.io/blog/cron-and-timers-with-cloud-scheduler.md): In-process timers do not fire on an idle Cloud Run app and fire twice on two instances. How to move each to Cloud Scheduler: endpoint or job, service account, run-once handlers, time zones, cost.
- [Files and uploads on Cloud Run: from disk to a Cloud Storage bucket](https://exodus.elim.io/blog/files-and-uploads-with-cloud-storage.md): A Cloud Run instance's disk is memory and dies with the instance. How to move uploads to Cloud Storage with signed URLs, serve downloads, move existing files, and what it costs.
- [Sessions on Cloud Run without Redis: signed cookies and the database you have](https://exodus.elim.io/blog/sessions-without-redis.md): In-memory sessions log people out on Cloud Run. How to use signed cookies with keys in Secret Manager, log out everywhere with one column, when a database table fits, and when Redis is worth it.
- [WebSockets and server-sent events on Cloud Run: timeouts, reconnects, fan-out and the bill](https://exodus.elim.io/blog/websockets-and-sse-on-cloud-run.md): On Cloud Run every open WebSocket or SSE connection is a request: it ends at the timeout, keeps its instance billed, and sees one instance. Timeouts, reconnects, fan-out through Postgres, the cost.
- [Work after the response on Cloud Run: why it stalls and the four ways out](https://exodus.elim.io/blog/work-after-the-response.md): Code that runs after the response gets almost no CPU on a request-billed Cloud Run service. How to find it, and when to finish it in the request, use Cloud Tasks or Pub/Sub, or pay per instance.
- [The patterns that break on Cloud Run, and their replacements](https://exodus.elim.io/blog/patterns-that-break-on-cloud-run.md): Queue workers, work after the response, timers, files on disk, in-memory sessions and open connections: why each breaks on Cloud Run, how to find it, what replaces it and what that costs.
