Hacker News new | ask | show | jobs
by eminh 4864 days ago
For those interested in doing monitoring outside of the process itself, we run this command every minute via cron

ps -o rss,pid= -U username | sort -k 1 -nr | head -2 | awk -F: '{FS=" ";if ($1>limit*1000) print $2}' limit=`jot -r 1 144 192` | xargs kill -QUIT

It will gracefully kill 2 most memory-consuming unicorn workers above random range of 144-192MB of memory. It proved to be extremely efficient and simple solution to our needs.