系统相关
首页 > 系统相关> > 澄清Nginx和所需的负载平衡

澄清Nginx和所需的负载平衡

作者:互联网

我现在正在阅读Instagram的设计,我发现了它们的负载平衡系统的描述.

Every request to Instagram servers goes through load balancing machines; we used to run 2 nginx machines and DNS Round-Robin between them. The downside of this approach is the time it takes for DNS to update in case one of the machines needs to get decomissioned. Recently, we moved to using Amazon’s Elastic Load Balancer, with 3 NGINX instances behind it that can be swapped in and out (and are automatically taken out of rotation if they fail a health check). We also terminate our SSL at the ELB level, which lessens the CPU load on nginx. We use Amazon’s Route53 for DNS, which they’ve recently added a pretty good GUI tool for in the AWS console.

问题是.我说的对吗,现在他们有一个DNS服务器,该服务器使用RR来决定在哪个nginx服务器上发送请求.每个nginx服务器又将请求重新发送到集群吗?

第二个问题是. nginx和负载均衡器之间有什么区别.为什么我们不能改为使用nginx?

解决方法:

对于第一个问题,我相信答案似乎是,Instagram现在使用Route53将DNS映射到Elastic Load Balancer,它执行两件事:将流量平均地路由到三个NGINX负载均衡器,并且为所有流量提供SSL.然后,NGINX服务器充当堆栈下方的内容/应用程序服务器的负载平衡器.使用ELB代替轮询DNS意味着他们可以添加/删除/更新附加到ELB的实例,而不必担心DNS更新或TTL.

至于第二个问题,您可以像使用HAproxy或其他服务一样容易地使用NGINX进行负载平衡.我敢肯定,选择NGINX对Instagram的吸引力在于它的惊人速度,并且它是异步的并且是“事件驱动的”,而不是像Apache2这样的线程.正确设置后,可以减轻重物下的头痛.

标签:nginx,load-balancing
来源: https://codeday.me/bug/20191120/2043849.html