AWS 应用程序负载均衡器上接收到的字节不一致

Inconsistent received bytes on AWS application load balancer

我正在调查为什么我的应用程序负载均衡器的 NetworkIn 出现峰值。

所以我启用了负载均衡器的访问日志,并且对2020-08-03 11:44:00 UTC+0800的所有请求求和received_bytes

received_bytes:

The size of the request, in bytes, received from the client (requester). For HTTP requests, this includes the headers. For WebSockets, this is the total number of bytes received from the client on the connection.

但是我从日志中得到的总字节数只有458355字节,远远小于上图中的476.966MB

我使用excel的函数SUM(K:K)来计算日志中的总字节数。

可以找到NetworkIn的定义here

The number of bytes received on all network interfaces by the instance. This metric identifies the volume of incoming network traffic to a single instance.

The number reported is the number of bytes received during the period. If you are using basic (five-minute) monitoring, you can divide this number by 300 to find Bytes/second. If you have detailed (one-minute) monitoring, divide it by 60.

Units: Bytes

为什么不一致?

NetworkIn 包含传输到负载均衡器后面的 EC2 实例的所有数据。

在我的例子中,这包括 EC2 从 MySQL 数据库接收的所有数据。

从数据库传输到EC2的数据不包含在received_bytes中,因为它没有经过负载均衡器。

这就解释了为什么 NetworkIn 的字节和 received_bytes 的字节不同。

可以通过点击Services -> EC2 -> Network Interfaces -> pick a network interface -> Flow Logs 选项卡启用网络接口日志 - > Create flow log.