How to detect scala executioncontext exhaustion?

给你一囗甜甜゛ 提交于 2019-12-04 06:24:23

That is pretty hard question to answer.

Configuration of dispatchers really depends on the type of work your actors are doing.

Probably you should look at the actors that spawn futures to do their work. It may be a good idea to predefine execution context in the configuration file and use them like this:

implicit val ec : ExecutionContext = context.system.dispatchers.lookup("someDispatcher")

those actors are likely to cause the starvation effect.

The effect you want to achieve is to make sure messages are processed quickly and long running task does not affect them so separation is the key thing here.

A good tool for monitoring your application is the Typesafe Console. You can look at the dispatcher there and see that the latency in handling messages increase.

Another concern is to identify actors that make a high risk work like network I/O. If something happens to the thread making in not available again in the pool it will create problems.

It is very likely that without experimenting with the threadpool size you won't know what is the best setting for you.

Most of those advises I wrote I know from the book Effective Akka by Jamie Allen and they seem to be working quite well for me. There is a section in this book Fixing Starvation. You may want to look at it closer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!