亚马逊 aws 上的故障转移代理?
这是一个相当普遍的问题。假设我有三个 ec2 盒子:两个应用程序盒子和一个托管 nginx 作为反向代理的盒子,将请求委托给两个应用程序盒子(我的数据库托管在其他地方)。现在,两台应用程序机器可以吸收彼此之间的故障,但第三台应用程序机器代表单点故障。如何配置我的设置,以便在反向代理出现故障时该站点仍然可用?
我正在研究 keepalived 和 HAproxy。对我来说,这些东西并不明显,任何对初学者耳朵的帮助都是值得赞赏的。
This is a fairly generic question. Suppose I have three ec2 boxes: two app boxes and a box that hosts nginx as a reverse proxy, delegating requests to the two app boxes (my database is hosted elsewhere). Now, the two app machines can absorb a failure amongst themselves, however the third one represents a single point of failure. How can I configure my setup so that if the reverse proxy goes down, the site is still available?
I am looking at keepalived and HAproxy. For me this stuff is non-obvious, and any help for the ears of a beginner is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的 nginx 只是代理 HTTP 请求,请查看 Amazon Elastic Load Balancer。您可以设置两个(或更多)应用程序框,保留一些备用应用程序框(以便始终保持两个或更多应用程序框,如果需要的话),设置运行状况检查,在平衡器处进行 SSL 终止,使用粘性不过
,有很多人希望看到能够为 ELB 设置弹性 IP 地址,而其他人也有很好的理由说明为什么不需要这样做。
我的建议是您查看 ELB 文档,因为它似乎完全满足您的需求。我还建议阅读这篇有趣的帖子关于这个主题的良好讨论。
If your nginx does no much more than proxying HTTP requests, please have a look at Amazon Elastic Load Balancer. You can set up your two (or more) app boxes, leave some spare ones (in order to keep always two or more up, if you need it), set up health checks, have SSL termination at the balancer, make use of sticky sessions, etc.
There is a lot of people, though, that would like to see the ability to set elastic IP addresses to ELBs, and others with good arguments why it is not neeeded.
My suggestions is that you take a look at ELB documentation, as it seems to perfectly fit your needs. I also recommend reading this interesting post for a good discussion on this subject.
我认为如果您是 HA 和集群的初学者,您最好的解决方案是由 Amazon 维护的弹性负载均衡器 (ELB)。它们自动扩展并实现高可用性的平衡器集群。因此,使用 ELB 服务您已经减轻了您评论的故障点。另外,请务必记住,一个 ELB 比 AWS 中的 2 个实例便宜。当然,它更容易启动和维护。
你看不到多个ELB,因为它是一项服务,所以你不必关心可用性。
其他重要的一点是,AWS 弹性 ip 未分配给操作系统实例的 NIC 接口,因此在经典基础设施中使用虚拟 ip 很困难。
经过此解释,如果您仍然希望 Nginx 作为 AWS 中的反向代理,因为您的原因,我认为您可以使用由 Nginx 实例组成的层来实现自动缩放组。但如果您不是自动缩放技术方面的专家,这可能会非常棘手。
I think if you are a beginner with HA and clusters, your best solution is Elastic Load Balancer (ELB) which is maintained by Amazon. They scale up automatically and implements a high availability cluster of balancers. So using ELB service you already mitigate the point of failure that you commented. Also it's important to have in mind that an ELB is cheaper than 2 instances in AWS. And of course it's easier to launch and maintain.
You can't see multiple ELB because it is a service, so you don't have to take care of the availability.
Other important point is that AWS elastic ips aren't assigned to NIC interface of your OS instance, so use virtual ips as well in classical infrastructures it's difficult.
After this explanation, if you still want Nginx as a proxy reverse in AWS because your reasons, I think you can implement an autoscaling group with a layer composed by Nginx instances. But if you aren't expert in autoscaling technology, it could be very tricky.