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。
配置文件修改
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进行热加载