2016-12-08 4 views
0

akka-httpとakka-streamでサーバーを構築しましたが、2K +リクエストでリクエストが失われました。私が何かを恋しくしているか、またはakkaの理解が間違っています。10kリクエストでakkaストリームでhtttpリクエストを行う方法

これは私のコードである

implicit val actorRef = ActorSystem("system", testConf) 
    implicit val materializer = ActorMaterializer(ActorMaterializerSettings(actorRef).withInputBuffer(initialSize = 4, maxSize = 16)) 
    implicit val requestTimeout = Timeout(8 seconds) 

    def response(req: HttpRequest): Future[Response] = { 
    val connectionFlow: Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]] = 
     Http().outgoingConnection(host = "url").async 
    for { 
     res <- Source.single(req.copy(uri = s"${req.uri.path}?${req.uri.rawQueryString.get}")).via(connectionFlow).runWith(Sink.head) 
     data <- res.entity.toStrict(5 second) 
    } yield (data.getData().decodeString("UTF-8"), res.status.intValue()) 
    } 

ありがとうございます。

答えて

1

ほとんどの場合、タイムアウトまたはサーバー側のエラーが理解の最初の部分にあったため、resに成功した応答しか得られませんでした。

withSupervisionStrategyでリクエストを処理するフロー/グラフをマテリアライザーに作成することをお勧めします。実装の詳細は、ビジネスロジックに依存します。

+0

将来的にHttpResponseをStringに変換するために私は読解を使用します。 –

関連する問題