CloudNginx- gray release

It refers to a gradation release release manner between black and white, can be a smooth transition. AB test is a kind of gray distribution so that users continue to use part A, part of the user to start with a B, if the user does not have any objections to B, then gradually expand the scope, all users are migrated to the B to the top.

Gray release can ensure the stability of the overall system, can be found in the initial gray when the adjustment problems, in order to ensure that the degree of influence.

Gray publish common generally three ways:

  • Nginx + LUA way

  • According Cookie Grayscale release

  • IP implementation according to published antecedents gray
    This article will explain the simple gray released under Cookie and IP antecedents of these two methods, Nginx + LUA in this way involves too much content is no longer paper launched.
    About AB testing process
    Here Insert Picture Description
    Here Insert Picture Description
    Nginx released under Cookie achieve gray

The Cookie Cookie query key value of the version if the Cookie value V1 is forwarded to alex_01, V2 is then forwarded to the alex_02. Cookie default value does not match the server to go alex_01 corresponds.

Implemented by instructions performed if
two servers are defined as:

mynginx_01 192.168.1.100:8080
mynginx_02 192.168.1.200:8080

Profile
upstream mynginx_01 {
Server 192.168.1.100:8080 max_fails fail_timeout = = 60. 1;
}

upstream mynginx_02 {
server 192.168.1.200:8080 max_fails=1 fail_timeout=60;
}

upstream default {
server 192.168.1.100:8080 max_fails=1 fail_timeout=60;
}

server {
listen 80;
server_name www.mynginx.com;
access_log logs/www.mynginx.com.log main;

#match cookie
set g r O in p " d e f a in l t " ; i f ( group "default"; if ( http_cookie ~* “version=V1”){
set $group mynginx_01;
}

if ($http_cookie ~* "version=V2"){
    set $group mynginx_02;
}

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;
}
}
用map指令实现

Nginx configuration in which a map, C O O K I E v e r s i o n C o o k i e v e r s i o n COOKIE_version be parsed version field inside the Cookie. group is a variable, which is the mapping rule {}.

If a version for users to access the V1, g r o u p m y n g i n x 0 1 s e r v e r 使 h t t p : / / m y n g i n x 0 1 v e r s i o n V 2 访 group is equal mynginx_01. Which will be used in a proxy server to http: On // mynginx_01. V2 version for users to access, Group equals mynginx_02. Which will be used in a proxy server to http: On // mynginx_02. Cookie default value does not match the server to go mynginx_01 corresponds.

upstream mynginx_01 {
server 192.168.1.100:8080 max_fails=1 fail_timeout=60;
}

upstream mynginx_02 {
server 192.168.1.200:8080 max_fails=1 fail_timeout=60;
}

upstream default {
server 192.168.1.100:8080 max_fails=1 fail_timeout=60;
}

map $COOKIE_version KaTeX parse error: Expected '}', got 'EOF' at end of input: group { ~*V1 mynginx_01;
~*V2$ mynginx_02;
default default;
}

server {
listen 80;
server_name www.mynginx.com;
access_log logs/www.mynginx.com.log main;

LOCATION / {
proxy_pass HTTP: // $ Group;
proxy_set_header the Host Host $;
proxy_set_header the IP-X-Real-$ REMOTE_ADDR;
proxy_set_header the For-X-Forwarded-$ proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
the Nginx achieved according to the IP origin gray release
if it is an internal IP, the reverse proxy to hilinux_02 (pre-release environment); if not then reverse proxy to hilinux_01 (production environment).

upstream mynginx_01 {
server 192.168.1.100:8080 max_fails=1 fail_timeout=60;
}

upstream mynginx_02 {
server 192.168.1.200:8080 max_fails=1 fail_timeout=60;
}

upstream default {
server 192.168.1.100:8080 max_fails=1 fail_timeout=60;
}

server {
listen 80;
server_name www.mynginx.com;
access_log logs/www.mynginx.com.log main;

set g r o u p d e f a u l t ; i f ( group default; if ( remote_addr ~ “211.118.119.11”) {
set $group mynginx_02;
}

LOCATION / {
proxy_pass HTTP: // $ Group;
proxy_set_header $ Host Host;
proxy_set_header the X-Real-IP-$ REMOTE_ADDR;
proxy_set_header the X-Forwarded-the For-$ proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
if you have only a single server , you can achieve the same purpose, depending on the different IP settings for the site root.

server {
listen 80;
server_name www.mynginx.com;
access_log logs/www.mynginx.log main;

set r o o t d i r " / v a r / w w w / h t m l " ; i f ( rootdir "/var/www/html"; if ( remote_addr ~ “211.118.119.11”) {
set $rootdir “/var/www/test”;
}

location / {
  root $rootdir;
}

}
To this basic method to achieve gray-scale release to explain finished.

Published 15 original articles · won praise 22 · views 2847

Guess you like

Origin blog.csdn.net/Mint_Alone/article/details/103818668