Restart workers on Memory Limits
Describe you feature request
Currently, in PHP, it allows setting a memory limit per a request. We also have worker scripts that restart based on the number of requests. Inspired by https://externals.io/message/126226, it may make sense to measure memory usage per the limit to handle potential memory leaks.
This needs a few things working together: GOMEMLIMIT for keeping the Go runtime in check, memory_limit ini settings, and the current container/cgroup memory limits (plus current number of threads).
From that, we can derive if a request is going to potentially exceed those limits, we can start a rolling restart of workers before handling the request. If after restarting the workers, and we are still brushing up against the limits, then we can assume there is a memory leak in go and we need to restart the entire process.
Note: this could also be an autoscaling strategy (density vs. speed)
Probably related: https://github.com/caddyserver/caddy/pull/6809
It would also be possible to restart single threads, not sure how safe that is though. Some leaking extensions could hang on shutdown (#1296)