Giter Club home page Giter Club logo

Comments (4)

dusterio avatar dusterio commented on July 22, 2024
  1. There are at least two points – first of all, you get a single point of configuration. All scheduled tasks are in PHP code, compiled using a convenient fluent API. If you use cron.yaml – you need to duplicate the same information (which tasks and when) for AWS and non-AWS environments.

And secondly, scheduled tasks are quasi-evenly distributed among instances. AWS will fire a /worker/schedule event every minute but it will be pushed to SQS queue and processed by a single EC2/EB instance. If you put it in your cron.yaml manually, either all instances will run the same task at the same time or you will have to look for a workaround/hack to make one of the instances a 'leader'. While there are solutions for this, they look way more complicated and uglier.

  1. With AWS Elastic Beanstalk, every worker has a special job queue. You could just put any job directly into the queue and one of the instances of your cloud will process that job. Scheduled tasks are kind of a wrapper for 'real' jobs.

  2. My code doesn't handle jobs - your application should :) My package is an interface between AWS and Laravel (or Lumen) - that's it, nothing more. It will make your standard scheduling and queuing tools work.

from laravel-aws-worker.

Hoya avatar Hoya commented on July 22, 2024

I understand that it might make sense when you're trying to implement AWS + non-AWS.

I might not be fully understanding the correct way to use your code but my goal and understanding is that multiple Laravel instances should be able to send queues via SQS to a single worker(Elastic Beanstalk Worker)for processing.

If that is the case, the single worker would need to be able to "listen" for new SQS messages, which is impossible on Elastic Beanstalk worker instances. The only option that I can think of is running Artisan::call('queue:work'); continuously using cron.yaml. My understanding was that your code would provide an alternative way of listening to SQS messages.

from laravel-aws-worker.

dusterio avatar dusterio commented on July 22, 2024

That is correct - my code is indeed providing an alternative way. It goes in the direction of least resistance - I'm relying upon Amazon sqsd to parse the queue and deliver the jobs. Laravel will simply receive a ready-to-deserialize payload.

It's a very important detail that using this package - you are pretty much guaranteed that each task (be it a scheduled task or a queued task) will be processed by one instance only.

If you run supervisor or regular cron inside of your worker (and some people do) - you will have to manage that manually, yourself.

If you put every scheduled task in cron.yaml - you lose a little bit of readability and opportunity to test on local machine using 'php artisan schedule:run'. This part is subjective, it's a matter of taste I suppose. I just like Laravel's scheduling API more than cron.yaml syntax so I would rather compose tasks there.

PS. It's always a hybrid AWS and non-AWS environment – I doubt there are developers who run local or development environments in Elastic Beanstalk, that would be awful :)

from laravel-aws-worker.

Hoya avatar Hoya commented on July 22, 2024

Thanks so much for the explanation, it looks like I was a bit confused as to how SQS and EB Worker functioned together, everything seems to be working out as I expected!

from laravel-aws-worker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.