Running beanstalkd worker on a remote server

2019-05-14 18:20发布

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?

1条回答
Fickle 薄情
2楼-- · 2019-05-14 18:42

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.

查看更多
登录 后发表回答