Skip to content

[WIP] Optimize K8s Operator LLAP scaling - #6723

Open
tanishq-chugh wants to merge 1 commit into
apache:masterfrom
tanishq-chugh:k8s-llap-scaling
Open

[WIP] Optimize K8s Operator LLAP scaling#6723
tanishq-chugh wants to merge 1 commit into
apache:masterfrom
tanishq-chugh:k8s-llap-scaling

Conversation

@tanishq-chugh

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

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

This PR updates the Hive Kubernetes Operator autoscaling model and LLAP scaling logic to better distinguish scale-up vs scale-down signals, using additional TezAM/LLAP metrics and a new scaleDownThreshold configuration surfaced through the CRD and Helm chart.

Changes:

  • Introduces scaleDownThreshold to AutoscalingSpec, wires it through CRD + Helm templates/values, and updates component default specs accordingly.
  • Extends JMX exporter configuration to expose new LLAP/TezAM metrics used for scaling decisions.
  • Refactors LLAP scaling strategy to use TezAM pending-task load + LLAP capacity/load signals, and adds a TezAM-metrics cache accessor to the autoscaler.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/util/HiveConfigBuilder.java Adjusts Tez config when LLAP autoscaling is enabled (locality delay override behavior).
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/util/ConfigUtils.java Adds config key constant for LLAP task scheduler locality delay.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/model/spec/TezAmSpec.java Updates default AutoscalingSpec construction to include the new field.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/model/spec/MetastoreSpec.java Updates default AutoscalingSpec construction to include the new field.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/model/spec/LlapSpec.java Updates LLAP + LLAP TezAM autoscaling defaults (including scale-down threshold for LLAP).
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/model/spec/HiveServer2Spec.java Updates default AutoscalingSpec construction to include the new field.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/model/spec/AutoscalingSpec.java Adds scaleDownThreshold with schema/docs and defaulting in the compact constructor.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java Exposes additional LLAP + TezAM metrics via JMX exporter config for autoscaling.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/autoscaling/LlapScalingStrategy.java Reworks LLAP desired-replica computation using Tez pending tasks and LLAP capacity/load signals.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/autoscaling/HiveClusterAutoscaler.java Adds cached TezAM-metrics accessor used by LLAP scaling strategy.
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/autoscaling/ComponentAutoscaler.java Modifies stabilization-window selection logic for LLAP scale-up decisions.
packaging/src/kubernetes/helm/hive-operator/values.yaml Updates LLAP autoscaling defaults (including new scale-down threshold).
packaging/src/kubernetes/helm/hive-operator/templates/hivecluster.yaml Emits scaleDownThreshold into rendered HiveCluster spec.
packaging/src/kubernetes/helm/hive-operator/crds/hiveclusters.hive.apache.org-v1.yml Adds scaleDownThreshold to the CRD schema and updates scaleUpThreshold description text.

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

if (component.startsWith(ConfigUtils.COMPONENT_LLAP + "-")) {
// HS2 sessions activation gate scales up the LLAP pods to atleast 1
// in presence of sessions. Avoid stabilizedMin in this start-up case.
target = currentReplicas == 0 ? clamped : scaleUpWindow.stabilizedMin();
Comment on lines 97 to +101
double queued = pm.metrics().getOrDefault(METRIC_QUEUED, 0.0);
double configured = pm.metrics().getOrDefault(METRIC_CONFIGURED, 0.0);
double available = pm.metrics().getOrDefault(METRIC_AVAILABLE, 0.0);
double busy = queued + configured - available;
totalBusy += busy;
podCount++;
totalLLAPCapacity += pm.metrics().getOrDefault(METRIC_MAX_FREE_SLOTS_CONFIGURED, 0.0);
totalLLAPLoad += queued + configured - available;
* desired = ceil(totalClusterLoad / capacityPerDaemon)
* <p>
* Activation gate: only scale if HS2 has open sessions (prevents zombie scaling).
* Activation gate: only scale if HS2 has open sessions & TezAMs are running DAGs (prevents zombie scaling).
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants