Versions Compared

Key

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

...

Expand
title작동결과

[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$e::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-12] [TestActor] akka://AkkaTestApp/user/workers/router2/$a::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$e::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-8] [TestActor] akka://AkkaTestApp/user/workers/router2/$d::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$b::Incommessage hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-4] [Workers] Workers::Received String message: hi2
[INFO] [05/18/2018 13:50:08.645] [AkkaTestApp-akka.actor.default-dispatcher-6] [TestActor] akka://AkkaTestApp/user/workers/router2/$c::Incommessage hi2


고급적 라우팅기능 부여하기

Info

우리가 지정한 옵션에따라 라우티가 동적으로 확장이되고 축소되는 기능을 부여할수가 있으며

성능문제를 해결하기위한 장치중 하나로 활용할수가 있습니다.


동적 라우티조절

Code Block
languagejava
themeEmacs
akka.actor.deployment {
  /parent/router29 {
    router = round-robin-pool
    resizer {
      lower-bound = 2
      upper-bound = 15
      messages-per-resize = 100
    }
  }
}

위와같이 유입에따른 메시지처리능력에 따라 (보통 사용자가 늘어나는 구간을 램프업이라고 합니다.) 

라우티를 동적으로 늘리고 줄일수있으며, AKKA에서 몇가지 유용한 유틸을 제공합니다. - https://doc.akka.io/docs/akka/current/routing.html#dynamically-resizable-pool


커스텀한 라우터 설계

Code Block
languagejava
themeEmacs
public class RedundancyRoutingLogic implements RoutingLogic {
  private final int nbrCopies;
  
  public RedundancyRoutingLogic(int nbrCopies) {
    this.nbrCopies = nbrCopies;  
  }
  RoundRobinRoutingLogic roundRobin = new RoundRobinRoutingLogic();
  
  @Override
  public Routee select(Object message, IndexedSeq<Routee> routees) {
    List<Routee> targets = new ArrayList<Routee>();
    for (int i = 0; i < nbrCopies; i++) {
      targets.add(roundRobin.select(message, routees));
    }
    return new SeveralRoutees(targets);
  }
}

AKKA에서 대부분 우리가 알고있고 쓸만한 라우터를 제공하지만, 제공되지 않는 특수한 라우터 방식을

사용할시 위와같이 라우터 설계가 가능합니다.


Dispatcher설정

Code Block
languagebash
themeEmacs
akka.actor.deployment {
  /poolWithDispatcher {
    router = random-pool
    nr-of-instances = 5
    pool-dispatcher {
      fork-join-executor.parallelism-min = 5
      fork-join-executor.parallelism-max = 5
    }
  }
}

라우터에 병렬처리에 관련된 능력을 지정하고자할때 설정될수 있습니다.

최대 5개의 스레드를 동시에 사용하겠다고 하는 설정사항입니다.

성능을 고려하여 이값을 잘 지정하는것은 생각보다 어려운주제이지만, 설정은 쉽습니다.