Dotnet应用程序在一段时间后停止接受连接

时间:2019-02-13 02:34:44

标签: nginx tcp linux-kernel .net-core

我们认为应用程序中的套接字泄漏可能是在VM上运行的ubuntu 16.04上的dontcore 2.1.7中出现的: 我们有一个运行在nginx和linux上的.Net核心应用程序。在两个不同的节点上运行,每个节点具有相同的代码库,并且负载均衡。通过每台服务器上的呼叫次数进行验证。

在负载下,在不一致的时间内,节点内的应用程序之一总是停止响应,总是在同一确切节点上,通过停止响应,我的意思是它不再接受任何新的连接,并且除非重新启动,否则它不会响应清理连接并释放所有资源的应用程序。 我们已经检查了两个节点中的代码是否完全相同。因此似乎代码不是问题,并且负载已正确平衡。 我们还仔细检查了我们的nginx.conf,并且两台机器上的节点之间是相同的。 我们还检查了TCP连接的系统内核设置,它们是相同的: /etc/sysctl.conf,我们也都一样。

/etc/sysctl.conf tcp的内容:     `

    net.ipv4.tcp_window_scaling = 1
    net.ipv4.tcp_max_syn_backlog = 3240000
    net.core.somaxconn = 65535
    net.ipv4.tcp_max_tw_buckets = 1440000
    net.core.rmem_default = 8388608
    net.core.rmem_max = 16777216
    net.core.wmem_max = 16777216
    net.ipv4.tcp_rmem = 4096 87380 16777216
    net.ipv4.tcp_wmem = 4096 65536 16777216
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
    net.ipv4.neigh.default.gc_thresh1 = 512
    net.ipv4.neigh.default.gc_thresh2 = 1024
    net.ipv4.neigh.default.gc_thresh3 = 2048
    net.ipv4.tcp_keepalive_time = 120```


When an app stops responding most of the connections are in ESTABLISHED state and some are in CLOSE_WAIT state
When the app is running the number of ESTABLISHED connections grow and no CLOSE_WAIT connections.

lsof command shows almost a million open files including the connections(in thousands)

Is there something else that we can be missing? 

0 个答案:

没有答案