neondatabase / autoscaling

Postgres vertical autoscaling in k8s
Apache License 2.0
157 stars 21 forks source link

We should provide metrics for per-pod resource requests / VM usage #385

Closed sharnoff closed 11 months ago

sharnoff commented 1 year ago

Rationale

There's a few reasons:

  1. The values "VM usage, else pod resources.requests" are used by cluster-autoscaler, and it currently doesn't expose those metrics
  2. The only similar thing we have is what the scheduler has reserved per-node for pods/VMs, which is further from the "ground truth" of what's actually used.
  3. We don't have a way to see the resource usage of VMs

Implementation ideas

I think all these problems can be solved in one go.

My tentative idea is to create a new, separately deployed single-instance-per-cluster component that will expose two metrics for every running pod in the cluster: pod_or_vm_cpu_requests and pod_or_vm_mem_requests (in bytes). Maybe the metrics should be prefixed by the component name, not sure.

These metrics will be defined for each running K8s pod as:

This is what our patched cluster-autoscaler is making decisions with.

The actual implementation should be pretty easy — pkg/util/watch can be used, and the "add"/"update"/"delete" callbacks should be relatively simple as well.

Areas of future work

We might also want to have a separate metric for VM usage that's only present for VMs, so in grafana we can say "VM usage OR regular pod CPU usage" (where pod CPU usage is actually more like

I could equally see this being used to show migrations for each VM. Cluster-wide totals can be derived from the autoscaler-agent's billing metrics (because it tracks the counts for each VM phase), but we don't have anything available per-VM.

Prior issues, discussions:

cc @cicdteam, @arssher as people who may be interested in the outcome of this.

sharnoff commented 1 year ago

This is also related to neondatabase/cloud#6444. From discussion about that, in addition to providing current CPU/memory reserved, it'd be good to also provide minimum and maximum for the VM (probably taking autoscaling.neon.tech/bounds into account?)