Free Java Hosting: Heroku vs OpenShift Comparison

13.05.2015 10:10:09

You can host your custom Java web application with database on your own domain completely for free on Heroku or OpenShift. I have several websites running this way (including this one) up and running for over a year now and I think I gathered enough experience to write a comparison. Note: OpenShift will have soon (june 2015) big upgrade, which might solve some issues.

UPDATE: 7.5.2015 Heroku announced that from July 2015 their free hosting will be severely restricted and practically unusable (idling each 30 minuts and application will have uptime only 18 hours - which means 6 hours mandatory downtime ... which completely destroys their free hosting)

Functionality

Heroku

OpenShift

Number of web. apps

unlimited

3 applications per account.

Server

Tomcat or Jetty, simplest is to deploy a runnable JAR file, which contains an embedded server (Spring Boot), otherwise you need to use Tomcat / Jetty runner. You control server version.

Tomcat / JBoss, you don't have complete control over server version (which is problematic when you run into a bug in this particular version). On the other hand if you don't use Spring Boot, deployment is simpler than in Heroku.

Boot Timeout

Application must start within 60 seconds, otherwise Heroku will kill it. This is especially troublesome when using Spring (Spring singletons are created upon application startup) and when creating database tables based on entites with Hibernate (that's also done upon application startup).

No startup timeout

Idling

If the application doesn't receive request for 1 hour, it will be idled (server will stop). When idled application receives a request, it will start running again. Idling causes severe timeout.

If the application doesn't receive request for 24 hours, it will be idled.

Latest Java Version

Java 8 (latest version)

Java 7 (older version, currently even EOL - End Of Life)

Database

PostgreSQL 9.4 (latest), max. 10 000 rows in all tables together (inside can be anything though, even binary data or JSON objects)

PostgreSQL 9.2 (older version - to be precise right now 2,5 years old), MySQL, MongoDB, unlimited number of rows. Database shares disc with web application, server and other data, together it cannot exceed 1 GB.

Files

You cannot store anything on filesystem, just temporary files which are garanteed to last only during single request.

You can store anything on the filesystem, you just cannot exceed 1 GB of all your data.

Upload web. application

Git, GitHub, DropBox

Git

Custom WAR file

Short answer: no, long answer: currently it's deprecated and doesn't have to work in the future.

Yes, you can create a WAR file any way you like and upload that to OpenShift

Uptime

Heroku will automatically restart your application each day (this will cause annoying timeout)

No automatic restart

Addons

Heroku has lot's of addons (145 addons), but you won't use most of them (or you can use them even without Heroku). Note: Addons are basically external subject's online services and their service can be terminated any time by their authors.

Not much addons (32 addons).

Notes

Working with Heroku is more high-level, you don't have to use only command line for all tasks.

You have to do almost everything from command line.

So should you use Heroku or OpenShift? There's no clear winner, I guess it depends on your web application and requirements.