Skip to content

Add a rate-limiter to dial() function? #115

Open

Description

@bboreham

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.

Activity

  1. changed the title [-]"Possible SYN flooding"[/-] [+]Add a rate-limiter to dial() function?[/+] on Aug 14, 2020
  2. bboreham commented on Aug 15, 2020

    @bboreham
    ContributorAuthor

    #86 could be used to add a rate-limiter from the outside. Or a circuit-breaker, which is perhaps an even better idea.

  3. bboreham commented on Jan 22, 2021

    @bboreham
    ContributorAuthor

    Update: I added a circuit-breaker using the code from #86, and the symptoms went away.
    I would like to see #86 merged.

  4. dormando commented on Apr 4, 2025

    @dormando
    Collaborator

    Note: Unsure if this should stay open. The custom dialer lets people fix it but is this also fixed via the backoff PR?

  5. bboreham commented on Apr 7, 2025

    @bboreham
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions