Update healthcheck troubleshooting documentation

- Document HealthCheckFilter solution
- Add exact file locations and line numbers
- Remove outdated solutions
This commit is contained in:
happybell80 2025-09-22 00:41:53 +09:00
parent d1464535d8
commit 48ef9e33a9

View File

@ -1,61 +1,36 @@
# 헬스체크 빈도 과다로 인한 로그 오염 문제
# 헬스체크 로그 오염 문제
**작성일**: 2025-09-21
**작성자**: happybell80
**상태**: 문제 확인
**상태**: 해결
## 문제 현상
## 문제
rb8001 서비스가 매 30초마다 다른 서비스들의 헬스체크를 수행하면서 과도한 로그를 생성하고 있음.
### 로그 패턴
httpx 라이브러리가 헬스체크 요청마다 INFO 레벨로 로그를 생성:
```
{"time":"2025-09-21 23:24:33,703","level":"INFO","module":"httpx","msg":"HTTP Request: GET http://172.17.0.1:8501/health "HTTP/1.1 200 OK""}
{"time":"2025-09-21 23:24:33,705","level":"INFO","module":"httpx","msg":"HTTP Request: GET http://localhost:8505/health "HTTP/1.1 200 OK""}
{"time":"2025-09-21 23:24:33,707","level":"INFO","module":"httpx","msg":"HTTP Request: GET http://localhost:9024/health "HTTP/1.1 404 Not Found""}
{"time":"2025-09-21 23:24:33","level":"INFO","module":"httpx","msg":"HTTP Request: GET http://localhost:8501/health "HTTP/1.1 200 OK""}
```
- 30초마다 실행 = 하루 8,640개 로그
- 다른 중요한 로그가 묻힘
## 해결책
### 1. Docker Compose 수정 (완료)
- rb8001/docker-compose.yml:79
- auth-server/docker-compose.yml:47
```yaml
interval: 300s # 30s → 300s
```
## 문제점
### 2. HealthCheckFilter 적용 (필요)
- 위치: rb8001/app/core/logger.py:39 (setup_logging 함수 끝)
- 추가할 내용: HealthCheckFilter 클래스 정의 및 httpx 로거에 필터 추가
- 효과: `/health` 경로 로그만 제거, 다른 API 호출 로그는 유지
1. **로그 과부하**
- 매 30초마다 3개 서비스 체크 = 분당 6개, 시간당 360개, 하루 8,640개 로그
- 실제 에러나 중요한 이벤트 로그가 헬스체크 로그에 묻힘
- 로그 분석 및 디버깅 어려움
2. **리소스 낭비**
- 불필요한 네트워크 요청
- 로그 파일 용량 증가
- 로그 로테이션 빈도 증가
3. **모니터링 실효성 부족**
- robeing-monitor (9024) 계속 404 반환
- 30초 간격은 실시간 모니터링으로는 부족, 로깅으로는 과다
## 현재 설정 위치 (추정)
- rb8001 서비스 내부 스케줄러 또는 백그라운드 태스크
- APScheduler 또는 asyncio 기반 정기 실행
## 제안 해결책
### 1. 즉시 조치
- 헬스체크 간격을 5분(300초)으로 증가
- robeing-monitor 404 문제 해결 또는 체크 제외
### 2. 로그 레벨 조정
```python
# httpx 로거 레벨을 WARNING으로 상향
logging.getLogger("httpx").setLevel(logging.WARNING)
# 또는 헬스체크 전용 로거 분리
health_logger = logging.getLogger("healthcheck")
health_logger.setLevel(logging.WARNING)
```
### 3. 장기 개선
- 헬스체크 결과를 메모리에 캐싱
- 상태 변경 시에만 로그 기록
- Prometheus 등 전문 모니터링 도구 도입 검토
### 3. 이미 완료된 수정
- rb8001/main.py:406 - logger.debug() 적용됨
- skill-email/main.py:414 - logger.debug() 적용됨
- skill-news/main.py:59 - logger.debug() 적용됨
## 영향 범위