java Akka Http大部分cpu时间都花在不安全的环境中。公园()
我正在编写一个Akka Http服务(v2.4.2),用于与cassandra实例对话。在我的笔记本电脑上运行这项服务时,它似乎与同时连接的数量不成比例
~/workspace/wrk $ ./wrk -t8 -c32 -d30s -s random-object.lua http://localhost:8080/buckets/newbucket
Running 30s test @ http://localhost:8080/buckets/newbucket
8 threads and 32 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 14.23ms 29.40ms 304.93ms 91.78%
Req/Sec 703.35 226.18 1.31k 75.40%
165252 requests in 30.03s, 27.74MB read
Requests/sec: 5503.64
Transfer/sec: 0.92MB
~/workspace/wrk $ ./wrk -t8 -c64 -d30s -s random-object.lua http://localhost:8080/buckets/newbucket
Running 30s test @ http://localhost:8080/buckets/newbucket
8 threads and 64 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 20.66ms 37.87ms 676.67ms 90.45%
Req/Sec 0.86k 288.76 2.09k 72.99%
199623 requests in 30.09s, 33.51MB read
Requests/sec: 6633.58
Transfer/sec: 1.11MB
~/workspace/wrk $ ./wrk -t8 -c128 -d30s -s random-object.lua http://localhost:8080/buckets/newbucket
Running 30s test @ http://localhost:8080/buckets/newbucket
8 threads and 128 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 27.52ms 35.14ms 506.00ms 88.56%
Req/Sec 0.87k 275.83 2.36k 72.13%
207498 requests in 30.08s, 34.83MB read
Socket errors: connect 0, read 96, write 2, timeout 0
Requests/sec: 6897.64
Transfer/sec: 1.16MB
事实上,我刚刚注意到断开64个连接时出现了socket错误。所有Akka配置都是默认配置。如果我看一下VisualVM中的统计数据,akka会创建一组新的调度器来处理负载,但90%的cpu时间都花在akka代码中(看起来):
"metadata-service-akka.actor.default-dispatcher-62" #101 prio=5 os_prio=31 tid=0x00007fc261a7f800 nid=0xa503 waiting on condition [0x0000700003f50000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006c0098818> (a akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinPool)
at scala.concurrent.forkjoin.ForkJoinPool.scan(ForkJoinPool.java:2075)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Locked ownable synchronizers:
- None
共 (0) 个答案