k3s-io / kine

Run Kubernetes on MySQL, Postgres, sqlite, dqlite, not etcd.
Apache License 2.0
1.56k stars 233 forks source link

Add ability to enable remote profiling using pprof #142

Closed radiohead closed 1 year ago

radiohead commented 1 year ago

What

This PR adds a new flag, which, when enabled, allows for remote profiling using net/http/pprof package, with the handlers mounted to the metrics server.

By default the flag is disabled, to ensure that the change is backwards-compatible.

Why

This allows for ad-hoc and continuous (e.g. using https://pyroscope.io/) profiling, which is useful for finding memory / cpu bottlenecks.

radiohead commented 1 year ago

Hey folks!

We're experimenting using kine with CockroachDB and I've run into OOMs with kine using up to 2GB of RAM in some situations. This seems to be related to https://github.com/k3s-io/kine/issues/87, since kine officially does not support CockroachDB.

That said, I'm looking into ways to improve peak memory usage, but I've noticed that there's no way to do remote profiling, so I've made this small change to enable it.

I've already tested this internally with https://hub.docker.com/repository/docker/radioheads/kine, but I'm happy to provide more info if necessary.