Amazon Elastic Load Balancer is not closing the connection to the server

Mat*_*ert 8 apache amazon-web-services ffserver amazon-elb

I have an EC2 instance with Apache as a reverse proxy and ffserver as a streaming server. There is an ELB (Classic) in front of the EC2 instance which works as an SSL termination point.

Apache configuration is rather simple:

<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>
Run Code Online (Sandbox Code Playgroud)

ffserver is used to stream live audio over the Internet. In ffserver's settings there is a MaxBandwidth option (default 1000). This setting become a problem when the connections are not closed properly. ffserver starts to respond with 503 server too busy instead of the stream's content.

If I connect to the server directly (no ELB on the road) everything works fine. If I connect over the ELB the connection won't close when I close it on the client's side (e.g. close the browser's tab).

I use the below command to check the current connections:

watch -n 2 'netstat -napt | grep 8081'
Run Code Online (Sandbox Code Playgroud)

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

编辑:似乎将经典负载平衡器更改为应用程序负载平衡器解决了该问题。我不知道如何解释这种行为。期待从AWS社区获得答案-AWS论坛

bur*_*ete 6

当OP与他的编辑共享时,可以通过更改负载平衡器类型来解决连接未关闭的问题。这个答案集中在为什么这种变化会产生如此影响?


经典负载均衡器(ELB)中似乎存在问题。我发现以下帖子中的问题非常相似;

似乎该问题源于ELB无法检测到客户端从连接断开的情况。尤其是在后端以周期性方式提供某种数据时,例如实时音频流,心跳等。

似乎没有一种方法可以禁用keep-alive负载均衡器的设置,但是,以某种方式,只有ELB这种麻烦才会发生。

我找不到在ELB&之间造成这种行为差异的确切功能ALB。我认为原因可能是由于;

ALB由于上述改进,我认为使用Application Load Balancer()时该问题已解决,并且更加灵活。

点击这里获取更多有关之间的差异ELBALB以及NLB


ps。AWS支持论坛太糟糕了,所有好的支持和技巧都被充实了,并存储在它们及其高级客户之间的PM中。