【发布时间】:2014-01-21 15:00:32
【问题描述】:
在我的游戏中! 2.1 Rest API App 我已经安装了New Relic。
我所有的控制器动作都继承自一个为响应的未来添加超时的方法。如果任何此类方法花费的时间超过 20 秒,则请求将终止,结果为 5XX 错误。
代码基本上是这样的:
val timeout = 20
action(request).orTimeout(
name + " backend timed-out after "+timeout+" seconds", timeout * 1000).map {
resultOrTimeout => { //... process response or timeout with fold
我遇到的问题是,在分析新文物中的数据时,我总是得到 20 秒的平均响应时间。
查看跟踪时,我可以看到 new relic 将超时函数解释为响应的容器。
Slowest components Count Duration %
Async Wait 7 20,000 ms 100%
Action$$anonfun$apply$1.apply() 2 2 ms 0%
PlayDefaultUpstreamHandler$$an....apply() 1 1 ms 0%
PlayDefaultUpstream....$$anonfun$24.apply() 1 1 ms 0%
SmaugController$class.akkify() 1 0 ms 0%
PlayDefaultUpstreamHandler.handleAction$1() 1 0 ms 0%
Total 20,000 ms 100%
有什么办法可以防止 new-relic 考虑超时?
谢谢!
编辑:我扩展了交易以获取更多信息:
Duration (ms) Duration (%) Segment Drilldown Timestamp
20,000 100.00% HttpRequestDecoder.unfoldAndFireMessageReceived()
20,000 100.00% Async Wait
Stack trace
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
java.lang.Thread.run (Thread.java:679)
107 0.53% SmaugController$class.akkify()
如您所见,真正的工作是在 akkify 方法中完成的,耗时 107 毫秒,其余的都被 Async Wait 调用消耗
【问题讨论】:
标签: asynchronous playframework-2.0 scala-2.10 newrelic