{"id":46999,"date":"2024-08-21T11:40:30","date_gmt":"2024-08-21T11:40:30","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=46999"},"modified":"2024-08-21T13:07:20","modified_gmt":"2024-08-21T13:07:20","slug":"aws-tutorials-finops-aws-elb-cost-optimization-strategies","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-finops-aws-elb-cost-optimization-strategies\/","title":{"rendered":"AWS Tutorials: FinOps \u2013 AWS ELB Cost optimization strategies"},"content":{"rendered":"\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Strategy<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Applicable ELB Types<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Use the Right Type of ELB<\/strong><\/td><td>Choose the appropriate load balancer type (ALB, NLB, CLB) based on traffic type and application needs.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Right-Size Your Load Balancer<\/strong><\/td><td>Use smaller instance types and pair with Autoscaling groups to avoid overprovisioning.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Enable Cross-Zone Load Balancing<\/strong><\/td><td>Distribute traffic evenly across Availability Zones to reduce instance size or number.<\/td><td>ALB, NLB<\/td><\/tr><tr><td><strong>Reduce Idle ELBs<\/strong><\/td><td>Identify and remove unused ELBs, or consolidate low-traffic ELBs into one.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Optimize Listener Configurations<\/strong><\/td><td>Reduce the number of listeners and rules; use HTTP\/2 to improve performance with fewer connections.<\/td><td>ALB<\/td><\/tr><tr><td><strong>Monitor and Analyze ELB Usage<\/strong><\/td><td>Use AWS Cost Explorer and CloudWatch to track usage and identify inefficiencies.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Use AWS Savings Plans or Reserved Instances<\/strong><\/td><td>Commit to Savings Plans or Reserved Instances for consistent workloads to reduce costs.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Leverage Spot Instances<\/strong><\/td><td>Use Spot Instances with your ELB for significant cost savings if your application can tolerate interruptions.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Optimize Traffic Routing<\/strong><\/td><td>Use geolocation routing with Route 53 or offload static content to a CDN like CloudFront.<\/td><td>ALB, NLB, CLB<\/td><\/tr><tr><td><strong>Review Data Transfer Costs<\/strong><\/td><td>Minimize inter-AZ data transfer to reduce additional charges.<\/td><td>ALB, NLB, CLB<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This table summarizes cost optimization strategies for AWS Elastic Load Balancers, including the applicable types for each strategy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Unused AWS Elastic Load Balancers (ELBs) created by Kubernetes cluster,<\/h2>\n\n\n\n<p>To locate and clean up unused AWS Elastic Load Balancers (ELBs) created by your Kubernetes cluster, you can follow these steps:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Identify Unused ELBs \u2022 Check Kubernetes Annotations:<\/h3>\n\n\n\n<p><br>\u2022 Kubernetes typically creates ELBs based on service annotations. You can identify which ELBs are associated with Kubernetes services by inspecting the annotations or tags that Kubernetes applies to the ELBs.<br>\u2022 Use AWS CLI to List ELBs:<br>\u2022 List all ELBs in your AWS account:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">#List all ELBs in your AWS account:<\/span>\naws elb describe-load-balancers --query <span class=\"hljs-string\">'LoadBalancerDescriptions&#91;*].&#91;LoadBalancerName,CreatedTime,DNSName]'<\/span> --output table\n\n<span class=\"hljs-comment\"># For ALBs and NLBs, use:<\/span>\naws elbv2 describe-load-balancers --query <span class=\"hljs-string\">'LoadBalancers&#91;*].&#91;LoadBalancerName,CreatedTime,DNSName]'<\/span> --output table<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Check Traffic Metrics:<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">\u2022   Use Amazon CloudWatch to monitor traffic and requests to each ELB. ELBs <span class=\"hljs-keyword\">with<\/span> zero or minimal traffic over a significant period might be unused.\n\u2022   Check metrics like RequestCount, HealthyHostCount, and UnHealthyHostCount.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To differentiate between real traffic and traffic generated by health checks on an Elastic Load Balancer (ELB), you can follow these steps:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Understand the Metrics<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">\u2022   RequestCount: This metric shows the total number <span class=\"hljs-keyword\">of<\/span> requests handled by the ELB. By <span class=\"hljs-keyword\">default<\/span>, it includes both real traffic and health check requests.\n\u2022   HealthyHostCount and UnHealthyHostCount: These metrics show the number <span class=\"hljs-keyword\">of<\/span> healthy or unhealthy instances behind the ELB, but they don\u2019t directly reflect user traffic.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">To find out the real traffic for each type of Load Balancer in AWS (Classic, Network, and Application)<\/h2>\n\n\n\n<p>To find out the real traffic for each type of Load Balancer in AWS (Classic, Network, and Application), you can refer to specific metrics in CloudWatch. Here\u2019s a breakdown of the key metrics to monitor real traffic for each type of Load Balancer:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Classic Load Balancer (CLB) \u2022 RequestCount: The total number of requests handled by the load balancer. This metric includes all incoming requests, which is useful for understanding the volume of traffic.<br>\u2022 HealthyHostCount: The number of healthy instances registered with the load balancer.<br>\u2022 UnHealthyHostCount: The number of unhealthy instances registered with the load balancer.<br>\u2022 Latency: The time taken for the load balancer to respond to a request. This can help gauge the load and performance of the load balancer.<br>\u2022 HTTPCode_Backend_2XX: The number of 2xx response codes from the backend, indicating successful requests.<br>\u2022 HTTPCode_Backend_4XX: The number of 4xx response codes from the backend, indicating client errors.<br>\u2022 HTTPCode_Backend_5XX: The number of 5xx response codes from the backend, indicating server errors.<br>\u2022 BackendConnectionErrors: The number of connections that were not successfully established between the load balancer and the backend instances.<\/li>\n\n\n\n<li>Network Load Balancer (NLB) \u2022 ActiveFlowCount: The total number of active TCP\/UDP flows (or connections) processed by the load balancer. This metric gives you an idea of the number of ongoing connections.<br>\u2022 NewFlowCount: The number of new connections established by the load balancer per second.<br>\u2022 ProcessedBytes: The total number of bytes processed by the load balancer, including both incoming and outgoing traffic. This metric can be used to estimate the volume of traffic.<br>\u2022 HealthyHostCount: The number of healthy targets (backend instances) for each load balancer target group.<br>\u2022 UnHealthyHostCount: The number of unhealthy targets (backend instances) for each load balancer target group.<br>\u2022 TCP_Client_Reset_Count: The number of reset (RST) packets sent from a client to a target. High numbers may indicate issues with traffic handling.<br>\u2022 TCP_Target_Reset_Count: The number of reset (RST) packets sent from a target to a client. It can indicate potential problems with target health.<\/li>\n\n\n\n<li>Application Load Balancer (ALB) \u2022 RequestCount: The number of requests processed by the load balancer. This metric provides an overall view of the traffic hitting the ALB.<br>\u2022 TargetResponseTime: The average time taken for a target to respond to a request. This helps in understanding the performance of the targets.<br>\u2022 HTTPCode_Target_2XX_Count: The number of 2xx response codes from targets, indicating successful requests.<br>\u2022 HTTPCode_Target_3XX_Count: The number of 3xx response codes from targets, indicating redirects.<br>\u2022 HTTPCode_Target_4XX_Count: The number of 4xx response codes from targets, indicating client errors.<br>\u2022 HTTPCode_Target_5XX_Count: The number of 5xx response codes from targets, indicating server errors.<br>\u2022 TargetConnectionErrorCount: The number of connections that were not successfully established between the load balancer and the target.<br>\u2022 ConsumedLCUs: Load Balancer Capacity Units (LCUs) consumed by the ALB, which helps in understanding the resource utilization and cost associated with the ALB.<\/li>\n<\/ol>\n\n\n\n<p>Key Considerations for Real Traffic Analysis:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">\u2022   Filtering Health Check Traffic: When analyzing RequestCount <span class=\"hljs-keyword\">and<\/span> similar metrics, remember that they might <span class=\"hljs-keyword\">include<\/span> health check traffic. To focus only on real user traffic, consider filtering out requests to known health check endpoints <span class=\"hljs-keyword\">or<\/span> <span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">application<\/span>-<span class=\"hljs-title\">level<\/span> <span class=\"hljs-title\">logs<\/span> <span class=\"hljs-title\">to<\/span> <span class=\"hljs-title\">differentiate<\/span> <span class=\"hljs-title\">between<\/span> <span class=\"hljs-title\">real<\/span> <span class=\"hljs-title\">and<\/span> <span class=\"hljs-title\">health<\/span> <span class=\"hljs-title\">check<\/span> <span class=\"hljs-title\">traffic<\/span>.\n\u2022   <span class=\"hljs-title\">HealthyHostCount<\/span> <span class=\"hljs-title\">and<\/span> <span class=\"hljs-title\">UnHealthyHostCount<\/span>: <span class=\"hljs-title\">These<\/span> <span class=\"hljs-title\">metrics<\/span> <span class=\"hljs-title\">are<\/span> <span class=\"hljs-title\">crucial<\/span> <span class=\"hljs-title\">to<\/span> <span class=\"hljs-title\">understanding<\/span> <span class=\"hljs-title\">the<\/span> <span class=\"hljs-title\">state<\/span> <span class=\"hljs-title\">of<\/span> <span class=\"hljs-title\">the<\/span> <span class=\"hljs-title\">backend<\/span> <span class=\"hljs-title\">targets<\/span> <span class=\"hljs-title\">and<\/span> <span class=\"hljs-title\">ensuring<\/span> <span class=\"hljs-title\">that<\/span> <span class=\"hljs-title\">your<\/span> <span class=\"hljs-title\">load<\/span> <span class=\"hljs-title\">balancer<\/span> <span class=\"hljs-title\">is<\/span> <span class=\"hljs-title\">distributing<\/span> <span class=\"hljs-title\">traffic<\/span> <span class=\"hljs-title\">effectively<\/span>.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<script src=\"https:\/\/gist.github.com\/rajeshkumarin\/299af54093f85d3beca1dab2b6bd65b1.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Strategy Description Applicable ELB Types Use the Right Type of ELB Choose the appropriate load balancer type (ALB, NLB, CLB) based on traffic type and application needs. ALB, NLB, CLB Right-Size Your Load Balancer Use smaller instance types and pair with Autoscaling groups to avoid overprovisioning. ALB, NLB, CLB Enable Cross-Zone Load Balancing Distribute traffic&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-46999","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=46999"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46999\/revisions"}],"predecessor-version":[{"id":47002,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46999\/revisions\/47002"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=46999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=46999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=46999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}