国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php做后臺,一個web請求過來了,能否使用多進程或者多線程來處理?
為情所困
為情所困 2017-06-05 11:09:26
0
4
749

都說php不支持多進程,
那這種場景是不是就不適合php了?如果我要更新一千個數(shù)據(jù)的信息,上傳一個sql文件,然后依次執(zhí)行這樣肯定會很慢,能否在代碼里利用pcntl_相關的函數(shù)來實現(xiàn)多進程處理這個請求呢?
http://php.net/manual/zh/intr...

Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.
At least for PHP 5.3.8 which I am using, and who knows how far back, it's not a matter of "should not", it's "can not". Even though I have compiled in PCNTL with --enable-pcntl, it turns out that it only compiles in to the CLI version of PHP, not the Apache module. As a result, I spent many hours trying to track down why function_exists('pcntl_fork') was returning false even though it compiled correctly. It turns out it returns true just fine from the CLI, and only returns false for HTTP requests. The same is true of ALL of the pcntl_*() functions.

這里面說pcnt對http請求無效,只適用再cli模式下,請問大神,php遇到這類場景,如何處理呢?難道就只能借用其他語言來實現(xiàn)么?

為情所困
為情所困

全部回復(4)
過去多啦不再A夢

可以使用隊列或者swoole

伊謝爾倫

PHP可以借助擴展做并發(fā)

PHPzhong

你一個進程去做不就好了。。只有后臺才有這種需求吧。。。一個進程足矣

習慣沉默

不是說不可以,只有你會不會的問題,swoole可以做這個,用協(xié)程并發(fā)性能很好,php雖然不是最好的語言,但也被低估的語言. 多線程不一定好.

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板