Parallel processing in PHP - How do you do it?

后端 未结 8 2111
礼貌的吻别
礼貌的吻别 2020-12-01 00:00

I am currently trying to implement a job queue in php. The queue will then be processed as a batch job and should be able to process some jobs in parallel.

I already

相关标签:
8条回答
  • 2020-12-01 00:41

    I prefer exec() and gearman. exec() is easy and no connection and less memory consuming. gearman should need a socket connection and the worker should take some memory. But gearman is more flexible and faster than exec(). And the most important is that it can deploy the worker in other server. If the work is time and resource consuming. I'm using gearman in my current project.

    0 讨论(0)
  • 2020-12-01 00:43

    First of all, this answer is based on the linux OS env. Yet another pecl extension is parallel,you can install it by issuing pecl install parallel,but it has some prerequisities:

    1. Installing ZTS(Zend Thread safety) Build PHP 7.2+ version
    2. if you build this extension by source, you should check the php.ini like config file,then add extension=parallel.so to it

    then see the full example gist :https://gist.github.com/krakjoe/0ee02b887288720d9b785c9f947f3a0a or the php official site url:https://www.php.net/manual/en/book.parallel.php

    0 讨论(0)
提交回复
热议问题