You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Dennis-Mircea (via GitHub)" <gi...@apache.org> on 2026/04/26 18:05:17 UTC
[PR] [FLINK-39549][flink-autoscaler] Compute OBSERVED_TPR for non-source vertices behind a feature flag [flink-kubernetes-operator]
Dennis-Mircea opened a new pull request, #1103:
URL: https://github.com/apache/flink-kubernetes-operator/pull/1103
<!--
*Thank you very much for contributing to the Apache Flink Kubernetes Operator - we are happy that you want to help us improve the project. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix][docs] Fix typo in event time introduction` or `[hotfix][javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can read more on how we use GitHub Actions for CI [here](https://nightlies.apache.org/flink/flink-kubernetes-operator-docs-main/docs/development/guide/#cicd).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
This pull request extends the autoscaler's *observed* (backpressure-derived) true processing rate computation, currently scoped to source vertices only, to **non-source vertices** as well, behind an opt-in feature flag.
Today, `OBSERVED_TPR` is populated only for sources, and every downstream vertex falls back exclusively to the busy-time based `TRUE_PROCESSING_RATE`. This creates an alignment asymmetry across the job graph: sources may be evaluated using a backpressure-aware capacity model while their downstream operators are evaluated purely from busy-time, which is known to be unreliable under sustained backpressure. When the real bottleneck of the pipeline is downstream, this asymmetry can produce inconsistent or suboptimal scaling decisions on the very vertex that matters most.
This change generalizes the observed-TPR path so that any vertex in the graph can, when locally appropriate conditions are met, be evaluated using the same capacity model as sources. The behavior is fully opt-in, defaults to off, and preserves existing behavior for all current deployments.
## Brief change log
- A new `FlinkMetric.NUM_RECORDS_IN_PER_SEC` is introduced for the task-level `numRecordsInPerSecond` metric used by non-source vertices.
- `ScalingMetricCollector#getFilteredVertexMetricNames` is extended to thread `Configuration` through and, when the new flag is on, **best-effort** request `BACKPRESSURE_TIME_PER_SEC` and `NUM_RECORDS_IN_PER_SEC` for non-source vertices. Missing metrics are silently skipped (never throw `MetricNotFoundException`) so older Flink versions are not broken.
- `ScalingMetrics#computeDataRateMetrics` is split into the existing source path (unchanged) and a new non-source path that computes `OBSERVED_TPR` via a small helper `getNonSourceObservedTpr`. The helper reuses the existing `computeObservedTprWithBackpressure` formula and is gated on a per-vertex **engagement signal**, `(busyTimeMsPerSecond + backPressuredTimeMsPerSecond) / 1000 ≥ engagement-threshold`, which is the per-vertex semantic dual of the source-side "has lag" gate (a vertex that is fully engaged is, by definition, not input-starved by upstream).
- Two new opt-in `AutoScalerOptions`:
- `job.autoscaler.observed-true-processing-rate.non-source.enabled` (default `false`)
- `job.autoscaler.observed-true-processing-rate.non-source.engagement-threshold` (default `0.95`)
- `ScalingMetricEvaluator` is left unchanged: `selectTprMetric` is already vertex-agnostic and naturally picks up `OBSERVED_TPR` for non-sources once it is populated, without any additional wiring or risk.
- Javadoc on `ScalingMetric.OBSERVED_TPR` is updated to reflect the new generality.
- Generated config table (`auto_scaler_configuration.html`) updated with the two new options.
The feature is intentionally scoped tightly: gates remain **local and independent** per vertex (no cross-vertex coupling between source and non-source decisions). Independence is the right primitive here as the local engagement gate already implicitly suppresses non-source observed-TPR when the pipeline is idle, while still allowing it to fire in the most important target case (downstream bottleneck while sources have no lag).
## Verifying this change
This change added tests and can be verified as follows:
- New unit tests in `ScalingMetricsTest` covering the non-source path:
- `testNonSourceObservedTprDisabledByDefault` - flag off ⇒ `OBSERVED_TPR` is never populated for non-sources, even with all metrics present and the vertex fully engaged.
- `testNonSourceObservedTprEnabled` - covers below-threshold (no `OBSERVED_TPR` / fallback to historical avg), engaged with backpressure (formula yields `rate / (1 - bp/1000)`), zero input rate while engaged (`+Infinity`, mirroring source semantics), and the degenerate `bp ≥ 1000ms/s` case.
- `testNonSourceObservedTprCustomEngagementThreshold` - verifies the engagement threshold option is honored.
- `testNonSourceObservedTprMissingMetricsAreSilentlySkipped` - verifies graceful behavior when the deployed Flink version does not expose the per-vertex metrics.
- Existing `ScalingMetricCollectorTest` updated for the new `Configuration` parameter on `getFilteredVertexMetricNames`; existing required-metrics coverage preserved.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changes to the `CustomResourceDescriptors`: no
- Core observer or reconciler logic that is regularly executed: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs & JavaDocs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org