Search code examples
laravellaravel-9laravel-sail

Can multiple clients connect to a Laravel dev server simultaneously?


I have a Laravel app running locally using ./vendor/bin/sail up. I also have a trivial NodeJS server (running locally as well) that waits 60 seconds on each request and returns dummy data. The Laravel app makes a request to the Node app and becomes unresponsive to client requests until the 60 seconds are up.

Is this a limitation of the Laravel dev server? Is there a setting I'm missing?


Solution

  • Answering my own question.

    Laravel uses php artisan serve underneath sail, which in turn uses the built-in server, which by default "runs only one single-threaded process."

    However, "You can configure the built-in webserver to fork multiple workers in order to test code that requires multiple concurrent requests to the built-in webserver. Set the PHP_CLI_SERVER_WORKERS environment variable to the number of desired workers before starting the server. This is not supported on Windows."

    Adding PHP_CLI_SERVER_WORKERS=5 to my .env file fixed the issue.