简体   繁体   English

Playframework线程池

[英]Playframework thread pools

I'm profiling a playframework 2.2.3 application with YourKit to try and troubleshoot some performance issues. 我正在使用YourKit对playframework 2.2.3应用程序进行性能分析,以尝试解决一些性能问题。 This is not my application and I am not familiar with play 2. The application is a multi-player social game that utilises web sockets. 这不是我的应用程序,也不熟悉Play2。该应用程序是利用Web套接字的多人社交游戏。 It runs on Amazon EC2 m3.large 它在Amazon EC2 m3.large上运行

What I can see in the profiler is that the game play logic (begun by web socket calls) is carried out in 1 of 2 threads in play-internal-execution-context. 我在探查器中看到的是,游戏逻辑(通过Web套接字调用开始)是在play-internal-execution-context中的2个线程中的1个执行的。 Some of the routines involve I/O and there is some blocking going on due to method synchronization in parts. 一些例程涉及I / O,并且由于部分中的方法同步而导致一些阻塞。 There is a pool of threads named play-internal-execution-context but only two are ever in use at anytime. 有一个名为play-internal-execution-context的线程池,但是随时都只有两个在使用。 Activity is moved to new threads from time to time and I can see right now the thread names in use are play-internal-execution-context-600 and 601. 活动不时移至新线程,我现在可以看到正在使用的线程名称为play-internal-execution-context-600和601。

I can see in the play docs 我可以在播放文档中看到

Play Internal Thread Pool - This is used internally by Play. Play内部线程池-Play在内部使用。 No application code should ever be executed by a thread in this thread pool, and no blocking should ever be done in this thread pool. 此线程池中的任何线程都不应执行任何应用程序代码,并且此线程池中也不应进行任何阻塞。 Its size can be configured by setting internal-threadpool-size in application.conf, and it defaults to the number of available processors. 可以通过在application.conf中设置internal-threadpool-size来配置其大小,并且默认为可用处理器的数量。

As I can see stack traces in the threads that involve application code is this likely that the developers have an incorrect design, or, is this just because of the async nature of the framework that the code is actually just executed by play in these internal threads? 如我所见,涉及应用程序代码的线程中的堆栈跟踪可能是开发人员设计错误,或者仅仅是由于框架的异步特性,即代码实际上只是在这些内部线程中通过执行而执行?

All the best 祝一切顺利

Jon 乔恩

Please make sure that you are not running blocking code inside onReady callback method of WebSocket. 请确保您没有在WebSocket的onReady回调方法中运行阻塞代码。 Any blocking or heavy computation should be offloaded to some other thread pool (use promise or actor). 任何阻塞或繁重的计算都应卸载到其他线程池中(使用promise或actor)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM