简体   繁体   English

php内置开发服务器的最大并发连接数

[英]Max concurrent connections for php's built in development server

I have encountered a problem using php's built in webserver, in that it appears to only allow a single concurrent connection. 我使用php内置的webserver遇到了一个问题,因为它似乎只允许一个并发连接。

I discovered this when testing some concurrent ajax requests which all appeared to complete at the same time. 我在测试一些似乎同时完成的并发ajax请求时发现了这一点。

This isnt a big deal, as i can always fire up apache (which is how i came to above conclusion), but i have gotten used to running php directly from my IDE. 这不是什么大问题,因为我总是可以启动apache(这是我得出的结论),但我已经习惯直接从我的IDE运行php。

Is there any way to increase this, or is it a php limitation? 有没有办法增加这个,还是php限制?

my example code that blocks with the inbuilt server but works fine on apache: 我的示例代码使用内置服务器阻止但在apache上正常工作:

        $.ajax({
            type: "POST",
            url: slow.php,
            data: "",
            success: function(data){
                clearInterval(checkid);
                console.log('slow call finished');
            }
        });

        checkid = setInterval(function(){
            $.get('somefile.txt', function(data){
                console.log('quick call finished');
            });
        },1000);


        //slow.php
        sleep(10);
        echo 'all done';

Quoting from the manual : 引自手册

PHP applications will stall if a request is blocked. 如果请求被阻止,PHP应用程序将停止。

So yes, it's single threaded. 所以是的,它是单线程的。 Also, it's just an aid for development, in practice you'll seldom want to use it anyway as it doesn't support important external technologies like FallbackResource , mod_rewrite and .htaccess which are intertwined with most web projects. 此外,它只是对开发的帮助,实际上你很少想要使用它,因为它不支持重要的外部技术,如FallbackResourcemod_rewrite.htaccess ,它们与大多数Web项目交织在一起。

Modern IDEs like PhpStorm support automatic deployment on save to local and remote testing webservers, which is far more practical in projects larger than a handful of files. 像PhpStorm这样的现代IDE支持在保存到本地和远程测试Web服务器时自动部署 ,这在大于少数文件的项目中更加实用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM