Skip to content

Clear sockets perform worse than TLS socket in some cases #27970

Open

Description

@tufosa

While writing and performing tests for this issue opened by @alexfernandez and fixed by @jmendeth, I noticed that in some cases, clear connections seem to perform worse than TLS connections, specially after the fix that enhances significantly the performance of the TLS connections. I will patch the existing secure-pair benchmark test to expose the issue.

The performance of clear connections seems to be the same across node versions (I've tested it in node 8, 10 and 13-pre). This means that this issue is not a regression, but an enhancement, and the fix needed is probably very similar to the one that solved the secure-pair performance issue.

Activity

  1. tufosa commented on May 30, 2019

    @tufosa
    Author

    I've submitted a PR that includes clear connections in the secure-pair performance test and exposes this issue. The following table shows the results of the test run on my machine.

    packet size MBs transferred(TLS) MBs transferred(clear)
    2 99.3 2.9
    100 1401.76 552.05
    1024 1611.28 3231.61
    1024 * 1024 2519.03 7797.26
  2. added
    performanceIssues and PRs related to the performance of Node.js.
    on Jun 26, 2020
  3. jasnell commented on Jun 26, 2020

    @jasnell
    Member

    It's not clear if there's anything further actionable here.

  4. mildsunrise commented on Jun 26, 2020

    @mildsunrise
    Contributor

    When constantly writing tiny buffers, TLS connections are much faster now because we concatenate them before passing to OpenSSL. For plaintext connections, all those buffers are sent directly to the kernel which seems to incur this overhead.

    Maybe concatenating would be possible for plaintext sockets too? @nodejs/net

    However I want to point out this seems like an artificial test case to me. When moving lots of data, chunks are unlikely to be tiny. And if they are tiny, you could easily concatenate them yourself in bigger ones.

  5. alexfernandez commented on Jun 26, 2020

    @alexfernandez

    This test case tries to reproduce what @tufosa and I found at Devo: we used Node.js to receive syslog streams over a socket, and we usually received lots of small packets. It is not always that you have the luxury of deciding what packet size customers send you 😅

    Concatenating would be ideal for this particular application, and it would speed up reception for everyone else, right?

  6. addaleax commented on Jun 26, 2020

    @addaleax
    Member

    We already support writev() for network sockets, so the next thing I could think off would be enabling Nagle’s algorithm where we currently disable it (e.g. HTTP/2), or build our own version of it?

  7. jasnell commented on Jun 26, 2020

    @jasnell
    Member

    With HTTP/2 we really should not enable Nagle at all, but it can certainly be enabled elsewhere.

  8. mildsunrise commented on Jun 27, 2020

    @mildsunrise
    Contributor

    IIRC we use writev and Nagle by default, something else may be causing this overhead. I'm just speculating, but I think passing tens of thousands of tiny buffers around (to libuv and the kernel) may be causing it. If I'm right, maybe not using writev (concatenating instead) would help.

  9. github-actions commented on Jun 27, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  10. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jun 27, 2026
  11. Farenheith commented on Jul 15, 2026

    @Farenheith
    Contributor

    I'm not personally affected at my current position, but this seems like a legitimate edge case that impacts real workloads (syslog aggregation, etc.). Closing it would hide a genuine performance discrepancy. Worth keeping open for visibility and potential future prioritization.

  12. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 16, 2026
  13. github-actions commented on Oct 15, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  14. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Oct 15, 2026
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

    performanceIssues and PRs related to the performance of Node.js.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions