Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Group : 이미존재하는 액터에대한 그룹화를 하는것으로 ,라우터 구성경로를 직접 지정합니다.  ( 경로지정 ,관련액터 직접생성)


라우터의 종류

...

이름작동다이어그램특징
round-robin

Round Robin RouterImage Added

단순하게 들어온 메시지 순서대로, 순차적으로 대상 노드를 바꿔가며 전송시 사용
broadcast

Broadcast RouterImage Added

어떠한 정보의 변경을 모든 노드가 알아야할시, 주로 전체 동기화및 전체 푸시용도

random


랜덤 메시지 전송
consistent-hashing

ConsistentHash RouterImage Added

특정 처리에 대해 해시값기반 베이스로 노드의 변경의 가능성을 최소화할때
tail-chopping

기본적으로 랜덤이나, 느린놈을 제외하고 특정시간이 지나야 다시 합류시킴(일반적으로 빠른 응답속도 보장용)

옵션:

within = 10s
tail-chopping-router.interval = 20ms
scatter-gather

ScatterGatherFirstCompleted RouterImage Added

성능을 위해 다중노드로 구성하였으며, 가장 빠르게 처리한 녀석의 결과를 사용할시
smallest-mailbox

SmallestMailbox RouterImage Added

덜바쁜 노드우선으로 메시지를 보내고자 할때, 대용량 메시지 전송 보증이 필요할때
scatter-gather

ScatterGatherFirstCompleted RouterImage Added

성능을 위해 다중노드로 구성하였으며, 가장 빠르게 처리한 녀석의 결과를 사용할시

옵션:

within = 10s


 키설정이 필요한,  consistent-hashing 제외하고 나머지 라우터전략을 옵션을 통해(라우터 이름만 알고 있으면됨)

이루어냅니다.


라우터 테스트

...


Code Block
themeFadeToGrey
title라우터 설정
              actor.deployment {
                /workers {
                router = round-robin-pool
                nr-of-instances = 5
                }
              }

라우터 Type을 선택하고, 인스턴수를 지정합니다. 위 라우터정의표에서 작동 이름만 바꾸면 

전략변경가능합니다.


Code Block
languagec#
themeEmacs
title테스트 액터
linenumberstrue
    public class ReActor : ReceiveActor
    {
        private ILoggingAdapter log = Context.GetLogger();

        public ReActor()
        {
            Receive<string>(message => {
                string reply = string.Format("I'am {0} RE:{1}", Self.Path, message);
                log.Info(reply);
                Sender.Tell(reply);
            });            
        }
    }

라우터 테스트가 잘되는지 확인하기 위해, 나의 이름을 말하고 "RE"로 받은 메시지 응답을 합니다.


Code Block
languagec#
title테스트코드
linenumberstrue
            var props = Props.Create<ReActor>().WithRouter(FromConfig.Instance);
            var actor = actorSystem.ActorOf(props, "workers");
            
            actor.Tell("t1");
            actor.Tell("t2");
            actor.Tell("t3");

해당 라우터에 여러번 메시지를 보냅니다.


Expand
titleResult

Image Added