linux – 根据流量或请求的百分比负载均衡HTTP?
发布时间:2020-12-14 02:40:11 所属栏目:Linux 来源:网络整理
导读:我希望将我的应用程序的v1放在一个池中,将版本v1.1放在另一个池中,然后慢慢增加流入池2的流量并将其减少到池1. 任何人都可以用HA Proxy,Varnish,Nginx或其他什么来展示这样做的具体例子吗? 解决方法 split clients模块专为此设计: # I like starting my up
我希望将我的应用程序的v1放在一个池中,将版本v1.1放在另一个池中,然后慢慢增加流入池2的流量并将其减少到池1.
任何人都可以用HA Proxy,Varnish,Nginx或其他什么来展示这样做的具体例子吗? 解决方法
split clients模块专为此设计:
# I like starting my upstream names with _ # so they're not confused with hostnames upstream _old_upstream { server 127.0.0.1:1234; } upstream _new_upstream { server 127.0.0.1:4321; } # Make sure the values here match the names of the upstream blocks above split_clients $remote_addr $split_upstream { 10% _new_upstream; - _old_upstream; } server { location / { # EDIT: I forgot,when using variables in a proxy_pass,you have to # specify the entire request proxy_pass http://$split_upstream$request_uri; } } 然后,当您想要将更多流量移动到新服务器时,只需更改百分比并运行nginx -s reload. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |