{"id":26519,"date":"2022-09-21T15:52:12","date_gmt":"2022-09-21T13:52:12","guid":{"rendered":"https:\/\/device-insight.com\/?post_type=developers-blog&#038;p=26519"},"modified":"2024-03-04T09:24:56","modified_gmt":"2024-03-04T08:24:56","slug":"fetching-heap-dump-spring-boot-k8s","status":"publish","type":"developers-blog","link":"https:\/\/device-insight.com\/en\/developers-blog\/fetching-heap-dump-spring-boot-k8s\/","title":{"rendered":"Fetching a heap dump from a Spring Boot service"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"26519\" class=\"elementor elementor-26519\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"developers-blog\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7b4f828b devel_blog_title elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7b4f828b\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1786bf7e blog_col\" data-id=\"1786bf7e\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fa4243a elementor-align-left devel_blog_back_btn ha-has-bg-overlay elementor-widget elementor-widget-button\" data-id=\"fa4243a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-button-wrapper\">\n\t\t\t\t\t<a class=\"elementor-button elementor-size-sm\" role=\"button\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t<span class=\"elementor-button-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"hm hm-arrow-left1\"><\/i>\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">Back<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-612acb44 elementor-widget elementor-widget-theme-post-title elementor-page-title elementor-widget-heading\" data-id=\"612acb44\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"theme-post-title.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">Fetching a heap dump from a Spring Boot service<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-539cc96 elementor-widget elementor-widget-post-info\" data-id=\"539cc96\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-6345c40 elementor-inline-item\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-custom\">\n\t\t\t\t\t\t\t\t\t\tPaul Vorbach\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-7f3e269 elementor-inline-item\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.linkedin.com\/in\/paul-vorbach-5a57571ba\/\" target=\"_blank\" rel=\"noopener\">\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-icon\">\n\t\t\t\t\t\t\t\t<i aria-hidden=\"true\" class=\"fab fa-linkedin\"><\/i>\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-custom\">\n\t\t\t\t\t\t\t\t\t\thttps:\/\/www.linkedin.com\/in\/paul-vorbach-5a57571ba\/\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-b86a0c7 elementor-inline-item\" itemprop=\"datePublished\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-date\">\n\t\t\t\t\t\t\t\t\t\t<time>2022\/09\/21<\/time>\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-808e92e elementor-inline-item\" itemprop=\"about\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-terms\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-post-info__terms-list\">\n\t\t\t\t<a href=\"https:\/\/device-insight.com\/en\/developers_blog_category\/spring-boot\/\" class=\"elementor-post-info__terms-list-item\">Spring Boot<\/a>\t\t\t\t<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-17c17f87 elementor-widget elementor-widget-text-editor\" data-id=\"17c17f87\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-selectable-paragraph=\"\">Taking heap dumps of your Java services is an important tool for analyzing problems around your application. With Spring Boot apps running on Kubernetes, a lot of the underlying infrastructure has changed. And so has taking and fetching heap dumps of Spring Boot apps on Kubernetes.<\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-de1fb1a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"de1fb1a\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-44e83259 blog_col\" data-id=\"44e83259\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2453a39a elementor-widget elementor-widget-text-editor\" data-id=\"2453a39a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>A little while ago, while working on a performance analysis, we had the problem that we wanted to look at the heap dump of one of our micro services. We quickly discussed a few possibilities how to do that. But since not every team member of the team was aware of the following method, here\u2019s a short blog post about it.<\/p><p data-renderer-start-pos=\"295\">Spring Boot comes with a dedicated actuator endpoint that makes creating and extracting heap dumps a breeze. But it needs to be exposed first. You need to add the string \u201cheapdump\u201d to the list of exposed endpoints: <a class=\"css-tgpl01\" title=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/actuator.html#actuator.endpoints.exposing\" href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/actuator.html#actuator.endpoints.exposing\" target=\"_blank\" rel=\"noopener\" data-renderer-mark=\"true\">Spring Boot Actuator: Exposing Endpoints<\/a>.<\/p><p data-renderer-start-pos=\"295\">Fortunately for us, we had already done this months ago.<\/p><p data-renderer-start-pos=\"601\">Downloading the heap dump is quite simple.<\/p><p data-renderer-start-pos=\"645\">In our <abbr title=\"Azure Kubernetes Services\">AKS<\/abbr> cluster, we expose the management API on port 9090, so we had to do the following:<\/p><ol class=\"ak-ol\" data-indent-level=\"1\"><li><p data-renderer-start-pos=\"742\">Forward port 9090 from the Pod: <code class=\"code css-1xivnph\" data-renderer-mark=\"true\">kubectl port-forward ms-iiqka-eval-ms-asset-manager-d4c98596-6bgc6 9090<\/code><\/p><\/li><li><p data-renderer-start-pos=\"849\">(Optional) Check if the <code class=\"code css-1xivnph\" data-renderer-mark=\"true\">heapdump<\/code> endpoint is actually enabled: <code class=\"code css-1xivnph\" data-renderer-mark=\"true\">curl localhost:9090\/actuator | jq<\/code><\/p><\/li><li><p data-renderer-start-pos=\"949\">Create and download the heap dump using curl: <code class=\"code css-1xivnph\" data-renderer-mark=\"true\">curl localhost:9090\/actuator\/heapdump -o heapdump.hprof<\/code><\/p><\/li><\/ol><p data-renderer-start-pos=\"1054\">And we\u2019re done.<\/p><p data-renderer-start-pos=\"1054\">The heap dump can now be analyzed by using tools like <a href=\"https:\/\/visualvm.github.io\/\" target=\"_blank\" rel=\"noopener\">VisualVM<\/a>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-15d7e9ce elementor-widget__width-auto elementor-widget elementor-widget-image\" data-id=\"15d7e9ce\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"400\" height=\"301\" src=\"https:\/\/device-insight.com\/wp-content\/uploads\/2022\/09\/thats-all-folks.gif\" class=\"attachment-full size-full wp-image-26521\" alt=\"That&apos;s all folks\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-98ab1b5 elementor-widget elementor-widget-text-editor\" data-id=\"98ab1b5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-renderer-start-pos=\"1074\">PS: There\u2019s a <code class=\"code css-1xivnph\" data-renderer-mark=\"true\">threaddump<\/code> endpoint as well. <span data-emoji-id=\"1f609\" data-emoji-short-name=\":wink:\" data-emoji-text=\"\ud83d\ude09\"><span class=\"emoji-common-main-styles emoji-common-node   emoji-common-emoji-image  css-1np3glt\" title=\":wink:\" data-testid=\"image-emoji-:wink:\" data-emoji-type=\"image\" aria-label=\":wink:\"><img decoding=\"async\" class=\"emoji\" style=\"visibility: visible;\" src=\"https:\/\/pf-emoji-service--cdn.us-east-1.prod.public.atl-paas.net\/standard\/caa27a19-fc09-4452-b2b4-a301552fd69c\/32x32\/1f609.png\" alt=\":wink:\" width=\"20\" height=\"20\" data-emoji-short-name=\":wink:\" data-emoji-id=\"1f609\" data-emoji-text=\"\ud83d\ude09\" \/><\/span><\/span><\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7917c55c elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7917c55c\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t\t<div class=\"elementor-background-overlay\"><\/div>\n\t\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-78099873 blog_col\" data-id=\"78099873\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-753c7837 elementor-widget elementor-widget-heading\" data-id=\"753c7837\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Recommended posts<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dc8065b elementor-widget elementor-widget-shortcode\" data-id=\"dc8065b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><div class=\"teasers teasers-single-post\"><\/div><\/div>\r\n\n<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>What has changed when fetching heap dumps from Spring Boot apps on Kubernetes.<\/p>\n","protected":false},"author":11,"featured_media":0,"menu_order":0,"template":"elementor_header_footer","meta":{"_acf_changed":false},"tags":[140],"developers_blog_category":[139],"class_list":["post-26519","developers-blog","type-developers-blog","status-publish","hentry","tag-spring-boot","developers_blog_category-spring-boot"],"acf":[],"_links":{"self":[{"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/developers-blog\/26519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/developers-blog"}],"about":[{"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/types\/developers-blog"}],"author":[{"embeddable":true,"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/users\/11"}],"version-history":[{"count":20,"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/developers-blog\/26519\/revisions"}],"predecessor-version":[{"id":34918,"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/developers-blog\/26519\/revisions\/34918"}],"wp:attachment":[{"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/media?parent=26519"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/tags?post=26519"},{"taxonomy":"developers_blog_category","embeddable":true,"href":"https:\/\/device-insight.com\/en\/wp-json\/wp\/v2\/developers_blog_category?post=26519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}