Balancing job processing across different users/tenants

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

ความคิดเห็น • 20

  • @prashank
    @prashank 3 ปีที่แล้ว +2

    I think rate limiting the dispatching of jobs onto the queue might be a better option. That will give opportunity to insert other tenant jobs in between any huge batch of jobs. Even releasing a job back onto the queue might be good enough if that puts the job at the end of the FIFO queue.

    • @themsaid
      @themsaid  3 ปีที่แล้ว +1

      Ia gree

  • @giorgijanjulia8280
    @giorgijanjulia8280 4 ปีที่แล้ว +1

    Very intresting ❤️

  • @MommyBethLogan
    @MommyBethLogan 3 ปีที่แล้ว

    hi friend you are now 3,4k congrats and thanks for your super chatter

  • @LasseRafnDk
    @LasseRafnDk 4 ปีที่แล้ว

    Not a fan of the final solution, but I like the idea - Its a good stepping stone into something more! Good thoughts

    • @Maldito011316
      @Maldito011316 4 ปีที่แล้ว

      I'm also not a fan. I posted my idea of a solution here: th-cam.com/video/F16Qw4zAo28/w-d-xo.html&lc=Ugw0RbZ37s0MF4CgArF4AaABAg

  • @davidllopgnahs8574
    @davidllopgnahs8574 4 ปีที่แล้ว

    Very interesting! But since you have a queue per tenant, and you can have like 300+ tenants, how would this be compatible with Laravel Horizon?
    Also, I'm not a big fan of that pick random tenant part, maybe you can check the redis keys to see which tenants have pending jobs? 🤔

    • @themsaid
      @themsaid  4 ปีที่แล้ว

      Agree, you can use something like:
      $tenants = static::tenants ?: Tenant::pluck('id');
      shuffle($tenants);
      As for Horizon. It'll work if your balancing strategy is "none".

    • @davidllopgnahs8574
      @davidllopgnahs8574 4 ปีที่แล้ว +3

      @@themsaid For the picking up tenants I meant something like `Redis::keys('queue:tenant-*')->get()` to check which tenants need to run queues, then the shuffle.
      Could you elaborate more about the horizon stuff? As far as I know, I need to tell horizon an array of queues to listen, but with this approach my queues will be dynamic and more than 300 at the same time

    • @Mrxr00t
      @Mrxr00t 4 ปีที่แล้ว

      @@themsaid good approach thanks. will be very helpful if you can record a video when u have some time to show us how we can use this approach with horizon. I'm also not sure how we can define queues dynamically with current horizon implementation.

  • @twtentertainment4778
    @twtentertainment4778 3 ปีที่แล้ว

    thank you for your super chatter and support for premier of #mommybethlogan

  • @GeorgeBoot
    @GeorgeBoot 4 ปีที่แล้ว

    In the scenario where the queue is empty, won’t this approach basically get into an infinite loop? Since there is no delay between rounds, and say one round takes 25ms to run, it will now do 40 runs/second.

    • @themsaid
      @themsaid  4 ปีที่แล้ว

      I don't see how this would lead to an infinite loop. Each worker loop we pick 5 different queues to look for jobs.

    • @GeorgeBoot
      @GeorgeBoot 4 ปีที่แล้ว

      Mohamed Said yeah sorry, infinite is not correct word here. Meant more in the sense of it will check lots of times/second, butting your db quite hard.

    • @themsaid
      @themsaid  4 ปีที่แล้ว +2

      @@GeorgeBoot That's a good point yes. This is just an example of what you can do, in production I think you'd need to use a Redis list for example and pick from that instead of a DB. Or you can actually have counters that you increment on each dispatch to show you which tenants actually have pending jobs.

  • @lolalinda8807
    @lolalinda8807 3 ปีที่แล้ว

    god bless you ans thanks for your support and super chatter to #mommybethlogan

  • @Maldito011316
    @Maldito011316 4 ปีที่แล้ว

    I don't like this solution. It doesn't seem very elegant to brute-force the database at 0 interval.
    I would propose randomizing only between the tenants that have jobs queued. This way a job is always picked by a worker if the queue is not empty.
    You have the jobs table, why not `DB::table('jobs')->distinct()->pluck('tenant_id')->random()` to randomly get a tenant?
    I don't even think you'd need multiple queues for this.

  • @unomadrid6898
    @unomadrid6898 3 ปีที่แล้ว

    thanks for your support and super chatter of #mommybethlogan

  • @mahmoudkhalil9272
    @mahmoudkhalil9272 4 ปีที่แล้ว +2

    ماتعملنا حاجه عربي يا هندسة أو تعمل نسخه من الفيديو بتعليق عربي .. المحتوى العربي بيفتقد النوع ده من التقنيات المتقدمة والإنجليزى بتاعنا حكومى زى مانت عارف 🤣

  • @louiseandluiekambal3859
    @louiseandluiekambal3859 3 ปีที่แล้ว

    thanks for your super chatter to 3mommybethlogan to premeir