Skip to content

Allow REUSEPORT for listener sockets #8794

Closed

Description

@mattklein123

We should optionally allow listener sockets to be created on each worker with SO_REUSEPORT. This should probably be the default for UDP listeners and opt-in for TCP listeners?

cc @danzh2010 @euroelessar @antoniovicente

Activity

  1. added
    enhancement
    help wanted
    on Oct 29, 2019
  2. self-assigned this
    on Oct 29, 2019
  3. added this to the 1.13.0 milestone on Oct 29, 2019
  4. danzh2010 commented on Oct 29, 2019

    @danzh2010
    Contributor

    Hi Matt, actually this is part of the plan in https://docs.google.com/document/d/1My-Tssc9d6rW-Xu96y4DdUxvzIKmptP6mm6i_zOXr58/edit?pli=1#. I was about to modify ListenerConfig to provide a listen socket factory interface instead of a socket as the first step of preparation for supporting multiple quic listeners on different worker threads.

    What's your plan for this?

  5. mattklein123 commented on Oct 29, 2019

    @mattklein123
    MemberAuthor

    What's your plan for this?

    To assign this issue to you. ;)

    We can use this for tracking.

  6. danzh2010 commented on Oct 29, 2019

    @danzh2010
    Contributor

    I can work on this. But one question here, is there any reason why this even needs to be an option for TCP listener? Do we want different TCP listeners on different worker threads to listen on different sockets?

  7. mattklein123 commented on Oct 29, 2019

    @mattklein123
    MemberAuthor

    But one question here, is there any reason why this even needs to be an option for TCP listener? Do we want different TCP listeners on different worker threads to listen on different sockets?

    It has been requested previously that we support this for TCP listeners also. In some cases this can lead to better performance in very high CPS use cases with many listening cores. IMO you don't need to implement it for TCP if you don't want to, but it would be nice to do it in such a way that someone could come along and do it for TCP later if they want?

  8. l8huang commented on Oct 30, 2019

    @l8huang
    Contributor

    @danzh2010 Considering this issue assigned to you, what's your plane? :) Are you working on both UDP and TCP change? Or only UDP?

    I recently did some LnP tests for HTTP traffic, one finding is: usually Envoy consumes <24 CPUs and occasionally Envoy consumes 46 CPUs(the node has 32 cores with Hyper-thread, that's 64 CPUs). Envoy run with 64 worker threads.

    Making this change for TCP is in my task list, just want to confirm if we have any overlapping ;) I'm willing to take the TCP part.

  9. danzh2010 commented on Oct 31, 2019

    @danzh2010
    Contributor

    Currently the one and only socket is passed to each listener on workder threads through Network:ListenerConfig. My plan is to change ListenerConfig to carry a socket factory instead of a socket. And create the socket during listener creation via the factory. UDP and TCP factory can have different socket management behavior.

    As the first step, I will just refactor the code to pass around socket factory. TCP socket factory always provide the same socket, but UDP socket factory creates a new socket for each listener.

  10. l8huang commented on Nov 5, 2019

    @l8huang
    Contributor

    @danzh2010 I did a quick change to make SO_REUSEPORT works for TCP listeners, and run a load test, connections distributed to worker threads every well(checked downstream_cx_total and downstream_cx_active in /stats output).

    A draft PR #8884 created, if you have time to do a quick view, that could be every helpful, just want to confirm this change is on correct direction.

  11. danzh2010 commented on Jan 2, 2020

    @danzh2010
    Contributor

    I just found that SO_REUSEPORT doesn't behave as expected in Mac OS. Mac doesn't dispatch UDP packets according to network 5 tuple within the SO_REUSEPORT socket group. For connection-oriented UDP traffic, this means we don't have stable connection as packets from the same connection can be sent to different sockets.

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

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions