How to detect scala running out of context?

I am having problems with the fact that the Playframework application does not respond from time to time, and I would like to detect this at runtime + a log of information about what is currently running in the exhausted execution context.

What would be the best strategy to implement this? I was thinking about placing small executables in execution contexts, and if they were not executed on time, I would have logged a warning. Of course, this maximum latency should be customizable. For example, the main context of web execution should never be blocked for more than 1 second, but the context of the db executable file may allow blocking for 30 seconds.

Someone must have done this before?

related information: http://www.playframework.com/documentation/2.2.x/ThreadPools

+6
source share
1 answer

This is a pretty tricky question.

The configuration of the dispatchers really depends on the type of work of your actors.

You should probably look at the actors who generate the futures to do their job. It might be a good idea to predefine the execution context in the configuration file and use them as follows:

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

these actors are likely to cause a starvation effect.

The effect you want to achieve is to make sure that messages are processed quickly, and long-term work does not affect them, so separation is the key here.

A good tool to monitor your application is the Configure Console . You can look at the dispatcher there and see that the delay in processing messages increases.

Another issue is identifying participants who are at high risk, such as network I / O. If something happens that the thread is again unavailable in the pool, this will create problems.

It is very likely that without experimenting with threadpool size, you will not know what works best for you.

Most of the tips I wrote I know from Effective Akka by Jamie Allen and they seem to work well for me. This book has a Fixing Starvation section. You can look at her closer.

+2
source

All Articles