
CPRA는 대규모 마이크로서비스 아키텍처를 관리하는 플랫폼 팀을 위해 설계된 고성능 인프라 모니터링 시스템입니다. ECS(Entity-Component-System) 아키텍처와 대기열 이론(Queueing Theory) 원리를 기반으로 구축된 CPRA는 SLO 목표를 충족하기 위해 자동 워커 풀 확장을 통해 1,000,000개 이상의 동시 상태 점검(health check)을 처리합니다.
자동 복구 및 동적 작업자 확장으로 수백만 개의 서비스를 동시에 모니터링합니다.
CPRA는 대규모 마이크로서비스 아키텍처를 관리하는 플랫폼 팀을 위해 설계된 고성능 인프라 모니터링 시스템입니다. ECS(Entity-Component-System) 아키텍처와 대기열 이론 원칙을 기반으로 구축된 CPRA는 SLO 목표를 충족하기 위해 자동 작업자 풀 확장을 통해 1,000,000개 이상의 동시 상태 확인을 처리합니다.
다음과 같은 경우 CPRA를 사용하세요:
자세한 벤치마크 및 분석은 아키텍처 개요를 참조하세요.
CPRA는 ECS(Entity-Component-System) 원칙을 기반으로 구축된 3-파이프라인 아키텍처를 사용합니다:


각 파이프라인은 자체 대기열과 동적으로 확장되는 작업자 풀을 사용하여 독립적으로 작동하므로 다음이 가능합니다:

대기열 구현:
동적 작업자 풀:
포괄적인 아키텍처 설명은 아키텍처 개요를 참조하세요.
# 사전 요구 사항: Go 1.25 이상
go version # go1.25 이상이 표시되어야 함
# 소스에서 빌드
git clone https://github.com/ziad/cpra.git
cd cpra
go build .
# 예제 구성으로 실행
./cpra --yaml mock-servers/test_10k.yaml
예상 출력:
Starting CPRA Optimized Controller for 1M Monitors
Profiling server listening at http://localhost:6060/debug/pprof/
Loading monitors from mock-servers/test_10k.yaml...
Monitor loading completed in 1.2s
[INFO] Controller started successfully
[INFO] Pulse pipeline processing 10,000 monitors
[INFO] Worker pool scaled to 143 workers (target SLO: 100ms)
저장소 복제:
git clone https://github.com/ziad/cpra.git
cd cpra
의존성 다운로드:
go mod download
애플리케이션 빌드:
go build .
설치 확인:
./cpra --help
Docker 이미지 빌드:
docker build -f docker/Dockerfile -t cpra:latest .
컨테이너 실행:
docker run -it --rm \
-v $(pwd)/my-monitors.yaml:/app/monitors.yaml \
cpra:latest \
./cpra --yaml monitors.yaml
상태 확인을 정의하는 monitors.yaml 파일을 만드세요:
monitors:
- name: "my-service-health-check"
pulse_check:
type: http
interval: 30s
timeout: 5s
max_failures: 3
config:
method: GET
url: http://my-service.example.com/health
retries: 2
intervention:
action: docker
config:
container: my-service-container
action: restart
codes:
red:
dispatch: true
notify: pagerduty
config:
url: https://events.pagerduty.com/v2/enqueue
yellow:
dispatch: true
notify: log
config:
file: /var/log/cpra-alerts.log
테스트 구성 생성:
mock-servers/generate_monitors.py를 사용하여 원하는 수의 모니터로 테스트 구성을 생성하세요.
프로그래밍 방식으로 CPRA 동작을 구성하세요:
package main
import (
"cpra/internal/controller"
)
func main() {
config := controller.DefaultConfig()
// 디버그 모드
config.Debug = true
// 작업자 풀 설정 (세 파이프라인 모두에 적용)
config.WorkerConfig.MinWorkers = 10
config.WorkerConfig.MaxWorkers = 500
// 대기열 설정
config.QueueCapacity = 131072 // 2의 거듭제곱이어야 함
// 성능 튜닝
config.BatchSize = 2000
config.SizingServiceTime = 20 * time.Millisecond // 평균 작업 시간
config.SizingSLO = 100 * time.Millisecond // 목표 지연 시간
config.SizingHeadroomPct = 0.15 // 15% 안전 버퍼
ctrl := controller.NewController(config)
// ... 나머지 초기화
}
전체 구성 옵션은 API 참조를 참조하세요.
./cpra [OPTIONS]
예제:
# 디버그 로깅으로 실행
./cpra --yaml monitors.yaml --debug
# 사용자 정의 pprof 포트로 실행
./cpra --yaml monitors.yaml --pprof.addr localhost:8080
# 프로파일링 비활성화
./cpra --yaml monitors.yaml --pprof=false
문제: YAML file not found
Warning: YAML file monitors.yaml not found, starting without loading monitors
해결 방법: 파일 경로가 올바른지 확인하세요. 절대 경로 또는 바이너리를 실행하는 위치 기준 상대 경로를 사용하세요:
./cpra --yaml $(pwd)/monitors.yaml
문제: Build fails with Go version error
go.mod requires go >= 1.25
해결 방법: Go를 버전 1.25 이상으로 업그레이드하세요:
go version # 현재 버전 확인
# https://go.dev/dl/ 에서 Go 1.25+ 다운로드
문제: High memory usage
해결 방법: pprof로 메모리 사용량을 확인하세요:
# CPRA 실행 중 pprof에 접근
go tool pprof http://localhost:6060/debug/pprof/heap
# 상위 메모리 소비자 보기
(pprof) top
구성에서 메모리 제한을 조정하세요:
config.WorkerConfig.MaxWorkers = 200 // 최대 작업자 수 줄이기
config.QueueCapacity = 65536 // 대기열 크기 줄이기
문제: Worker pool not scaling
해결 방법: 디버그 로깅을 활성화하여 확장 결정을 확인하세요:
./cpra --yaml monitors.yaml --debug
대기열 이론 매개변수를 확인하세요:
config.SizingServiceTime = 50 * time.Millisecond // 작업 시간이 더 오래 걸리는 경우 증가
config.SizingSLO = 200 * time.Millisecond // 필요한 경우 SLO 완화
문제: Monitors not executing
해결 방법: 모니터 구성 형식을 확인하고 로그를 확인하세요:
./cpra --yaml monitors.yaml --debug 2>&1 | grep ERROR
YAML 구문 검증:
# YAML 검증기 사용
python -m yaml monitors.yaml
--debug 플래그 사용)커뮤니티의 기여를 환영합니다! CPRA는 오픈 소스 프로젝트이며 다음을 환영합니다:
시작하기:
good first issue 레이블이 있는 이슈를 찾으세요개발 리소스:
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 LICENSE 파일을 참조하세요.
CPRA는 뛰어난 오픈 소스 라이브러리 위에 구축되었습니다:
| 메트릭 | 값 |
|---|
| 최대 동시 모니터 | 1,000,000개 이상 |
| 처리량 | 파이프라인당 초당 10,000개 이상의 검사 |
| 지연 시간 (P95) | < 100ms (SLO를 통해 구성 가능) |
| 모니터당 메모리 | ~100바이트 |
| 총 메모리 (1M 모니터) | ~100MB + 작업자 풀 오버헤드 |
| 작업자 확장 | 동적 (M/M/c 기반) |
| 옵션 | 유형 | 기본값 | 설명 |
|---|
--yaml | string | internal/loader/replicated_test.yaml | 모니터 YAML 파일 경로 |
--config | string | - | 구성 파일 경로 (선택 사항) |
--debug | bool | false | 디버그 수준 로깅 활성화 |
--pprof | bool | true | pprof 프로파일링 서버 활성화 |
--pprof.addr | string | localhost:6060 | Pprof 서버 수신 주소 |