Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
369 views
in Technique[技术] by (71.8m points)

(semi) rate limited queue with priority for 100% resource utilization

I'm working on a api that will make it possible for different users to queue up jobs for processing, and need a algorithm to make sure that one user doesn't hog up all the resources. This would be easily solved with a round robin queue between the users, but there's one more problem... Some users will have higher priority than others, capped at a certain jobs / minute. How can I design this in a way that doesn't make the priority users totally block the other users and at the same time allow the queue to be processed faster than the rate limits on the users if possible.

The main problem I have is that it would be easy to cap all the users to their rate limits, but that would cause artificial waiting times as the system is usually able to keep up with regular loads. So the algorithm needs to allow users to surpass their rate limit during low load.

TLDR:

  • need a queue algorithm
  • 2 different priority users, high prio users should take priority
  • high prio users should only take priority until their rate limit is reached
  • algorithm must allow users to surpass their rate limit if there are resources to spare (no use to idle the CPU, better to process everything as fast as possible)
  • no single user can be allowed to block the whole queue for the rest of the users
question from:https://stackoverflow.com/questions/65916833/semi-rate-limited-queue-with-priority-for-100-resource-utilization

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...