【发布时间】:2019-03-04 10:10:04
【问题描述】:
我们从使用 Camel HTTP4 转移到 Akka HTTP,虽然我们现在能够更好地控制错误,但考虑到 Akka HTTP(客户端)中的所有可调整参数,要获得更好的性能变得非常困难。
我们有一个参与者接收消息,向外部服务发出 HTTP GET 请求(可以轻松管理超过 1500 RPS),然后以字符串形式的 http 响应正文进行响应。
我们现在的上限为 650 RPS,即使我们没有遇到错误(如以前使用 Camel 的 HTTP4),我们也无法超过这 650(与之前使用默认参数的 HTTP4 的 800 RPS 不同)。
我们的 HTTP 请求是使用 singleRequest 发出的:
val httpResponseFuture: Future[HttpResponse] = http.singleRequest(HttpRequest(uri = uri))
val tokenizationResponse = for {
response <- httpResponseFuture
body <- Unmarshal(response.entity).to[String]
} yield transformResponse(response.status, body, path, response.headers)
然后这些是产生最佳结果的设置(检查这些数字并没有显示任何真正的改进:
akka {
actor.deployment {
/HttpClient {
router = balancing-pool
nr-of-instances = 7
}
}
http {
host-connection-pool {
max-connections = 30
max-retries = 5
max-open-requests = 8192
pipelining-limit = 200
idle-timeout = 30 s
}
}
}
我们尝试调整池的大小、actor 实例以及 host-connection-pool 下的所有其他参数,但我们无法做得更好。
欢迎提出任何建议!
【问题讨论】: