I Measured Six Ways to Connect ECS Services. Here's How Much Speed You Actually Lose.

I Measured Six Ways to Connect ECS Services. Here's How Much Speed You Actually Lose.

Latency for direct task IP, VPC Peering, Transit Gateway, ECS Service Connect, AWS PrivateLink and VPC Lattice, measured on ECS Managed Instances in ap-northeast-1 with 10,000 requests per condition. It also covers what crossing an Availability Zone costs, how the ranking changes with concurrency and keep-alive, and the problems I had to fix before the numbers were worth trusting.

Project Manager/General Manager
I recently joined a hands-on event run by two JAWS-UG chapters in Japan, the Container chapter and the Networking chapter. We built ECS Service Connect and VPC Lattice with our own hands.
The hands-on got each service running. But it didn't tell me how much latency each connection method costs. I wanted to know, so I built the environment myself and measured it.
This article compares several ways to connect ECS services inside the Tokyo region. Tasks are pinned to the same Availability Zone unless stated otherwise. I measured latency for six methods:
  • Same VPC, direct task IP (baseline)
  • VPC Peering, direct task IP
  • VPC Peering with ECS Service Connect
  • Transit Gateway, direct task IP
  • AWS PrivateLink
  • Amazon VPC Lattice
I also ran two extra tests. One reuses the same NLB and server task, so I can isolate what PrivateLink alone adds. The other measures what happens when tasks sit in different AZs.
This is the second article in a series. The first one measured three private connection methods between the Tokyo and Osaka regions. I won't compare the numbers across the two articles, because the environment and the measurement method are different.
This article is for engineers who already know how ECS task definitions and services work. It is for those who want to see the practical trade-offs between connection methods.
Try guessing which one is fastest before you read on.

2. What I measured

2.1 Two layers

A connection method has two parts. One is how packets arrive. The other is how the client addresses the server.
The first part is the network layer (L3) of the OSI model, so I'll call it L3 reachability.
The second part covers DNS names, direct IPs, proxies and load balancers. It's how the client names the destination and reaches the actual service from there. I'll call it how the client addresses the server.
The six methods are combinations of these two.
PrivateLink and VPC Lattice come as one piece. You can't mix and match the two layers the way you can elsewhere. With same VPC, VPC Peering and Transit Gateway, you're free to choose either direct task IP or Service Connect. With PrivateLink, you connect through an Interface VPC Endpoint in the client VPC. You normally use the DNS name attached to that endpoint. With Lattice, you use the DNS name of the Lattice service. I kept these differences in mind while measuring.

2.2 The paths

Path
Setup
L3 reachability
How the client addresses the server
What the difference tells you
A
Same VPC, direct task IP
none
direct IP
the baseline number
B
Peering + direct task IP
Peering
direct IP
B−A = the plain cost of crossing VPCs
C
Peering + Cloud Map DNS
Peering
Cloud Map DNS
(not measured) after name resolution it behaves like B
D
Peering + Service Connect
Peering
Envoy sidecar
D−B = the cost of two sidecar hops
E
Internal ALB
-
ALB DNS
(not measured) it brings ALB-specific handling into the comparison
F
TGW + direct task IP
TGW
direct IP
F−B = the cost of the TGW hop
G
PrivateLink
PrivateLink
endpoint DNS
G−B = PrivateLink with NLB versus Peering direct
G′
Peering + internal NLB direct (extra run)
Peering
internal NLB DNS
G−G′ = what PrivateLink adds on top of the same NLB
H
VPC Lattice
VPC Lattice
Lattice service name
H−B = VPC Lattice versus Peering direct
Here's the whole set as a diagram. I got confused myself partway through, so I drew it out.

C resolves a Cloud Map service name and then opens a TCP connection straight to the task IP it gets back. I explain the measurement conditions in section 5, but with keep-alive on, the connection is reused, so name resolution happens only once. After the connection is up, the path is identical to B. At the request volume I used, that one lookup disappears into the average. So I decided I couldn't evaluate B versus C in any meaningful way, and I skipped it.
E, the internal ALB, has private IPs that can change. So I can't point at an IP directly the way I do with G. An internal ALB is reached by DNS name. Connecting from another VPC over Peering is possible, but ALB adds its own L7 handling, which adds another variable to the comparison. I left it out. I dropped it before settling the L3 side, which is why the table shows "-" there.
C and E are out of scope. But the path IDs are shared keys across this article, my S3 bucket and my CSVs. So I left the letters as gaps rather than reusing them.
  • G′ is the extra run. G and G′ use the same tasks. Only the route from the client to the NLB changes. Taking G−G′ isolates the time that PrivateLink itself adds.
I also measured AZ placement, as a separate axis from the connection method. Before measuring, I expected the differences between A and H to be small. I was curious how much an AZ hop would cost by comparison, so I measured that too.
Path
Setup
What the difference tells you
L1
Same VPC, same AZ (identical to path A)
baseline
L2
Same VPC, across AZs
L2−L1 = the cost of crossing one AZ

2.3 What I held constant

To isolate the connection method, I kept the following the same across every path.
One note first. In the previous round of measurements, I ran into patterns that turned out not to work partway through. Checking what is measurable at the start, before you commit to a method, is worth the time.
I fixed the desired count of every ECS service to 1. I also made sure no two tasks under test landed on the same Managed Instance. I'll explain how later. CPU and memory are identical across paths, except path D, which carries the extra Envoy sidecar on top.
The load-generating client task always runs on a different instance from the server task under test. The same goes for path A's peer task. Traffic between two tasks on one instance may take a different network path from the other cases. I don't know where it turns around.
If you know how task-to-task traffic works inside a single instance, I'd like to hear it.

3. The methods in detail

Here's what each route looks like. This is the table above, mapped onto the physical layout.


3.1 Same VPC, direct task IP (path A)

The client task sends an HTTP request straight to the server task's private IP, inside one VPC. Nothing sits in between, and no VPC boundary is crossed. This is the baseline every other path is compared against.

3.2 VPC Peering, direct task IP (path B)

Two VPCs are peered, with static routes added to the route tables. The client then reaches the server's task IP directly.
It doesn't affect this test, but VPC Peering isn't transitive. As VPCs multiply you end up needing a full mesh. I covered that in the previous article.

3.3 Peering + ECS Service Connect (path D)

ECS Service Connect injects an Envoy sidecar into the task. It gives you name resolution through Cloud Map and routes traffic through that proxy.
You don't write the sidecar into the task definition. You set  ServiceConnectConfiguration  on the service, and ECS adds it for you.
The client connects to the Envoy inside its own task. That Envoy forwards to the Envoy on the server side, which hands off to the server application. Two hops.
App Mesh reaches end of support on September 30, 2026. AWS points to ECS Service Connect and VPC Lattice as the places to move to, depending on the use case. I left App Mesh out of this test, and included both of those instead.

3.4 Transit Gateway, direct task IP (path F)

Transit Gateway is a hub-and-spoke design. With only two VPCs in one region, this isn't what TGW is for. I'm measuring one thing: what the TGW hop costs.
I reuse the same client and server pair as path B and only switch the route from Peering to TGW. That way F−B is the TGW hop and nothing else.

3.5 AWS PrivateLink (path G)

A service behind an NLB is published as an endpoint service. The consumer VPC creates an Interface VPC Endpoint and connects to it privately. The direction matters: it's for the consumer reaching the service, not the other way around. The client uses the DNS name of that endpoint.
Both VPCs are in the same region here, so I could have set  PrivateDnsEnabled  to true. I didn't prepare a custom domain on the endpoint service side. So I left it false and used the DNS name AWS issues automatically.

3.6 Amazon VPC Lattice (path H)

VPC Lattice provides service-mesh style features as a managed service. You attach a Lattice target group to an ECS service, and ECS registers task IPs automatically when tasks start. There's no manual target registration like with an NLB.
A Lattice service listener can be HTTP, HTTPS or TLS. A TLS listener passes encrypted TCP through to the target, but it isn't a way to configure an arbitrary plain TCP listener. I wanted the same conditions everywhere, so I settled on HTTP for all measurements. More on that in section 5.

3.7 Two side notes

Overlapping CIDRs

VPC Peering and TGW can't connect VPCs whose CIDRs overlap. PrivateLink and VPC Lattice reach the target through the addressing layer instead, by endpoint or by service name. So the L3 CIDR design doesn't constrain them, and the two VPCs can overlap.
I designed this test so nothing overlapped. Still, freedom in CIDR design versus a simpler L3 path is a real thing to weigh when you pick a service.

About App Mesh

App Mesh reaches end of support on September 30, 2026, so it's out of scope here. AWS points to ECS Service Connect and VPC Lattice as the migration targets depending on the use case, and both are in this comparison.
This article reflects each service as of the end of August 2026. Supported protocols and other limits may change.

4. Building the environment

I built part of it by hand, then reproduced that in CloudFormation and built the whole thing from there.

4.1 Setting up Managed Instances

The IAM roles

I created four IAM roles. Two are for Managed Instances itself. Two are for the tasks running on top.
ecs-conn-cluster-infra-role
The role ECS uses to launch and manage EC2 instances on my behalf. It also registers targets in VPC Lattice for path H.
I added  iam:PassRole  inline. The AWS managed policy scopes its PassRole permission to  arn:aws:iam::*:role/ecsInstanceRole* , which doesn't cover an instance role I named myself. I hit that and added it afterwards.
ecs-conn-cluster-instance-role
The role the EC2 instance itself uses to join the ECS cluster. It reaches the instance through an instance profile.
ecs-conn-app-common-exec-role
The role the ECS agent uses when a task starts. It pulls the image from ECR and writes logs to CloudWatch Logs.
ecs-conn-app-common-task-role
The role the application inside the container uses. It grants ECS Exec access and permission to write results to S3.

Creating the ECS cluster

One cluster, with three capacity providers hanging off it.
Two VPCs but three capacity providers, because the security groups you attach to a capacity provider are only valid inside one VPC. A single capacity provider can't cover both VPC-A and VPC-B, so I needed one for each. The third one is for the other subnet in VPC-A, where the server task sits for the AZ comparison (L2).
I tried to name a capacity provider starting with  ecs-  and it was rejected. Names beginning with  ecs  appear to be reserved. Every other resource uses the stack name as its prefix. This one had to be different, so they're named like  conn-cp-vpc-a-main .
For the instance requirements, I set the same value for the minimum and maximum of both vCPU count and memory, pinning it to  c7g.xlarge . I needed the instance capacity fixed for the one-task-per-instance trick I describe below.

The task definitions

Two task definitions, one for the client and one for the server.
 RequiresCompatibilities  is set to  MANAGED_INSTANCES . Network mode is  awsvpc . CPU is 4096 and memory is 7168. A  c7g.xlarge  has 4 vCPU and 8192 MiB, so I left 1024 MiB of memory for the host OS and the ECS agent. The CPU architecture is Graviton, so  ARM64  is set explicitly.
One thing caught me out on the service side.  AvailabilityZoneRebalancing  is enabled by default. With it on, every deployment needs room for the old task and the new task to exist at the same time. Even for a service with a single task, that means asking for twice the capacity.
As I said, I wanted as few tasks running at once as possible. So I turned  AvailabilityZoneRebalancing  off, set  MinimumHealthyPercent  to 0 and  MaximumPercent  to 100, and let deployments stop the task before creating the new one.
I use ECS Exec, so  EnableExecuteCommand  is on as well.

The CloudFormation templates

Everything I built by hand is written out as CloudFormation. The templates for every path, the measurement app, and the aggregation scripts are here:
 cfn/ecs-conn-cluster.yaml  is the cluster and its three capacity providers.  cfn/ecs-conn-app-a.yaml  is the task definitions and services for path A, and the other paths follow the same shape.

4.2 Two decisions about the stack layout

Routes that conflict

VPC Peering and TGW both point at the same destination CIDR, so both routes can't live in the same route table. I hit the same limit in the previous article, with the cross-region setup. I left those two conflicting route entries out of CloudFormation and switched them from the CLI instead.

Keeping the cost down

Partway through, I split the network layer and the endpoint layer into separate stacks. Partly because of the cost, and partly because I wasn't good enough at this yet. The measurements didn't go smoothly, I had to redo them several times, and the work ended up spread across several days.
Fourteen Interface VPC endpoints bill by the hour, and that adds up. VPCs, subnets and security groups are free. So I split the cheap things I could leave running from the expensive things I should delete after each session. I also set desired counts to 0 by hand, which kept the cost down while letting me restart quickly next time.

4.3 Why ECS Managed Instances

I used ECS Managed Instances. The reason is simple. I've used Fargate many times in these articles. Managed Instances is the newest of the ECS launch types, so I wanted to try it.
I didn't compare speed against Fargate. The underlying platform is different, from the host to the way ENIs are attached to where things are placed. A direct comparison wouldn't mean much.
Managed Instances feels like Fargate in one way: you place a task and an instance appears for it. But it really is managed EC2. The host OS is Bottlerocket, SSH is disabled, and you can't specify a custom AMI or a placement group. Every measurement was run from inside the container through ECS Exec.

4.4 The hard part: getting one task per instance

The documentation says to "use single-task mode when needed." It also says you configure Amazon ECS Managed Instances to use single-task mode if your workloads require stronger isolation. I couldn't find the parameter for it.
The same page also says that by default, Managed Instances places multiple tasks on a single instance. That optimizes cost and utilization. It also relaxes workload isolation compared to Fargate. If tasks from different paths shared an instance, the whole comparison would fall apart.
In the end I forced it. I sized the task to almost fill the instance: 4 vCPU and 7168 MiB against a  c7g.xlarge  with 4 vCPU and 8192 MiB. If the task uses up nearly the whole instance, there's no physical room for a second one. I confirmed on real infrastructure that two services on the same capacity provider don't share an instance, so I went with it.
If you know the right way to do this, please tell me.

4.5 The hard part: missing VPC endpoints in the private subnet

The Managed Instances tasks sit in a private subnet, and I don't use a NAT gateway. At first I only created endpoints for ECR, CloudWatch Logs and SSM. The deployment then produced  Task timed out after 300  over and over, and not a single container instance registered.
The cause was three missing endpoints:  ecs ,  ecs-agent  and  ecs-telemetry . The instance needs those to reach the ECS control plane. With only the ECR, logs and SSM endpoints, the instance can't join the cluster at all. I worked through it with an AI agent, added the three, and it started working.
Those three are specific to Managed Instances, where an ECS agent really runs on an EC2 instance. With Fargate there's no EC2 instance for you to think about, so I'd never met this requirement in all the time I used Fargate. It's the kind of thing you only find by building Managed Instances for the first time.

5. How I measured

5.1 Why everything is HTTP

I measured the connection methods over HTTP only. I planned to record TCP connect time as well. The proxy paths made it impossible to keep conditions equal, so I dropped it.
On path D, the client application connects to the Envoy inside its own task. Measuring TCP connect time there gives you the time to reach a local proxy, which is close to zero. It would look faster than path A. On path H, a Lattice service listener can be HTTP, HTTPS or TLS. None of those let me compare plain TCP connect time on the same terms as the other methods. Putting a metric in the comparison table that only some paths can produce would mislead people. So I used HTTP, which works everywhere.
The request protocol is plain HTTP/1.1 on every path. Lattice can terminate TLS at the listener, so I could have used an HTTPS or TLS listener without touching the application. But the test application I wrote doesn't support TLS, so I couldn't put every path on HTTPS. Everything stays plain instead.

5.2 Conditions

Item
Setting
Requests per condition
10,000
Runs per condition
3
keep-alive
both on and off
Concurrency
1 and 16
Payload
1 KB on every path. 1 MB on B, D, G and H only
Protocol
plain HTTP/1.1 everywhere
Statistics
p50 / p95 / p99
I used oha, an HTTP load testing tool written in Rust, to generate the load. JSON output comes from  --output-format json .
Here's an example of what I actually ran, for path A with a 1 KB payload. keep-alive on/off and concurrency 1/16 make four conditions. So I run the same command four times. Each run changes whether  --disable-keepalive  is present, and what  -c  is set to. For concurrency 16,  -c 16 .
OHA="oha --no-tui --output-format json --worker-threads 4"
URL=http://<server-ip>:8080/bytes/1024

$OHA -n 10000 -c 1 --disable-keepalive $URL > A_ka-off_c1_1k.json
$OHA -n 10000 -c 1 $URL > A_ka-on_c1_1k.json
$OHA -n 10000 -c 16 --disable-keepalive $URL > A_ka-off_c16_1k.json
$OHA -n 10000 -c 16 $URL > A_ka-on_c16_1k.json
Here's the metrics section of  A_ka-on_c1_1k.json , which is keep-alive on at concurrency 1.
{
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 15352.41,
"latency_ms": {
"min": 0.052,
"mean": 0.064,
"p50": 0.064,
"p95": 0.07,
"p99": 0.08,
"max": 0.329
}
}
}
I collected output in this shape for four conditions, three runs each, across nine paths. The numbers above are from one single run. The tables in section 6 are averages of three, so they differ slightly.

5.3 The hard part: percentiles and the number of requests

I planned to use 300 requests, matching the previous article. The results moved around a lot.
Looking into it, oha's p99 sorts every request from fastest to slowest and takes the value at position 0.99 × N. For 300 requests that's number 297. So with 300 requests, p99 is one single measured value, the third slowest one. A brief pause from runtime GC or OS scheduling landing on that one request moves p99 a long way.
I tried 3,000 requests, three runs of the same condition. p99 still varied by up to 17 percent from the average. Not enough. At 10,000 requests, again three runs, the variation came down to about 4 percent. So I measured everything at 10,000.

5.4 The hard part: TIME_WAIT exhaustion with keep-alive off

While re-running measurements, p50 with keep-alive off would jump by 3 to 25 times, roughly once every three or four runs. p99 moved even more. I didn't know why, and one possibility was a resource shortage, so I enabled ECS Container Insights to look. Client-side CPU usage was close to five times higher, but only when the anomaly happened.
I still couldn't pin it down, so I worked through it with an AI agent, and we found it.
With  --disable-keepalive , every request opens a new TCP connection. Ten thousand requests consume a lot of client-side ports. Each one stays in TIME_WAIT in the kernel for up to about 60 seconds after it closes. I was running three times in a row. With short gaps between runs, ports get consumed again before TIME_WAIT clears, so they pile up. Once the total passed roughly 14,000, the cost of getting a new port jumped.
I set  net.ipv4.tcp_tw_reuse=1  through  SystemControls  in the task definition, which allows a TIME_WAIT socket to be reused right away. After that, six runs of the same condition in a row and p50 stopped moving.
This is a test environment, so I applied it immediately. Whether it's appropriate in production depends on your setup. The network path, the kernel version, and whether NAT or a load balancer sits in the way all matter. That needs checking case by case. Here it's only a setting to stabilize the measurements.
While digging into this, I remembered running into port exhaustion blocking new sessions, years ago.
I applied this to every path and measured keep-alive off again, and again. The variation in p99 (the largest deviation from the average of three runs) improved from 249 percent to 33.7 percent. Section 6 uses the data from after this fix.

6. Results

Here are the numbers. Everything is in milliseconds.

6.1 Comparing the connection methods (1 KB, average of three runs of 10,000 requests)

keep-alive on (1 KB, milliseconds)

Path
p50
p95
p99
p50 at c16
p99 at c16
A (same VPC, direct)
0.065
0.072
0.085
0.104
0.249
B (Peering, direct)
0.077
0.082
0.091
0.105
0.209
D (Peering + Service Connect)
0.463
0.508
0.564
1.614
2.792
F (TGW, direct)
0.257
0.271
0.285
0.212
0.395
G (PrivateLink)
0.509
0.559
0.609
0.527
0.718
H (VPC Lattice)
1.330
1.712
1.872
1.221
1.858
At keep-alive on and concurrency 1, the order is A, B, F, D, G, H, from fastest to slowest. That order is the same whether you look at p50, p95 or p99.
Every gap below is a difference between p50 values. Same VPC (A) and Peering direct (B) are almost identical, with B−A at about 0.012 ms. Service Connect (D) carries two Envoy sidecar hops and lands about 0.39 ms behind B. PrivateLink (G) and VPC Lattice (H) are slower still, with H the slowest of all.
The order holds, but the size of each gap changes with the percentile.

The main gaps, by percentile

Gap
What it is
p50
p95
p99
B−A
the plain cost of crossing VPCs
0.012
0.010
0.006
F−B
the cost of the TGW hop
0.180
0.189
0.195
D−B
the cost of two sidecar hops
0.387
0.426
0.473
G−B
PrivateLink with NLB versus Peering direct
0.432
0.477
0.518
H−B
the cost of VPC Lattice
1.253
1.630
1.781
G−G′
what PrivateLink adds on top of the same NLB
0.108
0.134
0.139
Index each gap so its own p50 is 100, and the shape comes out clearly.

VPC Lattice (H) falls further behind the slower the requests get. Against Peering direct, H−B is 1.25 ms at p50 and 1.78 ms at p99, a factor of 1.4. Against PrivateLink it's the same story: 0.82 ms at p50 against 1.26 ms at p99, a factor of 1.5. If you pick Lattice, expect the gap on slow requests to be wider than p50 suggests.
G−G′ from the extra run is what PrivateLink adds. It widens the same way: 0.108 ms at p50 against 0.139 ms at p99, a factor of 1.3. For both PrivateLink and VPC Lattice, the gap against the base setup was larger at p99 than at p50.
B−A is the only one that goes the other way. It narrows on slower requests, from 0.012 ms at p50 to 0.006 ms at p99. The difference between same VPC and VPC Peering gets quite small when you look at the slow side.
All of that is at concurrency 1. At concurrency 16 the order changes, and Service Connect (D) drops behind VPC Lattice (H).

p50 by concurrency (keep-alive on, 1 KB)

Path
c1
c16
Factor
A (same VPC, direct)
0.065
0.104
1.6x
B (Peering, direct)
0.077
0.105
1.4x
F (TGW, direct)
0.257
0.212
0.8x
D (Service Connect)
0.463
1.614
3.5x
G (PrivateLink)
0.509
0.527
1.0x
H (VPC Lattice)
1.330
1.221
0.9x

Going to concurrency 16 barely moved p50 for most paths. TGW (F) and VPC Lattice (H) came out lower at 16. With this many runs, I can't call that a real improvement. Service Connect (D) is the exception. It got 3.5 times slower, passing PrivateLink (G) and VPC Lattice (H) to become the slowest of the six.
This is a guess, but Service Connect routes through an Envoy sidecar inside the client task and another inside the server task. As concurrency rises, the application container and Envoy compete for the same limited CPU and memory inside one task. That makes a bottleneck easy to hit. Lattice goes through a data plane that AWS manages outside the task, so it's less exposed to one task's resource limits. That may be why it didn't degrade the way D did. Again, this is my guess and I haven't verified it.
That's all with keep-alive on. Turning it off changes the picture.
keep-alive off (1 KB, milliseconds)
Path
p50
p95
p99
p50 at c16
p99 at c16
A (same VPC, direct)
0.222
0.272
0.293
0.357
0.645
B (Peering, direct)
0.235
0.293
0.300
0.371
0.652
D (Peering + Service Connect)
0.589
0.651
0.707
2.403
4.224
F (TGW, direct)
0.572
0.931
1.104
0.623
1.156
G (PrivateLink)
2.021
2.594
2.800
1.909
2.706
H (VPC Lattice)
2.621
3.710
4.051
2.256
3.366

Every path gets slower with keep-alive off, but by very different amounts. PrivateLink (G) is hit hardest, going from 0.509 ms to 2.021 ms, a factor of 4.0. Same VPC direct (A) is next at 3.4x, then Peering direct (B) at 3.1x.
The least affected is Service Connect (D), at 1.3x. The client connects to the Envoy inside its own task, so turning keep-alive off only tears down that local connection. The Envoy keeps its connection to the server side. That's what I think is happening. VPC Lattice (H) sits in the middle at 2.0x. It also goes through a managed data plane, so the reason may be the same. I haven't verified either explanation.
As for why PrivateLink was hit hardest, each new connection has to be set up through the Interface VPC Endpoint and the NLB. I didn't observe the internals directly, so I can't say that's the cause. In this test the effect with keep-alive on was small. But if your workload opens a new connection every time, this difference is worth knowing about.

6.2 The extra run: what PrivateLink adds to a direct NLB connection

G and G′ share the same server task. Only the client's destination changes. G−G′ isolates the time PrivateLink adds.
Path
p50, keep-alive on
p50, keep-alive off
G′ (NLB direct)
0.401
1.532
G (PrivateLink)
0.509
2.021
At p50, PrivateLink costs about 0.11 ms more with keep-alive on, and about 0.49 ms more with it off. My reading is that a PrivateLink Interface Endpoint isn't a plain route. It includes machinery for service connectivity, something like bidirectional NAT, which is what lets overlapping CIDRs work. I think that's where the difference comes from.

6.3 What AZ placement costs (L2−L1)

Separate from the connection methods, I moved the server task to another AZ and measured the effect. The metric here is TCP connect time.
Path
p50
p99
L1 (same AZ, identical to path A)
0.260
0.318
L2 (across AZs)
1.151
1.237
Crossing one AZ adds about 0.89 ms to TCP connect time at p50. This is a different metric from the HTTP latency in section 6.1, so the two can't be compared directly. Still, for a workload that opens new connections often, AZ placement clearly matters.

6.4 Throughput (1 MB, concurrency 16)

With a 1 MB payload at concurrency 16, B, D, G, H and G′ all converged around 1,470 to 1,480 requests per second. That works out to 1 MB (1,048,576 bytes) × 1,477 RPS, or about 12.4 Gbps.
I measured the bandwidth ceiling separately with iperf3. A single stream reached 9.53 Gbps, and 16 parallel streams reached 12.40 Gbps, which matches what oha produced at concurrency 16. So under this condition the limit isn't the connection method. It's the network bandwidth of the instance type I used, a  c7g.xlarge  rated at up to 12.5 Gbps.
I gave up on evaluating throughput.

7. What I take from this

7.1 Differences against the baseline

Working from p50 at keep-alive on and concurrency 1, here's how I read it. Every number is a difference between p50 values.
  • A to B, about +0.01 ms. In this environment and under these conditions, going through VPC Peering inside one AZ added almost nothing.
  • B to D, about +0.39 ms. The cost of two Envoy sidecar hops. With a local proxy on the client side and another on the server side, an increase around this size seems reasonable.
  • B to F, about +0.18 ms. The cost of the TGW hop. Slower than Peering direct. The previous article found the same thing across regions, and this same-AZ result points the same way.
  • B to G, about +0.43 ms. The difference between reaching the task IP directly over Peering and going through PrivateLink plus an NLB. What PrivateLink itself adds is separated out by G−G′, using the same NLB and server task.
  • G to H, about +0.82 ms. VPC Lattice came out slower than the PrivateLink setup. Lattice probably does more per request, such as service-level routing.
  • B to H, about +1.25 ms. Going through VPC Lattice was slower than reaching the task IP directly over Peering. This was the largest gap in the comparison. In absolute terms it's about 1.25 ms, but B itself is 0.077 ms, so in relative terms it's a big difference. Honestly, I expected Lattice to land closer to the others.

7.2 The gaps are milliseconds, but the shape changes with the conditions

In this environment, the absolute p50 differences between connection methods stayed within a few milliseconds. In relative terms the methods differ a lot, and both the order and the size of the gaps changed with concurrency and with keep-alive.
If your workload can absorb a few milliseconds, speed alone doesn't need to drive the decision. Connectivity, authentication and authorization, observability, operational effort and cost all belong in the same conversation.
If microseconds matter to you, the differences aren't something to wave away. They add up, for example when requests are chained one after another.
One honest note: I expected VPC Lattice to come out roughly level with the rest. It didn't. That's something I only learned by running it.

8. Limits of this test

This is a personal test. It doesn't claim to be rigorous.
  • Each number is the average of three runs of 10,000 requests. As in the previous article, I didn't test across different times of day or days of the week. I ran no statistical significance testing.
  • Instances stay fixed within a measurement session, so per-instance variation isn't covered.

9. Wrapping up

I built six ways to connect ECS services in the Tokyo region and measured their latency. Every task ran in the same AZ. The six were direct within one VPC, direct over VPC Peering, ECS Service Connect, Transit Gateway, AWS PrivateLink, and Amazon VPC Lattice.
At keep-alive on and concurrency 1, p50 ranked in this order. Same VPC direct 0.065 ms, Peering direct 0.077 ms, TGW direct 0.257 ms, Service Connect 0.463 ms, PrivateLink 0.509 ms, VPC Lattice 1.330 ms. The absolute differences are milliseconds. The relative differences are large. The pattern also shifted with concurrency and with keep-alive.
Crossing an AZ added about 0.89 ms to TCP connect time at p50. That's a different metric from HTTP latency, so it isn't a direct comparison. But for workloads that open a lot of new connections, AZ placement deserves as much attention as the connection method.
I had to redo a lot along the way. Getting one task per instance on Managed Instances. The missing VPC endpoints in the private subnet. The relationship between percentiles and request count. The bandwidth ceiling. TIME_WAIT exhaustion with keep-alive off. You only find these by building the thing, so I wrote them down for anyone running a similar test. There were plenty of smaller mistakes too, and the whole thing took longer than I expected.
Based on these results, I don't think speed alone should decide the connection method. Required latency, concurrency, connection reuse, CIDR design, authentication and authorization, operational effort and cost all belong in the decision. Next I'd like to see how these methods behave during scale-out, scale-in and rolling deployments. From there I want to build a guide for choosing between them.
I hope this helps if you are deciding how to connect your ECS services.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article