简体   繁体   English

NGINX 负载均衡器和部署

[英]NGINX load balancer and deployments

My website depends on server affinity.我的网站取决于服务器亲和力。 My setup has 2 nodes (A and B) serving client request.我的设置有 2 个节点(A 和 B)服务客户端请求。

Just before a deployment I want the NGINX load balancer to stop sending new requests to node B but all request that already have an affinity to node B be should be send to node B.就在部署之前,我希望 NGINX 负载均衡器停止向节点 B 发送新请求,但所有已经与节点 B 有关联的请求都应该发送到节点 B。

Is this possible with NGINX?这可以用 NGINX 实现吗?

Like @mikhailov told me in the comments, current requests will be finished, although the server is removed from the configuration.就像@mikhailov 在评论中告诉我的那样,当前请求将完成,尽管服务器已从配置中删除。 So here is the tactics:所以这里是战术:

  • Remove the server (which will be under deployment) from the configuration从配置中删除服务器(将在部署中)
  • Reload the nginx configuration重新加载nginx配置

When the deployment has finished:部署完成后:

  • Add the server to the configuration again再次将服务器添加到配置中
  • Reload the nginx configuration重新加载nginx配置

You can use server "someserverip" down;你可以使用server "someserverip" down; This is how we do it and it works great!我们就是这样做的,而且效果很好! It allows current requests to finish and then all new requests to go other servers.它允许完成当前请求,然后将所有新请求发送到其他服务器。 Then you deploy to that server and remove "down".然后部署到该服务器并删除“down”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM