Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: avoid fd exhaustion #12274

Closed
wants to merge 6 commits into from
Closed

http: avoid fd exhaustion #12274

wants to merge 6 commits into from

Commits on Jan 25, 2018

  1. http: respond to errors immediately rather than scheduling

    Responses are usually added to the response queue by worker threads. As an
    optimization, and in order to close connections as quickly as possible, allow
    for immediate replies (bypassing the queue) when there is no need for a worker
    to service the request.
    theuni committed Jan 25, 2018
    Configuration menu
    Copy the full SHA
    5f5099a View commit details
    Browse the repository at this point in the history
  2. http: return initialized listeners

    No functional change, just preparation for the next commits.
    theuni committed Jan 25, 2018
    Configuration menu
    Copy the full SHA
    dc53bec View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2018

  1. http: add a connection limiter

    Rather than potentially accepting an unbounded number of connections, give them
    a ceiling of twice the size of the processing queue.
    
    Once the ceiling is reached, new connections will not be accepted until the
    count has fallen back under the limit.
    
    Note that file descriptors are removed from the limiter in the request's
    close callback.
    theuni committed Jan 26, 2018
    Configuration menu
    Copy the full SHA
    c56cf1a View commit details
    Browse the repository at this point in the history
  2. http: don't re-use connections when slots are full

    If we're unable to service a request, close the connection rather than
    potentially keeping it alive longer. This helps to be slightly more fair to new
    connections.
    theuni committed Jan 26, 2018
    Configuration menu
    Copy the full SHA
    3b0ebb3 View commit details
    Browse the repository at this point in the history
  3. http: defer accepting until there's data to read

    This avoids assigning file descriptors faster than we can close them.
    
    It is the same as using an evconnlistener with the LEV_OPT_DEFERRED_ACCEPT
    flag, which is only available with libevent 2.1+.
    theuni committed Jan 26, 2018
    Configuration menu
    Copy the full SHA
    de6cfce View commit details
    Browse the repository at this point in the history
  4. http: use new libevent callback to drop connections quickly

    Libevent 2.2 adds a callback allowing us to drop connections as they come in.
    Use it when possible.
    theuni committed Jan 26, 2018
    Configuration menu
    Copy the full SHA
    cdcc0ed View commit details
    Browse the repository at this point in the history