Vertx-java-HttpClient:如何获取maxPoolSize和maxWaitQueueSize值及其影响 [英] Vertx-java-HttpClient: How to derive maxPoolSize and maxWaitQueueSize values and their impact

查看:234
本文介绍了Vertx-java-HttpClient:如何获取maxPoolSize和maxWaitQueueSize值及其影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 vertx java 中创建了一个Java后端服务。我使用启用了连接池 httpClient io.vertx.core.http.HttpClient )连接到外部服务。我不包括 50的吞吐量。对于对服务的每个请求,我都需要连接到外部服务。我的服务的平均响应时间为4秒,外部服务的响应时间约为3秒。

I have created a one java backend service in vertx java. I used httpClient(io.vertx.core.http.HttpClient) with connection pooling enabled to connect to external services. I am excepting throughput of 50. For each request to my service I need to connect to external service. Average response time for my service is 4 seconds and external service is around 3 seconds.

现在我的问题是


  1. 如何为HttpClient导出 maxPoolSize maxWaitQueueSize 值?

  2. maxPoolSize maxWaitQueueSize 值对内存和cpu有什么影响?

  3. 我可以设置为 maxPoolSize maxWaitQueueSize 的最大值是什么?

  4. 我还应该使用 HttpClient setPipelining 选项吗?

  1. How can I derive maxPoolSize and maxWaitQueueSize values for HttpClient?
  2. What is the impact maxPoolSize and maxWaitQueueSize values on memory and cpu?
  3. What are the maximum values I can set to maxPoolSize and maxWaitQueueSize?
  4. Should I also use setPipelining option of HttpClient?


推荐答案

首先,请注意 maxPoolSize 适用于每个目标。因此,如果您想要不同的池大小,请为后端创建不同的 HttpClient

First, beware that maxPoolSize applies to each destination. So if you want different pool sizes, create different HttpClient for your backends.

然后,除非您在在受限的环境中,我建议将 maxWaitQueueSize 保留为默认值,即 -1 (无界)。给定您期望的负载,内存中队列的大小应该相对较小。

Then, unless you work in a constrained environment, I would recommend to leave maxWaitQueueSize to the default, which is -1 (unbounded). The size of the queue in memory should be relativeley small given the load you're expecting.

要确定池大小值,可以使用利特尔定律。为了在平均3秒钟的服务时间内支持50 req / sec的吞吐量,您需要150个连接池。

To determine the pool size value you can use Little's law. To support a 50 req/sec throughput with an average 3s service time, you need a pool of 150 connections.

您可以为 maxPoolSize 取决于系统的配置方式。特别是,您需要配置打开文件描述符的最大数量。

The maximum value you can set for maxPoolSize depends on how your system is configured. In particular, you need to configure the max number of open file descriptors.

对于您的用例,我相信您应该避免启用管道。首先,并不是所有的HTTP服务器都正确地支持它。其次,如果服务时间在0到3秒之间变化,则后端可能会保留一个响应,因为尚未处理管道中的先前请求(行头阻塞)。

For your use case, I believe you should avoid enabling pipeling. First not all HTTP server support it correctly. Second if the service time varies between 0-3 secs, a response might be hold by the backend because previous requests in the pipeline are not handled yet (head-of-line blocking).

这篇关于Vertx-java-HttpClient:如何获取maxPoolSize和maxWaitQueueSize值及其影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆