How to enable agent dependency caching
Purpose
Bamboo 6.2 introduces proxy support for agent dependency caching. That means, startup time of agents can now be decreased by enabling content caching on your reverse proxy. Once you enable it on the proxy side, Bamboo will display the confirmation information in the agent log file.
You'll see the following INFO
message in the <BAMBOO_AGENT_HOME>/atlassian-bamboo-agent.log file when content caching is enabled:
INFO [WrapperSimpleAppMain] [ClasspathBuilder] Content caching is enabled for high performance bootstrap.
Otherwise, if it is not, you'll see the following WARN
message:
WARN [WrapperSimpleAppMain] [ClasspathBuilder] Content caching is not enabled. This can cause performance impact on servers with high-tier licenses.
The dependencies we're talking about here are the JAR files the agent must download from the server during startup. So in order to speed up the agent startup time it's possible to cache plugin information at the proxy level. You won't have to change anything on the Bamboo side, only at the reverse proxy level. One important note is that you don't need to tell the proxy what items need to be cached, Bamboo will do this for you once content caching is enabled.
This should work with most reverse proxies as long as they support content/response caching. However, in this article, you'll find instructions on how to enable agent dependency caching for Apache HTTP Server and NGINX only.
Solution
Testing agent dependency caching
The following cURL command will help you test whether caching is successful even before starting up an agent. You don't need to have an agent installed for the purpose of this test.
curl -v http://<BAMBOO_BASE_URL>/agentServer/bootstrap/content-cache-test
You should see X-Cache-Status HIT. Similar to the following:
< HTTP/1.1 200 OK
< Server: nginx/1.13.10
< Date: Fri, 30 Mar 2018 16:20:50 GMT
< Content-Type: text/plain;charset=UTF-8
< Content-Length: 5001
< Connection: keep-alive
< X-ASEN: SEN-500
< X-Frame-Options: SAMEORIGIN
< Last-Modified: Fri, 30 Mar 2018 16:20:07 GMT
< Cache-Control: public, max-age=30
< X-Cache-Status: HIT
This means the entity was fresh, and was served from cache. If you see MISS then the entity was fetched from the upstream server and was not served from cache.