phplaravel-4beanstalkdpheanstalk

Running beanstalkd worker on a remote server


My stack set-up consists of the following

Machine1 - Main Server (Running laravel)
Machine2 - MySql Server for the laravel codebase
Machine3 - Beanstalkd worker

I have setup Supervisord on Machine1 and added the following queue listener

[program:queue1]
command=php artisan queue:listen --queue=queue1 --tries=2
...

My laravel queue config file(app/config/queue.php) reads the following

'beanstalkd' => array(
    'driver' => 'beanstalkd',
    'host'   => '--- Machine3 IP ---',
    'queue'  => 'queue1',
    'ttr'    => 60,
),

And I have installed beanstalkd on Machine3 along with Beanstalk console and can see my tasks being pushed to the queue and executing successfully. However I am not sure if Machine3 is actually executing them, and the reason for my suspicion is the High CPU usage on the main server as compared to no spikes in CPU usage on Machine3

I completely shutdown my beanstalkd Server to check if the queue still processes and the outcome was an error reported by laravel indicating it could not connect to the beanstalkd server.

I read somewhere that you need to have your laravel codebase on the beanstalkd server(Machine3) too, was that really the way to go?


Solution

  • Whichever machine you run queue:listen on is the machine that does the actual processing of the queue.

    At the moment all you are doing is storing the queues on machine3, but processing them on machine1.

    So you need to have machine3 run the queue:listen command if you want it to process the queue.