Akka Http在Unsafe.park()中花费的大部分cpu时间

时间:2016-04-15 14:36:14

标签: java performance scala akka akka-http

我正在写一个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个连接,就会注意到套接字错误。所有Akka配置都是默认的。如果我查看可视VM中的统计信息,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 个答案:

没有答案