frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

interface to collect necessary stats for building a k8s readiness probe.

Open travisghansen opened this issue 1 year ago • 10 comments

Describe you feature request

Is your feature request related to a problem? Please describe. I am very new to frankenphp so could certainly have missed something in the docs that allow me to do this.

I am trying to deploy frankenphp to k8s. I would like to sanely configure readiness probes to keep instances from getting overloaded with requests. I think this would predominantly come down to having 2 key metrics:

  • how many of the workers are currently handling a request
  • how many requests are queued up waiting for workers

Additional metrics may be good:

  • avg delay before queued requests are dispatched?

Describe the solution you'd like I would like to have some sort of interface (http, cli that can be invoked, etc) which would export the above and perhaps more. I would then write a script to be executed which would retrieve that info, allow for some threshold of queued requests waiting for a thread, and if above the threshold k8s would stop sending traffic to that instance until things settle a bit.

Ideally the metrics would exclude any requests that are for non-php workers (ie: static files, etc).

Perhaps the caddy admin port already has some of this data?

Describe alternatives you've considered I can have an endpoint in my app, but that seems less than ideal as each check would itself take up a thread/worker.

travisghansen avatar Oct 28 '24 19:10 travisghansen