Download the PHP package jayesbe/php-process-executive without Composer
On this page you can find all versions of the php package jayesbe/php-process-executive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jayesbe/php-process-executive
More information about jayesbe/php-process-executive
Files in jayesbe/php-process-executive
Package php-process-executive
Short Description Control execution of script in child processes
License MIT
Homepage https://github.com/jayesbe/php-process-executive
Informations about the package php-process-executive
php-process-executive
Execute forked processing easily.
Features
- Execute many concurrent child processes keeping the parent process clean.
- Execute as a daemon to keep the parent process alive. Combine with CRON and supervisor for an effective and lightweight PHP Daemon.
Requirements
- Process Control (PCNTL)
Installation
In order to install php-process-executive you need the PHP Process Control Extension.
On Ubuntu
Open a command console and execute the following command to install PCNTL:
Usage
Here is a sample implementation of a Symfony2 Command using ProcessExecutive
Notes
Doctrine is known to continually increase memory in a CLI environment. Its recommended to use PDO. However if you really want to use Doctrine, the only efficient way is to make sure that memory is cleared out when youre done with it. We have been utilizing this same code for the past two years in production. We use it for a variety of applications in both single run and daemonized modes. We use it for both Symfony 1 / Doctrine 1 and Symfony 2 / Doctrine 2 with the same results. A parent process that doesn't move when it comes to memory consumption and cpu usage. We also combine our execution with 'nice' which allows us to control the process priority of the parent and child processes executed.
for example, the above Symfony2 Command can be run as
The performance will be based on how much work your child processes do and potentially how often they hit the disk. Vary the getMaxProcess() return value between 1, 2, 4, 8 or more to see how much you can eak out of it.
The above Symfony2 Command is perfect to compare timing.
for example, on a simple i5 with 4GB of available memor, creating 100 users with:
2 processes
4 processes
8 processes
Most importantly is memory consumption. The above Symfony2 Command results in a parent process that consumes 40 MB of memory and does not move. The process can run indefinitely without chewing up all the memory in the system.
LEGAL DISCLAIMER
This software is published under the MIT License, which states that:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.