Heroku Scala Support

Last Updated: 11 April 2014

cedar scala

Table of Contents

The Heroku Cedar stack is capable of running a variety of types of Scala applications.

This document describes the general behavior of the Cedar stack as it relates to the recognition and execution of Scala applications. For a more detailed explanation of how to deploy an application, see:

Getting Started with Scala on Heroku


Scala applications are recognized when files matching any of the following patterns are found:

  • /*.sbt
  • /project/*.scala
  • /project/build.properties
  • /.sbt/*.scala

When a deployed application is recognized as a Scala application, Heroku responds with -----> Scala app detected.

$ git push heroku master
-----> Scala app detected

If an application also contains a /conf/application.conf file, a Play 2.0 application is detected and Heroku responds with -----> Play 2.0 app detected. Please see the Heroku Play Support article for more information.

Scala applications that use Maven can be deployed as well, but they will be treated as Java applications, so Heroku Java Support will apply.


The following environment variables will be set:

  • PATH: .sbt_home/bin:/usr/local/bin:/usr/bin:/bin
  • JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops
  • SBT_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops
  • REPO: /app/.sbt_home/.ivy2/cache
  • PORT: HTTP port to which the web process should bind
  • DATABASE_URL: URL of the Heroku Postgres database connection

Resizing dynos does not automatically change JVM memory settings. The JAVA_OPTS config var should be manually adjusted for the JVM.

Adjusting Environment for a Dyno Size

When a new dyno size is selected, the following JAVA_OPTS updates are recommended:

  • 1X: -Xmx384m -Xss512k
  • 2X: -Xms768m -Xmx768m -Xmn192m
  • PX: -Xmx4g -Xms4g -Xmn2g

Monitoring Resource Usage

Additional JVM flags can be used to monitor resource usage in a dyno. The following flags are recommended for monitoring resource usage:

-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+UseConcMarkSweepGC

See the troubleshooting article for more information about tuning a JVM process.

Build behavior

Applications must include a /project/build.properties file with the sbt.version property specifying a release version of SBT 0.11.0 - 0.13.1. SBT release candidates (i.e. RC versions) are not supported.

The Heroku Scala buildpack will run sbt compile stage to build the application. Applications must include a stage task, which performs any tasks needed to prepare an application to be run in-place. For example, Typesafe’s xbst-start-script-plugin adds a stage task to SBT that generates start scripts for an application. To use the plugin, create a /project/build.sbt file containing:

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.5.1")

Clean builds

In some cases, builds need to clean artifacts before compiling. If a clean build is necessary, configure builds to perform clean by setting SBT_CLEAN=true:

$ heroku config:set SBT_CLEAN=true
Setting config vars and restarting example-app... done, v17

All subsequent deploys will use the clean task. To remove the clean task, unset SBT_CLEAN:

$ heroku config:unset SBT_CLEAN
Unsetting SBT_CLEAN and restarting example-app... done, v18

Runtime behavior

By default, Scala applications are launched with start script generated by the xbst-start-script-plugin:

web: target/start -Dhttp.port=$PORT $JAVA_OPTS

If an application is not using the xbst-start-script-plugin or should be launched in a different way, a custom Procfile can be included in the root of the project specifying a different entry for the web process.

JVM Versions

By default, OpenJDK 1.6 is installed with your app. However, you can choose to use a newer JDK by specifying java.runtime.version=1.7 in the system.properties file.

Here’s what a system.properties file looks like:


You can specify 1.6, 1.7, or 1.8 (1.8 is in beta) for Java 6, 7, or 8 (with lambdas), respectively.

The JDK that your app uses will be included in the slug, which will affect your slug size.


A Heroku Postgres starter-tier database add-on is automatically provisioned for Scala applications. This populates the DATABASE_URL environment variable.