前提说明
灰度发布一般有三种方式 nginx+lua,nginx根据cookie分流,nginx 根据权重来分配
nginx+lua根据来访者ip地址区分,由于公司出口是一个ip地址,会出现访问网站要么都是老版,要么都是新版,采用这种方式并不适合
nginx 根据权重来分配,实现很简单,也可以尝试
nginx根据cookie分流,灰度发布基于用户才更合理
参考
http://blog.csdn.net/yangpl_tale/article/details/48495343
总结
- 灰度发布,实质上是动态修改proxy_pass的值
server {
listen 80;
server_name test.taotaosou.com;
access_log logs/test.taotaosou.com.log main buffer=32k;
#match cookie
set $group “default”;
if ($http_cookie ~* “tts_version_id=tts1”){
set $group tts_V6;
}
if ($http_cookie ~* “tts_version_id=tts2”){
set $group tts_V7;
}
location / {
proxy_pass http://$group;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
猜测QQ空间的灰度发布:
1.所有选择升级的用户给定一个固定的cookie,判断此值就可设置不同的proxy_pass,而不必根据QQ号判断
2.在upstream节点中,设置成IP_hash模式和权重,慢慢调整过来.