How to run multiple working beanstalk using php

Currently, I only run one beanstalk workflow for my project, which processes cron-based jobs and real-time jobs. So, I want to divide it into two workers. One worker is used to track cron-based jobs, and another to track asynchronous jobs in real time. In this way, work efficiency will improve. Anyone can help me with this,

  • How to start and demonize multiple working beanstalk using php?
  • Sample script to handle multiple working beanstalk?

NOTE. I am currently using pheanstalk php lib.

+5
source share
1 answer

With pheanstalk (or other libraries), if you want to accept jobs from multiple queues, just watch them.

$pheanstalk->watch('testtube')
           ->watch('tube2')
           ->watch('tube3');
$pheanstalk->reserve();  // get the next job from any of the tubes (+ 'default')

Regarding worker processing, I'm currently using Supervisord for some very similar scenarios that I want to keep working. Its a python-based daemon, where the script you want to run is listed in a very simple configuration file. (adding more workers literally changes one number and reloads the configuration).

, , running-the-worker. Supervisord script. script PHP, , , ( exit($x)). () 99, script, . , - , , .

+6

All Articles