Skip to content

HttpRemoteTaskRunnerV2#18729

Closed
jtuglu1 wants to merge 1 commit into
apache:masterfrom
jtuglu1:http-remote-task-runner-revamp
Closed

HttpRemoteTaskRunnerV2#18729
jtuglu1 wants to merge 1 commit into
apache:masterfrom
jtuglu1:http-remote-task-runner-revamp

Conversation

@jtuglu1

@jtuglu1 jtuglu1 commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

Description

Still a draft.

I've seen on the giant lock in HttpRemoteTaskRunner cause severe performance degradation under heavy load(200-500ms per acquisition with 1000s of activeTasks can slow down the startPendingTasks loop in TaskQueue). This leads to scheduling delays, which leads to more lag, which auto-scales more tasks, ..., etc. The runner also has a few (un)documented races abundant in the code. This overhead also slows down query tasks under load (e.g. MSQE and others) which utilize the scheduler for execution.

I'm attempting a rewrite of this class to optimize for throughput and safety.

Apart from the performance improvements/bug fixes, this will also include some new features:

  • Simpler code. The old task runner had old, legacy ZK references dangling around as well as a pretty complicated scheduling loop.
  • Task priority-based scheduling onto workers (e.g. prioritize realtime tasks for scheduling), follows a simple priority-based fair-queueing policy.

I would ultimately like to make this the default HttpRemoteTaskRunner and have it run in all tests/production clusters, etc. as I think that would help catch more bugs/issues.

Performance Testing

Test results thus far have shown ~100-300ms speed up per task runner operation (add(), etc.). Over 1000s of tasks, this amounts to minutes of delay saved.

Release note


Key changed/added classes in this PR
  • MyFoo
  • OurBar
  • TheirBaz

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@jtuglu1 jtuglu1 changed the title Initial draft of HttpRemoveTaskRunnerV2 HttpRemoveTaskRunnerV2 Nov 8, 2025
@jtuglu1 jtuglu1 changed the title HttpRemoveTaskRunnerV2 HttpRemoteTaskRunnerV2 Nov 8, 2025
@jtuglu1
jtuglu1 force-pushed the http-remote-task-runner-revamp branch 5 times, most recently from b55b58f to 6638117 Compare November 11, 2025 03:13
@jtuglu1
jtuglu1 requested a review from kfaraz November 14, 2025 17:08
@jtuglu1

jtuglu1 commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@kfaraz any thoughts here?

@jtuglu1
jtuglu1 requested review from clintropolis and gianm December 8, 2025 18:28
@jtuglu1

jtuglu1 commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@gianm @clintropolis could I get your thoughts here?

@jtuglu1
jtuglu1 force-pushed the http-remote-task-runner-revamp branch from 6638117 to 00e4680 Compare December 13, 2025 00:35
@jtuglu1
jtuglu1 force-pushed the http-remote-task-runner-revamp branch from 00e4680 to 1fd6e97 Compare December 13, 2025 02:09
@jtuglu1

jtuglu1 commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

Bumping this @kfaraz 🙃.


final String workerHost = workerToAssign.getWorker().getHost();
try {
if (!runTaskOnWorker(taskId, workerHost)) {

@jtuglu1 jtuglu1 Dec 16, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A quick note: @kfaraz I was tempted to place this inside the above .compute() to avoid the race, but given it could be holding the lock for a while (and concurrent hashmap locks a range of keys, not necessarily just the key), I opted to unlock (similar to what the existing runner does). Additionally, if something like a removeWorker callback occurs, I'd prefer to update the state right away, rather than wait for an assignment timeout, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants