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

Increase ServerConnector accept queue size #15596

Merged
merged 10 commits into from
Jan 5, 2024

Conversation

georgew5656
Copy link
Contributor

@georgew5656 georgew5656 commented Dec 21, 2023

Increase TCP accept queue size.

Description

The ServerConnector class defaults _acceptQueueSize to 0 which appears to result in a value of min(net.core.somaxconn, 50) on Jetty being passed to the listen() system call. This number can be too low especially when there are many brokers/coordinators trying to setup connections to a historical or real-time index process.

When this queue fills up there will be dropped packets and there can be downstream connection timeouts/connection resets depending on the underlying system settings (e.g. if syncookies are enabled).

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...

I originally decided to make _acceptQueueSize a configurable property, but to avoid adding another configuration I decided to follow the logic I saw in dropwizard (a java web framework) when configuring jetty.(https://github.com/dropwizard/dropwizard/blob/7f6827d119639a57d2a696d371c3bbdb3007acb5/dropwizard-jetty/src/main/java/io/dropwizard/jetty/NetUtil.java#L37).

Essentially this checks the value of '/proc/sys/net/core/somaxconn' and sets _acceptQueueSize to that value, or the default linux value for somaxconn of 128 if the file is not readable.

Release note

Increase _acceptQueueSize based on value of net.core.somaxconn.

Key changed/added classes in this PR
  • JettyServerModule

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@georgew5656 georgew5656 changed the title Allow overwriting ServerConnector accept queue size Increase ServerConnector accept queue size Jan 4, 2024
@georgew5656 georgew5656 requested a review from gianm January 4, 2024 21:25
Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach LGTM although it would be nice to only log the warning on Linux.

return Integer.parseInt(in.readLine().trim());
}
catch (Exception e) {
log.warn("Unable to read /proc/sys/net/core/somaxconn, falling back to default value for TCP accept queue size");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to only log this warning on Linux. The file will never be there on macOS so the warning is always going to happen, which isn't ideal. Maybe use System.getProperty("os.name")?

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@georgew5656 georgew5656 merged commit 9fe6795 into apache:master Jan 5, 2024
83 checks passed
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants