How to control the speed of performing a job
See original GitHub issueI need to make a request to an API, but the API limits the speed of requests to 10 per sec. when the redis queue A has 1000 jobs called jobB to perform, how to control the speed of performing the job, or performing it at a constant speed, e.g. 10 jobs per second.
const jobs = {
jobB: {
plugins: ["JobLock"],
pluginOptions: {
JobLock: {}
},
perform: async (a, b) => {
// request a api
}
}
};
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to Get an Employee to Work Faster
Confront them with data on how they are slow compared to others. · Leave it all to them to make changes to their...
Read more >5 Ways to Speed Up Employee Work Execution | Smartsheet
Start by listening. Sit down with the employee and ask how they feel about the pace of their performance. Focus on listening to...
Read more >How To Work Faster (With Tips and Examples) | Indeed.com
1. Use a timer while you work ... You can use a timer or a stopwatch to track how long you work on...
Read more >4 Ways to Speed Up Your Productivity and Work - Cflow
1. Sharpen your focus: ... Narrowing down your focus on work-related stuff helps in increasing productivity. Steering clear from distractions and ...
Read more >Speed Up Your Productivity By Slowing Down Your Work Habits
Here's a better strategy: Work slowly. Yes, you should tackle your in-box aggressively. But from a place of stillness that you must consciously ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @evershy can you provide me with your final RateLimit version? Thanks a lot and best regards Henning
At a quick glance that looks a good stat! Be sure to write some tests for it.
There’s a race condition you can get into where you read the key (it has a value of 9) and by the time you write back to it, another worker has started the 10th job before this worker did. You can use
watch
to prevent this - https://redis.io/topics/transactions#optimistic-locking-using-check-and-setHere’s an example of the node-resque scheduler using watch to precent a command if someone else changes the key https://github.com/actionhero/node-resque/blob/master/src/core/scheduler.ts#L268-L280