Skip to content

[feature](fe) Add meta service RPC rate limit dry-run mode - #66940

Open
mymeiyi wants to merge 1 commit into
apache:masterfrom
mymeiyi:fe-enable-rpc-limiter
Open

[feature](fe) Add meta service RPC rate limit dry-run mode#66940
mymeiyi wants to merge 1 commit into
apache:masterfrom
mymeiyi:fe-enable-rpc-limiter

Conversation

@mymeiyi

@mymeiyi mymeiyi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Enabling FE-side meta service RPC rate limiting immediately waits for or rejects requests, so operators cannot evaluate whether the configured limits fit production traffic first.
Add a dry-run mode that evaluates the shared rate limiter and reports would-wait and would-reject decisions without delaying or rejecting RPCs.

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Enabling FE-side meta service RPC rate limiting immediately waits for or rejects requests, so operators cannot evaluate whether the configured limits fit production traffic first. Add a dry-run mode that evaluates the shared rate limiter and reports would-wait and would-reject decisions without delaying or rejecting RPCs. Enable rate limit evaluation and dry-run mode by default so deployments collect observations before enforcement.

### Release note

Add meta_service_rpc_rate_limit_dry_run and enable FE meta service RPC rate limit dry-run evaluation by default.

### Check List (For Author)

- Test: Unit tests added but not run, as requested
- Behavior changed: Yes, rate limit evaluation and dry-run reporting are enabled by default without enforcing limits
- Does this need documentation: No
Copilot AI lite review requested due to automatic review settings August 19, 2026 07:37
@mymeiyi
mymeiyi requested a review from gavinchou as a code owner August 19, 2026 07:37
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@mymeiyi

mymeiyi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a “dry-run” mode to the FE meta service RPC rate limiter so operators can observe would-wait / would-reject outcomes (via logs/metrics) without actually delaying or rejecting RPC traffic. This fits into Doris FE cloud-mode meta service client behavior and its operational observability (CloudMetrics).

Changes:

  • Introduces meta_service_rpc_rate_limit_dry_run and uses it in MetaServiceRpcRateLimiter.acquire() to bypass waiting/rejecting while still reporting outcomes.
  • Adds new CloudMetrics for dry-run would-reject counts and would-wait latency histograms.
  • Extends existing FE tests to cover dry-run behavior and ensures test helpers explicitly disable dry-run when needed.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fe/fe-core/src/main/java/org/apache/doris/cloud/rpc/MetaServiceRpcRateLimiter.java Adds dry-run branches for would-reject / would-wait reporting without enforcement.
fe/fe-core/src/main/java/org/apache/doris/metric/CloudMetrics.java Registers new per-method + aggregate counters and per-method histogram for dry-run rate-limit observations.
fe/fe-common/src/main/java/org/apache/doris/common/Config.java Adds the new dry-run config flag and adjusts rate-limit-related defaults.
fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceRpcRateLimiterTest.java Adds tests validating dry-run does not reject or wait.
fe/fe-core/src/test/java/org/apache/doris/cloud/rpc/MetaServiceProxyTest.java Ensures tests save/restore the new dry-run config and keep rate limiting disabled by default within tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ConfField(mutable = true, description = "Whether to only evaluate and report meta service RPC rate limits "
+ "without waiting or rejecting requests. This takes effect only when meta service RPC rate limiting "
+ "is enabled.")
public static boolean meta_service_rpc_rate_limit_dry_run = true;

@ConfField(mutable = true, description = "Whether to enable QPS rate limit for RPC requests to meta service.")
public static boolean meta_service_rpc_rate_limit_enabled = false;
public static boolean meta_service_rpc_rate_limit_enabled = true;
@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review context preparation failed before Codex ran; inspect the 'Prepare authoritative PR context and required AGENTS guides' step.
Workflow run: https://github.com/apache/doris/actions/runs/32228859946

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

boolean dryRun = Config.meta_service_rpc_rate_limit_dry_run;
if (nanosToWait < 0) {
if (dryRun) {
if (MetricRepo.isInit && Config.isCloudMode()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why should we check Config.isCloudMode() in a cloud context object MetaServiceRpcRateLimiter?
the cloud check is redundant?

CloudMetrics.META_SERVICE_RPC_ALL_RATE_LIMIT_DRY_RUN_REJECTED.increase(1L);
CloudMetrics.META_SERVICE_RPC_RATE_LIMIT_DRY_RUN_REJECTED.getOrAdd(methodName).increase(1L);
}
LOG.debug("meta service rpc rate limiter dry run would reject request, method: {}, permits: {}, "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

better check if (debug enabled) first, because it may be a hot path.

Comment on lines +75 to +76
CloudMetrics.META_SERVICE_RPC_ALL_RATE_LIMIT_DRY_RUN_REJECTED.increase(1L);
CloudMetrics.META_SERVICE_RPC_RATE_LIMIT_DRY_RUN_REJECTED.getOrAdd(methodName).increase(1L);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the metrics should always be recorded if it is throttled
the meta_service_rpc_rate_limit_dry_run is used to return 0 instead of throw error only.


long waitMs = TimeUnit.NANOSECONDS.toMillis(nanosToWait);
if (dryRun) {
if (MetricRepo.isInit && Config.isCloudMode()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

public static AutoMappedMetric<LongCounterMetric> META_SERVICE_RPC_TOTAL;
public static AutoMappedMetric<LongCounterMetric> META_SERVICE_RPC_FAILED;
public static AutoMappedMetric<LongCounterMetric> META_SERVICE_RPC_RATE_LIMITED;
public static AutoMappedMetric<LongCounterMetric> META_SERVICE_RPC_RATE_LIMIT_DRY_RUN_REJECTED;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the name should not contains dryrun, because when we are not running in dry run mode, the throttled metrics should be recorded too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if there are metrics record throttled request, reuse them, so there are no more new metrics should be added

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.

4 participants