A local filesystem path does not establish durability on Cloud Run. Classify each file as packaged input, temporary instance-local work or externally durable state, then define recovery after instance replacement. A library named PersistentClient can persist within a directory while that directory still has an instance-limited lifetime. Deployment configuration, storage backing and rebuild strategy determine the real contract.
Inventory files by the work they support
For a synthetic report worker, separate a packaged search index, a temporary export and a completed downloadable report. The packaged index is versioned with the application image and can be reconstructed from its build inputs. The temporary export can be discarded and retried under its job identity. The completed report needs an explicitly durable destination and authorization policy if users must retrieve it after the worker disappears.
Cloud Run's current documentation distinguishes the writable filesystem and supported storage options, including ephemeral-disk configuration for services. Check launch stage, execution environment, capacity and billing conditions before selecting that option. Ephemeral disk changes the local storage mechanism and capacity contract; it should not be treated as an external durability guarantee across instance replacement.
Cloud Run: service ephemeral-disk configuration and constraints
An instance-replacement worksheet
Give every file class an owner, source of truth, expected lifetime and cleanup rule. A path under data/ may be packaged in the image, created at runtime or mounted from another service. Inspect the container build and deployed volume configuration to know which. Source code opening a directory is insufficient evidence of how the live deployment stores it.
| File class | Source of truth | Replacement behavior |
|---|---|---|
| Packaged search index | Versioned build inputs | Recreate with image |
| Temporary export | Durable job parameters | Regenerate original job |
| Completed report | Explicit durable store | Retrieve same artifact |
| Abandoned temporary files | No user-facing authority | Cleanup within budget |

The table describes a proposed synthetic worker, not a deployed architecture. If the vector index is mutable at runtime, its rebuild inputs and consistency policy need additional design. A packaged read-only index and a user-updated vector store have different requirements even if the same library opens both. Keep the index generation version in metadata so an operator can identify which search corpus an instance uses.
Make completion mean durable completion
Do not mark an export done merely because a local file exists. If the user contract requires later download, completion should follow the durable handoff and any necessary metadata transaction or reconciliation. A failure between object upload and database status update creates a partial state to recover, not a reason to blindly create a second export. Use a stable job and artifact identity across retries.
Proposed export states
queued -> generating locally -> durable upload accepted
-> metadata reconciled -> available
instance lost while generating -> retry original job
instance lost after upload -> reconcile existing artifactBound temporary storage and close files on cancellation. Multiple concurrent jobs can consume the instance budget together even when each job fits individually. Review what counts toward memory or disk limits for the chosen configuration and measure the workload before making capacity claims. Clean temporary files after both successful handoff and rejected work, with a fallback sweep for abandoned operations.
Test replacement instead of only process restart
Use disposable inputs and a controlled service. Generate a temporary file, record its job state, replace the instance and verify the promised recovery. Separately confirm that a completed durable artifact remains accessible through current account authorization. A restart in the same local development directory is not equivalent to a newly created Cloud Run instance and can hide a missing storage contract.
No Cloud Run storage experiment was executed for this article. The inventory is a proposed test plan; a source-level local-directory observation is not proof of deployed durability. Before release, retain build provenance, deployed volume settings, recovery trace and cleanup observations. If the data can be rebuilt, prove the rebuild from versioned inputs. If it cannot, choose and verify an explicit durable service rather than relying on the reassuring name of a local path or client class.
FastAPI background jobs versus task queues
Building UltraFit360: the app, coach portal and shared backend
Bring one API or data workflow and a sanitized failure example for a bounded implementation assessment.
Are local files durable on Cloud Run?
Do not assume so. Classify packaged and temporary instance-local files separately from explicitly durable external storage and test instance replacement.
Does a PersistentClient make its directory durable across instances?
No. Its persistence semantics depend on the directory’s actual deployment storage and lifetime.
When should an export be marked complete?
After the durable handoff and required metadata state are confirmed or reconciled under the product’s retrieval contract.
