Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Consider dropping connections when the threshold is full #20

Open
Stebalien opened this issue May 8, 2019 · 3 comments
Open

Consider dropping connections when the threshold is full #20

Stebalien opened this issue May 8, 2019 · 3 comments

Comments

@Stebalien
Copy link
Member

That is, consider dropping connections from the underlying TCP socket. Maybe there's an option we can set on the TCP socket to let the kernel do this?

@Stebalien
Copy link
Member Author

// This records the fact that the connection has been
// setup and is waiting to be accepted. This call
// *never* blocks, even if we go over the threshold. It
// simply ensures that calls to Wait block while we're
// over the threshold.
l.threshold.Acquire()
defer l.threshold.Release()
select {
case l.incoming <- conn:
case <-ctx.Done():
if l.ctx.Err() == nil {
// Listener *not* closed but the accept timeout expired.
log.Warningf("listener dropped connection due to slow accept")
}
// Wait on the context with a timeout. This way,
// if we stop accepting connections for some reason,
// we'll eventually close all the open ones
// instead of hanging onto them.
conn.Close()
}

@Stebalien
Copy link
Member Author

This doesn't look like the issue. Instead, it looks like a sleep in the error catcher.

@raulk
Copy link
Member

raulk commented May 8, 2019

We have a lot of piecemeal mechanisms for backpressure scattered across the codebase. At one point we'll need to consider a reusable backpressure gadget, maybe inspired by SEDA.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants