Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite job worker #159

Merged
merged 1 commit into from
Aug 21, 2020
Merged

Rewrite job worker #159

merged 1 commit into from
Aug 21, 2020

Conversation

ChrisKujawa
Copy link
Collaborator

Description

Rewrote job worker completely.

Job Handling

The worker now allows to handle jobs concurrently. Via a new configuration HandlerThreads you can set the thread count, which are used to handle activated jobs. Make sure your given Handler implementation is thread-safe. Per default the HandlerThread is set to 1, to be backwards compatible.

Interaction between Handling and Polling

Fixed some concurrency issues in activating and job handling, which caused that either for a longer time no jobs are polled or not handled or polled to fast. Poll interval are now respected better. It is rewritten in a way that it is now also better testable.

Job Polling

Introducing an threshold activation mechanism, which means that new jobs are only activated after the working queue reaches a threshold of 0.6.

Example:

maxActivationCount = 32
threshold = Ceil(32 * 0.6) = 20

If the maxActivationCount is set to 32, then for first twelve jobs no new jobs are activated. After going under 20 jobs it will poll again for new jobs, based on the work queue (32 - work queue count). This allows to batch better job activation it will reduce the load on the gateway and broker and avoids doing to much requests for a single job activation.

Related issues

closes #133
closes #149

@ChrisKujawa ChrisKujawa requested a review from saig0 August 14, 2020 08:57
@ChrisKujawa ChrisKujawa force-pushed the zell-rewrite-job-worker branch 2 times, most recently from 17ac318 to ab2c670 Compare August 15, 2020 19:04
@ChrisKujawa
Copy link
Collaborator Author

@saig0 do you want and have time to check this?

@saig0
Copy link

saig0 commented Aug 18, 2020

I can have a look. But remember that I have zero C# knowledge 😂

@ChrisKujawa
Copy link
Collaborator Author

Thanks! I think this is fine. It's more about the concept.

Copy link

@saig0 saig0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as far as I can tell 👍

Just one comment on the docs.

Client/Api/Worker/IJobWorkerBuilderStep1.cs Outdated Show resolved Hide resolved
The worker now allows to handle jobs concurrently. Via a new configuration `HandlerThreads` you can set the thread count, which are used to handle activated jobs. Make sure your given Handler implementation is thread-safe. Per default the HandlerThread is set to 1, to be backwards compatible.

Fixed some concurrency issues in activating and job handling, which caused that either for a longer time no jobs are polled or not handled or polled to fast. Poll interval are now respected better. It is rewritten in a way that it is now also better testable.

Introducing an threshold activation mechanism, which means that new jobs are only activated after the working queue reaches a threshold of 0.6.

**Example:**

maxActivationCount = 32
threshold = Ceil(32 * 0.6) = 20

If the maxActivationCount is set to 32, then for first twelve jobs no new jobs are activated. After going under 20 jobs it will poll again for new jobs, based on the work queue (32 - work queue count). This allows to batch better job activation it will reduce the load on the gateway and broker and avoids doing to much requests for a single job activation.

closes #133
closes #149
@ChrisKujawa ChrisKujawa merged commit 81beb4a into master Aug 21, 2020
@ChrisKujawa ChrisKujawa deleted the zell-rewrite-job-worker branch August 21, 2020 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Worker does not long poll correctly maxJobsActive in JobWorker
2 participants