Skip to content

Field Notes

ECS Service Connect vs Cloud Map Service Discovery

A practical decision matrix for ECS Service Connect, Cloud Map DNS discovery, namespaces, aliases, ports and migration constraints.

EmailLinkedIn
On this page

Environment covered: AWS ECS services using awsvpc networking, Cloud Map namespaces and Service Connect aliases

Cloud Map and ECS Service Connect are not simply two ways to spell a service name. Direct discovery leaves endpoint selection and reconnection with the client; Service Connect adds an ECS-managed proxy path for participating services.

Choose from the consumer inventory and failure behavior. An ECS frontend, a maintenance job outside Service Connect and a long-lived streaming client may need different access paths to the same API.

This comparison draws on architecture and deployment experience. The example services, rollout and IAM failure are hypothetical; no measured migration result is claimed.

Consumer requirements set the boundary

Consider an ECS frontend calling an API, with a separate maintenance job also needing the API. The frontend is an obvious candidate for ECS Service Connect. The maintenance job may be outside that participation model and need an ordinary, network-reachable endpoint.

Cloud Map is a registry and discovery building block. Depending on the namespace and integration, a client can obtain records through DNS or a discovery API and then connect to an endpoint itself. DNS resolution, routing and service authorization remain separate concerns.

Service Connect provides an ECS-managed proxy path and service aliases for participating ECS services, using Cloud Map resources for discovery. An arbitrary process does not gain that path merely because it can resolve a name in the same VPC. Inventory consumers before choosing a convenient alias for the main application.

Follow the connection, not only the lookup

Cloud Map direct discovery path compared with the Service Connect managed proxy pathCloud MapClient applicationDNS or service registrylookupTask IPand portApplicationService ConnectClient applicationLocal managedproxyDestinationproxyApplication
Cloud Map returns an address that the client uses directly; Service Connect places managed proxies in the application traffic path.

With direct discovery, the client receives an address and owns how long it caches that answer, which endpoint it selects and how it reconnects. In the Service Connect path, participating tasks use managed proxies. The proxy changes endpoint selection and observability, while application deadlines and the meaning of a retry still belong to the application.

The simplified architecture below retains both paths because they answer different consumer requirements. The maintenance caller must not be forgotten when the ECS frontend’s configuration changes.

Decision Direct Cloud Map discovery ECS Service Connect
Where connection behavior lives Client or its library Managed proxy plus application contract
Important rollout observation DNS caching and connection lifetime Proxy endpoint awareness and resources
Caller boundary Network-reachable DNS/API consumers as configured ECS services configured to participate
Cost to plan in a task Application discovery behavior Application plus proxy CPU and memory

Neither choice creates missing network routes or opens the required security-group path. Nor does discovery replace authentication and authorization at the destination. A maintenance client outside the VPC needs a reviewed network path and a usable discovery mechanism; a private name alone provides neither. For a simple client with stable requirements, a proxy can add operational cost without solving a problem the client actually has.

Verify the named port against the application listener

For an ECS server using Service Connect, the service configuration refers to a named port mapping. That name, the actual application listener and the service’s configuration must agree.

{
  "name": "api",
  "containerPort": 8080,
  "protocol": "tcp",
  "appProtocol": "http"
}

This is an illustrative portMappings entry, not a complete task definition. Its numbers and name are synthetic. Changing a container image does not guarantee that the process inside it still listens where the task definition says it does.

A deployment can therefore fail in several distinct ways: tasks never start, a proxy is configured against the wrong port name, a connection is blocked, or the application responds too slowly. “The alias does not work” is a symptom that should be divided into those stages.

Separate launch permissions from discovery behavior

In the hypothetical rollout, replacement tasks cannot retrieve a required launch-time resource. The older tasks remain available, so an occasional successful request makes it look like an intermittent discovery fault.

Read the ECS service events and stopped-task reason before changing DNS or application retries. Distinguish the task execution role, which supports agent-side launch operations such as image pulls and configured secret retrieval, from the task role used by application code to call AWS APIs. Service-linked and optional infrastructure roles cover other service operations; they are not interchangeable escape hatches.

aws ecs describe-services \
  --cluster "$CLUSTER" --services "$SERVICE" \
  --query 'services[0].{deployments:deployments,events:events[0:5]}'

Run this only in the relevant authorized environment, with identifiers supplied by its owner. The example intentionally contains no account, cluster or role identifiers.

The repair in this teaching scenario is the narrowly scoped permission required by the failing launch operation, not broad application-role access. Resource policies and encryption-key permissions can also participate in the decision. A useful error investigation identifies the exact denied action, identity and resource before proposing a policy.

Compare replacement behavior and runtime cost

Once tasks can start, discovery still needs a deployment test. A one-time connection to a healthy task does not show what happens when that task drains.

For direct discovery, observe the client’s actual DNS and connection caches; do not infer them from the advertised TTL alone. For Service Connect, observe both proxy and application behavior during endpoint replacement. Long-lived connections, streaming and non-idempotent requests deserve their own checks.

Budget for the proxy before comparing steady-state memory or rollout capacity. A service that fits its task limit without a proxy may not fit with one, and a rolling deployment can require old and new capacity simultaneously. Use current AWS sizing guidance as a starting point, then measure the workload rather than presenting the guide’s minimum as a capacity guarantee.

Migrate one dependency boundary at a time

Keep the old discovery configuration available while validating a small client-provider pair. Verify normal requests, task replacement, unavailable destinations and rollback. Then expand by dependency group rather than changing every caller in one release.

Mixed consumers can justify both patterns: ECS application traffic uses Service Connect while another approved consumer retains a direct discovery route. Document which name and health assumptions belong to each path. Avoid two similarly named endpoints whose ownership and behavior are allowed to drift.

Regional recovery adds another boundary. Discovery resources and task capacity are not a substitute for a database role change, secrets, storage access or application validation in a secondary region. The retained regional-recovery case makes the same architectural point: routing success is only one recovery gate.

Record the decision for each caller

Choose direct discovery when broad consumers or explicit endpoint control matter. Choose Service Connect when the participating ECS services benefit from its proxy path enough to justify the runtime and operational cost. Use both when the consumer inventory requires both, not because a diagram looks more complete with another box.

For each caller, record the endpoint contract, owner, network and authorization requirements, timeout/retry behavior and evidence from task replacement. If a consumer cannot participate in Service Connect, specify its supported access path explicitly; sharing a namespace does not make it a Service Connect client.

Sources and further investigation

References support the protocol and product behavior discussed here; they are not evidence that the illustrative scenario occurred.

Continue the investigation

Need a second set of eyes?

Working through a similar production issue?

Discuss the technical context