英文:
Can multiple clients connect to a Laravel dev server simultaneously?
问题
这可能是 Laravel 开发服务器的限制。我是否有遗漏的设置?
英文:
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?
答案1
得分: 1
Laravel使用sail
底层使用php artisan serve
,而php artisan serve
又使用内置服务器,默认情况下“仅运行一个单线程进程”。
然而,“您可以配置内置的Web服务器以分叉多个工作进程,以便测试需要对内置Web服务器进行多个并发请求的代码。在启动服务器之前,将PHP_CLI_SERVER_WORKERS
环境变量设置为所需工作进程的数量。此功能不支持Windows。”
将PHP_CLI_SERVER_WORKERS=5
添加到我的.env
文件中解决了问题。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论