
How to connect ECS services across VPCs so traffic moves to new tasks: nine paths measured during scaling and deployments
I measured how fast nine ways of connecting ECS services across VPCs move traffic to new tasks during scale-out, scale-in and rolling deployments, with HTTP keep-alive off and on. The post shows how to run the same measurement, how each path is wired in CloudFormation (Cloud Map, Service Connect, ALB, NLB with PrivateLink, VPC Lattice), and how to choose one.
Project Manager/General Manager
When one ECS service calls another, you have many ways to connect them: task IPs over VPC Peering, Cloud Map DNS, ECS Service Connect, an internal ALB, an internal NLB behind PrivateLink, or Amazon VPC Lattice.
In an earlier post , the first in this ECS service connectivity series, I measured the static HTTP latency of six of these paths. The numbers were useful, but they did not answer the question I kept running into in practice. Tasks come and go. When I scale out, how long does it take before the client actually reaches the new tasks? When I roll out a new version, when does traffic really move to it?
So I built all of these paths again and measured how quickly each one follows changes to the server service. I ran 105 trials in the Tokyo Region between November 11 and 14, 2026. I start with how the measurement works and how each path is wired in CloudFormation, so you can run it yourself, and then show my numbers and how I would choose a path. I assume you know VPCs, load balancers and CloudFormation; I explain Service Connect, PrivateLink and VPC Lattice where they first matter.
I only measured the normal cases here: scale-out, scale-in and rolling deployment. What happens when a task or instance fails is a separate topic, and I will cover it in a later post.
In short
- With keep-alive off, the time from "the new task can answer" to "the path sends it traffic" was about 9 to 11 seconds for VPC Lattice, 9 to 13 seconds for an internal ALB, 10 to 16 seconds for Service Connect, 16 to 20 seconds for an NLB and 28 seconds for Cloud Map DNS.
- With keep-alive on, the NLB and Cloud Map paths stayed on old tasks until those tasks stopped. VPC Lattice and Service Connect did not.
- Slow or not, most paths that discover tasks almost never dropped a request: at most two connection resets per trial, at 20 requests per second. Service Connect was the exception: it returned HTTP 503 in 9 of 12 rolling and scale-in trials, up to 48 requests per trial, and the access logs point to the proxy of the stopping task. Calling the task IP directly started failing within about a second of the task stopping and never recovered.
- All the code is public. You can run the same measurement on your own setup and see whether your numbers match mine.
What I measured
The server runs on ECS Managed Instances, where ECS launches and manages the EC2 instances for you (c7g.xlarge, Graviton, Bottlerocket, one task per instance). A single client task sends
GET /health to the server through the path under test at 20 requests per second, on a fixed schedule. Each path was measured with the same three operations:- Scale-out: desired count 1 to 4.
- Scale-in: desired count 4 to 1.
- Rolling deployment: 4 tasks,
MinimumHealthyPercent=100,MaximumPercent=200. The image is the same; only theAPP_VERSIONenvironment variable changes, so the code does not affect the result.
Scale-in and rolling were measured both with HTTP keep-alive off and on. With keep-alive on, the client reuses one TCP connection for all its requests. With it off, every request opens a new connection, so the path gets a fresh chance to pick a task each time. Each condition ran 3 times on the six main paths. The three direct-IP controls ran once per condition.
I split the timeline into points, because "the task is RUNNING" and "the client uses the task" are different moments.
Point | Meaning |
|---|---|
T0 | The API call that changes the server service |
T1 | The new task is first seen as PENDING |
T2 | The new task is first seen as RUNNING |
T3 | An observer task in the server VPC first gets 200 from the new task's own IP |
T4 | The client first gets a response from that new task through the normal path |
T5 | Traffic is spread across the expected tasks (each task within 25% ± 15 points, for three 30-second windows in a row) |
The diagram below shows who records which point. The client task also runs the session: it calls the ECS API at T0 and reads the task states every second (T1, T2). A separate observer checks each task IP (T3), and the client's requests through the path give T4 and T5. For path A, the server tasks and the observer are in VPC-A.

The next diagram puts the points on one timeline for a scale-out or a rolling deployment.

Scale-in starts no new task, so T1 to T4 do not apply. What matters there is whether the path stops sending requests to the tasks being removed before they go away. For scale-in, I record, measured from T0, when ECS first shows a task being removed as stopping, the last response the client gets from such a task through the path, and when the task leaves the registry (the target group, or Cloud Map for C and D). I also record when failed requests start.

Rules I followed
These are the decisions that the numbers in this post depend on. They also apply if you measure your own paths with different tools.
- Compare T4 − T3, not T4 − T0. T4 − T0 also includes instance provisioning and image pull, so it says more about Managed Instances than about the path. T4 − T3 is the time between "the task can answer" and "the path sends traffic to it".
- Check readiness outside the path. The observer calls each task IP directly and does not go through the path under test, so T3 does not depend on the path.
- Do not let the client hide failures. The client sends on a fixed schedule and does not retry, because a retry would hide exactly the failed requests I want to count.
- Do not take an ECS status as the moment a task is ready. In some trials, T2 came several seconds after T3 and T4, which polling ECS once a second does not account for, and I cannot explain it. For the same reason, I do not read ECS's "deployment completed" as traffic having moved (see Early Success Criteria in the wiring section).
- Set an upper limit, because traffic may never switch. Some paths never sent a request to a new task: the direct-IP controls kept calling their fixed IP. So I stopped waiting 360 seconds after T0, and if T4 or T5 had not happened by then, I recorded the trial as cut off instead of inventing a value.
- Know what your clocks can tell you. T3 and T4 are recorded by different tasks, so any clock drift between them goes straight into T4 − T3. I did not measure that drift. This is one reason I read a difference of a few seconds as "about the same".
The nine paths
ID | Path |
|---|---|
A | Same VPC, task IP directly (control) |
B | VPC Peering, task IP directly (control) |
C | VPC Peering + Cloud Map DNS |
D | VPC Peering + ECS Service Connect |
E | VPC Peering + internal ALB |
F | Transit Gateway, task IP directly (control) |
G | PrivateLink endpoint + endpoint service + internal NLB |
G' | VPC Peering + the same internal NLB as G |
H | Amazon VPC Lattice (both VPCs associated with the service network) |
The letters are the same as in my earlier post. That post measured A, B, D, F, G and H, and ran G' as an extra test. This post adds C and E and treats G' as a main path, which makes nine.
PrivateLink (G) lets the client VPC reach one service in another VPC through an endpoint in its own VPC, without routing between the two VPCs. VPC Lattice (H) is a managed layer that routes requests between services across VPCs and balances them per request. G' shares the NLB, target group and server with G. I ran them back to back so that the only difference is the PrivateLink endpoint.
It helps to read each path as two layers. One layer carries packets between the VPCs: the same VPC, VPC Peering, Transit Gateway or PrivateLink. The other decides which task a request goes to: a fixed IP, Cloud Map DNS, Service Connect, a load balancer or VPC Lattice. In practice you pick one from each. I did not test every pair. C, D, E and G' all run over VPC Peering, and Transit Gateway appears only with fixed IPs (F).
A, B and F have no layer that finds tasks: the client calls a fixed task IP. They are controls that show what happens without one, and they also show whether the network layer alone (same VPC, Peering, Transit Gateway) changes anything.
The next diagram puts the nine paths side by side. The thing to look at is what sits between the client and the tasks on each path: nothing, a name lookup, a proxy or a load balancer.

In C, the client resolves a DNS name and connects to the task IP it gets. In D, the Service Connect proxy in each task gets the endpoints from Cloud Map and the proxies talk to each other.
How each path is wired
All templates are CloudFormation, and the full files are in the repository. Here I only show the few lines per path that decide how it follows tasks, because those are the lines you would have to get right in your own templates.
Every server service uses the same deployment settings. I turned off Early Success Criteria so that ECS's "deployment completed" status would not be mistaken for traffic having moved. I turned off Availability Zone rebalancing so that ECS would not move tasks on its own in the middle of a trial.
AvailabilityZoneRebalancing: DISABLEDDeploymentConfiguration: MinimumHealthyPercent: 100 MaximumPercent: 200 EarlySuccessCriteria: Enable: false DeploymentCircuitBreaker: Enable: true Rollback: trueFor the same reason, I set
InfrastructureOptimization.ScaleInAfter: -1 on the Managed Instances capacity providers, so that consolidation would not replace tasks during a measurement. This has a cost at cleanup time: the instances no longer go away when their tasks are gone, and the cluster cannot be deleted until you deregister the empty container instances.C: Cloud Map DNS across VPCs
A private DNS namespace can only be resolved in the VPCs it is associated with. So I associated it with the client VPC and registered the server tasks, which live in the other VPC, through
ServiceRegistries .Namespace: Type: AWS::ServiceDiscovery::PrivateDnsNamespace Properties: Name: !Ref NamespaceName Vpc: !Ref VpcAId # client VPCDiscoveryService: Type: AWS::ServiceDiscovery::Service Properties: NamespaceId: !Ref Namespace DnsConfig: DnsRecords: - Type: A TTL: 10# server service (in VPC-B)ServiceRegistries: - RegistryArn: !Ref CloudMapServiceArnThe ECS documentation does not say whether a task in another VPC can be registered like this, so I checked it before measuring: the client resolved all four server IPs over Peering.
D: Service Connect
The server publishes a name. The client only turns Service Connect on, without a
Services entry, and reaches the server at discoveryName.namespace .# serverServiceConnectConfiguration: Enabled: true Namespace: !Ref ServiceConnectNamespaceArn Services: - PortName: app DiscoveryName: !Ref ServerDiscoveryName ClientAliases: - Port: !Ref AppPort# clientServiceConnectConfiguration: Enabled: true Namespace: !Ref ServiceConnectNamespaceArnE: internal ALB
ECS registers task IPs through
LoadBalancers . I shortened the health check and the deregistration delay so that the comparison would not be dominated by AWS defaults.TargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup Properties: TargetType: ip HealthCheckPath: /health HealthCheckIntervalSeconds: 5 HealthCheckTimeoutSeconds: 4 HealthyThresholdCount: 2 UnhealthyThresholdCount: 2 TargetGroupAttributes: - Key: deregistration_delay.timeout_seconds Value: "10"10 seconds is far shorter than the default of 300 seconds. I chose it for measurement, not as a production recommendation: in production the delay has to cover your longest in-flight request.
G and G': NLB with and without PrivateLink
The provider side is an internal NLB with an
ip target group and a VPC endpoint service. The consumer side is an interface endpoint in the client VPC. G' calls the NLB's own DNS name over Peering. The endpoint and endpoint service are standard, so I only show the target group, where the two settings that affect draining are.TargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup Properties: TargetType: ip HealthCheckProtocol: TCP HealthCheckIntervalSeconds: 5 HealthCheckTimeoutSeconds: 4 HealthyThresholdCount: 2 UnhealthyThresholdCount: 2 TargetGroupAttributes: - Key: deregistration_delay.timeout_seconds Value: "10" - Key: deregistration_delay.connection_termination.enabled Value: "true"AWS recommends a deregistration delay of at least 120 seconds for NLB, and connection termination is off by default for TCP. I changed both on purpose: I wanted old connections to be closed when the delay ends, so that the results show the path and not a long default timer. I did not measure the defaults.
In my runs, even with these settings, the NLB target took about 100 to 148 seconds after T0 in individual trials to disappear from the target group during scale-in. I have not found out why it takes so much longer than the 10-second delay.
H: VPC Lattice
Both VPCs are associated with the service network, which is what makes the service reachable from the client VPC without Peering. The server service registers its task IPs in a Lattice target group through
VpcLatticeConfigurations . The target group uses the same 5-second health check as the ALB.ServiceNetworkAssociationA: Type: AWS::VpcLattice::ServiceNetworkVpcAssociation Properties: ServiceNetworkIdentifier: !GetAtt ServiceNetwork.Id VpcIdentifier: !Ref VpcAIdServiceNetworkAssociationB: Type: AWS::VpcLattice::ServiceNetworkVpcAssociation Properties: ServiceNetworkIdentifier: !GetAtt ServiceNetwork.Id VpcIdentifier: !Ref VpcBId# server serviceVpcLatticeConfigurations: - TargetGroupArn: !Ref LatticeTargetGroupArn PortName: app RoleArn: !Ref InfrastructureRoleArnI used
AuthType: NONE so that every path is plain HTTP and the comparison is not skewed by signing on one path only. In production, you would normally use AWS_IAM , and the client would need to sign its requests with SigV4. TLS and mTLS are not part of this measurement on any path.How to reproduce the measurement
You can run the same measurement before reading my numbers, or afterwards to check them. The templates, the app, the measurement code and the ops scripts are in the repository below. The README lists the scripts in the order you run them, so I do not repeat them here.
The measurement has three parts.
- A client task sends requests through the path on a fixed schedule (20 per second, 2-second timeout, no retries) and records the task ID, version and time of every response. The server app returns
X-Task-IdandX-App-Versionheaders, so each response tells you which task answered.
- An observer task in the server VPC reads the server task IPs from the ECS API every second and calls each task's
/healthdirectly. This gives T3 for every path, including PrivateLink, where the client cannot reach task IPs.
- A runner records ECS task states and Cloud Map or target group registrations every second, and writes everything as JSONL to S3 with the same UTC clock. An aggregation script then computes T0 to T5 per trial and draws the charts.
The D template turns on Service Connect access logs for the proxies in both the client and the server tasks. I added them to find out which proxy returned the 503s, and the D numbers in this post come from the run with them on, so keep them on if you want to compare your results with mine. The proxy in the client task still wrote no access log, and I did not measure whether logging slows the proxy. The logs add CloudWatch Logs charges, and the log groups stay after you delete the stacks, so delete them or set a retention period afterwards. The README explains the setting in more detail.
One session (15 trials) took a few hours, most of it spent waiting for Managed Instances to provision. A rolling deployment with 100/200 briefly doubles the server to 8 tasks on 8 instances, so check your vCPU quota first. Delete everything when you are done, because the instances keep running. Delete the cluster before the VPC interface endpoints: in a VPC with no NAT gateway, the ECS agent reaches ECS only through those endpoints, and when I removed them first, the agents lost their connection and the cleanup stopped.
The rest of this post is what I got when I ran it.
Results
All 105 trials were valid. Time values are the average of 3 trials, in seconds.The scale-in column and the failure column need the explanation that follows the table.
Path | Scale-out T4 − T3 | Rolling T4 − T3, keep-alive off | Rolling T4 − T3, keep-alive on | Scale-in: last response from a stopping task | Failed requests (range per trial, all conditions) |
|---|---|---|---|---|---|
C Cloud Map | 28.0 | 28.8 | 103.0 (T5 cut off 3/3) | 26.1 | 0; 1 to 2 resets with keep-alive on |
D Service Connect | 10.2 | 15.5 | 17.0 | 19.5 | HTTP 503 in 9 of 12 rolling and scale-in trials, 1 to 48 per trial |
E internal ALB | 13.0 | 9.4 | 20.6 | 63.9 | 0 |
G PrivateLink + NLB | 19.0 | 20.3 | 112.7 (T5 cut off 3/3) | 40.1 | 0; up to 2 resets with keep-alive on |
G' Peering + NLB | 17.2 | 15.8 | 107.2 (T5 cut off 3/3) | 23.1 | 0; 1 reset with keep-alive on |
H VPC Lattice | 9.4 | 11.4 | 10.9 | 23.5 | 0 |
A request counts as failed if it does not get HTTP 200 within 2 seconds: a timeout, a reset or other connection error, or an HTTP error.
The scale-in column is for keep-alive off: the last response from a stopping task, measured from T0. The tasks' removal from the target group came later than that for E, G, G' and H (77 to 120 seconds), and Cloud Map deregistration for C (17 seconds) and D (11 seconds) came earlier. G's 40.1 seconds comes from one trial at 65 seconds; the other two were 28 and 27 seconds.
The direct-IP controls (A, B, F) never sent a single request to a new task. When their fixed target stopped, requests kept failing until the 360-second cutoff, about 5,000 to 7,000 failures per trial.
When did the failures start? I recorded the send time of every failed request and compared it with the moment ECS first reported the target task as stopping. ECS state was polled once a second, so these differences are accurate to about 1 second.
Path | Failed requests | First failure, after the task started stopping |
|---|---|---|
A, B, F (direct IP) | about 5,000 to 7,000 per trial, until the cutoff | −0.8 to 1.4 seconds |
C, keep-alive on | 1 to 2 resets | 18 to 30 seconds |
G and G', keep-alive on | 1 to 2 resets | 22 to 90 seconds (scale-in), 36 to 47 seconds (rolling) |
D, rolling and scale-in | 218 HTTP 503 in 9 of 12 trials, 1 to 48 per trial | 13 to 32 seconds |
With direct IP, the client started failing as soon as its task started stopping and never recovered. On the other paths, the failures came well after the stop began. For G, G' and D, the client talks to an NLB or a proxy, so I cannot tell which task a failed request was meant for. For those, I measured from the first old task that started stopping.
Why did most of the slow paths not drop requests? Following new tasks slowly only means the old tasks keep serving a little longer. Requests fail when they go to a task that is no longer there. When ECS stops a task, it first removes the task from the load balancer, waits for the deregistration delay, and only then sends
SIGTERM . By the time the task stops, the load balancer is no longer sending it new requests. My server app does nothing special on shutdown, so I think this ordering is why the load balancer paths had zero errors. The one or two resets with keep-alive on most likely came from the reused connection: it stayed open to an old task and was cut when that task stopped. I have not confirmed this. For Cloud Map, I could not find the same ordering documented, but the old tasks kept answering after their Cloud Map record was removed, so they were still running.Note that this is a planned removal. When a task or instance fails, nothing removes it first, and that is the topic of my next post.
Service Connect did drop requests. All 218 failures were HTTP 503. With access logs on, the Service Connect proxies in the server tasks logged 1,723 responses with status 503, each returned in about 1 ms without reaching the app. The 971 of them that were addressed to the service name came from tasks that were stopping: the proxy kept answering 200 for 11 to 16 seconds after ECS marked the task as stopping, then returned 503 until 13 to 22 seconds after. The client saw 218 failures against these 971 log lines, which fits the proxy retrying failed requests, but that is arithmetic, not proof. The proxy in the client task wrote no access log at all, so I cannot rule out that it also produced some of the 503s, and I cannot match a failed request to a log line. I did not find documentation of this removal order for Service Connect.
I measured D three times with the same setup, and the total failures varied widely: 2, 237 and 218. I do not know why. The D numbers in this post are from the third run, the one with access logs on. One more point is unconfirmed: the observer's
/health call may pass through the proxy, and if it does, T3 includes the time until the proxy is ready.With keep-alive on, the paths sent requests in completely different ways. The two charts below show a rolling deployment with keep-alive on, stacking the share of requests each task received in every 30 seconds. Each block is one task: blue is an old task that was running before the deployment, and orange is a new task that the deployment started.

With the NLB (G), every request went to one old task. When that task stopped, every request moved to one new task. The move was instant: the first new response came about 0.1 seconds after the last old response. The bar for 120 to 150 seconds has two blocks only because the switch happened inside that window. The other six tasks received no requests at all until the 360-second cutoff. Cloud Map (C) and G' behaved the same way. Traffic never spread across the four new tasks, so T5 never happened.

With VPC Lattice (H), requests were spread across every running task. Orange blocks appear as new tasks join, blue blocks disappear as old tasks stop, and from 120 seconds the four new tasks get 25% each. In the 60 to 90 second window, all eight tasks, old and new, received about the same share. It was the same with keep-alive off, and Service Connect (D) also showed no difference between keep-alive on and off.
This matches how the services are documented. An NLB sends all packets of a TCP connection to one target for the life of the connection, and Cloud Map clients connect directly to the IP they resolved. An ALB terminates the client connection and opens its own connections to targets, and the Service Connect proxy and VPC Lattice balance per request.
How to choose
This section leaves the numbers to the previous one. It uses the trends from the results and the conditions that matter when you run these paths in production.
I leave out calling task IPs directly (A, B, F). A task gets a new IP every time it is replaced, and these paths did not follow that change at all. Unless you build something to rewrite the IPs yourself, they are not usable in production.
- If both the caller and the called service run on ECS and can share one namespace, use Service Connect (D). It needs no load balancer and no endpoint, and it has no extra charge. The proxy balances per request, so traffic spreads to new tasks even when connections are reused. On the other hand, it followed new tasks a little more slowly than the ALB and VPC Lattice, and the whole deployment took longer. The proxy of a stopping task returned 503s, so plan for the caller to retry. I could only see where those 503s likely came from after I turned on the access logs, so turn them on before you need them. Callers outside the namespace (anything outside ECS, or tasks without Service Connect) cannot call it by name.
- If callers outside ECS also need the service, or you want to expose it per service across VPCs or accounts with IAM authorization, use VPC Lattice (H). It was in the fastest group to follow new tasks, and keep-alive made no difference. In my earlier post it had the highest static latency of the paths. You pay an hourly charge per service plus charges for data and requests.
- Overlapping CIDRs, or a consumer that should see only an endpoint in its own VPC, is where PrivateLink with an NLB (G) fits. The networks stay unconnected. An NLB balances per connection, though, so a reused connection stayed on an old task until that task stopped and never spread to new tasks. Most HTTP clients reuse connections, so design for this. One option is to give connections a maximum lifetime on the client so they reconnect, but I did not measure that.
- If the VPCs are already connected and you want Layer 7 load balancing, use an internal ALB (E). It was in the fastest group with VPC Lattice, even with reused connections, because the ALB terminates them. Only rolling deployments with keep-alive on were slower, and I do not know why yet.
That leaves Cloud Map DNS (C), for when you want neither a load balancer nor an endpoint. It was the slowest to follow, and with reused connections it stayed on old tasks like the NLB. Its behavior depends on the DNS TTL and on client caching, so use it with care.
If you copy my templates for production, change the timers I shortened for measurement, such as the 10-second deregistration delay and the short health checks. Set them for your longest in-flight request. I did not measure the default values, so my results do not tell you how scale-in behaves with them.
If your VPCs are connected with Transit Gateway rather than Peering, I cannot say for sure, because I did not measure Cloud Map, Service Connect or the ALB over Transit Gateway. Two things I can say. The network layer alone did not move traffic to new tasks: with fixed IPs, the same VPC, Peering and Transit Gateway all behaved the same. And putting a PrivateLink endpoint in between did not clearly change how fast a path followed new tasks (G and G'). I expect Transit Gateway, which routes packets without an endpoint in between, to behave like Peering, but that is a guess.
Cost
On-demand prices in the Tokyo Region as of November 22, 2026. I checked them in the AWS Price List API price files, and Service Connect in the ECS documentation.
Service | Price |
|---|---|
Cloud Map (C) | 0.10 USD per registered resource per month + 1.00 USD per million discovery API calls; DNS-based discovery adds Route 53 hosted zone and query charges |
ECS Service Connect (D) | No additional charge, including the Cloud Map usage it creates; the proxy uses vCPU and memory from the task's allocation |
ALB (E) | 0.0243 USD per hour + 0.008 USD per LCU-hour |
Transit Gateway (F) | 0.07 USD per hour per VPC attachment + 0.02 USD per GB |
NLB (G, G') | 0.0243 USD per hour + 0.006 USD per NLCU-hour |
PrivateLink interface endpoint (G) | 0.014 USD per hour + 0.01 USD per GB |
VPC Lattice (H) | 0.0325 USD per hour per service + 0.0325 USD per GB + request charges |
I did not look up cross-AZ data transfer prices. Check the current pricing pages before you decide.
Wrapping up
The static latency in my earlier post did not show any of this. What I take from this measurement: if your clients reuse connections, decide how they reconnect before you choose a path. Behind an NLB or DNS, reused connections stayed on old tasks; through Service Connect, an ALB or VPC Lattice, they did not. I did not test any fix, such as limiting connection lifetime on the client, so I cannot tell you how well one works.
My numbers come from one Region, one client and three trials. If you run the code in your own account, with your own app or settings, I would like to know whether you see the same order and the same keep-alive behavior.
Next, I will stop instances on purpose and see how each path handles failures.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article