For my Java application cf push
takes too long.
Uploading ${APPNAME}...
Uploading app files from: ${PATH}.jar
Uploading 19.8M, 6584 files
Done uploading
When pushing, the first line is shown for minutes (with 100% CPU load). Afterwards, the actual upload starts (second line) and is completed in just a second.
With CF_TRACE=true
I see a resource match
request (https://apidocs.cloudfoundry.org/220/resource_match/list_all_matching_resources.html). For this request a JSON string is sent, containing the hash sums of all files in my JAR file. Gathering this information is what takes too long in my case, as the JAR file contains many files.
Is there a way to disable the resource match request? As far as I see, it is only used to not upload files which are unchanged (already known by the CloudFoundry instance). Uploading 20M of data takes just a second, though.
I see this when running jars that contain a lot of class files. Cloud Foundry is not able to cache small files and if you are uploading thousands of 3rd party class files it's wasteful. This happens if you use a "shaded" jar. If you repackage it so the dependencies are in jars, rather than in a flat directory structure, it will significantly improve the chances of getting a cache hit in the stager. The Spring Boot tools (for Maven and Gradle) for instance do this for you, and don't require that you use Spring Boot for the application code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With