8

我有一个EC2实例,Apache作为反向代理,ffserver作为流服务器。在EC2实例前面有一个ELB (经典),用作 SSL 终止点。

Apache的配置相当简单:

<Location "/mp3/">
    ProxyPass http://127.0.0.1:8081/ DisableReuse=On KeepAlive=Off
    ProxyPassReverse http://127.0.0.1:8081/
    SetEnv force-proxy-request-1.0.1
    SetEnv proxy-nokeepalive 1
</Location>

ffserver用于通过 Internet 流式传输实时音频。在ffserver的设置中有一个MaxBandwidth选项(默认1000)。当连接未正确关闭时,此设置会成为问题。ffserver开始响应503 server too busy而不是流的内容。

如果我直接连接到服务器(路上没有ELB )一切正常。如果我通过ELB连接,当我在客户端关闭它时连接不会关闭(例如关闭浏览器的选项卡)。

我使用以下命令检查当前连接:

watch -n 2 'netstat -napt | grep 8081'

所有连接都永远保持在 ESTABLISHED 状态(至少 30 分钟)。ELB的默认空闲超时为60。这意味着有人正在从ffserver接收流(连接处于活动状态)。

编辑:看起来将 Classic Load Balancer 更改为 Application Load Balancer 解决了这个问题。我不知道如何解释这种行为。期待 AWS 社区的回答 - AWS 论坛

4

2 回答 2

6

As OP shared with his edit, the issue of connections not getting closed can be resolved with a change of load balancer type. This answer focuses on why this change has such an affect?


There seems to be an issue within Classic Load Balancer (ELB). I've found the following posts with very similar issues;

It seems the issue stems from ELB not being able to detect the client dropping from a connection. Especially when back-end is supplying some sort of data in a periodical manner, e.g. live audio stream, heartbeat, etc.

There doesn't seem to be a way to disable the keep-alive setting of load balancers, yet, somehow, only with ELB this trouble occurs.

I couldn't find exact feature that is creating this behavioural difference between ELB & ALB. I think the reason is either due to;

  • Improved Health Checks in ALB, and/or
  • an internal structural difference that is not visible to us users, that somehow keeps this issue from happening on ALB

I think the issue resolves when Application Load Balancer (ALB) is used due to said improvements and it being much more flexible.

Check here for more on the differences between ELB, ALB, and NLB


ps. AWS support forums are terrible, all the good support & tips are paywalled and stored within PMs between them & their premium customers.

于 2019-07-18T08:01:04.170 回答
1

我知道这是一个旧线程,但我最近遇到了同样的问题,解决方案是切换到 ALB。之后正常工作。

于 2020-08-07T09:49:04.953 回答