<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eugene White on Medium]]></title>
        <description><![CDATA[Stories by Eugene White on Medium]]></description>
        <link>https://medium.com/@eugenewhitie?source=rss-d6744a40ab91------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qDTvxI-YE0whYMOW</url>
            <title>Stories by Eugene White on Medium</title>
            <link>https://medium.com/@eugenewhitie?source=rss-d6744a40ab91------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:23:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eugenewhitie/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part Three — HTTP Request Based Routing (ALB only)]]></title>
            <link>https://medium.com/slalom-build/part-three-http-request-based-routing-alb-only-14143c9e52e6?source=rss-d6744a40ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/14143c9e52e6</guid>
            <category><![CDATA[elastic-load-balancer]]></category>
            <category><![CDATA[application-load-balancer]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[aws-load-balancing]]></category>
            <category><![CDATA[network-load-balancer]]></category>
            <dc:creator><![CDATA[Eugene White]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 12:50:25 GMT</pubDate>
            <atom:updated>2025-12-23T00:11:38.396Z</atom:updated>
            <content:encoded><![CDATA[<h3>Compare and Troubleshoot ALBs and NLBs in AWS</h3><h4>Part Three — HTTP Request Based Routing (ALB only) and Overall Comparison</h4><p>In this series of blog posts, I first examined ALB and NLB performance differences in <a href="https://medium.com/@eugenewhitie/84ef8ab2ac41">Part 1</a>. Then I explored how each ELB works in <a href="https://medium.com/@eugenewhitie/1bbb865e12dd">Part 2</a>. In this series’ third and final blog post, I will cover a key advantage of using ALB. Let’s look at how ALB can direct traffic at layer 7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACUuCkjepKBhi2I9RPzHpw.png" /></figure><p>In the ALB console, you can see several different routing conditions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*A-tevKsZKadnglfCi8LoUQ.png" /></figure><p>We’re going to now check out each of these conditions experimentally. I have set up the same ALB from <a href="https://medium.com/@eugenewhitie/84ef8ab2ac41">Post 1</a> and <a href="https://medium.com/@eugenewhitie/1bbb865e12dd">Post 2</a> of the series, but this time with two target groups, each with one target in it. This one target group will be our default or catch-all target group. The other will be a test for our condition rule.</p><h3>Host Header Based Routing</h3><p>We’re going to turn our attention to how a host header, and its close relative, the HTTP header, work.</p><p>When we run an HTTP request using curl, a web browser, or any other tool, an HTTP host header (and often other headers) is always included. Here’s a request to <a href="http://google.com/">http://google.com</a> below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6uhZpRvduns5PbLJhYTVdg.png" /></figure><p>You can see that curl includes a header with a key of “Host.”</p><p>Examining at this interaction from a packet perspective, you see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q56SXi7YIRbmbpmi6xW9Gg.png" /></figure><p>The TCP three-way handshake is completed with the server. Then an HTTP GET request is sent. The host header (and others) are included in the GET request in packet number 4. Headers are not exclusive to GET requests and apply to other HTTP verbs such as PUT, PATCH, <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">etc</a>.</p><p>Bringing this back to my ALB, I set one host header rule to match for “<a href="http://my-website.com/">my-website.com</a>” and direct this traffic to Target Group 2. My default rule directs traffic to Target Group 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bixt28hdhiwh4fxsVmWuLg.png" /></figure><p>When I run a default curl request to the ALB, it specifies its own hostname in the host header;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_YHOGBTARlx04cn2P1Fag.png" /></figure><p>To test if my condition is working, I sent a request to the ALB with the host header of “Host:my-website.com”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPx1opVr7gfG3Fe9nPdGZg.png" /></figure><p>This time the request went through to Target Group 2 as our host header condition matched.</p><p>If I try with any other host header, I’m directed to my default target group as per this request with a host header of “not-my-website.com”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2Af1ie0SkpjpPEelrgq3g.png" /></figure><p>Host headers do not effect the DNS query of the local device. Their primary function is to separate out different domain names so you can host multiple services, like websites, behind a single ALB.</p><h3>HTTP Header Based Routing</h3><p>HTTP header-based routing is closely related to host header routing. We can include any header we want in an HTTP header. I’m going to show you another curl so you can see how I define the custom header:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TnHbRgnvcWgQnm_DU2IhbA.png" /></figure><p>Here’s a packet capture of the above curl:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6fqDNkQVfsYX__IWpsi2g.png" /></figure><p>As seen previously, there is always the TCP three-way handshake with the remote server, and then the HTTP GET request. In this GET request, notice that there are three standard headers and the one I defined myself, “my-custom-header:alpha”.</p><p>To test how this works in an ALB, I created three target groups and directed traffic as per below:</p><pre>Default http headers      → Default Target group<br>&quot;User-Group:alpha&quot; header → Target Group 1<br>&quot;User-Group:beta&quot; header  → Target Group 2</pre><p>You can see more of my ALB header-based routing setup and testing results in this short video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJE9co_NFgCA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJE9co_NFgCA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJE9co_NFgCA%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3d46fd35802a03e44a2054fb02cc8b9/href">https://medium.com/media/f3d46fd35802a03e44a2054fb02cc8b9/href</a></iframe><p>Check out how I specified the headers in the curl requests and how the ALB conditions directed each request to the specific target groups.</p><h3>Path Based Routing</h3><p>Moving on, we’ll now examine how to define a path in a request to Google and what this looks like at a packet level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwP62R56sBScRX09PHOE7g.png" /></figure><p>The packet capture of the above exchange looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e0RfxDLbMV36rVwJA46ing.png" /></figure><p>To test how my ALB distributed requests with different paths, I modified my previously defined ALB header rules to instead distribute based on the following paths:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGlAncV8Y7ZHNt4KdW95Zg.png" /></figure><p>Here’s a video that demonstrates how to run a variety of path-based requests and how to test which target group the requests are routed to.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FrzqEqg8VRQ8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrzqEqg8VRQ8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FrzqEqg8VRQ8%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/72e0c5cebb5f1a22be71dfbc28518498/href">https://medium.com/media/72e0c5cebb5f1a22be71dfbc28518498/href</a></iframe><h3>Routing by HTTP Method, Query String, and Source IP</h3><p>In the video below, I’ve added a few more rules to my ALB to show you how to create requests that hit each rule.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8MxS7otLAkA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8MxS7otLAkA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8MxS7otLAkA%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7f211fa5205a1a34ed5191ef58d5915/href">https://medium.com/media/a7f211fa5205a1a34ed5191ef58d5915/href</a></iframe><p>Notice exactly where the request method and the query are located in the HTTP request. If I send a dummy request to Google,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdUuJRatsjwOMWn7Lt7EwQ.png" /></figure><p>and look in my packet capture of this interaction,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbviDZ3v_YXl_GaGxIUEGg.png" /></figure><p>you can see above precisely what the ALB is routing traffic based on. This application layer distribution ability is only offered by ALB. If HTTP distribution was required for your application, ALB would be your choice over NLB.</p><h3>What Can’t the NLB See?</h3><p>NLBs can only see up to layer 4, transmission control protocol. So they cannot route traffic based on any of the ALB filters discussed above.</p><p>We can see this if we examine the same packet from above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqQVEYfeuibcQ31PkGsqDw.png" /></figure><h3>Overall Comparison (TLDR)</h3><p>Based on the testing I’ve done in this series of blog posts, here’s how I would summarize the advantages of each ELB flavor:</p><ul><li>NLB does not need to scale. ALB does, and it requires about three minutes to do so. This means for very spikey workloads where scaling extremely quickly is required, NLB may be a better choice. See <a href="https://medium.com/@eugenewhitie/1bbb865e12dd">Part 2</a> of this series for more detail.</li><li>Due to ALB scaling, the ALB requires IP changes. Whereas NLB can, theoretically, retain the same IPs for its lifetime. If you require stable IPs for your use case, NLB may be a better choice. See <a href="https://medium.com/@eugenewhitie/1bbb865e12dd">Part 2</a> of this series for more detail.</li><li>ALB can route traffic to backend targets based on various HTTP application layer properties. Where this is required, ALB may be a better choice (covered earlier in this post).</li><li>If you have a client/server that is sending large GET/PUT data streams, NLB may be your better choice. See <a href="https://medium.com/@eugenewhitie/84ef8ab2ac41">Part 1</a> of this series for more on this.</li><li>ALB can only listen on HTTP(/s) protocol. If your application is using another protocol, you will need to use an NLB to pass through to your backends.</li><li>Due to WAF (Web Application Firewall) operating in the application layer, it is not supported by NLB. You can attach your ALB to a WAF for security. ALB would be your choice if you have a hard requirement for WAF security.</li></ul><h3>Conclusion</h3><p>I hope the information we have been through in this blog post series has helped you compare the two most common AWS ELB types. I have spent many hours as an ELB user and with customers trouble shooting specific aspects of their operations. With the visuals I’ve included in each of the examples above, you are not only better equipped to pick which best suits your use case, but to troubleshoot some of the common issues you might come across. Happy Load Balancing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14143c9e52e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/slalom-build/part-three-http-request-based-routing-alb-only-14143c9e52e6">Part Three — HTTP Request Based Routing (ALB only)</a> was originally published in <a href="https://medium.com/slalom-build">Slalom Build</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part Two — Scaling and Load Distribution]]></title>
            <link>https://medium.com/slalom-build/part-two-scaling-and-load-distribution-1bbb865e12dd?source=rss-d6744a40ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bbb865e12dd</guid>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[application-load-balancer]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[network-load-balancer]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Eugene White]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 14:19:02 GMT</pubDate>
            <atom:updated>2025-12-22T23:16:50.821Z</atom:updated>
            <content:encoded><![CDATA[<h3>Compare and Troubleshoot ALBs and NLBs in AWS</h3><h4>Part Two — Scaling and Load Distribution</h4><p>In my <a href="https://medium.com/@eugenewhitie/84ef8ab2ac41">first blog post</a> in this series, we established there are some key performance differences between ALBs and NLBs. This blog post will give you a sense of what conditions these are most obvious under.</p><p>To fully understand the differences between an ALB and an NLB, let’s look at how each ELB type scales to reach client demand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCMoe5DJ9Zsr-zQkCcRV4w.png" /></figure><h3>ALB Scaling</h3><p>The first layer of ALB load distribution is internet initiated requests. These requests are initiated with DNS, and the DNS responses correspond directly to ALB infrastructure. I will use DNS in this example to present how applied load scales an ALB.</p><p>I will start with an ALB enabled across three AZs with two instances in a single target group. If I look at the initial DNS record created for my ALB, I see two IPs returned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*1Ak_Na83jLNOE5eze3BiOA.png" /></figure><p>If I take a packet capture (PCAP) on one of the targets I have set up behind the ALB, I see traffic being initiated from two private IPs to my target port (80 in this case). My target IP is 172.31.16.119.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*gdOFRPQz_II12SbRb4PeUQ.png" /></figure><p>Note that I have filtered traffic so we only see the initial TCP SYN packets and the source IPs above are from two different subnets, 172.31.0.0/20 and 172.31.16.0/20.</p><p>From this data we can tell certain pieces of information:</p><ul><li>The ALB has two public-facing nodes.</li><li>The targets are receiving health checks/traffic from each of those nodes i.e. We have hub-n-spoke communication between the nodes and targets where the nodes are the hubs and traffic can travel cross-AZ.</li><li>As the target receives traffic from the node’s private IP, the ALB must maintain two TCP connections for each inbound request, one for the client side and one for the target side.</li></ul><p>Representing this using a diagram, we see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JtZ197NdhQPVvbuh-iE8oQ.png" /></figure><p>Let’s apply some load to our ALB nodes and monitor what our public-facing nodes are doing simultaneously by observing their DNS records. To monitor the DNS I will watch the ALB DNS record every two seconds. This is done using a simple two second loop of our dig command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*1Ak_Na83jLNOE5eze3BiOA.png" /></figure><p>I have a web server running on the targets at directory /data, so I hit both ALB IPs on that directory with Siege load tester.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*RjOiSM0jPTChA0zdW-nz9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*YgQZXeOD6WJRFVYRMOxTOQ.png" /></figure><p>Within three minutes, the DNS record set changes:</p><pre>Sat 24 Sep 2022 12:52:12 AEST<br>3.105.180.157<br>52.62.190.237<br>Sat 24 Sep 2022 12:52:14 AEST<br>54.206.182.191<br>54.66.208.166</pre><p>At this point, I turn off Siege. And approximately twelve hours after that, I can see the record changes back to the original IPs:</p><pre>Sun Sep 25 2022 01:26:18 AEST<br>52.62.190.237<br>3.105.180.157</pre><h3>What are the nodes?</h3><p>You may be able to guess that the ALB nodes are, in fact, simply AWS managed ec2 instances. They are managed by the ELB service and run a reverse proxy software, likely a customized open source software.</p><h3>How does the ALB handle increased demand from clients?</h3><p>What we are observing in the first IP set change at T=3 minutes is a scale up event. The ALB nodes are a special type of Auto Scaling Group (ASG) that can scale out instances or scale up to larger instance types.</p><p>All ALBs are created with small instance types, so the initial nodes with IPs 3.105.180.157 and 52.62.190.237 could have been a T-2 or T-3 instance types. After the load was applied, the new nodes with IPs 54.206.182.191 and 54.66.208.166 would have been larger. We don’t have visibility to tell what these types were, but for argument’s sake, let’s say they were an M type, and if we applied more load, this would scale up to multiples of higher-end instance types. The scale up does not have to happen step-by-step; it can scale straight to its highest instance type if necessary. The ALB algorithm will make a judgement based on traffic metrics and scale straight to that point.</p><p>Note how quickly the scale up event happened. Within three minutes new nodes were created, and DNS was updated to reflect this. Compare this to how slowly the scale down event occurred. The old IPs were substituted back into DNS after twelve hours. AWS promotes a sensitive scale up time, and an insensitive scale down time.</p><p>If you believe this scale up time is not going to be fast enough for an anticipated event, there is a manual request AWS customers can put through called an ALB pre-warm, whereby AWS will scale up your ALB before a certain time. This usually isn’t necessary as ALBs can go from zero to fully scaled out to multiple high-end instance types within five minutes.</p><h3>What happens to long running client TCP sessions to the old nodes?</h3><p>Old nodes are gracefully shifted away from by taking them out of the ALB DNS record and waiting until their active TCP sessions drop to zero. Looking at the Siege load testing I showed you above, the old ALB node IPs were eventually shifted back onto. This implies the old nodes still had some connections on them even though they did not appear in the DNS record for some time. This process is known as “connection draining,” and it has a very long timeout (hours) before nodes are forcefully retired and TCP connections terminated.</p><h3>NLB Scaling</h3><p>Let’s contrast the above ALB scaling with that of an NLB. I have brought up an NLB with two backend targets across two AZs. This gives me two returned IPs in its DNS record:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xubyeTOJDD1_2pijgvz3OA.png" /></figure><p>If I apply the same load to the NLB IPs as I did the ALB, should I expect the same scaling to take place?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*iJ8jpEATb3bQ62re6y5q2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*sHyzIr19ttovk42dqsufRA.png" /></figure><p>After 5 minutes of running the Siege load test, here’s the results:</p><pre>Sun Sep 25 05:18:59 UTC 2022<br>13.238.180.178<br>54.252.197.84<br>Sun Sep 25 05:19:01 UTC 2022<br>54.252.197.84<br>13.238.180.178<br>....<br>....<br>Sun Sep 25 05:25:29 UTC 2022<br>54.252.197.84<br>13.238.180.178</pre><p>Note the DNS record IPs do not change. Does this mean there was no scaling? Not exactly. The NLB operates very differently.</p><p>Let’s take a PCAP on a target sitting behind the NLB. Looking only at health check (HC) traffic, we see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*S0XhgHNvGDmJgFXbFccdsg.png" /></figure><p>The HCs are coming only from a single IP, 172.31.10.32. The target is 172.31.14.12. This indicates the HCs are coming from the same AZ as they are both a part of subnet 172.31.0.0/20.</p><p>If I run a curl to both NLB IPs, I can see I am directed to targets in different AZs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*w1QrRO58duUL3WlgPSTimg.png" /></figure><p>And this AZ separation is consistent across multiple curls. When I run multiple requests to 13.238.180.178, I always get sent to SERVER2, and vice-versa with 54.252.297.84 to SERVER1.</p><p>When I PCAP that curl from one of my instances, this is what I saw:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*_Sc8UEsXz6K-w5sgMFcIMw.png" /></figure><p>The IP address of my source box is preserved. We have visibility of the public IP that I sourced my curl from. Essentially what has been achieved here is destination-based NATTing. The destination IP has changed from the NLB public IP to the target private IP.</p><p>Summarizing the results above, we can see:</p><ul><li>NLB does not scale up instances as an ALB does when put under load.</li><li>Health checks come from an IP in the local subnet to the target (default <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html#cross-zone-load-balancing">cross-zone</a> NLB setting).</li><li>Client requests have their source IP addresses preserved (default <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html#client-ip-preservation">client-ip-preservation</a> setting).</li></ul><h3>What is happening under the hood?</h3><p>The NLB technology operates with some key features that AWS customers do not have direct access to.</p><p>Represented as a diagram, the behaviors we examined above would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySKfYmqrm2V8Ssu6TZnuTg.png" /></figure><p>The two private IPs in this visual, 172.31.10.32 and 172.31.26.79 came from the HC PCAP I used earlier. I also took one on the other target to get 172.31.26.79.</p><p>What is invisible to us as customers is a distributed device whose job is to take incoming traffic directed to an IP:port tuple and distribute it out to any target instance in its AZ and target group.</p><p>As this device technology is proprietary, it can be said that it is highly redundant, fault tolerant, can detect failures fast, will self heal and is brought up singularly per AZ.</p><p>The devices operate on customer traffic only at the TCP layer. The TCP connection between client and target is carried all the way through (thus the preserved client IP). This is very different from an ALB, which does terminate the TCP connection at its nodes before distributing out connections.</p><p>In terms of scaling, the devices representing 172.31.10.32 and 172.31.26.79 are already scaled up to the equivalent of very high-end instance types in an ALB scenario. These devices are not dedicated to a single customer as they are in the case of an ALB. They are shared across many customers, with each customer getting assigned a set of public IP addresses which are translated through the same devices to other private IPs in their VPC. So there’s no need to scale up an NLB!</p><h3>Load Distribution Comparison</h3><p>To demonstrate a key difference in how the two ELB flavors distribute load, let’s run an experiment looking at how each distributes TCP connections and HTTP requests.</p><h3>ALB distribution</h3><p>I’m using the same setup for my ALB as per my first blog post in this series. I have two targets in a single target group sitting behind it. Let’s run some segregated TCP requests to an ALB node using curl and some pipelined HTTP requests to that node using nc:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3M7r2Gk1xFk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3M7r2Gk1xFk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3M7r2Gk1xFk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d50edba7903f41719b4abcdb4ab3abb2/href">https://medium.com/media/d50edba7903f41719b4abcdb4ab3abb2/href</a></iframe><p>We can confirm that an ALB node will distribute inbound connections across targets equally. This was clear in the demo above because I was the only client calling that node. If you have hundreds of clients calling a node, like within a production environment, you may have several requests from your client in a row that are directed to the same target. This is because other clients may have been directed to other targets in between your requests. This is why we sometimes see two SERVER1’s in a row or two SERVER2’s in a row when running segregated curl requests.</p><p>When we pipelined all HTTP requests through a single TCP connection, it oscillated between the two SERVERs evenly because it knew where it sent the last request for that TCP connection.</p><h3>NLB Distribution</h3><p>Let’s run the same experiment on an NLB. I have the exact same setup as above, except to use an NLB. It is also slightly different from the original (default NLB setting) setup I had in that I have allowed <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html#cross-zone-load-balancing">cross-zone load-balancing</a>. I made this adjustment because my backend servers are in different AZs and we want to see if/how the server load distribution is done.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fem63J_HEjjw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dem63J_HEjjw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fem63J_HEjjw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f529fcbe05fc2aadfbe32b3a03243191/href">https://medium.com/media/f529fcbe05fc2aadfbe32b3a03243191/href</a></iframe><p>As we can see in the above demo, one of the main differences between NLBs and ALBs is that NLBs do not terminate the TCP connection between the client and the backend target. This means that they do not have the ability to distribute HTTP connections (i.e., at layer 7). They can only distribute at the TCP layer (i.e., layer 4). All HTTP requests are completely transparent to the NLB.</p><p>TCP distribution vs. application layer distribution is not a disadvantage/advantage of either ELB, but there may be requirements on how you want requests distributed to your compute layer which would make one preferable over the other. For example, if you require HTTP request granularity, then ALB would be your choice. If you only require TCP distribution, then NLB may be your preference.</p><p>In my <a href="https://medium.com/slalom-build/compare-and-troubleshoot-albs-and-nlbs-in-aws-84ef8ab2ac41">first blog post</a> in this series, we looked at ALB and NLB performance characteristics. This post took a deeper look at the mechanics of each ELB type. In the next post in this series, we’ll examine some of the key abilities ALB has, that NLB does not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bbb865e12dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/slalom-build/part-two-scaling-and-load-distribution-1bbb865e12dd">Part Two — Scaling and Load Distribution</a> was originally published in <a href="https://medium.com/slalom-build">Slalom Build</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compare and Troubleshoot ALBs and NLBs in AWS]]></title>
            <link>https://medium.com/slalom-build/compare-and-troubleshoot-albs-and-nlbs-in-aws-84ef8ab2ac41?source=rss-d6744a40ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/84ef8ab2ac41</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[network-load-balancer]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[application-load-balancer]]></category>
            <dc:creator><![CDATA[Eugene White]]></dc:creator>
            <pubDate>Mon, 31 Jul 2023 20:16:38 GMT</pubDate>
            <atom:updated>2023-08-21T12:51:10.961Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part One— ALB vs. NLB Performance Comparison</h4><p>Does selecting a load balancer keep you up at night? How do you know which flavor of AWS Load Balancer suite is best for your specific use case? In this series of blog posts, I’ll discuss the architecture of the two most commonly used ELBs, the Application Load Balancer (ALB) and the Network Load Balancer (NLB). Understanding the differences between ALB and NLB will help you select which one is best for your needs and troubleshoot and design solutions for your customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O8delFFYoubE7QWwB4x6tQ.png" /></figure><p>I will break this comparison down across three blog posts:</p><ul><li>Part One — ALB vs. NLB Performance Comparison</li><li><a href="https://medium.com/slalom-build/part-two-scaling-and-load-distribution-1bbb865e12dd?source=friends_link&amp;sk=83438e7c94812c619ea46f857bfe4f26">Part Two — Scaling &amp; Load Distribution</a></li><li><a href="https://medium.com/@eugenewhitie/14143c9e52e6?source=friends_link&amp;sk=07a6188d28f5bdf91c37dff87fb40bb9">Part Three — HTTP Request-Based Routing (ALB Only)and Overall Comparison (TLDR)</a></li></ul><p>In this blog post, we’ll look at performance differences between the two load balancers using practical examples with videos so you can see firsthand how to run tests and capture data.</p><p>First, let’s examine what ELBs are and why we need them. Load balancers have been used in traditional on-prem environments to distribute requests from clients, often on the public internet, to servers in the service provider’s private network. Their primary function is to ensure TCP sessions or layer 7 requests are evenly distributed to internal servers. Also, a load balancer can stop sending requests to servers if it detects the server is unhealthy, helping to make the user experience seamless. This same functionality is required by AWS to distribute requests across various services such as EC2 instances, ECS clusters, EKS clusters, and Lambda functions.</p><p>Just as your server capacity may need to expand and contract based on user demand, your ELB will need to do the same. AWS’s management of your ELB enables them to handle this “low value” scaling task while your developers stay focused on your application code.</p><h3>Part One— ALB vs. NLB Performance Comparison</h3><p>To gain a broad understanding of what each ELB can do in terms of performance, let’s run some simple performance tests on each one.</p><h3>TCP Testing</h3><p>I ran 50,000 curl requests to each ELB using a well-known curl performance script:</p><pre>cat curl_script.txt<br>    time_namelookup:  %{time_namelookup}s\n<br>       time_connect:  %{time_connect}s\n<br>    time_appconnect:  %{time_appconnect}s\n<br>   time_pretransfer:  %{time_pretransfer}s\n<br>      time_redirect:  %{time_redirect}s\n<br> time_starttransfer:  %{time_starttransfer}s\n<br>                    ----------\n<br>         time_total:  %{time_total}s\n</pre><p>This script gives a variety of information, but in our case, the important part is the time_total. You can see it can be used for testing dns (time_namelookup), tcp connection time (time_connect), ssl negotiation (time_appconnect), redirect, and download times.</p><p>The client I used was another EC2 instance in the same region, so I expected a generally low latency. For the ALB, I got these results (all units are ms):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*HHfpzizBvVy6xC2S5tF81A.png" /></figure><p>Here are the results obtained from the NLB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*A0wePAJTp7ejMoFGxbutzw.png" /></figure><p>You can see that the NLB testing is more than four times faster, and its results are more reliable than the ALB; there’s a tighter standard deviation.</p><h3>Pipelined requests testing</h3><p>Testing where each request is pipelined into a single TCP connection is also essential. You can see an example of how request pipelining is done in the video I’ve linked to <a href="https://www.youtube.com/watch?v=hAgi7NiTwpQ">here</a>.</p><p>In the below testing, fifty thousand requests were pipelined through a connection. This testing is much faster than the above TCP testing. Each output below is the result of running all 50,000 requests.</p><p>For the ALB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*qztwPdqpM6XsFSSl7ijdRw.png" /></figure><p>For the NLB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*igXEjZpV4thNVLCW7eu7Hw.png" /></figure><p>Here you can see the results shown above are much faster than running a new TCP connection per request. But these tests were done with very little response data from the server. I also ran some tests where the server responded with approximately 50KB per request.</p><p>Here are the results for the ALB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*Eypf5133OurLHcofVYohjw.png" /></figure><p>And for the NLB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*wPQA2H15R8KcZiXEdqq5ew.png" /></figure><p>We can see the results were very different this time. Why is the ALB so much slower in this case? The reason is due to the extra operations an ALB node must carry out. It must terminate an incoming TCP session, bring the payload data into memory, potentially route traffic based on this payload, then do a read operation in sending the data to its target. This write/read is not done in the case of the NLB. We can view the NLB as operating at the TCP layer only; it is essentially only rewriting IP-TCP headers.</p><p>The results above show the performance improvement that can be gained by using NLB, especially if your client/servers are doing large GET/PUT operations.</p><p>Are you ready to dive deeper into the architecture of each ELB? In <a href="https://medium.com/slalom-build/part-two-scaling-and-load-distribution-1bbb865e12dd?source=friends_link&amp;sk=83438e7c94812c619ea46f857bfe4f26">my next post</a> you’ll discover how the inherent operations of each ELB give rise to their performance differences whilst examining some of the abilities that an ALB has over an NLB and how those additional abilities can impact performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84ef8ab2ac41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/slalom-build/compare-and-troubleshoot-albs-and-nlbs-in-aws-84ef8ab2ac41">Compare and Troubleshoot ALBs and NLBs in AWS</a> was originally published in <a href="https://medium.com/slalom-build">Slalom Build</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>