I am using cloudfoundry with multiple instances. I am trying to generate heapdump using /actuator endpoint of spring.
My doubt is in case of cloudfoundry env where at a time 2 instances running , for which instance it will generate the heapdump. How to know the heapdump is for which instance and is there anyway we can hit a specific instance .
Note: I want to use spring boot actuator /heapdump url option only .
You can't really know where the request will land in advance. Requests to your app instances are load balanced by Gorouter (round-robin), so unless there is no traffic to your app, the request could hit either backend app instance.
You can, however, determine the app instance to which a request went, after the fact.
In a terminal, run
cf logs
for your app.In another terminal, run
curl -v ...
. The output will have a header calledX-Vcap-Request-Id
. Copy that guid.Look in the output of
cf logs
for the guid you captured in the previous step. This will identify the access log entry for the request (see thevcap_request_id
field). Theapp_index
field on the same record will tell you which app received the request.This is what you want: https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html#surgical-routing
If you send the
X-Cf-App-Instance
you can pick a specific app instance. You can then target a specific app instance or ensure you get heap dumps from all of your app instances.Ex:
curl myapp.example.com -H "X-Cf-App-Instance: 5cdc7595-2e9b-4f62-8d5a-a86b92f2df0e:9"
The contents of
X-Cf-App-Instance
isX-Cf-App-Instance: APP_GUID:APP_INDEX
. You can retrieve your app guid withcf app myapp --guid
. The APP_INDEX is zero-based, so 0 is the first instance, 1 is the second instance, etc...