Skip to content

[ISSUE#311] Improve broker register topicrouter info performance#312

Closed
fuyou001 wants to merge 4 commits intoapache:developfrom
fuyou001:issues-311
Closed

[ISSUE#311] Improve broker register topicrouter info performance#312
fuyou001 wants to merge 4 commits intoapache:developfrom
fuyou001:issues-311

Conversation

@fuyou001
Copy link
Contributor

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

XXXXX

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls
Copy link

coveralls commented May 22, 2018

Coverage Status

Coverage decreased (-0.02%) to 41.385% when pulling 8ce8a54 on fuyou001:issues-311 into c264de9 on apache:develop.

@lizhanhui
Copy link
Contributor

I understand the purpose of this pull request is to combine topic changes and report them all to nameserver in one registration action. The problem is, each time a new topic is registered, data version of topic config increases and needRegister method always returns true, causing active registration immediately, regardless of forceRegister being true or false for registerBrokerAll.

@fuyou001 fuyou001 changed the title #issues-311 improve broker register topicrouter info performance [issues-311] improve broker register topicrouter info performance May 23, 2018
@fuyou001 fuyou001 changed the title [issues-311] improve broker register topicrouter info performance [issues-311] Improve broker register topicrouter info performance May 23, 2018
@fuyou001 fuyou001 changed the title [issues-311] Improve broker register topicrouter info performance [issues#311] Improve broker register topicrouter info performance May 23, 2018
@lizhanhui
Copy link
Contributor

It makes sense now. Good!

@lizhanhui lizhanhui requested a review from dongeforever May 23, 2018 03:43
@fuyou001 fuyou001 changed the title [issues#311] Improve broker register topicrouter info performance [ISSUE#311] Improve broker register topicrouter info performance May 23, 2018
* If set to 0, newly created topics will be immediately reported to name servers and interval of periodical
* registration defaults to 10, 000 in milliseconds.
*/
private int registerNameServerPeriod = 1000 * 30;
Copy link
Member

@vongosling vongosling May 23, 2018

Choose a reason for hiding this comment

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

registerNameServerPeriod is not a good name, maybe aliveCheckInterval is better. Another, do we need to polish here if no changes in a long time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

origin default value

}
}
}, 1000 * 10, 1000 * 30, TimeUnit.MILLISECONDS);
}, 1000 * 10, Math.max(10000, Math.min(brokerConfig.getRegisterNameServerPeriod(), 60000)), TimeUnit.MILLISECONDS);
Copy link
Member

Choose a reason for hiding this comment

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

How do we prove this is a better value, why not other?

Copy link
Contributor

@lizhanhui lizhanhui May 23, 2018

Choose a reason for hiding this comment

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

Name servers will mark the broker as dead and remove routes to this broker if they do not receive registration heartbeat within 2T period. Empirically, brokers should send heartbeats every T moments at most to maintain their aliveness in case of occasional network failure, to tolerate one-time heartbeat loss.

As lite heartbeat mechanism has already been implemented, it's safe to heartbeat more frequently. This is why we allow interval of 10 seconds.

this.brokerController.registerBrokerAll(false, true, true);

if (brokerController.getBrokerConfig().getRegisterNameServerPeriod() == 0) {
this.brokerController.registerBrokerAll(false, true, true);
Copy link
Member

Choose a reason for hiding this comment

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

If could not get the topic route info immediately after the topic is created, this may fail some unit tests and confuse some users.

It may be better to detect if the topic route info is changed, and then decide whether it is necessary to register or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

We may set the interval to 0 to fix unit tests. Purpose of this pull requests is to group changes and register them all periodically. Users are unlikely to administratively create a topic and send messages immediately. IMO, this change won't bring about much confusion. I won't say no if we keep the default value 0 to maintain behavioral consistency between before and after this pull requests.

Copy link
Member

Choose a reason for hiding this comment

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

If creating topic is frequenct, it is better to register the just created topic only. In fact, we do not need to change the register protocol, just do something in preparing heartbeat data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Following your suggestions, name server has to be updated to accept route data delta type of heartbeat. This would force name server upgrade in deployment prior to deployment of brokers having this patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

This results in extra complexities to existing users and deployments.

@vongosling
Copy link
Member

well, Please update your pr template and make your pr description clearly.

@lizhanhui
Copy link
Contributor

This issue is partially merged. In case incremental yet immediate topic registration is required, let's discuss it in a separate thread.

@lizhanhui lizhanhui closed this May 31, 2018
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.

5 participants