You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every few days, one of my servers issues a kernel log message:
TCP: request_sock_TCP: Possible SYN flooding on port 11211. Sending cookies. Check SNMP counters.
Mostly processing continues after this, but sometimes the entire server is unresponsive for minutes.
In this environment we have 10 Go programs using gomemcache hitting one memcached server, and each Go program has 60 goroutines that will call through this library. So I expected a maximum of 600 connections at a time.
I have seen the SYN flooding message at the default memcached connection backlog of 1024, and also after I raised it to 4096.
From inspection of logs, packet traces, etc., I have formed the impression that some glitch in processing or network causes timeout errors (at the default of 100ms), which then cause gomemcache to dial new connections. 60 goroutines waiting 100ms each to dial gives 600 new connections dialed each second, per process.
If the dial attempts are not being discarded on the other end of the wire, then I think it can quickly go over the backlog limit.
I wondered if gomemcache should have a rate-limiter on dial()? I would prefer gomemcache to fail quickly rather than raising the timeout to slow it down.
Any other insight would be valued.
The only related issue I could see here is #108 ; interestingly we are both running the same system.
PR #185, if I read it correctly, waits 50us then 150us, 350us, 750us, up to 25ms (then it errors). This is not much of an improvement on the 100ms timeout I cited in the description above.
Also, the thing with exponential back-off is you can get a lot of them running in parallel, which still adds up to a lot of load.
This is why I felt a rate-limiter across all goroutines would be a better solution. Or a circuit-breaker.
Activity
[-]"Possible SYN flooding"[/-][+]Add a rate-limiter to dial() function?[/+]bboreham commentedon Aug 15, 2020
#86 could be used to add a rate-limiter from the outside. Or a circuit-breaker, which is perhaps an even better idea.
bboreham commentedon Jan 22, 2021
Update: I added a circuit-breaker using the code from #86, and the symptoms went away.
I would like to see #86 merged.
dormando commentedon Apr 4, 2025
Note: Unsure if this should stay open. The custom dialer lets people fix it but is this also fixed via the backoff PR?
bboreham commentedon Apr 7, 2025
PR #185, if I read it correctly, waits 50us then 150us, 350us, 750us, up to 25ms (then it errors). This is not much of an improvement on the 100ms timeout I cited in the description above.
Also, the thing with exponential back-off is you can get a lot of them running in parallel, which still adds up to a lot of load.
This is why I felt a rate-limiter across all goroutines would be a better solution. Or a circuit-breaker.