Will this Work for Me?

ARTIFACTORY: How to improve a Large Maven Virtual's Performance in 3 Easy Steps

AuthorFullName__c
Patrick Russell
articleNumber
000005772
ft:sourceType
Salesforce
FirstPublishedDate
2023-06-07T08:57:21Z
lastModifiedDate
2023-06-07
VersionNumber
1
Do you have a Virtual Repository that aggregates many public package sources? In other words, do you have more than 15 Remote Repositories in 1 Virtual?

If so, yes this advice applies to you!

The performance problem happens when a "mvn install" checks for a package's maven-metadata.xml file. The Maven Virtual repository has to check every Remote Repository for this metadata file, resulting in a lengthy download time:
2023-03-01T12:00:00.000Z|df0b890004ecd3a6|10.0.0.1|jenkins-build-user|GET|/maven-public/com/public/proxy/plugins/proxy-plugin/maven-metadata.xml | 200 |-1| 10453 [10.4 KB] | 10848 [10.8 seconds] |Apache-Maven/3.6.3 (Java 11.0.14.1.101; Linux 3.10.0-1062.12.1.el7.x86_64)

This is due to the concept of "metadata freshness." Artifactory has to check every remote site to answer these questions:
1. Does the package exist there?
2. If so, is there an updated version?

Whenever you pull a Maven package, Artifactory checks all the remote sites every 5 minutes. This is defined by the Metadata Cache Retrieval Period (MCRP).

If the remote site returns a 404 Not Found, the next check is done after 30 minutes have passed. The 30 minute period is defined by the Missed Cache Retrieval Period.

When a large set of remotes is aggregated by a Virtual, a simple HEAD check on a POM file can take multiple seconds because of this cache miss:
2023-03-01T12:00:00.000Z|df0b890004ecd3a6|10.0.0.1|jenkins-build-user|HEAD|/maven-public/com/public/proxy/plugins/proxy-plugin/proxy-plugin.pom | 404 |-1| 0 [bytes] | 12566 [12.5 seconds] |Apache-Maven/3.6.3 (Java 11.0.14.1.101; Linux 3.10.0-1062.12.1.el7.x86_64)

Increasing both the MCRP and Missed Cache Retrieval Period values means most builds will run more quickly.

Please note the tradeoff here: You are improving overall performance by making update checks less frequent. If frequent update checks are important to your team, implement the "Zap cache" API in important builds or make due with the slower, more frequent checks.