Pushing Large Java based Applications to the CloudFoundry
search cancel

Pushing Large Java based Applications to the CloudFoundry

book

Article ID: 294587

calendar_today

Updated On:

Products

Services Suite

Issue/Introduction

When pushing a large Java-based application (including anything running on the JVM like Grails and Java Play), it is possible that the application takes longer to start. 

A large or slow starting application can give an issue similar to the following when you run cf push:

Checking status of app '<app-name>'................
0 of 1 instances running (1 starting)
...
0 of 1 instances running (1 starting)
0 of 1 instances running (1 down)
0 of 1 instances running (1 starting)
0 of 1 instances running (1 starting)
Push unsuccessful.

Cause

When a large or slow starting application runs locally, it does not cause an issue while starting as the local application container waits for the application to start. However, when pushing it to the CloudFoundry (CF), the system restricts the time that the application has to start and begins listening for the requests.

Resolution

There are two workarounds for this issue:

  1. Adjust the application to start faster. In some cases, this can be done by deferring the work that is done during the start of the application. The work can be deferred until after the application has started or by performing those actions in a separate thread that does not block the start of the application.
  2. Set the -t option for cf push. This allows to increase the amount of time that CF waits for the application to start. Then, you can increase the value up to 180 seconds on Pivotal web Services (PWS).

If the application is taking an unexpectedly long time to start, investigate what is happening at start up. This Java Web Applications Start Slow or are Failing discusses a common case for why Java/JVM based applications start slowly. 

Another common cause of slow start of an application is the failed connections to the external resources, like databases. In some cases, when a connection cannot be established, the connection attempt just hangs. It will eventually timeout slowly. Also, there can be a connection pool that is making multiple connections at the start up. This can cause the application to fail to start within the time given by the PWS.