13 Jan 2018
I have been trying to get Playframework to use memory less than 512MB for a while. The reason for targeting 512MB is because it's the cheapest dyno on Heroku. The 1GB dyno costs twice.
The site is load-tested with ~5QPS for a few days.
With my unscientific approach, I minimize my memory setting to:
-Xms64m -Xmx64m -Xss256k -XX:MaxMetaspaceSize=128m -Xmn32m -XX:SurvivorRatio=2. I don't have understanding why I use these numbers.
However, with the above setting, the memory usage easily exceeds 512MB within several hours.
Then, I stumbled upon Tuning glibc memory behaviour. So, I started experimenting with the value.
MALLOC_ARENA_MAX=4 exceeds 512MB within 20 hours.
MALLOC_ARENA_MAX=2 seems to keep the memory under 512MB with no issue. In fact, the memory usage seems to flat around 470MB. The response time doesn't seem increase at all. So, this setting isn't bad.