You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object StatsRepo{
val totConn = new AtomicInteger(0)
val concReq = new AtomicInteger(0)
val currOpenConn = new AtomicInteger(0) // how to count this?
}
object CommonRepo{
implicit val system = ActorSystem("akka-http")
val materializer = ActorMaterializer()
val executionContext = system.dispatcher
val workerExecutionContext = system.dispatchers.lookup("worker-dispatcher")
}
object Boot2 extends App{
val requestHandler: HttpRequest => Future[HttpResponse] = {
// do some work here...
case HttpRequest(POST, url, headers, entity, _) => {
StatsRepo.totReq.incrementAndGet()
StatsRepo.concReq.incrementAndGet()
// ...
implicit val ec = CommonRepo.workerExecutionContext
val bodyF: Future[String] = Unmarshal(entity).to[String]
val resp = processRequestAsync(bodyF)
convertToHttpResponseAsync(resp)
}
}
def processRtbRequestAsync( bodyF: Future[String]): Future[MyRequestContext] = {
implicit val ec = CommonRepo.workerExecutionContext
extractBody(bodyF).
withFilter(ctx=>ctx.body != null ).
flatMap(ctx=> callToFunc1(ctx)). // func1:MyRequestContext->Future[MyRequestContext]
flatMap(ctx => callToFunc2(ctx)) // func2 similar to func1 app code
// both funcs does not execute any blockind code, for test purpose I event put some immediate dummy response there, like Future{ctx}
}
def convertToHttpResponseAsync(resp: Future[MyRequestContext]): Future[HttpResponse] = {
implicit val ec = BidderDIRepo.repo.clientTP
resp.map { ctx =>
StatsRepo.concReq.decrementAndGet()
HttpResponse(StatusCodes.OK, entity = HttpEntity(`application/json`, ctx.resp))
}
}
implicit val system = ActorSystem("akka-http")
implicit val materializer = ActorMaterializer()
implicit val executionContext = system.dispatcher
val serverSource = Http().bind("0.0.0.0", 8080)
val bindingFuture: Future[Http.ServerBinding] =
serverSource.to(Sink.foreach { connection =>
StatsRepo.totConn.incrementAndGet()
connection handleWithAsyncHandler requestHandler
}).run()
println(s"Server online at http://0.0.0.0:8080")
}
The issue I see in production, that in-spite of the max-connection limit the server has much more open-connections and processing big amount of concurrent requests
In addition such behavior could be reproduced with ab
If you run two windows with
In this case I'm getting ~15 concurent requests that also comes in spiky behavior
Also the latencies has spikes between start, func1,func2 processing... (but those futures are with already dummy data...?)
The text was updated successfully, but these errors were encountered:
ktoso
added
1 - triaged
Tickets that are safe to pick up for contributing in terms of likeliness of being accepted
and removed
t:http
labels
Sep 8, 2016
jonas
changed the title
Potential bug in managing number of connections in akka-http sever
Potential bug in managing number of connections in akka-http server
Dec 18, 2016
Issue by sjulias
Monday May 23, 2016 at 21:24 GMT
Originally opened as akka/akka#20600
I'm evaluating akka-http
dependencies:
The code look like as following:
In the the application.conf:
The issue I see in production, that in-spite of the max-connection limit the server has much more open-connections and processing big amount of concurrent requests
In addition such behavior could be reproduced with ab
If you run two windows with
In this case I'm getting ~15 concurent requests that also comes in spiky behavior
Also the latencies has spikes between start, func1,func2 processing... (but those futures are with already dummy data...?)
The text was updated successfully, but these errors were encountered: