Skip to content

listener: performance degradation when exact balance used with original dst #15146

Closed

Description

@caitong93

Title: listener:performance degradation when exact balance used with original dst

Description:

We use Envoy as a sidecar, all out bound traffic is first redirected to 127.0.0.1:15001(Envoy) by iptables, then forwarded to different listeners by original dst. When exact balance is enabled(on all listeners), we found the connection balance being worse. Tested with 32 downstream connections, 2 workers, connection distribution between the two handlers is always 1:31(sometimes 2:30) by observing downstream_cx_active.
When a new connection being received, it will be handled by ExactConnectionBalancer first, and increase numConnections() of the selected handler by one. Then connection is forwarded to a new listener in ConnectionHandlerImpl::ActiveTcpSocket::newConnection() , and decrease that gauge immediately.
If connections arrive quickly, there is a high chance that the first handler is always selected since numConnections() of all handlers are zero.

Activity

  1. added
    triage
    on Feb 23, 2021
  2. lambdai commented on Feb 23, 2021

    @lambdai
    Contributor

    IMHO the rebalance should be applied to the second listener. In most of the cases, the first listener doesn't own any connection

  3. caitong93 commented on Feb 23, 2021

    @caitong93
    Author

    IMHO the rebalance should be applied to the second listener. In most of the cases, the first listener doesn't own any connection

    I also expect rebalance to be applied to the second listener. But(correct me if i am wrong) it seems rebalance can only happen at the first listener, see comments here. If exact_balance is only enabled for the second listener, I guess it won't work.

  4. lambdai commented on Feb 23, 2021

    @lambdai
    Contributor

    @caitong93 It won't work under the current code.

    This is a reasonable scenario that to apply to the second listener. @mattklein123 I can change if you agree.

  5. mattklein123 commented on Feb 23, 2021

    @mattklein123
    Member

    Yeah I agree we probably need to specially handle this case where for forwarded connections we do the rebalance at that point and not initially.

  6. added
    help wanted
    and removed
    triage
    on Feb 23, 2021
  7. self-assigned this
    on Feb 23, 2021
  8. lambdai commented on Mar 9, 2021

    @lambdai
    Contributor

    Plan to fix this along with #15126

  9. boeboe commented on Apr 16, 2021

    @boeboe

    @lambdai

    Will the fix mean that users have to configure exact_balance on the first catch_all listener 0.0.0.0:15001, or do users have to configure it on the next listener 0.0.0.0:9080 (in case the upstream service/cluster is at 9080)?

    Related to istio/istio#18152, where @hobbytp tried to apply the exact_balance on the second listener.

    From a end-user perspective, when somebody is digging into this setting, it is because of performance tuning in high throughput and low latency environments and I would assume that he/she thereby expects to have to only tune this setting once, instead of once for every target cluster, handled by a separate 2nd in line 0.0.0.0:<svc_port> listener? Or do you foresee that users should have the ability to configure this per second_in_line_listener/upstream_service pair?

  10. lambdai commented on Apr 20, 2021

    @lambdai
    Contributor

    Will the fix mean that users have to configure exact_balance on the first catch_all listener 0.0.0.0:15001, or do users have to configure it on the next listener 0.0.0.0:9080 (in case the upstream service/cluster is at 9080)?

    Sorry for the late reply.
    For istio where the 15001 listener usually doesn't hold connection, the 15001 should use no-op balancer (the goal is to reduce latency) and the huge amount of "9080" sub listeners should use exact_balancer (trade cross thread migration for balancing).

    Yeah, you can also use exact_balancer for 9080 listener and not to use balancer for 9070.

  11. added a commit that references this issue on Apr 29, 2021
    3e96780
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions