Skip to content
Can Railway Serverless services use persistent volumes safely?
dilson123-tech
OP

a month ago

Hello Railway Support,

We have a production FastAPI application running on Railway Hobby, using Railpack and Python 3.12.

The application currently has Serverless (App Sleeping) enabled and uses PostgreSQL with its own persistent volume.

We need to add a separate persistent volume to store legal case attachments at:

/backend/storage/case_attachments

Before making any production changes, could you please confirm:

  1. Are persistent volumes compatible with Serverless (App Sleeping)?
  2. If not, must we disable Serverless before attaching the volume?
  3. Will attaching a new volume trigger a redeployment or downtime?
  4. Can we safely mount the volume at /backend/storage/case_attachments?
  5. Are there any permissions or configuration requirements we should consider?

Our priority is preventing document loss and preserving existing PostgreSQL data.

We have not made any changes yet.

Thank you!

Solved

1 Reply

Railway
BOT

a month ago

Yes, volumes work with Serverless, so you don't need to disable it. The volume stays attached while the service sleeps, and the service wakes with the same volume and data.

Attaching the volume triggers a redeploy, because a volume only takes effect on a new deployment. Expect a short gap during that redeploy, and during every later redeploy too: only one deployment can have a volume mounted at a time, even with a healthcheck. Your PostgreSQL service and its volume are separate and aren't affected. Each service can have only one volume, and replicas can't be used with volumes.

The app sees exactly the absolute path you mount. Railpack places your code in /app. If your code writes storage/case_attachments relative to /app/backend, mount at /app/backend/storage/case_attachments rather than /backend/.... Pick the path that matches where your code actually writes. Files written during the build or by a pre-deploy command won't land on the volume, since it's only mounted when the app starts. Volumes mount as root, so if your process runs as a non-root user, set RAILWAY_RUN_UID=0. More detail is in Using Volumes.

New builds are currently paused for all workspaces (incident). Running services aren't affected, but you may want to wait until builds resume before making this change.


Status changed to Awaiting User Response Railway • about 1 month ago


Railway
BOT

22 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway • 22 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...