3

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?

dylanfa88
  • 65
  • 3
  • 9
  • Hi, I'm trying to do something very similar - using beanstalkd to facilitate communication between two Laravel microservices. Did you need to copy your Job class across the two projects to make this work? Thanks – mils Jun 14 '17 at 05:32

1 Answers1

3

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.

Laurence
  • 58,936
  • 21
  • 171
  • 212
  • So that does imply that I need to have my codebase (or atleast part of it that performs the queued jobs) on **machine3**, but will the jobs pushed by **machine1** be read and executed on **machine3** considering that both of them will be hooked to the same MySql server i.e **machine1**? – dylanfa88 Oct 20 '14 at 12:16
  • 1
    Correct. You should `git pull` your codebase onto **Machine3**. Or if you want, you could have a 'scaled down' version on **Machine3** - but it is usually easier to maintain just the one version. – Laurence Oct 20 '14 at 12:21
  • Yep, will give that a try! thank you for all your help! – dylanfa88 Oct 20 '14 at 12:37
  • So how actually get rid of the two versions of the codebase on two servers? – Epoc Oct 01 '15 at 16:02
  • May be setup some kind of auto-sync between the primary and secondary code bases? – Usama Ejaz Dec 07 '16 at 08:38