mar*_*kba 5 linux nginx varnish load-balancing haproxy
我希望将应用程序的 v1 版本放在一个池中,将版本 v1.1 放在另一个池中,然后慢慢增加流向池 2 的流量,并将其减少到池 1。
谁能展示一些使用 HA Proxy、Varnish、Nginx 或其他东西执行此操作的具体示例?
拆分客户端模块是专门为此设计的:
# 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;
}
}
Run Code Online (Sandbox Code Playgroud)
然后,当您想要将更多流量转移到新服务器时,只需更改百分比并运行即可nginx -s reload
。