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

Guide for how to use keda to auto scaling #314

Open
hongbo-miao opened this issue Mar 12, 2025 · 6 comments
Open

Guide for how to use keda to auto scaling #314

hongbo-miao opened this issue Mar 12, 2025 · 6 comments

Comments

@hongbo-miao
Copy link

It would be great to provide a guide for how to use Keda to auto scaling.

Currently I have Keda in my Kubernetes cluster. Here is my Trino values.yaml file:

# ...
server:
  workers: 10
  keda:
    enabled: true
    pollingInterval: 30
    cooldownPeriod: 300
    initialCooldownPeriod: 0
    minReplicaCount: 0
    maxReplicaCount: 20
    triggers:
      - type: prometheus
        metricType: Value
        metadata:
          serverAddress: http://hm-mimir-query-frontend.production-hm-mimir.svc:8080/prometheus
          threshold: "1"
          metricName: required_workers
          query: >-
            sum by (service)
            (avg_over_time(trino_execution_ClusterSizeMonitor_RequiredWorkers{service={{ include "trino.fullname" . | quote }}}[5s]))

If I have

jmx:
  enabled: true
  exporter:
    enabled: true

and let Prometheus scrape it and write to Mimir.

Do I still need?

serviceMonitor:
  enabled: true

Sorry I am quite lost. 😞

@nineinchnick
Copy link
Member

Are you using the Prometheus Operator? Then you need the service monitor. I'm not sure if we need a complete guide, or just reference Prometheus docs.

@hongbo-miao
Copy link
Author

hongbo-miao commented Mar 12, 2025

Thanks, @nineinchnick! I believe the ServiceMonitor approach and direct scraping are two different ways to write data to Prometheus, so we might only need one of them (?) Please correct me if I am wrong. Thanks!

jmx:
  enabled: true
  exporter:
    enabled: true
serviceMonitor:
  enabled: false

or

jmx:
  enabled: true
  exporter:
    enabled: false
serviceMonitor:
  enabled: true

@nineinchnick
Copy link
Member

You haven't answered if you're using Prometheus Operator, so I can't recommend you any specific setup.

@hongbo-miao
Copy link
Author

hongbo-miao commented Mar 12, 2025

@nineinchnick
Copy link
Member

ServiceMonitor is used by the Operator to configure Prometheus to scrape metrics from Trino. You need the JMX exporter, so Prometheus can scrape metrics. Trino also exposes JMX metrics as OpenMetrics, so you might not need the exporter, but it might require some extra configuration: https://trino.io/docs/current/admin/openmetrics.html

@luismacosta
Copy link

luismacosta commented Mar 13, 2025

It would be great to provide a guide for how to use Keda to auto scaling.

Currently I have Keda in my Kubernetes cluster. Here is my Trino values.yaml file:

...

server:
workers: 10
keda:
enabled: true
pollingInterval: 30
cooldownPeriod: 300
initialCooldownPeriod: 0
minReplicaCount: 0
maxReplicaCount: 20
triggers:
- type: prometheus
metricType: Value
metadata:
serverAddress: http://hm-mimir-query-frontend.production-hm-mimir.svc:8080/prometheus
threshold: "1"
metricName: required_workers
query: >-
sum by (service)
(avg_over_time(trino_execution_ClusterSizeMonitor_RequiredWorkers{service={{ include "trino.fullname" . | quote }}}[5s]))
If I have

jmx:
  enabled: true
  exporter:
    enabled: true

and let Prometheus scrape it and write to Mimir.

Do I still need?

serviceMonitor:
  enabled: true

Sorry I am quite lost. 😞

I've implemented workers autoscaling based in this https://medium.com/bestsecret-tech/maximize-performance-the-bestsecret-to-scaling-trino-clusters-with-keda-c209efe4a081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants