{"id":79257,"date":"2026-05-24T14:56:48","date_gmt":"2026-05-24T09:26:48","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=79257"},"modified":"2026-06-08T18:40:43","modified_gmt":"2026-06-08T13:10:43","slug":"ecs-service-discovery-vs-service-connect","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/ecs-service-discovery-vs-service-connect\/","title":{"rendered":"ECS Service Discovery VS Service Connect"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In early microservices architectures on AWS, communication between services relied on infrastructure components like load balancers. There was no native, built-in way for services to discover each other dynamically.<\/p>\n<p>A common architecture looked like this:<\/p>\n<pre>Public DNS \u2192 Amazon Application Load Balancer \u2192 Frontend Service \u2192 Private ALB \u2192 Backend Service<\/pre>\n<div id=\"attachment_79252\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-79252\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-79252\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1-1024x490.png\" alt=\"Service Connectivity Flow - Old Way\" width=\"625\" height=\"299\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1-1024x490.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1-300x143.png 300w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1-768x367.png 768w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1-624x298.png 624w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-1.png 1518w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-79252\" class=\"wp-caption-text\">Service-to-Service Communication<\/p><\/div>\n<p>While this approach worked, it introduced several practical challenges:<\/p>\n<ul>\n<li>Multiple hops between services increased the latency<\/li>\n<li>Higher operational overhead in managing multiple load balancers<\/li>\n<li>Increased cost due to additional ALBs<\/li>\n<li>Static configuration of endpoints (hardcoding or manual updates)<\/li>\n<li>Scaling complexity, since every new service required routing rules<\/li>\n<\/ul>\n<p>To improve external access and routing flexibility, teams often introduced an API Gateway layer using Amazon API Gateway:<\/p>\n<pre>Client \u2192 API Gateway \u2192 Services (via host\/path-based routing)<\/pre>\n<div id=\"attachment_79253\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-79253\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-79253\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-1024x468.png\" alt=\"Traffic Flow via API Gateway\" width=\"625\" height=\"286\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-1024x468.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-300x137.png 300w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-768x351.png 768w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-1536x702.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2-624x285.png 624w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-2.png 1996w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-79253\" class=\"wp-caption-text\">Service-to-Service Communication via API Gateway<\/p><\/div>\n<p>This helped centralise routing for incoming traffic, but internal service-to-service communication remained complex. Services still needed a way to:<\/p>\n<ul>\n<li>Discover each other dynamically<\/li>\n<li>Avoid hardcoded endpoints<\/li>\n<li>Scale without manual intervention<\/li>\n<\/ul>\n<p>This led to the evolution of native AWS solutions like ECS Service Discovery and later Service Connect, which simplify internal communication without requiring load balancers.<\/p>\n<hr \/>\n<h2>ECS Service to Service Communication: Without ELBs<\/h2>\n<p>Before these features, ECS services typically relied on:<\/p>\n<ul>\n<li>Internal load balancers<\/li>\n<li>Static DNS entries<\/li>\n<li>Environment variables with hardcoded service URLs<\/li>\n<\/ul>\n<p>These approaches worked but did not scale well in dynamic environments where tasks are frequently created and destroyed.<\/p>\n<p>To address this, AWS introduced two key approaches:<\/p>\n<ul>\n<li><strong>Service Discovery<\/strong> (Cloud Map-based DNS resolution)<\/li>\n<li><strong>Service Connect<\/strong> (proxy-based service communication abstraction)<br \/>\n<hr \/>\n<\/li>\n<\/ul>\n<h3>Service Discovery<\/h3>\n<p>Service Discovery is built on AWS Cloud Map and integrates with Amazon Route 53 to enable services to find each other using DNS names rather than static IP addresses.<\/p>\n<p>Here is how it works:<\/p>\n<ol>\n<li>When an ECS service starts, it registers itself with Cloud Map<\/li>\n<li>Cloud Map maintains a registry of running tasks (IP + port)<\/li>\n<li>A DNS record is created\/updated in Route 53<\/li>\n<li>Other services resolve the DNS name to get the IP address<\/li>\n<li>Requests are sent directly to the resolved endpoint<\/li>\n<\/ol>\n<p>Example:<\/p>\n<pre>backend.service.local \u2192 10.0.2.45<\/pre>\n<p>A frontend service can call:<\/p>\n<pre>http:\/\/backend.service.local:8080<\/pre>\n<div id=\"attachment_79255\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-79255\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-79255\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-1024x668.png\" alt=\"Service Discovery Flow\" width=\"625\" height=\"408\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-1024x668.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-300x196.png 300w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-768x501.png 768w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-1536x1002.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4-624x407.png 624w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-4.png 1822w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-79255\" class=\"wp-caption-text\">Service Discovery Working<\/p><\/div>\n<p><strong>Key Concepts:<\/strong><\/p>\n<ul>\n<li><strong>Namespace<\/strong>: A logical grouping of services under a domain (e.g., service.local)<\/li>\n<li><strong>Service Registry<\/strong>: Keeps track of healthy tasks and their endpoints<\/li>\n<li><strong>DNS Records<\/strong>: Automatically managed records that map service names to IP addresses<\/li>\n<\/ul>\n<p><strong>What is CloudMap Namespace?<\/strong><\/p>\n<ul>\n<li>It is a Private Registry for MicroServices.<\/li>\n<li>If we define a namespace in a microservice, it is registered in the CloudMap.<\/li>\n<li>The DNS is created like this: <strong>&lt;discovery name&gt;.&lt;namespace&gt;<\/strong><\/li>\n<li>There are two types of Namespaces\n<ol>\n<li><strong>API Only<\/strong> (No R53 record is created, and the application code manages the DNS routing) &#8211; <strong>Hard to Manage<\/strong><\/li>\n<li><strong>API + DNS<\/strong> (This creates an R53 entry, and the services use this DNS to communicate internally\/externally) &#8211; <strong>Easy to Manage<\/strong><\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<div id=\"attachment_79254\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-79254\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-79254\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-1024x179.png\" alt=\"CloudMap Namespace\" width=\"625\" height=\"109\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-1024x179.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-300x53.png 300w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-768x134.png 768w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-1536x269.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-2048x359.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-3-624x109.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-79254\" class=\"wp-caption-text\">Types of CloudMap Namespaces<\/p><\/div>\n<hr \/>\n<h3>Service Connect<\/h3>\n<p>Service Connect is a more advanced and managed approach that builds on top of Service Discovery but introduces a service mesh-like experience without requiring complex setup.<\/p>\n<p>It uses a sidecar proxy (based on Envoy) inside each ECS task to manage communication between services <strong>(No need for the R53 records to manage DNS)<\/strong>. Inside the container <strong>\/etc\/hosts file<\/strong>, the IP and the SC endpoint mapping are auto-populated by the SC Envoy.<\/p>\n<p>Here is how it works:<\/p>\n<ol>\n<li>Each task runs a sidecar proxy container<\/li>\n<li>Applications communicate with services using logical names<\/li>\n<li>The proxy handles:\n<ul>\n<li>Service discovery<\/li>\n<li>Load balancing<\/li>\n<li>Retries and timeouts<\/li>\n<li>Traffic routing<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Example:<\/p>\n<pre>http:\/\/backend:8080<\/pre>\n<p>No need to manage DNS records or endpoints manually.<\/p>\n<div id=\"attachment_79256\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-79256\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-79256\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-1024x604.png\" alt=\"Service Connect\" width=\"625\" height=\"369\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-1024x604.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-300x177.png 300w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-768x453.png 768w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-1536x907.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5-624x368.png 624w, \/blog\/wp-ttn-blog\/uploads\/2026\/03\/ECS-Blog-5.png 1928w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-79256\" class=\"wp-caption-text\">Service Connect Flow<\/p><\/div>\n<p><strong>Key Concepts:<\/strong><\/p>\n<ul>\n<li>Transparent service-to-service communication<\/li>\n<li>Built-in load balancing across tasks<\/li>\n<li>Automatic retries and failure handling<\/li>\n<li>Centralised traffic management via proxy<\/li>\n<li>Better observability (metrics, logs, tracing)<\/li>\n<\/ul>\n<p><strong>Working Summary:<\/strong><\/p>\n<ol>\n<li>The application sends a request to the local proxy<\/li>\n<li>Proxy resolves the service name internally<\/li>\n<li>Proxy routes the request to a healthy task<\/li>\n<li>Handles failures and retries automatically<\/li>\n<\/ol>\n<hr \/>\n<h2>Service Discovery Pros &amp; Cons<\/h2>\n<p><strong>Pros:<\/strong><\/p>\n<ul>\n<li>Simple architecture [name \u2192 DNS \u2192 IP \u2192 direct TCP\/HTTP connection].<\/li>\n<li>No sidecar container.<\/li>\n<li>Works well with any DNS\u2011capable client (Lambda, EC2, on\u2011prem, scripts).<\/li>\n<li>Supports blue\/green and other patterns that depend on DNS\/Cloud Map records.\u200b<\/li>\n<\/ul>\n<p><strong>Cons:<\/strong><\/p>\n<ul>\n<li>Failover speed depends on DNS TTL and client caching. Some clients keep using dead IPs for a while.<\/li>\n<li>Client libraries must handle retries, timeouts, and load balancing themselves.\u200b<\/li>\n<li>Limited built\u2011in observability. Only Route 53 metrics and app\u2011level logs.<\/li>\n<\/ul>\n<hr \/>\n<h2>Service Connect Pros and Cons<\/h2>\n<p><strong>Pros:<\/strong><\/p>\n<ul>\n<li>Faster failover when a task dies, as Envoy maintains live endpoint lists instead of relying on DNS TTL.\u200b<\/li>\n<li>Built\u2011in traffic features: retries, connection draining, and cross\u2011VPC service communication using logical names.\u200b<\/li>\n<li>Better observability: ECS console shows service graph and real\u2011time network metrics; Envoy emits detailed logs and latency stats.\u200b<\/li>\n<li>Simplified naming (short logical names with client aliases)<\/li>\n<\/ul>\n<p><strong>Cons:<\/strong><\/p>\n<ul>\n<li>Extra resource cost: an Envoy sidecar per task increases CPU and memory usage.\u200b<\/li>\n<li>SC\u2011style names are really for SC\u2011enabled ECS tasks. External or legacy clients still need DNS\/Cloud Map or a load balancer in front.\u200b<\/li>\n<\/ul>\n<hr \/>\n<h2>Conclusion<\/h2>\n<p>ECS service-to-service communication has evolved significantly from traditional load balancer-based architectures to more dynamic and scalable approaches.<\/p>\n<ul>\n<li>Service Discovery provides a DNS-based mechanism that allows services to locate each other without hardcoding endpoints. It is simple, cost-effective, and suitable for less complex systems.<\/li>\n<li>Service Connect takes this further by introducing a proxy-based architecture that abstracts networking complexities and provides built-in load balancing, retries, and observability.<\/li>\n<\/ul>\n<p>For modern microservices on ECS, Service Connect is often the preferred choice due to its operational simplicity and production-grade features. However, Service Discovery remains relevant for simpler use cases or when fine-grained control is required.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In early microservices architectures on AWS, communication between services relied on infrastructure components like load balancers. There was no native, built-in way for services to discover each other dynamically. A common architecture looked like this: Public DNS \u2192 Amazon Application Load Balancer \u2192 Frontend Service \u2192 Private ALB \u2192 Backend Service While this approach [&hellip;]<\/p>\n","protected":false},"author":1644,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[2348],"tags":[248,1892,3688],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/79257"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1644"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=79257"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/79257\/revisions"}],"predecessor-version":[{"id":79870,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/79257\/revisions\/79870"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=79257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=79257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=79257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}