3

I have a Laravel app that does video processing. I am currently doing the encoding in the same server. Now, I want to create 3 more servers to do the "encoding" in parallel in multiple servers.

Is this possible multiple servers doing the same queue?

          --- Server 1 

My App -- --- Server 2

          --- Server 3

These Server 1, 2, 3 only run "encoding" task.

The job class would look something like:

class MyJob implements ShouldQueue {

   // use traits
  
   private $video;

   public function __construct($video) {
      $this->video = $video;
   }

   public function handle() {
       // Encode Video and save

       $this->video->update([
          'processed_at' => now()
       ]);
   }
}

I'd appreciate any answer or if there are any resources on this topic.

For this do I need a separate database server and cache server?

senty
  • 12,385
  • 28
  • 130
  • 260
  • I faced a similar challenge and given up on the idea as it meant deploying the full app on all servers, see a [similar question here](https://stackoverflow.com/questions/38032919/laravel-job-dispatched-on-one-server-handled-on-another). In short all job classes need to exist on all nodes and the changes kept in sync. See the comment by @Atraketur in the accepted answer. – Alex Andrei Nov 18 '20 at 12:25
  • I'm okay with uploading the full app on all servers (I control them in sync via [i2cssh](https://github.com/wouterdebie/i2cssh)). But I couldn't find any tutorial/walkthrough on how to set it up. Did you find any? – senty Nov 18 '20 at 12:31
  • nope, and also I hit the realization of needing 3 horizon instances, couldn't figure out how to manage a distributed set-up like this, but it [seems possible](https://github.com/laravel/horizon/issues/158) – Alex Andrei Nov 21 '20 at 19:44

0 Answers0