She*_*gon 5 java nio apache-httpclient-4.x quasar
应用说明:
根据以上各节,这是我的光纤http客户端的调谐(当然,我正在使用的单个实例):
PoolingNHttpClientConnectionManager connectionManager =
new PoolingNHttpClientConnectionManager(
new DefaultConnectingIOReactor(
IOReactorConfig.
custom().
setIoThreadCount(16).
setSoKeepAlive(false).
setSoLinger(0).
setSoReuseAddress(false).
setSelectInterval(10).
build()
)
);
connectionManager.setDefaultMaxPerRoute(32768);
connectionManager.setMaxTotal(131072);
FiberHttpClientBuilder fiberClientBuilder = FiberHttpClientBuilder.
create().
setDefaultRequestConfig(
RequestConfig.
custom().
setSocketTimeout(1500).
setConnectTimeout(1000).
build()
).
setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE).
setConnectionManager(connectionManager).
build();
Run Code Online (Sandbox Code Playgroud)将打开文件的ulimit设置为超高(软值和硬值都为131072)
kernel.printk = 8 4 1 7 kernel.printk_ratelimit_burst = 10 kernel.printk_ratelimit = 5 net.ipv4.ip_local_port_range = 8192 65535 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.rmem_default = 16777216 net.core .wmem_default = 16777216 net.core.optmem_max = 40960 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.core.netdev_max_backlog = 100000 net.ipv4.tcp_max_syn_backets = 20000.net net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 10 net.ipv4.tcp_slow_start_after_idle = 0 net.ipv4.tcp_sack = 0 net.ipv4.tcp_timestamps = 1
问题描述
Pending统计信息也飙升到30K的待处理连接请求lsof在Java进程中,我可以看到它有成千上万个文件描述符,几乎所有文件描述符都在CLOSE_WAIT中(这很有意义,因为I / O反应堆线程死亡/停止运行,并且从不真正关闭它们)问题
忘了回答这个问题,但我在发布问题后大约一周才知道发生了什么:
存在某种错误配置,导致 io-reactor 仅生成 2 个线程。
即使提供更多反应器线程后,问题仍然存在。事实证明,我们的传出请求大部分都是 SSL。Apache SSL 连接处理将核心处理传播到 JVM 的 SSL 设施,这些设施的效率不足以每秒处理数千个 SSL 连接请求。更具体地说,SSLEngine 中的一些方法(如果我没记错的话)是同步的。在高负载下执行线程转储显示 IORecator 线程在尝试打开 SSL 连接时相互阻塞。
即使尝试以连接租约超时的形式创建压力释放阀也不起作用,因为创建的积压量太大,导致应用程序无用。
将 SSL 传出请求处理卸载到 nginx 的性能更差 - 因为远程端点会抢先终止请求,因此无法使用 SSL 客户端会话缓存(JVM 实现也是如此)。
最终在整个模块前面放置了一个信号量,在任何给定时刻将整个模块限制为 ~6000,这解决了问题。
| 归档时间: |
|
| 查看次数: |
2274 次 |
| 最近记录: |