nginx dyups动态修改upstream说明

nginx dyups模块https://github.com/yzprofile/ngx_http_dyups_module实现了upstream动态热更新,减少配置后的reload操作。

修改upstream check 模块(https://github.com/yzprofile/nginx_upstream_check_module)支持nginx dyups module。

配置文件修改

server {

         listen 80;

         allow 127.0.0.1;

         deny all;

         access_log off;

         location /check_healthcheck_status {

                 check_status csv;

         }

         location /check_req_status {

                 req_status_show req_server_status;

         }

         location = /nginx_status {

                 stub_status     on;

         }

         location / {

                 dyups_interface;                            #设置dyups控制接口

         }

 }

server {

         listen 10.56.66.78:888;

         proxy_set_header Host $http_host;

         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

         proxy_set_header X-Forwarded-Proto $scheme;

         proxy_set_header X-Forwarded-Port $remote_port;

         limit_req zone=req10k burst=1000;

         location / {

                 set $rs10_56_66_78_888 rp_10_111_85_107_888;      #定义变量为upstream url

                 proxy_pass http://$rs10_56_66_78_888;                           #proxy_pass 后url为变量

                 session_sticky_hide_cookie upstream=rs10_56_66_78_888;

         }

 }

 upstream rs10_56_66_78_888{

         session_sticky cookie=OLWAFSID mode=insert option=indirect maxidle=3600;

         server 10.10.20.20:80 weight=100;

         server 10.0.20.20:80 weight=100;

 }

dyups接口

 GET

  • /detail get all upstreams and their servers
  • /list get the list of upstreams
  • /upstream/name find the upstream by it's name

POST

  • /upstream/name update one upstream
  • body commands;
  • body server ip:port;

DELETE

  • /upstream/name delete one upstream

dyups对现有功能支持

支持session sticky功能,修改了session sticky模块。

需要在所有location配置块中显示的配置session_sticky_hide_cookie。

session sticky功能的开关由upstream下的session_sticky决定。

支持last_conn功能。

dyups对性能的影响

nginx作为proxy,设置1024个dynamic upstream

短链接请求:14w/s

长连接请求:21w/s

长连接在做增删操作时(每秒操作1次):20w/s

nginx作为proxy,设置2048个dynamic upstream

短链接请求:14w/s

长连接请求:21w/s

长连接在做增删操作时(每秒操作1次):20w/s

nginx作为proxy,设置static upstream

短链接请求:14w/s

长连接请求:21w/s

dynamic upstream lua支持

dyups lua支持对nginx upstream的热加载

采用动态修改json文件的形式json配置格式如下:

{                                                                                                     

        "update":{                                                                                    

                "rs_aaa": "check  type=http default_down=false timeout=3000 rise=5 fall=4 interval=5000; check_http_send  \"HEAD / HTTP/1.0\r\nHOST:10.10.16.96\r\n\r\n\"; server  127.0.0.3:91 weight=20;",  

                "rs_bbb": "check  type=http default_down=false timeout=3000 rise=5 fall=4 interval=5000; check_http_send  \"HEAD / HTTP/1.0\r\nHOST:10.10.16.96\r\n\r\n\"; server  127.0.0.3:92 weight=20;",  

        },

                 

        "delete":{

                "rs_ccc": "check  type=http default_down=false timeout=3000 rise=5 fall=4 interval=5000; check_http_send  \"HEAD / HTTP/1.0\r\nHOST:10.10.16.96\r\n\r\n\"; server  127.0.0.3:91 weight=20;"   

        }                                                                                             

}

每次调用location /dyups进行热加载

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值