Recommended setup for serving production PHP/Symfony with concurrent requests
alanbasavilbaso
PROOP

a month ago

Hi Railway team,

I'm running a Symfony 7.1 / PHP 8.2 application in production on Railway. My current deploy uses the PHP built-in CLI server via the startCommand in railway.json:

"startCommand": "php bin/console doctrine:migrations:migrate --no-interaction && php -S 0.0.0.0:$PORT -t public"

The issue is that php -S is single-threaded — it handles one request at a time. This is becoming a bottleneck: image uploads, database queries, and outbound calls to third-party APIs (payment processors, email/WhatsApp providers) can block other incoming requests while in flight.

I'd like to move to a proper multi-process setup so the app can serve concurrent requests. What's the recommended approach on Railway?

Specifically:

Is there an official PHP buildpack / Nixpacks provider that sets up nginx + php-fpm (or equivalent) automatically? If so, what's the minimal config I need to switch to it?

If not, is a custom Dockerfile the expected path? Any Railway-recommended base image for PHP + FPM + a reverse proxy in a single container?

Are there Railway-specific considerations around long-running processes, graceful shutdown, signal handling, or health checks I should know when moving away from php -S?

For context: this is a multi-tenant SaaS (appointment booking) with a public-facing booking flow, so concurrency really matters during peak hours. I also have separate services running on Railway for the async messenger worker and a cron daemon — I want to be sure the new setup doesn't affect those.

Any pointers, docs, or example repos would be appreciated.

Thanks!

$20 Bounty

2 Replies

Railway
BOT

a month ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway about 1 month ago


I'd suggest using Railpack or Dockerfile, as Nixpacks is deprecated.

Also, I would recommend moving the migration step to the pre-deploy step.


a month ago

yeah I would not keep php -S for production here. it is fine for dev, but it will bottleneck exactly like you are seeing.

I would do either Dockerfile with nginx + php-fpm, or FrankenPHP/Caddy if you want fewer moving parts. also move:

php bin/console doctrine:migrations:migrate --no-interaction

to a pre-deploy command, not the web start command. web start should basically just start the HTTP worker stack, and migrations should happen once before deploy promotion.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...