-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
With just a few task clients it's no big deal, but with a very large number of TaskClient's running, the CPU hit on Redis of all the clients checking for jobs continuously with no delay, because the queue is empty, is quite noticeable. What are your thoughts if I added a configurable Thread.sleep(nodatasleep) if info==null?
I started up a ridiculous number of TaskClients (~1800 instances spread across 18 VM's) as a test, and saw Redis start consuming 50% of the CPU :D
private async Task ExecuteQueuedTask()
{
var (json, info) = await TaskQueue.SafeDequeue();
if (info != null)
{
LogTaskStarted(info);
try
{
var now = DateTime.Now;
await info.ExecuteTask();
var completionSeconds = (DateTime.Now - now).TotalSeconds;
LogTaskFinished(info, completionSeconds);
}
catch (Exception e)
{
LogTaskException(info, e);
}
} else { // some kind of sleep code would go here I guess
}
}
Metadata
Metadata
Assignees
Labels
No labels