찾다
운영 및 유지보수엔진스카나리아 게시에 nginx 시뮬레이션을 사용하는 방법

카나리아 릴리스/그레이스케일 릴리스

카나리아 릴리스의 핵심은 시행착오입니다. 카나리아방출의 기원 자체는 인간 산업의 발전 과정에서 자연의 아름다운 생명체들이 겪는 비극적인 이야기입니다. 카나리아는 광부의 안전을 위해 목숨을 걸고 실수를 저지릅니다. 전반적인 보안을 위해 약간의 비용이 사용됩니다. 지속적 배포를 실행하는 경우 카나리아는 1% 또는 10분의 1과 같은 아주 적은 양의 트래픽을 사용하여 특정 버전이 정상인지 확인합니다. 비정상적인 경우에는 최저 비용으로 기능을 달성하고 위험이 줄어듭니다. 정상이라면 100%에 도달할 때까지 점차적으로 가중치를 늘려가며 모든 트래픽을 새 버전으로 원활하게 전환할 수 있습니다. 그레이스케일 출판은 일반적으로 비슷한 개념입니다. 회색은 검정색과 흰색 사이의 전환입니다. 파란색 또는 녹색인 파란색 및 녹색 배포와는 다릅니다. 그레이스케일 릴리스/카나리아 릴리스는 두 가지가 동시에 존재하는 기간을 가지지만 둘의 해당 트래픽은 카나리아 릴리스가 그레이스케일 릴리스와 다르다면 차이점은 목적에 따라야 합니다. 카나리아 릴리스의 목적은 시행착오인 반면, 그레이스케일 릴리스는 안정적인 릴리스에 관한 것이며 카나리아 릴리스에서는 문제가 없습니다. 그레이 스케일 출판 상황에서.

카나리아 릴리스 시뮬레이션

다음으로 nginx의 업스트림을 사용하여 카나리아 릴리스 시나리오를 간단히 시뮬레이션합니다. 구체적인 시나리오는 다음과 같습니다. 현재 메인 버전이 활성화되어 있으며, nginx 설정을 조정하고 카나리아 버전의 가중치를 지속적으로 조정함으로써 최종적으로 원활한 출시가 이루어졌습니다.

카나리아 게시에 nginx 시뮬레이션을 사용하는 방법

미리 준비하세요

시연의 편의를 위해 7001/7002 두 포트에서 두 서비스를 미리 시작하여 서로 다른 정보를 표시하도록 tornado를 사용하여 이미지를 만들고 도커 실행 시 전달된 매개변수를 전달했습니다. 컨테이너가 시작되었습니다. Different는 서비스 간의 차이점을 표시하는 데 사용됩니다.

docker run -d -p 7001:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello main service: v1 in 7001"
docker run -d -p 7002:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello canary deploy service: v2 in 7002"

실행 로그

[root@kong ~]# docker run -d -p 7001:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello main service: v1 in 7001"
28f42bbd21146c520b05ff2226514e62445b4cdd5d82f372b3791fdd47cd602a
[root@kong ~]# docker run -d -p 7002:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello canary deploy service: v2 in 7002"
b86c4b83048d782fadc3edbacc19b73af20dc87f5f4cf37cf348d17c45f0215d
[root@kong ~]# curl http://192.168.163.117:7001
hello, service :hello main service: v1 in 7001
[root@kong ~]# curl http://192.168.163.117:7002
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#

Start nginx

[root@kong ~]# docker run -p 9080:80 --name nginx-canary -d nginx
659f15c4d006df6fcd1fab1efe39e25a85c31f3cab1cda67838ddd282669195c
[root@kong ~]# docker ps |grep nginx-canary
659f15c4d006    nginx           "nginx -g 'daemon ..."  7 seconds ago    up 7 seconds    0.0.0.0:9080->80/tcp   nginx-canary
[root@kong ~]#

nginx 코드 스니펫

다음 nginx 코드 스니펫을 준비하여 nginx의 /etc/nginx/conf.d/default.conf에 추가하고 시뮬레이션 방법은 매우 간단합니다. down을 사용하여 트래픽이 0임을 나타냅니다(nginx에서는 가중치를 0으로 설정할 수 없음). 처음에는 트래픽의 100%가 기본 버전으로 전송됩니다.

http {
upstream nginx_canary {
  server 192.168.163.117:7001 weight=100;
  server 192.168.163.117:7002 down;
}
server {
  listen    80;
  server_name www.liumiao.cn 192.168.163.117;
  location / {
    proxy_pass http://nginx_canary;
  }
}

default.conf 수정 방법

컨테이너에 vim을 설치하면 효과를 얻을 수 있고, 로컬에서 수정한 다음 docker cp를 통해 전달하거나 sed로 직접 수정할 수도 있습니다. 컨테이너에 vim을 설치하는 경우 다음 방법을 사용하세요

[root@kong ~]# docker exec -it nginx-lb sh
# apt-get update
...省略
# apt-get install vim
...省略

수정 전

# cat default.conf
server {
  listen    80;
  server_name localhost;
  #charset koi8-r;
  #access_log /var/log/nginx/host.access.log main;
  location / {
    root  /usr/share/nginx/html;
    index index.html index.htm;
  }
  #error_page 404       /404.html;
  # redirect server error pages to the static page /50x.html
  #
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  /usr/share/nginx/html;
  }
  # proxy the php scripts to apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #  proxy_pass  http://127.0.0.1;
  #}
  # pass the php scripts to fastcgi server listening on 127.0.0.1:9000
  #
  #location ~ \.php$ {
  #  root      html;
  #  fastcgi_pass  127.0.0.1:9000;
  #  fastcgi_index index.php;
  #  fastcgi_param script_filename /scripts$fastcgi_script_name;
  #  include    fastcgi_params;
  #}
  # deny access to .htaccess files, if apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #  deny all;
  #}
}
#

수정 후

# cat default.conf
upstream nginx_canary {
  server 192.168.163.117:7001 weight=100;
  server 192.168.163.117:7002 down;
}
server {
  listen    80;
  server_name www.liumiao.cn 192.168.163.117;
  #charset koi8-r;
  #access_log /var/log/nginx/host.access.log main;
  location / {
    #root  /usr/share/nginx/html;
    #index index.html index.htm;
    proxy_pass http://nginx_canary;
  }
  #error_page 404       /404.html;
  # redirect server error pages to the static page /50x.html
  #
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  /usr/share/nginx/html;
  }
  # proxy the php scripts to apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #  proxy_pass  http://127.0.0.1;
  #}
  # pass the php scripts to fastcgi server listening on 127.0.0.1:9000
  #
  #location ~ \.php$ {
  #  root      html;
  #  fastcgi_pass  127.0.0.1:9000;
  #  fastcgi_index index.php;
  #  fastcgi_param script_filename /scripts$fastcgi_script_name;
  #  include    fastcgi_params;
  #}
  # deny access to .htaccess files, if apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #  deny all;
  #}
}
#

nginx 설정 다시 로드

# nginx -s reload
2018/05/28 05:16:20 [notice] 319#319: signal process started
#

결과 확인

10번 호출 후 모두 출력 All 7001의 v1

[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; let cnt++; hello 메인 서비스: 7001의 v1
안녕하세요, 서비스 :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스 : v1 in 7001
[root@kong ~]#

Canary 릴리스: Canary 버전 트래픽 가중치 10%

default.conf의 가중치를 조정한 후 nginx -s reload를 실행하여 가중치를 조정합니다. Canary 버전을 10%로 설정하면 트래픽의 10%가 새 서비스를 실행합니다.

default.conf 수정 방법

다음과 같이 업스트림에서 서버의 가중치만 조정하면 됩니다.

upstream nginx_canary {
  server 192.168.163.117:7001 weight=10;
  server 192.168.163.117:7002 weight=90;
}

nginx 다시 로드 settings

# nginx -s reload
2018/05/28 05:20:14 [notice] 330#330: signal process started
#

결과 확인

[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; let cnt++; 7002의 v2

hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, 서비스 : hello 메인 서비스 : 7001의 v1
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: v2 in 7002
hello, service :hello canary 배포 서비스: v2 in 7002
[root@kong ~]#

Canary 릴리스: Canary 버전 트래픽 가중치는 50%

기본 가중치를 조정하여 .conf 그런 다음 nginx -s reload를 실행하고 카나리아 버전의 가중치를 50%로 조정하면 트래픽의 50%가 새 서비스를 실행합니다

default.conf를 수정하는 방법


가중치만 조정하면 됩니다. 다음과 같이 업스트림에 서버를 추가합니다:

upstream nginx_canary {
  server 192.168.163.117:7001 weight=50;
  server 192.168.163.117:7002 weight=50;
}

Reload nginx settings

# nginx -s reload
2018/05/28 05:22:26 [notice] 339#339: signal process started
#

确认结果

[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#

金丝雀发布: 金丝雀版本流量权重90%

通过调整default.conf的weight,然后执行nginx -s reload的方式,调节金丝雀版本的权重为90%,流量的90%会执行新的服务

修改default.conf的方法

只需要将upstream中的server的权重做如下调整:

upstream nginx_canary {
  server 192.168.163.117:7001 weight=10;
  server 192.168.163.117:7002 weight=90;
}

重新加载nginx设定

# nginx -s reload
2018/05/28 05:24:29 [notice] 346#346: signal process started
#

确认结果

[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#

金丝雀发布: 金丝雀版本流量权重100%

通过调整default.conf的weight,然后执行nginx -s reload的方式,调节金丝雀版本的权重为100%,流量的100%会执行新的服务

修改default.conf的方法

只需要将upstream中的server的权重做如下调整:

upstream nginx_canary {
  server 192.168.163.117:7001 down;
  server 192.168.163.117:7002 weight=100;
}

重新加载nginx设定

# nginx -s reload
2018/05/28 05:26:37 [notice] 353#353: signal process started

确认结果

[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#

위 내용은 카나리아 게시에 nginx 시뮬레이션을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
이 기사는 亿速云에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제
Nginx의 주요 기능 : 성능, 확장 성 및 보안Nginx의 주요 기능 : 성능, 확장 성 및 보안Apr 13, 2025 am 12:09 AM

NGINX는 이벤트 중심 아키텍처 및 비동기 처리 기능을 통해 성능을 향상시키고 모듈 식 설계 및 유연한 구성을 통해 확장 성을 향상 시키며 SSL/TLS 암호화 및 요청 속도 제한을 통해 보안을 향상시킵니다.

Nginx vs. Apache : 웹 호스팅 및 트래픽 관리Nginx vs. Apache : 웹 호스팅 및 트래픽 관리Apr 12, 2025 am 12:04 AM

NGINX는 동시성이 높은 자원 소비 시나리오에 적합하지만 APACHE는 복잡한 구성 및 기능 확장이 필요한 시나리오에 적합합니다. 1.NGINX는 고성능과의 많은 동시 연결을 처리하는 것으로 알려져 있습니다. 2. Apache는 안정성과 풍부한 모듈 지원으로 유명합니다. 선택할 때는 특정 요구에 따라 결정해야합니다.

NGINX : 최신 웹 애플리케이션을위한 다목적 도구NGINX : 최신 웹 애플리케이션을위한 다목적 도구Apr 11, 2025 am 12:03 AM

nginxissentialderformodernwebapplicationsduetoitsrolessareareverseproxy, loadbalancer 및 Webserver, HighperformanceAndscalability를 제공합니다

Nginx SSL/TLS 구성 : HTTPS로 웹 사이트 보안Nginx SSL/TLS 구성 : HTTPS로 웹 사이트 보안Apr 10, 2025 am 09:38 AM

Nginx를 통해 웹 사이트 보안을 보장하려면 다음 단계가 필요합니다. 1. 기본 구성을 만들고 SSL 인증서 및 개인 키를 지정하십시오. 2. 구성 최적화, HTTP/2 및 OCSPStapling 활성화; 3. 인증서 경로 및 암호화 제품군 문제와 같은 공통 오류 디버그; 4. Let 'sencrypt 및 세션 멀티플렉싱 사용과 같은 응용 프로그램 성능 최적화 제안.

Nginx 인터뷰 질문 : ACE 귀하의 DevOps/System Admin 인터뷰Nginx 인터뷰 질문 : ACE 귀하의 DevOps/System Admin 인터뷰Apr 09, 2025 am 12:14 AM

NGINX는 고성능 HTTP 및 리버스 프록시 서버로 높은 동시 연결을 처리하는 데 능숙합니다. 1) 기본 구성 : 포트를 듣고 정적 파일 서비스를 제공합니다. 2) 고급 구성 : 리버스 프록시 및로드 밸런싱을 구현하십시오. 3) 디버깅 기술 : 오류 로그를 확인하고 구성 파일을 테스트하십시오. 4) 성능 최적화 : GZIP 압축을 활성화하고 캐시 정책을 조정합니다.

Nginx 캐싱 기술 : 웹 사이트 성능 향상Nginx 캐싱 기술 : 웹 사이트 성능 향상Apr 08, 2025 am 12:18 AM

Nginx 캐시는 다음 단계를 통해 웹 사이트 성능을 크게 향상시킬 수 있습니다. 1) 캐시 영역을 정의하고 캐시 경로를 설정하십시오. 2) 캐시 유효성 기간 구성; 3) 다른 컨텐츠에 따라 다른 캐시 정책을 설정합니다. 4) 캐시 저장 및로드 밸런싱을 최적화합니다. 5) 캐시 효과를 모니터링하고 디버그합니다. 이러한 방법을 통해 NGINX 캐시는 백엔드 서버 압력을 줄이고 응답 속도 및 사용자 경험을 향상시킬 수 있습니다.

Docker와 Nginx : 컨테이너화 된 응용 프로그램을 배포하고 스케일링합니다Docker와 Nginx : 컨테이너화 된 응용 프로그램을 배포하고 스케일링합니다Apr 07, 2025 am 12:08 AM

dockercompose를 사용하면 Nginx의 배포 및 관리를 단순화 할 수 있으며 Dockerswarm 또는 Kubernetes를 통한 스케일링은 일반적인 관행입니다. 1) DockerCompose를 사용하여 Nginx 컨테이너를 정의하고 실행하십시오. 2) Dockerswarm 또는 Kubernetes를 통한 클러스터 관리 및 자동 스케일링 구현.

고급 NGINX 구성 : 서버 블록 마스터 링 및 리버스 프록시고급 NGINX 구성 : 서버 블록 마스터 링 및 리버스 프록시Apr 06, 2025 am 12:05 AM

NGINX의 고급 구성은 서버 블록 및 리버스 프록시를 통해 구현 될 수 있습니다. 1. 서버 블록을 사용하면 여러 웹 사이트를 한쪽으로 실행할 수있게되면 각 블록은 독립적으로 구성됩니다. 2. 리버스 프록시는 요청을 백엔드 서버로 전달하여로드 밸런싱 및 캐시 가속도를 실현합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구