zombocom / puma_worker_killer

Automatically restart Puma cluster workers based on max RAM available
747 stars 77 forks source link

Determine better ram default #68

Closed freeformz closed 3 years ago

freeformz commented 5 years ago

FWIW, you can determine the amount of available RAM in MB in a Heroku Dyno (or probably any container that uses cgroups in which that cgroup data is exposed in the container) with:

Integer(Integer(IO.read("/sys/fs/cgroup/memory/memory.limit_in_bytes")) / 1024 / 1024)

The current amount of memory being used by all processes in a dyno can be found in /sys/fs/cgroup/memory/memory.usage_in_bytes. This is only currently exposed in private space dynos though.

schneems commented 5 years ago

oh, that’s useful. Previously I’ve had to map “ulimit” results to different dyno types. This seems better.

oyeanuj commented 4 years ago

@schneems Just checking if this is on your radar to incorporate in this library? Thank you for creating this library!

schneems commented 4 years ago

@oyeanuj want to send me a PR?

oyeanuj commented 4 years ago

Unfortunately, I don't understand Heroku spaces or puma much to be able to PR this. Maybe @freeformz can?

schneems commented 4 years ago

On a standard-1 dyno:

~ $ cat /sys/fs/cgroup/memory/memory.limit_in_bytes
536870912

and 536870912 / 1024 /1024 => 512 so it looks like this is right. I still want to make this the default, but also don't know when i'll have time to work on it.