3

If I have an application looks like the following:

Client <--> ELB <--> EC2

Would the E2E latency possibly be lower if I set up ELB as TCP passthrough mode than I make it as HTTP listener?

The reason I guess TCP passthrough mode may make my E2E latency better (lower) is because ELB in this scenario almost does not cause any extra hop cost than the following scenario:

Client <--> EC2

Is my understanding correct? Please walk me through if not.

3
  • I think you better latency with tcp mode, you can test using curl in this way stackoverflow.com/questions/18215389/…
    – c4f4t0r
    Apr 6, 2018 at 8:48
  • 1
    Are you referring to TCP Passthrough as implemented by ELB Classic, or something else? Apr 6, 2018 at 12:10
  • 1
    @Michael-sqlbot, Yes, I meant ELB Classic
    – chen
    Apr 6, 2018 at 20:44

1 Answer 1

6

Your understanding isn't quite correct, because TCP pass-through is really payload pass-through. The balancer accepts the connection, then creates a new connection to the instance, then passes the payload back and forth on the connection. Traffic still passes through an extra device -- the balancer.

It will not likely make a substantial difference in latency because once the request is cut-through in HTTP mode, the behavior is similar, with bytes copied from one connection to the other.

The disadvantage of TCP mode is that you lose something a Classic ELB in HTTP mode is able to do: reuse the same connections to the instances for handling sequential requests for multiple clients -- it holds idle connections open to the instances, waiting for more client requests to arrive, which means fewer connections being initiated to the instances, and many requests potentially using connections that are already established.

Depending on the application, an ALB -- application load balancer -- offers a further advantage, not only reusing instance connections, but supporting HTTP/2 on the browser side, allowing the browser to send concurrent requests, which are fanned out to the instances as parallel HTTP/1.1 requests.

Or, if you really want a TCP pass-through scenario, you probably want an NLB -- network load balancer. Unlike the other two balancer types, an NLB actually modifies the network behavior to create dynamic NAT translations to the instances -- there isn't a separate system handling the traffic, because NLBs are virtual entities. Classic and Application balancers are actually (as far as anyone can tell) implemented on "hidden" EC2 instances.

4
  • What do you mean with "NLBs are virtual entities"? By reading the AWS documentation I don't get that idea: "After the load balancer receives a connection request, it selects a target from the target group for the default rule. It attempts to open a TCP connection to the selected target on the port specified in the listener configuration... The TCP connections from a client have different source ports and sequence numbers, and can be routed to different targets. Each individual TCP connection is routed to a single target for the life of the connection."
    – andresp
    Jan 13, 2019 at 17:56
  • It also supports healthchecks, auto-scaling/elastic... Seems quite feature rich for something purely "virtual".
    – andresp
    Jan 13, 2019 at 17:57
  • 1
    @andresp the documentation is speaking conceptually. Classic and Application balancers actually create hidden EC2 instances that the traffic literally passes through. NLB does not. It is an integrated service provided by the network infrastructure, not individual purpose-specific VMs, which is how it "is architected to handle millions of requests/sec, sudden volatile traffic patterns and provides extremely low latencies.". When Classic/App balancers scale, you see ENIs for those VMs created and destroyed in your VPC, but not with NLB. Jan 13, 2019 at 18:09
  • 1
    How the health checks are specifically implemented is not documented, but NLB seems to have some additional infrastructure specific to this purpose -- this part would necessarily be somewhat less "virtual" in the sense I used it here, but it is not part of the normal traffic flow. NLB is provided by an internal network service called AWS Hyperplane, which also runs NAT Gateway (which is another virtual service provided by the network infrastructure, not accomplished with EC2 VMs). Jan 13, 2019 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .