Java/Java 파헤치기

Spring MSA 를 간단하게 구현해보자 (+ 최신 release, 모니터링, heapdump)

동현 유 2022. 5. 5. 02:37

 

 

GitHub - Dong-Hyeon-Yu/spring-cloud-monitoring-example: Monitoring Spring MSA example (release train-2021.01) / gateway+discover

Monitoring Spring MSA example (release train-2021.01) / gateway+discovery+config+feign / grafana+prometheus+docker / jvm heap dump example - GitHub - Dong-Hyeon-Yu/spring-cloud-monitoring-example:...

github.com


 

환경

▪️ Release Trains : 2021.0.1 (https://spring.io/projects/spring-cloud)

▪️ Java : openjdk-11

▪️ Spring Boot : 2.6.6

▪️ Gradle : 7.4

▪️ OS : linux 20.04.4 LTS

▪️ IDE : IntelliJ IDEA Ultimate Edition


▪️ Test EndPoint

: localhost:8080/api/member (gateway) -> (resoure-service)


Spring Cloud 구성요소

  • spring-cloud-eureka-server
  • spring-cloud-gateway
  • spring-cloud-config
  • spring-cloud-openfeign
  • springdoc-openapi-ui:1.6.0

모니터링 툴 

  • prometheus :9090 포트로 접속
  • grafana : 3000 포트로 접속
  • docker-compose

실행 주의사항

: spring-cloud-config 를 먼저 실행시켜야, 나머지 JVM 인스턴스가 떴을때 설정파일을 받을 수 있음
(you must execute 'spring-cloud-config' first so that the other services get it's own application.yml files)

: 모니터링을 위해서는 docker-compose 를 이용해서 컨테이너를 띄워야함. (.monitor 폴더에 위치)
(you should do docker-compose up for monitoring under '.monitor' folder)


모니터링 예시 

 [jvm(Micrometer)]

스크린샷, 2022-04-04 21-14-11

 [node_exporter

스크린샷, 2022-04-04 21-14-24


[jvm 힙 덤프 분석해보기]

: 아래 명령어로 덤프파일 생성 후, Eclipse Memory Analyzer(MAT) 로 열어서 확인
(After creating a dumpfile using command lines below, open the file with 'Eclipse Memory Analyzer')

~$ jps  # jvm 프로세스 id를 알아내는 명령어 (finding all jvm pid)
85887 config service 
84762 discovery service
...(생략)...

~$ jmap -dump:format=b,file=heapdump.hprof 85887  # heapdump 파일 생성 명령어 (create heapdump files)

스크린샷, 2022-04-24 20-19-46