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

AdaptiveServerSelection: Fix timer #9697

Merged
merged 1 commit into from Nov 1, 2022

Conversation

vvivekiyer
Copy link
Contributor

Label = BugFix

ExponentialWeightedMovingAverage class currently uses a Timer to periodically autoDecay the value if there are no updates. We maintain stats for each Server. So if there number of servers are too many, the number JVM threads could blow up.

In this PR we create a ScheduledThreadPoolExecutor with just a single thread. This thread is responsible for processing all the periodic tasks.

@vvivekiyer vvivekiyer marked this pull request as ready for review November 1, 2022 05:31
@vvivekiyer
Copy link
Contributor Author

@dmyang please review.

Copy link

@dmyang dmyang left a comment

Choose a reason for hiding this comment

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

Left a comment on sharing the same executor service. Changes look good to me otherwise. Thanks for addressing this!

private ExecutorService _executorService;

// ScheduledExecutorServer for processing periodic tasks like decay.
private ScheduledExecutorService _periodicTaskExecutor;
Copy link

Choose a reason for hiding this comment

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

Could the periodic tasks share the same executor service by changing the main executor service to a scheduled one? That way the threadpool size can still be modified w/ pinot config

Copy link
Contributor Author

@vvivekiyer vvivekiyer Nov 1, 2022

Choose a reason for hiding this comment

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

The reasoning for not using the same executorService is as follows: The main executor service is responsible for collecting stats about servers. The number of periodic tasks is proportional to the number of servers. And we wouldn't want it to interfere with stats collection - which is critical for making the routing decision.

However, we can have a separate config to control the number of periodic task threads. But I do not see us needing more than 1 thread for this purpose. Let's say, autoDecay window is 30seconds. With 200 severs, we would be generating 2*200 = 400 periodic tasks every 30 seconds. A single thread should be sufficient to process these tasks.

I've also DM'ed you on the Apache Pinot slack channel.

Thoughts?

Copy link

Choose a reason for hiding this comment

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

👍 Thanks for explaining reasoning. That makes sense to me and seems fine to leave as is.

Copy link
Contributor

@siddharthteotia siddharthteotia left a comment

Choose a reason for hiding this comment

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

If needed, we can add the config for number of threads in a separate PR

@siddharthteotia siddharthteotia merged commit 7a93045 into apache:master Nov 1, 2022
@vvivekiyer vvivekiyer deleted the serverSelectionTimer branch November 1, 2022 22:59
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.

None yet

3 participants