alibaba / tengine

A distribution of Nginx with some advanced features

Home Page:https://tengine.taobao.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

upstream keepalive配置在使用dyups更新upstream后失效问题

binghe1918 opened this issue · comments

nginx http块配置如下:
upstream aaa {
  #check interval=5000 rise=3 fall=3 timeout=3000 type=tcp;
  server 100.0.0.100:3344 weight=100;
  keepalive 20;    
}
server {
  listen 200.0.0.200:7788 default_server;
  location / {
      client_max_body_size 1000m;
      proxy_http_version 1.1;

      proxy_set_header Connection $conn_upgrade;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Host $host;
      proxy_set_header J-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_pass http://aaa;  
  }
}
server {
listen 80;
gzip off;

    allow 127.0.0.1;
    deny all;
    location / {
        dyups_interface;
        access_log /export/log/nginx/dyups.log main;
    }

}

nginx启动后客户端发起请求后,可以通过netstat看到nginx到上游的长连接,并且后续请求会复用连接池中的连接。
然后调用dyups,增加upstream中的server:
curl -d "server 100.0.0.100:3344 weight=100;server 100.0.0.100:5566 weight=100;" 127.0.0.1:80/upstream/aaa

此时再发的请求将不再复用dyups模块连接池中的连接,每次都是新建连接来连接上游服务,连接池中的连接也会全部超时释放。
keepalive配置失效。

经定位,在调用dyups接口扩缩容之后,uscf->peer.init函数指针指向了ngx_http_dyups_init_peer,整体上会走ngx_http_dyups_module模块的流程(关键是get和free函数),不再使用keepalive模块中的连接池机制。导致keepalive配置失效。
请问有针对此问题的修复方案吗?即在使用dyups接口后,upstream中的keepalive配置依然需要生效

已解决

@binghe1918 怎么解决的,没看见提交代码