Workers spawns jobs without any limit #337
-
Workers seem to spawn jobs without any limit of how many should be run concurrently. This is pretty bad if you have hundreds of thousands of jobs and worker will pull new jobs from active list as fast as backend is configured to check for new jobs. The problematic code is in worker.spawn(fut.map(move |res| {
if let Err(e) = res {
if let Some(ctx) = state.context.as_ref() {
ctx.notify(Worker {
state: Event::Error(e.into()),
id: WorkerId::new_with_instance(
worker_id.name(),
instance,
),
});
};
}
})); Much healthier approach is to limit workers to run just a single job at a time and then expect the user of In the current shape, worker might end up running hundreds or even thousands of jobs concurrently that can have very nasty side-effects. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The key thing to note is that the part you are highlighting is conditional to the service being ready. |
Beta Was this translation helpful? Give feedback.
The key thing to note is that the part you are highlighting is conditional to the service being ready.
This means you can manage concurrency by adding something like
ConcurrencyLayer
.See this comment and thread for a similar conversation.