The Steps

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
1. Copy the remote repository list from the UI
From the Admin -> Repositories -> <Virtual> menu, there is an "Included Repository" list towards the bottom. It shows the repository resolution order, the remotes should be below the locals.

This menu is a text list, and it can be copied with your mouse:

User-added image


Copy the text and paste it into a text file:
vim remotes-to-update.txt

User-added image

2. Create this simple BASH script
This script will iterate over each Remote Repository name in the list and raise its settings. Try raising the MCRP to 3,600 seconds (1 hour) and the Missed Cache to 14,400 seconds (4 hours).

vim scripted-fix.sh
!/bin/bash

#
# Note: Update admin:password with an admin account and ID Token
#

cat remotes-to-update.txt | while read ITEM
do 
    echo "Updating: $ITEM"
    curl -u admin:password -X POST -H "Content-type: application/json" --data '{"retrievalCachePeriodSecs":"3600", "missedRetrievalCachePeriodSecs": "14400"}' http://localhost:8082/artifactory/api/repositories/$ITEM
    sleep 1s
done

Don't forget to update the URL if you plan to run this externally, "localhost:8082" probably won't work from your laptop or build server.

3. Run the Script
chmod +x scripted-fix.sh; ./scripted-fix.sh

# Expected Output
User-added image

That's it, you're done! The remote repositories should start to serve requests from their metadata cache more frequently.

Feel free to use cache period numbers that your team is comfortable with, the above settings are a good baseline, but everybody has different needs when it comes to metadata.