Versions Compared

Key

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

...

  • parallelism-min =2 : 동시에 활성화되는 최소 스레드수 (available processors * factor)
  • parallelism-max = 8 : 동시에 활성화되는 최대 스레드수
  • parallelism-factor =2.0 : Core개수대비 최대가 될수있는 스레드수
  • throughput =100 : 동시에 처리하는 메시지수
  • fixed-pool-size =32 : 스레드 개수 고정

Dispatcher 설정 샘플

Code Block
languagebash
themeEmacs
collapsetrue
akka {
	loggers = ["akka.event.Logging$DefaultLogger"]
	loglevel = "INFO"
	stdout-loglevel = "ERROR"	
}

blocking-io-dispatcher {
	type = Dispatcher
	executor = "thread-pool-executor"
	thread-pool-executor {
	fixed-pool-size = 2
	}
	throughput = 1
}

my-thread-pool-dispatcher {
  # Dispatcher is the name of the event-based dispatcher
  type = Dispatcher
  # What kind of ExecutionService to use
  executor = "thread-pool-executor"
  # Configuration for the thread pool
  thread-pool-executor {
    # minimum number of threads to cap factor-based core number to
    core-pool-size-min = 2
    # No of core threads ... ceil(available processors * factor)
    core-pool-size-factor = 2.0
    # maximum number of threads to cap factor-based number to
    core-pool-size-max = 10
  }
  # Throughput defines the maximum number of messages to be
  # processed per actor before the thread jumps to the next actor.
  # Set to 1 for as fair as possible.
  throughput = 100
}
	
my-dispatcher {
  # Dispatcher is the name of the event-based dispatcher
  type = Dispatcher
  # What kind of ExecutionService to use
  executor = "fork-join-executor"
  # Configuration for the fork join pool
  fork-join-executor {
    # Min number of threads to cap factor-based parallelism number to
    parallelism-min = 2
    # Parallelism (threads) ... ceil(available processors * factor)
    parallelism-factor = 2.0
    # Max number of threads to cap factor-based parallelism number to
    parallelism-max = 10
  }
  # Throughput defines the maximum number of messages to be
  # processed per actor before the thread jumps to the next actor.
  # Set to 1 for as fair as possible.
  throughput = 100
}



동시처리 스레드 제한 예제

Code Block
languagejava
themeEmacs
//application.conf 설정
blocking-io-dispatcher {
 type = Dispatcher
 executor = "thread-pool-executor"
 thread-pool-executor {
 fixed-pool-size = 2
 }
 throughput = 1
}


//구현부
//특정 액터 Dispatcher지정
ActorRef testActor = system.actorOf(ext.props("testActor")
 .withDispatcher("blocking-io-dispatcher"),
 "service1");


// 동시에 메시지 전송
for(int i=0;i<10;i++)
 testActor.tell("test message wiht dispatcher",null);
Expand
title실행결과

[INFO] [05/06/2018 23:27:21.795] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.798] [AkkaTestApp-blocking-io-dispatcher-9] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.799] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.800] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.801] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.801] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.802] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.807] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.807] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher
[INFO] [05/06/2018 23:27:21.807] [AkkaTestApp-blocking-io-dispatcher-8] [TestActor] Incommessage test message wiht dispatcher

...