어플리케이션에서 생성하는 정보를 분석하고,모니터링 하기 위해서 다음과 같은 방법을 가장 많이 사용합니다.
- 로그를 적재한다. ( Nlog,Log4j등등 모듈)
- 로그를 통합한다. ( 엘라서틱 로그 스태쉬)
- 로그를 데시보드화하고 분석한다 ( 키바나등 )
하지만, 너무나 큰 대용량 처리횟수에대해 실시간성으로 모니터링을 하고 싶다고 하면
Matrix를 활용 합니다. 시간별 CPU변화량,네트워크 변화량 등에 일반적으로 사용되고 있으며
매초마다 로그를 기록하는 방식이아닌 변화량을 특정주기로 폴링을 할수 있습니다.
로컬 피씨하나가, 초당 만 TPS에 이상 발생하는 이벤트를 실시간 모니터링을 해야할경우 어떻게할지 고민을 해봅시다.
전통적인 방법 로깅으로는 불가능 해보입니다. 로그는 파일에 기록하는것이며 초당 만 TPS에 해당하는 이벤트를 처리할수 없습니다.
그리고 싱글노드에서 액터의 메시지 전송 능력을 하번 살펴 보겠습니다.
링크 : https://akka.io/
초당 5천만 메시지를 커버 할수 있으며, 실시간 모니터링 객체로 사용하기 충분한 스펙을 가지고 있습니다.
액터 모니터링 시스템 탑재하기
using Akka.Actor; using Akka.Monitoring; using Akka.Monitoring.ApplicationInsights; using Akka.Monitoring.PerformanceCounters; using Akka.Monitoring.Prometheus; switch (appConfig.MonitorTool) { case "win": var win = ActorMonitoringExtension.RegisterMonitor(actorSystem, new ActorPerformanceCountersMonitor( new CustomMetrics { Counters = { "akka.custom.metric1", "akkacore.message" }, Gauges = { "akka.messageboxsize" }, Timers = { "akka.handlertime" } })); break; case "azure": var azure = ActorMonitoringExtension.RegisterMonitor(actorSystem, new ActorAppInsightsMonitor(appConfig.MonitorToolApiKey)); break; case "prometheus": // prometheusMonotor 를 사용하기위해서, MerticServer를 켠다...(수집형 모니터) // http://localhost:10250/metrics metricServer = new MetricServer(10250); metricServer.Start(); var prometheus = ActorMonitoringExtension.RegisterMonitor(actorSystem, new ActorPrometheusMonitor(actorSystem)); break; }
대표적인 매트릭스 기반 모니터링 시스템인, 윈도우 성능 프로파일러 / 애져 AppInsight / Promethes 3가지 모두 연동가능합니다.
이벤트 발생
// 사용부 : 10만 이벤트 발생 for (int i = 0; i < 100000; i++) MonitorActor.Tell(value); // 구현부 : 액터에 모니터링 카운팅 탑재 ReceiveAsync<string>(async msg => { int auto_delay = random.Next(1, 100); //1 이벤트를 임의로 지연 ( 특정 도메인기능 수행 ) await Task.Delay(auto_delay); Context.IncrementCounter("akka.custom.metric1"); // 1단위로 증가 Context.IncrementCounter("akka.custom.metric2",100); // 특정 단위로 증가 });
특정 네임스페이스("akka.custom.metri1") 에 해당하는 카운팅을 1이벤트 단위로 증가 시킬수 있습니다.
카운팅 측정및 모니터링하기
참고링크: