News

CAP Java Health Check 빠뜨리면 큰일 #shorts #SAP #CAP

이 글이 답하는 질문

  • CAP Java 앱에 Health Check가 없으면 어떤 일이 생기나?
  • Cloud Foundry / Kyma에서 Health Check는 어떻게 설정하나?
  • Actuator와 커스텀 Health Indicator는 어떻게 추가하나?

Health Check란

플랫폼(CF/Kyma)이 앱이 살아 있는지 주기적으로 확인하는 메커니즘입니다. Health Check 실패 시 인스턴스를 재시작하거나 트래픽을 끊습니다. 없으면 앱이 죽어도 플랫폼이 모르고 트래픽을 계속 보냅니다.

직접 해보기

1. Spring Actuator 추가 (pom.xml)

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2. application.yaml 설정

management:
  endpoints:
    web:
      exposure:
        include: health, info
  endpoint:
    health:
      show-details: always

3. 커스텀 Health Indicator

@Component
public class DbHealthIndicator implements HealthIndicator {
    @Override
    public Health health() {
        try {
            // DB 연결 확인
            dataSource.getConnection().close();
            return Health.up().build();
        } catch (Exception e) {
            return Health.down().withDetail(error, e.getMessage()).build();
        }
    }
}

4. CF manifest.yml Health Check 설정

applications:
  - name: my-cap-app
    health-check-type: http
    health-check-http-endpoint: /actuator/health

삽질 노트

  • Health Check endpoint가 인증 필요하면 CF가 401을 받아 앱을 계속 재시작함 — /actuator/health는 인증 없이 열어둘 것
  • Kyma는 livenessProbe/readinessProbe를 Deployment YAML에 별도 설정해야 함
  • DB 연결이 느리면 Health Check 타임아웃으로 false negative 발생 — timeout 여유있게 설정

핵심 한 줄

Health Check 없는 CAP Java 앱 = 죽어도 트래픽 받는 좀비. Actuator + manifest 2개로 해결.

더 파볼 주제

  • CAP Java — Readiness vs Liveness 차이
  • Cloud Foundry — Blue-Green 배포와 Health Check
  • Kyma — livenessProbe/readinessProbe 설정

댓글 0

아직 댓글이 없습니다.