1

スプレー缶のバージョン 1.3.3 と akka 2.3.9 を使用しています。サーバー コードはかなり標準的に見えます。

アプリケーション.conf:

spray.can {
 server {
  pipelining-limit = 10
  request-timeout = 50ms
  stats-support = on
 }
...

ブート:

object Boot extends App {
  implicit val system = ActorSystem("on-spray-can")
  val service = system.actorOf(Props[MyServiceActor], "demo-service")
  IO(Http) ! Http.Bind(service, "0.0.0.0", port = 8080)
 }

MySeviceActor:

  class MyServiceActor extends Actor with MyService {
    def actorRefFactory = context
    def receive = runRoute(route)
  }

trait MyService extends HttpService {
  implicit def executionContext = actorRefFactory.dispatcher
 val route: Route =
   path("do") {
     post {
       detach() {          
          entity(as[String]) { body =>
            complete {
              val resp = processRequestAsync(body)
              convertToHttpResponseAsync(resp)
            }}}}
 }

 def processRequestAsync(body:String):Future[MyContext]={
     // do some non-blocking using async client.api, spray-client..
 }
 def convertToHttpResponseAsync(resp: Future[MyContext]): Future[HttpResponse] = {
  resp.map { ctx => 
 // ... Do some non blocking ops
    HttpResponse(StatusCodes.OK, entity = HttpEntity(`application/json`, ctx.getData))
  }
 }
}

私のローカルホスト環境では、統計は妥当に見えます (少なくともオープン接続の数)。ab、wrk ベンチマークを使用しています。

Total requests        : 2434475
Open requests         : 1847228
Max open requests     : 1847228
Total connections     : 1995540
Open connections      : 142
Max open connections  : 1239
Requests timed out    : 189196

外部リクエストを受け取り、アプリケーションにディスパッチする ngnix があります。

問題は、これほど多くの接続が開かれている根本的な原因は何でしょうか? どのようなパラメーター、ヘッダー、その他に注意を払い、調査する必要がありますか?

私のアプリケーションは Docker コンテナーから実行されます

4

0 に答える 0