MBG
MBG

Reputation: 102

.net core application socket leak under load

we have an application running on .net core 2.1 in linux. When we apply load to this app ( 5 concurrent requests of a specific API, just after 5 hits) it hangs, meaning the api does not longer respond to any request. After going into the Linux box and running:

netstat -anp --tcp

I can see several CLOSED_WAIT connections.

If I run "good load" (different api call, higher rate and higher concurrency during several minutes) this behavior does not happen. as I dont see any connection in the CLOSE_WAIT state.

We tried to reproduce locally in windows, but it does not happen.

Any one has experienced this behavior for leaking sockets that I presume the issue is?

Upvotes: 1

Views: 585

Answers (1)

又见昨天
又见昨天

Reputation: 31

You may adjust Tcp Wait Delay's time.

In Windows, modify regedit \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpTimedWaitDelay

IN Linux, modify

net.ipv4.tcp_syn_retries=2  
net.ipv4.tcp_keepalive_time=1200  
net.ipv4.tcp_orphan_retries=3  
net.ipv4.tcp_fin_timeout=30      
net.ipv4.tcp_max_syn_backlog = 4096  
net.ipv4.tcp_syncookies = 1 
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_tw_recycle = 1  
net.ipv4.tcp_keepalive_probes=5  
net.core.netdev_max_backlog=3000  

Upvotes: 2

Related Questions