Вопрос по – Нужно ли мне повторно использовать ту же Akka ActorSystem, или я могу просто создать ее каждый раз, когда она мне понадобится?

62

Error: User Rate Limit ExceededActorSystemError: User Rate Limit ExceededMyActorError: User Rate Limit Exceeded

val system = ActorSystem()
val myActor = system.actorOf(Props[MyActor])

Error: User Rate Limit ExceededActorSystemError: User Rate Limit ExceededsystemError: User Rate Limit Exceeded

Error: User Rate Limit ExceededActorSystemError: User Rate Limit ExceededActorSystemError: User Rate Limit ExceededActorSystemError: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededActorSystem classError: User Rate Limit Exceeded

Question(s)

What are the implications of sharing the same ActorSystem object or creating a new one each time?

What are the best practices here? Passing around an ActorSystem all the time seems surprisingly heavy-handed.

Some examples give the ActorSystem a name: ActorSystem("MySystem") others just call ActorSystem(). What difference does this make, and what if you use the same name twice?

Does akka-testkit require that you share a common ActorSystem with the one you pass to the TestKit constructor?

Error: User Rate Limit Exceeded Viktor Klang
Error: User Rate Limit Exceeded Roland Kuhn
Error: User Rate Limit Exceeded Viktor Klang
Error: User Rate Limit Exceeded Viktor Klang

Ваш Ответ

2   ответа
49

MySystemakka://MySystem/user/$acontext.system

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
4

The heaviest part of an ActorSystem is the dispatcher. Each ActorSystem has at least one. The dispatcher is the engine that makes the actors running. In order to make running, it needs threads (usually got from a thread pool). The default dispatcher uses a fork-join thread pool with at least 8 threads.

There are shared facilities, like the guardian actors, the event stream, the scheduler, etc. Some of them are in user space, some are internal. All of them need to be created and started.

One ActorSystem with one thread pool configures to the numbers of cores should give the best results in most cases.

Here document mentions logical application, I prefer to consider blocking or non-blocking application. According to dispatcher's configuration, one ActorSystem is for one configuration. If the application is for the same logics, one ActorSystem should be enough.

Похожие вопросы