I'm maintaining an already built system. The current system operates as following:

Current situation:

  1. Client (UI) submits a request.
  2. Web layer round-robins to one of backends.
  3. Backend takes request and handles.
  4. Backend can spend millis / seconds / minutes on request depending on which job it was asked to do.

so let's say

  • train-model global cluster limit - 4 (large task) limitation by shared resource like db.
  • generate-model global cluster limit - 8 (large task) limitation by shared resource like db.

My plan:

I want to do the least amount of work and make this system more resilient, meaning it would not loose and fail jobs and timeout.

  1. Every job is first placed inside a queue, for multitanency a queue per each customer.
  2. Backends take jobs from queue according to their capacity.
  3. Each time a backend takes a job it takes it from the "next" customer queue to be fare among them.


  1. If cluster already handles 4 train-model (cluster wide limit) I cannot take more long running tasks.
  2. This means that even if I have split my queue into long running tasks and short running tasks (2 queues for each customer instead of one) this would mean I would not consume also tasks from the long running queue tasks because one of the type of long running tasks there reached the global cluster capacity (like db is fully utilized shared resource).

Now if I then decide to take the train and have a queue for it because of it's hard global cluster limitation I would have

  1. train-queue (heavy task)
  2. generate-queue (heavy task)
  3. short-queue (lightweight task).

So if I have hit the top ceiling of 4 trains per cluster I would take pull out tasks from the other 2 queues, the problem is that if i have now many tasks in the generate-queue and short-queue queues i then will starve the train-queue, wouldn't i?

Is there any well known pattern to deal with it?

*Note: I cannot change the whole architecture like to introduce yarn/spark, the system is already built and coded in a way I can only change how I route the requests. When I rewrite it, I will, but now no-rewrite. All jobs are in-process, meaning, it's not spawning new processes. (simple java nio and some multithreading).

  • 1
    This is pretty common software in HPC environments. So you might want to research the operating principles behind these, particularly the ones marked as job schedulers. Cluster software. – Kasey Speakman Dec 15 '17 at 19:31
  • @KaseySpeakman thanks, good idea I will! as a side note, I canno't stop a job once it started meaning, i cannot freeze it and then get back to it, will check if HPC have to deal with that as well. – Jas Dec 16 '17 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.