[FLINK-39938] FLIP-586: Composable Parallelism Alignment Modes for Flink Autoscaler#1088
Merged
Merged
Conversation
e5fcdc6 to
7a57985
Compare
702edaf to
bc46d0d
Compare
gyfora
requested changes
Jun 25, 2026
gyfora
left a comment
Contributor
There was a problem hiding this comment.
Looks nice overall, but. a lot of code and new interfaces so let's take it a step at a time :)
gyfora
approved these changes
Jul 2, 2026
bc455b2 to
5d082a4
Compare
5d082a4 to
f0f61a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
The autoscaler currently hard-codes how it aligns a vertex's computed parallelism to the number of key groups or source partitions, using a single boolean adjust mode and an inline two-phase search inside
JobVertexScaler. This change replaces that with a small set of named, composable alignment modes and an extensible plugin SPI, so the behavior is easy to reason about and operators can plug in their own alignment strategy without forking the autoscaler. Deployments that pinned the deprecated adjust mode keep their exact previous behavior, including theScalingLimitedevent.Brief change log
org.apache.flink.autoscaler.alignmentpackage: the@ExperimentalAlignmentModeSPI (anisApplicablegate plus analignmethod),AlignmentContext(a plain immutable inputs object exposing parallelism, partitions, ship strategies, the autoscaler context, evaluated metrics, topology, and a per-mode configuration),BuiltInAlignmentMode(BALANCEDdefault,EVENLY_SPREAD,OFF), the deprecatedKeyGroupOrPartitionsAdjustModethat preserves the old blocking behavior, andParallelismAlignerwhich holds the shared per-direction region search, the terminal fallbacks, mode resolution, and event emission.JobVertexScalerso it no longer hard-codes the source/keyBy gate or the two-phase search. It now computes the clamped target parallelism and delegates toParallelismAligner, which resolves the configured mode and applies it (or keeps the target when the mode does not apply).scaling.alignment.modeoption (defaultBALANCED), plus the per-modescaling.alignment.mode.<name>.classandscaling.alignment.mode.<name>.<parameter>keys. The oldscaling.key-group.partitions.adjust.modeis deprecated, retained for backward compatibility, and superseded by the new option.ServiceLoaderin the standalone autoscaler and Flink'sPluginManagerin the operator, selected by name and class.AutoscalerFactoryin the operator,StandaloneAutoscalerEntrypointin standalone) throughScalingExecutorintoJobVertexScaler.plugins.mdand its Chinese mirror, and regenerated the autoscaler configuration reference.Verifying this change
This change added tests and can be verified as follows:
AlignmentModeTestcovers the built-in single-region search per scaling direction, the keep-the-target fallback, the legacy blocking behavior with itsScalingLimitedevent, applicability gating for non source / non keyBy vertices, and mode resolution (built-in by name, custom by class, deprecated key migration, and the default).JobVertexScalerTestpins the deprecated legacy mode so every existing tuple reproduces the previous behavior exactly.ServiceLoader, and the operator test packages a custom mode into a plugin JAR and loads it viaPluginManager.ConfigOptionsDocsCompletenessITCase.Does this pull request potentially affect one of the following parts:
CustomResourceDescriptors: noDocumentation