hi,
I’m implementing an micro service that communicates with other services over http. Essentially the service makes a backend http api calls to other servers to fulfill request.
I use akka http connection pool by default.
To maintain higher throughput at high(~10 sec) latency between services at a high request rates, I allow a larger connection pool size on the client side
For the first requests takes a lot of time(~20 second ) before they get forwarded upstream. reducing “max-connections” seems to lessen the delay.
can anyone suggest, how I can maintain a larger connection pool without the initial delays.
I have added the config & some code I use for the testing below.
Config:
akka.http.host-connection-pool {
max-open-requests = 32768
max-connections = 2048
min-connections = 256
max-retries = 0
}
Code:
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpMethods, HttpRequest, Uri}
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.stream.ActorMaterializer
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContextExecutor}
object APIClient {
def main(args: Array[String]): Unit = {
implicit val system:ActorSystem = ActorSystem()
implicit val materializer:ActorMaterializer = ActorMaterializer()
implicit val executionContext:ExecutionContextExecutor = system.dispatcher
val http = Http(system)
val message = Await.result(http.singleRequest(HttpRequest(HttpMethods.GET,
Uri("http://example.com:80/"))), 10.second)
val payload = Await.result(Unmarshal(message.entity).to[String], 1.second)
message.discardEntityBytes()
print(payload)
system.terminate()
}
}
Thanks
Prasanna Josium