Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding worker autoscaling support with KEDA #277

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

sdaberdaku
Copy link
Member

No description provided.

@cla-bot cla-bot bot added the cla-signed label Dec 13, 2024
@sdaberdaku
Copy link
Member Author

For some reason, the trino_execution_resourcegroups_InternalResourceGroup_RunningQueries JMX metric is not exposed by Trino 446. It is by versions 435 and by 467. My KEDA test starts with 0 worker replicas. Then, a query on TPCH is launched on the coordinator, which increases this value from 0 to 1 and triggers the creation of a worker pod. Unfortunately, queries that are submitted when no workers are available enter a state of "WAITING_FOR_RESOUCES" which is not blocked nor queued.

@nineinchnick I am open to suggestions for a better metric or testing strategy.

@sdaberdaku sdaberdaku force-pushed the feature/add-keda-support branch 2 times, most recently from 35dc778 to b9dcd3b Compare December 14, 2024 18:20
@sdaberdaku sdaberdaku marked this pull request as ready for review December 14, 2024 18:31
@sdaberdaku sdaberdaku force-pushed the feature/add-keda-support branch 2 times, most recently from 52c79e9 to 757de90 Compare December 15, 2024 13:00
@sdaberdaku
Copy link
Member Author

I found the trino_execution_ClusterSizeMonitor_RequiredWorkers metric that works with all versions of Trino and allows us to test scaling up from 0 workers.

I am also wondering if the Chart should support the creation of TriggerAuthentication objects to cover the cases when Prometheus requires authentication. One could always create this object outside the chart and reference it in the ScaledObject trigger, so it is not mandatory. What is blocking me is how to implement the trigger - TriggerAuthentication assignment. One TriggerAuthentication can be referenced by multiple triggers. Naming also needs to be deterministic, since the trigger needs to reference the TriggerAuthentication object by name. I could "inject" the {{ Release.Name }} prefix to these objects, but I don't like it very much.

Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

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

First pass, I haven't yet checked all the new properties.

charts/trino/values.yaml Outdated Show resolved Hide resolved
tests/trino/test-values.yaml Show resolved Hide resolved
@sdaberdaku sdaberdaku force-pushed the feature/add-keda-support branch from 757de90 to d20836f Compare December 21, 2024 16:19
Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

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

Are there any other popular autoscalers for Kubernetes? I see this just creates the ScaledObject resource. What's the value in including this in the Trino chart? How hard is to manage this as an add-on, for example using an umbrella chart?

charts/trino/templates/tests/test-connection.yaml Outdated Show resolved Hide resolved
charts/trino/values.yaml Show resolved Hide resolved
charts/trino/templates/configmap-coordinator.yaml Outdated Show resolved Hide resolved
charts/trino/templates/autoscaler.yaml Outdated Show resolved Hide resolved
@sdaberdaku
Copy link
Member Author

Are there any other popular autoscalers for Kubernetes?

I am not aware of other open-source Kubernetes autoscalers for Pods/Jobs.

I see this just creates the ScaledObject resource. What's the value in including this in the Trino chart?

KEDA allows for scaling worker Pods down to zero replicas when the cluster is unused, and to me this is a pretty interesting feature that cannot be achieved with vanilla HPA.

How hard is to manage this as an add-on, for example using an umbrella chart?

It is definitely doable, I am currently managing it with Kustomize and ArgoCD. One pain point in having to do this outside of the Chart is that I cannot remove the spec.replicas field in the worker deployment and keep the HPA disabled (as discussed here: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#replicas, this field should not be set when using horizontal scaling). Moreover, I have to explicitly configure ArgoCD so that it ignores this particular field so that it does not try to reconcile it.

@sdaberdaku sdaberdaku force-pushed the feature/add-keda-support branch from d20836f to 30756e8 Compare January 11, 2025 17:48
@nineinchnick nineinchnick added enhancement New feature or request breaking-change Potentially breaking changes that require user action. Will be highlighted in release notes. labels Feb 10, 2025
@nineinchnick
Copy link
Member

I added the breaking-change label, because installations which were relying on server.workers=0 now also need to set coordinator.config.nodeScheduler.includeCoordinator=true.

@nineinchnick nineinchnick merged commit d1cd051 into trinodb:main Feb 10, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Potentially breaking changes that require user action. Will be highlighted in release notes. cla-signed enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants