-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix Huge Number of Watches in ZooKeeper #17482
base: master
Are you sure you want to change the base?
Conversation
* Tear down nodeAnnouncer * Remove useless Logger and ExecutorService * Init CuratorListener by lambda * Improve explicit type * Using CuratorMultiTransaction instead of CuratorTransaction * Add @GuardedBy("toAnnounce") for toUpdate field * Improve docs
Ready for review, PTAL @kaijianding @leventov @jihoonson @asdf2014 @gianm |
I did some benchmarking on a single cluster, deploying two druid instances into two namespaces. We can see a lowered memory usage in ZooKeeper after the change. I conducted the benchmark by submitting 5 instances of the IngestionQueryingI ran a python script to conduct 10 groups of queries on the ingested datasources. Each group of queries are repeated 500 times. To simulate a concurrent querying environment, I allocated 9 threads to send these queries. |
Fixes #6647
Description
This PR is built upon #6683 and #9172 and aims to reduce the number of ZooKeeper watch counts.
Fixed Huge Number of Watches in ZooKeeper
The current
Announcer.java
leverages on Apache Curator's PathChildrenCache. In its present form, the announcement mechanism watches the immediate parent of the specified path. This results in all child nodes under the parent path being monitored by the ZooKeeper ensemble, including sibling nodes and children of the specified path. This causes an unnecessarily large number of ZooKeeper watches to be produced.The new
NodeAnnouncer.java
class is simplyAnnouncer.java
but leverages on NodeCache instead to watch a single node during announcement. By eliminating the watches on child nodes, this approach significantly reduces the total number of watch counts in ZooKeeper.Tests conducted on the production server also indicate a decrease in watch counts resulting from this change.
An additional add-on is that while
Announcer.java
is partially replaced in the previous two PRs, this PR replaces all instances ofAnnouncer.java
(See reason below). Should the reviewers feel it is ok to remove the entireAnnouncer
class, I would be happy to do so.The use of the two different announcer classes simultaneously may result in a
KeeperException.NotEmptyException
. This happens when two nodes are sharing the same parent, and since both announcers do not have a full picture of the nodes it is watching, the exception will be thrown when the following occurs:Announcer
removes all of its tracked children nodes.Announcer
tries to remove the parent node.NodeAnnouncer
is still watching one or more child node, the attempt byAnnouncer
in removing the parent node will result in the exception.Documentation
Refactoring
Announceable
class inAnnouncer.java
toAnnounceable.java
.ZKPathsUtils.java
to abstract the retrieval of ZooKeeper path and ZooKeeper node.Release note
Improved: ZooKeeper no longer spins up an unnecessary large number of watches when running realtime tasks.
Key changed/added classes in this PR
Announcer.java
NodeAnnouncer.java
Announceable.java
AnnouncerModule.java
ZKPathsUtils.java
Classes that use NodeAnnouncer in favour of Announcer.java
The following classes have switched to using
NodeAnnouncer.java
instead ofAnnouncer.java
:CuratorDruidNodeAnnouncer.java
WorkerCuratorCoordinator.java
BatchDataSegmentAnnouncer.java
CuratorDataSegmentServerAnnouncer.java
This PR has: