Skip to content

[improve][broker] Add dedicated partition configuration for system topics to reduce resource usage#23785

Open
zjxxzjwang wants to merge 7 commits intoapache:masterfrom
zjxxzjwang:master-optimizeTheNumberOfPartitionsForAutomaticSystemTopic
Open

[improve][broker] Add dedicated partition configuration for system topics to reduce resource usage#23785
zjxxzjwang wants to merge 7 commits intoapache:masterfrom
zjxxzjwang:master-optimizeTheNumberOfPartitionsForAutomaticSystemTopic

Conversation

@zjxxzjwang
Copy link
Contributor

@zjxxzjwang zjxxzjwang commented Dec 26, 2024

Motivation

The number of partitions for creating system topics depends on the value of the "defaultNumPartitions" configuration field, but this field is also the number of partitions for automatically creating topics. If the value of defaultNumPartitions is set to a large value, the system theme partition is also large, causing resource waste.

Modifications

New "systemTopicDefaultNumPartitions" configuration field, isolation system topic creation and automatically create topic for "defaultNumPartitions" fields of mutual dependence. When metadata is mounted, the system topic and common topic depend on the default partition configuration parameters

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 26, 2024
@zjxxzjwang zjxxzjwang requested a review from dao-jun December 31, 2024 13:17
@HQebupt
Copy link
Contributor

HQebupt commented Jan 3, 2025

LGTM

@HQebupt
Copy link
Contributor

HQebupt commented Jan 3, 2025

/pulsarbot rerun-failure-checks

@lhotari
Copy link
Member

lhotari commented Jan 3, 2025

Please rename the title of this PR since it's currently misleading.

@lhotari
Copy link
Member

lhotari commented Jan 3, 2025

/pulsarbot rerun-failure-checks

@lhotari lhotari changed the title [improve][broker]Optimize the partition size of the system theme to reduce resource consumption [improve][broker] Add dedicated partition configuration for system topics to reduce resource usage Jan 3, 2025
@HQebupt
Copy link
Contributor

HQebupt commented Jan 6, 2025

/pulsarbot rerun-failure-checks

@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.16%. Comparing base (bbc6224) to head (5b52438).
Report is 834 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23785      +/-   ##
============================================
+ Coverage     73.57%   74.16%   +0.59%     
+ Complexity    32624     2376   -30248     
============================================
  Files          1877     1853      -24     
  Lines        139502   143471    +3969     
  Branches      15299    16292     +993     
============================================
+ Hits         102638   106406    +3768     
+ Misses        28908    28675     -233     
- Partials       7956     8390     +434     
Flag Coverage Δ
inttests 26.67% <25.00%> (+2.08%) ⬆️
systests 23.14% <25.00%> (-1.19%) ⬇️
unittests 73.69% <100.00%> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...org/apache/pulsar/broker/ServiceConfiguration.java 98.15% <100.00%> (-1.25%) ⬇️
...rg/apache/pulsar/broker/service/BrokerService.java 84.94% <100.00%> (+4.16%) ⬆️

... and 1019 files with indirect coverage changes

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@zjxxzjwang
Copy link
Contributor Author

@lhotari i,Hello, can you help me review it

@HQebupt
Copy link
Contributor

HQebupt commented Feb 4, 2026

/pulsarbot rerun-failure-checks

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

Please check the review comments. Please ensure that the command line tool pulsar-admin also supports setting the value for the override.

Comment on lines +55 to +62
if (override.getSystemTopicDefaultNumPartitions() == null) {
return ValidateResult.fail(
"[systemTopicDefaultNumPartitions] cannot be null when the type is partitioned.");
}
if (override.getSystemTopicDefaultNumPartitions() <= 0) {
return ValidateResult.fail(
"[systemTopicDefaultNumPartitions] cannot be less than 1 for partition type.");
}
Copy link
Member

Choose a reason for hiding this comment

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

This wouldn't be backwards compatible for existing deployments of Pulsar. Please handle backwards compatibility in some way.

Copy link
Member

Choose a reason for hiding this comment

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

One possible way would be to use defaultNumPartitions in the case that systemTopicDefaultNumPartitions is null or <= 0

dynamic = true,
doc = "Default number of partitions for the system topics."
)
private int systemTopicDefaultNumPartitions = 1;
Copy link
Member

Choose a reason for hiding this comment

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

It would be useful to support existing way where the default number of partitions is determined by defaultNumPartitions, for example setting this value to -1.
For backwards compatibility the default value should be -1 when this change is introduced. We could make the default 1 in master branch for the feature release of Pulsar.

Comment on lines +3735 to +3736
return isSystemTopic(topicName) ? pulsar.getConfiguration().getSystemTopicDefaultNumPartitions()
: pulsar.getConfiguration().getDefaultNumPartitions();
Copy link
Member

Choose a reason for hiding this comment

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

this should check that systemTopicDefaultNumPartitions > 0.

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.

6 participants