如何优雅地关闭或从ELB组中删除AWS实例组中、实例、优雅、ELB

2023-09-11 08:32:28 作者:Dance灬倾城

我有一个云亚马逊运行使用它们的负载平衡器来分发流量的服务器实例。现在,我要寻找到正常规模网络下的好方法,而不会导致在浏览器端连接错误。

I have a cloud of server instances running at Amazon using their load balancer to distribute the traffic. Now I am looking for a good way to gracefully scale the network down, without causing connection errors on the browser's side.

据我所知,一个实例的任何连接将被粗暴地终止从负载平衡器中删除时。

As far as I know, any connections of an instance will be rudely terminated when removed from the load balancer.

我想有一种方式来通知我的情况下像前一分钟就被关闭或具有负载平衡器停止发送流量给垂死的实例,但没有终止它现有的连接。

I would like to have a way to inform my instance like one minute before it gets shut down or to have the load balancer stop sending traffic to the dying instance, but without terminating existing connections to it.

我的应用程序的Node.js基于在Ubuntu上运行。我也有在其上运行一些特殊的软件,所以我preFER不要用很多PaaS产品的node.js托管。

My app is node.js based running on Ubuntu. I also have some special software running on it, so I prefer not to use the many PAAS offering node.js hosting.

感谢您的任何提示。

推荐答案

这个想法使用ELB的探测能力不健康的节点,并从池中删除它,但它依赖于ELB按预期在以下假设。这是我一直想测试自己,但已经没有时间呢。我会更新的答案时,我做的。

This idea uses the ELB's capability to detect an unhealthy node and remove it from the pool BUT it relies upon the ELB behaving as expected in the assumptions below. This is something I've been meaning to test for myself but haven't had the time yet. I'll update the answer when I do.

工艺概述

下面的逻辑可以被包装并运行在节点需要被关闭的时间。

The following logic could be wrapped and run at the time the node needs to be shut down.

在阻止新的HTTP连接nodeX而是继续让现有的连接 在等待现有的连接排,或者通过监视您的应用程序,或者允许的时间安全的数量现有的连接。 在直接或抽象脚本,以使用EC2 API启动的nodeX EC2实例关闭。

安全的根据你的应用,这是不可能的,以确定对于一些应用

"safe" according to your application, which may not be possible to determine for some applications.

假设需要测试

我们知道,ELB 删除不健康的情况下,从它的游泳池我希望这是优雅的,这样:

We know that ELB removes unhealthy instances from it's pool I would expect this to be graceful, so that:

要最近关闭的端口一个新的连接将会优雅地重定向到下一个节点在游泳池 当一个节点被标记为坏,已建立的连接到该节点不受影响。

可能的测试案例:

消防HTTP(从卷曲脚本例)连接在ELB日志记录 期间的结果脚本化打开节点中的一个的闭合 HTTP端口。您需要通过试验来找到一个 可接受的时间,让ELB总是确定的状态 的变化。 在保持一个较长的HTTP会话(例如文件下载),同时阻挡新 HTTP连接,长长的会议应该有希望继续下去。 Fire HTTP connections at ELB (E.g. from a curl script) logging the results during scripted opening an closing of one of the nodes HTTP ports. You would need to experiment to find an acceptable amount of time that allows ELB to always determine a state change. Maintain a long HTTP session, (E.g. file download) while blocking new HTTP connections, the long session should hopefully continue.

1。如何阻止HTTP连接

使用上nodeX本地防火墙来阻止新的会话,但继续允许建立的会话。

Use a local firewall on nodeX to block new sessions but continue to allow established sessions.

例如IP表:

iptables -A INPUT -j DROP -p tcp --syn --destination-port <web service port>
 
精彩推荐
图片推荐