Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Foundry `cf push` is slow: high CPU usage, disable resource matching

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.

like image 964
C-Otto Avatar asked Oct 31 '22 17:10

C-Otto


1 Answers

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.

like image 181
Dave Syer Avatar answered Nov 08 '22 07:11

Dave Syer