简体   繁体   English

为什么在使用 WebSockets 时,Amazon CloudWatch 指标中的 ActiveConnectionCount 会翻倍?

[英]Why is ActiveConnectionCount doubled in Amazon CloudWatch metrics when using WebSockets?

If we run a WebSocket load test with a max of 10K open connections we always get double the ActiveConnectionCount, the included image is a screenshot of a CloudWatch metric of the Application Load Balancer of our wss://endpoint.如果我们运行最多 10K 个打开连接的 WebSocket 负载测试,我们总是会得到两倍的 ActiveConnectionCount,其中包含的图像是我们的 wss://endpoint 的应用程序负载均衡器的 CloudWatch 指标的屏幕截图。 If we run a HTTP load test the ActiveConnectionCount is correct.如果我们运行 HTTP 负载测试,则 ActiveConnectionCount 是正确的。 Why is this?为什么是这样?

Pseudo Load test code:伪负载测试代码:

const WebSocket = require('ws');

for (let i = 0; i < 10000; i++) {
const client = new WebSocket('wss://endpoint');

client.on('open', () => {
  setInterval(() => {
    client.send('random message');
  }, 15000);
});

} }

Screenshot of ActiveConnectionCount in Amazon CloudWatch Metrics: Amazon CloudWatch 指标中 ActiveConnectionCount 的屏幕截图:

ActiveConnectionCount Amazon CloudWatch

According to the AWS docs, ActiveConnectionCount is "The total number of concurrent TCP connections active from clients to the load balancer and from the load balancer to targets."根据 AWS 文档,ActiveConnectionCount 是“从客户端到负载均衡器以及从负载均衡器到目标的活动的并发 TCP 连接总数”。

So if you have 10 connections through a load balancer to a target, this metric should show 20 connections (10 from clients, and 10 to targets).因此,如果您有 10 个通过负载均衡器连接到目标的连接,则该指标应显示 20 个连接(10 个来自客户端,10 个连接到目标)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM