Say I have a Heroku app that is deployed to various different sizes of dynos over time or by different users. How can I reliably determine what size dyno the app is running in? I know that $DYNO
will tell me what the process name is (e.g. web.123
or worker.456
), but none of the Heroku environment vars indicate whether that's a 256MB 1X, 1024MB 2X, or a 6GB PX dyno.
Heroku support provided this answer, which they refused to document because it's a hack, and they intend to provide a reasonable solution in the future.
The only way to do this would be to shell out and call
ulimit -u
to get the max number of tasks. 256 for 1X dynos, 512 for 2X and MAX_SUPPORTED_BY_LINUX for PX.
Bash example:
function dyno_size() {
case $(ulimit -u) in
256)
echo "1X"
;;
512)
echo "2X"
;;
32768)
echo "PX"
;;
*)
echo "unknown"
;;
esac
}