Memory Consumption on Heroku

Hey everyone,

We’re running Metabase on Heroku and have a pretty standard setup there. I’m noticing that regardless of application usage, the memory consumption of Metabase is consistently high (screenshot). Notice that this is the case even at times of day where no one is using the application.

This consistently causes generic “Application Errors” when using the application. We’ve had to up our Dynos a few times but memory usage keeps going up.

Any idea if this is normal?
Is there anything else we could be doing aside from throwing more Dynos at it?

Thanks!

We noticed this as well, version 0.29 had it the most, we reverted it back to 0.28 and this helped a bit but what really helped was adjusting the start script to:

if [ -n "$HEROKU" ]; then
    if [ `ulimit -u` = 256 ]; then
        JAVA_OPTS="$JAVA_OPTS -Xmx248m"                    # This seems to be the right amount that prevents the dyno from going over the quota
    fi
    if [ `ulimit -u` = 512 ]; then
        JAVA_OPTS="$JAVA_OPTS -Xmx496m"                    # This seems to be the right amount that prevents the dyno from going over the quota
    fi
    JAVA_OPTS="$JAVA_OPTS -XX:-UseGCOverheadLimit"         # Disable limit to amount of time spent in GC. Better slow than not working at all
    JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"         # ConcMarkSweepGC seems to cause less OOM issues in my testing on low-mem Heroku envs
    JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"   # Not 100% sure this does anything in Java 8 but if it does, we want to enable it
    JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"          # Use 32-bit pointers. Reduces memory usage and GC events
    JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedClassPointers" # Same as above. See also http://blog.leneghan.com/2012/03/reducing-java-memory-usage-and-garbage.html
    echo "I have set a bunch of JAVA_OPTS, they now are:"
    echo $JAVA_OPTS
fi

This changes some java options to also be set on the 2x dyno, and reduced our memory usage.

Are these settings still applicable with the latest metabase version. We're also on a 2x but are maxed out most of the time

You can't use something that has over 5 years in an application today. I would suggest you take a look at how to optimize a Java application in Production