Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR 타입(하나 이상의 PR 타입을 선택해주세요)
개요
이번 수정 작업에서는 Redis 기반 캐시 서버 운영에서 발생할 수 있는 다양한 상황을 고려하여 개선을 진행했습니다.
Spring Cache에 Circuit Breaker 추가를 통한 가용성 확보
특정 서버의 Circuit Breaker OPEN 상태를 다른 서버로 전파하는 기능 구현
Spring Actuator의 Health Check Indicator 커스터마이징
Spring Actuator는 서버의 상태를 체크 후 UP, DOWN으로 결과를 알려주는 endpoint를 제공합니다. 이때 Actuator가 서버의 상태를 판단하는 기준을 명확히 아는 것이 중요합니다.
Actuator는 애플리케이션이 정상 작동하는 것만을 판단하는 것이 아닌, 애플리케이션에 연결된 외부 리소스들의 정상 커넥션 여부도 함께 고려합니다. 예를 들어, 현재 서비스에는 두 개의 DB와 두 개의 REDIS 총 4개의 외부 리소스가 연결되어 있습니다. Actuator는 4개 리소스의 상태를 모두 체크한 후, 하나라도 정상 연결이 되어있지 않으면 Health Check의 결과로 DOWN을 반환합니다.
해당 현상은 AWS 상에서 Load Balancer를 사용하여 분산 어플리케이션을 운영할때 문제를 일으킵니다. Load Balancer는 연결된 서버 인스턴스들의 상태를
/actuator/health
라는 endpoint를 사용해 체크합니다. 만약 Cache 서버가 장애를 일으킨 상황에서 Load Balancer를 통해 요청이 들어올때, 모든 서버 인스턴스에 대해 Cache 서버와의 커넥션이 끊어졌기에 Actuator는 DOWN을 반환합니다. 따라서 Load Balancer로 연결된 모든 서버 인스턴스로 요청을 보낼 수 없는 장애 상황이 발생할 수 있습니다.따라서 특정 외부 리소스와의 커넥션 여부가 서비스 전체의 장애와 필수적인 관계가 아니라면 Actuator의 HealthIndicator를 커스터마이징 해서 장애로 판단하지 않도록 만들어야 합니다.
변경 사항
코드 리뷰시 참고 사항
테스트 결과