{"id":651,"date":"2021-11-11T12:22:07","date_gmt":"2021-11-11T12:22:07","guid":{"rendered":"http:\/\/18.141.20.153\/?p=651"},"modified":"2023-04-28T06:16:03","modified_gmt":"2023-04-28T06:16:03","slug":"how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/","title":{"rendered":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)?"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p><strong><img src=\"https:\/\/lh6.googleusercontent.com\/cDVy79FOKOTmxvzcrAXjVDI5_O7FPiu64sRTXvyv6viImqfXBNDv3AMWKrQMNzdci28ReX5KQ-FDJ0zWw9YV4kroIZGoMo9YD3GhE2j3IVjU3OgNi1ixXrkMaEdRXbB6HTFck_7G\" style=\"width: 1600px;\"><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">A Spot Instance is a virtual machine that runs on spare EC2 capacity that is offered at a lower price than the On-Demand price. Spot Instances allow you to request unused EC2 instances at great discounts, allowing you to dramatically reduce your Amazon EC2 expenditures. A Spot Instance&#8217;s hourly pricing is known as a Spot price. Amazon EC2 sets the Spot pricing for each instance type in each Availability Zone, which is modified over time depending on long-term supply and demand for Spot Instances.&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Your Spot Instance will run whenever capacity becomes available and your request&#8217;s maximum price per hour exceeds the Spot pricing. If you can be flexible about when your applications run and if your applications may be interrupted, Spot Instances are a cost-effective option. When spare capacity is no longer available, EC2 Spot Instances can be halted with a two-minute notification.&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Spare capacity on <a href=\"https:\/\/aws.amazon.com\/ec2\/spot\/\" target=\"_blank\" rel=\"noreferrer noopener\">Amazon EC2 Spot Instances<\/a> is offered at substantial savings compared to the EC2 On-Demand pricing, generally between 70% and 90% off. Amazon EC2 Auto Scaling enables the formation of Amazon EC2 Auto Scaling groups (ASGs), which will maintain, scale up, or scale down the number of instances required based on scaling policies that are set based on the application&#8217;s demands.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we will see how to create a stateless, fault-tolerant workload using Amazon EC2 Auto Scaling with launch templates to request Amazon EC2 Spot Instances.<\/p>\n\n\n\n<p>Refer to part 1 of the blog <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-run-fault-tolerant-workloads-for-up-to-90-off-using-amazon-ec2-spot-instances\/\">here<\/a>.<\/p>\n\n\n\n<h2>Amazon EC2 Spot Instances &#8211; Recap<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/iiWH0fLE_KD_GJfkDnnky0kvstmUAFWz2YB8xsQncb_Q79U_Ms0m6ggfN605yne3VmyKOWtOB2MjmianbgeV_a0A_-oNnT_stOYq81Hpe85fbziXiyRvEo-WAaKe3NMt2dQ4tNA0\" alt=\"Amazon EC2 Spot Instances\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Amazon EC2 Spot Instances take advantage of unused AWS EC2 capacity. When compared to On-Demand rates, Spot Instances offer up to a 90% reduction. Spot Instances can be used for a variety of stateless, fault-tolerant, or flexible applications, including large data, containerized workloads, <a href=\"https:\/\/www.workfall.com\/learning\/blog\/aws-developer-tools-to-build-ci-cd-pipeline\/\">CI\/CD<\/a>, web servers, HPC, and test &amp; development workloads. One can select how to launch and maintain your Spot Instances-based applications because Spot Instances are intimately connected with AWS services such as Auto Scaling, EMR, <a href=\"https:\/\/www.workfall.com\/learning\/blog\/create-and-run-web-app-on-ecs-using-aws-fargate\/\">ECS<\/a>, <a href=\"https:\/\/www.workfall.com\/learning\/blog\/deploy-aws-resources-with-ease-using-amazon-cloudformation-templates\/\">CloudFormation<\/a>, <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-create-ci-cd-workflow-using-aws-codestar\/\">Data Pipeline<\/a>, and <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-easily-replicate-existing-s3-objects-using-s3-batch-replication\/\">AWS Batch<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">To further optimize workload cost and performance, Spot Instances can be easily paired with On-Demand, RIs, and Savings Plans Instances. Spot Instances can provide the size and cost reductions needed to run hyper-scale applications. When EC2 reclaims capacity, you have the choice to hibernate, pause, or terminate your Spot Instances with two minutes&#8217; notice.<\/p>\n\n\n\n<h2>Hands-on<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/o-ipmVB87XMBxyV-e02giWBt5Gr1feMv6B7yXFsFgZODvolQ85Rmq7Ol0il_WaFYP0JmiE3PHifI73qbRftdYq0Rub6gl0v_3h3WvzoyQb69PiWV0MB4G4hgJ7NmNso6KiVguPxQ\" alt=\"Amazon EC2 Spot Instances\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">In this hands-on, we will see how we can make use of Amazon EC2 Auto Scaling with launch templates, AWS Application Load Balancer, and Amazon EC2 Spot instances to create a stateless, fault-tolerant workload requesting for Spot Instances on termination of a few instances. When spare capacity is no longer available, EC2 Spot Instances can be halted with a two-minute notification. Applications that use EC2 Spot Instances must be stateless, fault-tolerant, and loosely linked. Ephemeral instances should be able to be readily changed and removed as needed.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">The following hands-on will be accomplished by creating an AWS Application Load Balancer and using it in concert with Amazon EC2 Auto Scaling to add and remove spot instances as needed. The hands-on will also use launch templates and the capacity-optimized allocation strategy which will automatically provision EC2 Spot Instances from the most-available Spot Instance pools by analyzing capacity metrics. We will not be transmitting any sensitive data during this implementation. Load balancing will distribute HTTP requests to the fleet of Amazon EC2 Spot Instances that you will create later in the hand. This hands-on makes use of the VPC of our AWS account. You can use your own VPC if your account doesn&#8217;t have a default VPC. If you use your own VPC, the AWS Application Load Balancer you create must be configured to use public subnets, and the EC2 instances must be either in the same public subnets as the AWS Application Load Balancer, with public IP addresses assigned automatically, or in private subnets with a NAT Gateway configured to allow outbound internet access. To maximize the number of Spot capacity pools accessible to Amazon EC2 Auto Scaling, it is also suggested that your VPC has a subnet mapped to each Availability Zone of the AWS region you are operating in.<\/p>\n\n\n\n<p>To implement this, we will do the following:<\/p>\n\n\n\n<ul><li>Login to your AWS console and navigate to the dashboard.<\/li><li>Navigate to the Load Balancer configuration page in the EC2 dashboard.<\/li><li>Create a new Application Load Balancer following the steps in the blog.<\/li><li>Navigate to the Security Group dashboard and create a new Security group.<\/li><li>Navigate to the Target Group dashboard and create a new Target Group to be attached to the Load Balancer and the Auto Scaling group.<\/li><li>Navigate to the Auto Scaling configuration page to create a new Auto Scaling group.<\/li><li>Create a new Launch template to be attached to the newly created Auto Scaling group.<\/li><li>Add a set of commands in the User Data that is to be executed on all instances on first time creation, select an AMI and a primary instance for the launch template.<\/li><li>Make the configuration changes for the Auto Scaling group following the steps in the blog.<\/li><li>Review all the settings and create an Auto Scaling group.<\/li><li>Traverse through the Auto Scaling group dashboard and look at the history for the newly created spot instances.<\/li><li>Manage your spot instances under the Instance Management tab.<\/li><li>Navigate to the EC2 dashboard and test the creation of Spot Instances on demand by the Auto Scaling group by terminating a few instances on the EC2 dashboard.<\/li><li>Navigate back to the Activity History to have a look at the Spot Instance termination and Creation logs.<\/li><\/ul>\n\n\n\n<p>Log in to the AWS console and navigate to the dashboard.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Ti4hqSW9j_H9bd-6pQjjnj3pgqbpe1QihZM9F7IfI9J5fAjlrjYquK7716bf6ofZJD7-hDXDGONJQdSFgpw2ZZo4ASpu8Ztw60IBFN5JhsvVHvamHqsXqqEM1t_cYB7z-dM7THrs\" alt=\"\"\/><\/figure>\n\n\n\n<p>Search for Load Balancer and open the service by clicking on it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/PKW3IGzaXzT-79Diy7EKBB5kXWAlc3CkPWiHXi_Hr9AJXCIOH3LfBGtGs0YLaWSiZrk7MbxPd6O_2WPP1IKkEY8up0TP_IPgOBMBjP02Gy8bU3QwTfZMdSnDksztxaWZYrgAZO8E\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Click on Create Load Balancer.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/lh6.googleusercontent.com\/sQKC1icLjmVMOxMWQrZIb7leiNaO8l7G0Tk68fCT_MC0REP3Nr0lgc0810FlfNhDBIRC6cR6QBdNW5PsTR2g5ypwvqLcb6x_D8wOfSGUC2evwhvoqv6p85Wj9Bp5W7PqUEnYXk92\" alt=\"Spot Instances\" width=\"840\" height=\"472\"\/><\/figure>\n\n\n\n<p>Click on Create under the Application Load Balancer.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/N8AOHwQUe36o7Hf42Bmprmz04soY4yu6yp_pLrFBj5WaNzgrQrl7vBVcgbTNiELpwxlmD1NO4_P3llNylNxhv_BfZorNIL7jlLnGgCNx5Bv5Wy59xY9OLqI1_Hul_m0EFtOpzDsK\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>You can check out the working of the Application load balancer by expanding the modal.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/K4MXyNiXwVhmldKW4R3uNBVXKklWEX_JjFV8eGtuQ50SXK9_0lcYES-bTthf8QMU60Nhx4zejwD0I_sHkuDIdtza9nZJDoYcO5n4ATBkprw9IfyOYFOEEHdXD9bbYxOm-6mxj7na\" alt=\"\"\/><\/figure>\n\n\n\n<p>Enter a name for the load balancer and select the other options as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/ahLKDD5Rm8LK5X0vOuzNgX3K2VOyNXO2OtqIfSAeR38gcGTH4LC4GffgwPBAsxZQ42_5gwPc1M9TLFTyNWjuj9WtJ0bisA8CPyiNU0bEoJ2jy3IosaHi89lHuzVyFI-Sp5njU0Du\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Select a VPC from the dropdown and select both the regions along with the corresponding subnets inside the region.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/XKZWT_8FhOeLVd3kEqFEuMeKmvmqo0p9vNvrpJbtNl0SzK66SIHB_MBwrfjeuKlJDfz79YUh0U0vGoZmUeV14yME7g9oQfGL2jaApoTSoWnotrbujKoc1v8Oo7iRTnct7LDzmEi8\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Click on Create new security group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/QYE7CS6N2Q4GTmGR6CDPtQCB2wTurmyuqzwMg7gHLGp4s78BAnvEZnw0y_JUc2elaczxzeDpReceD7WAaExcGIobyCv9c2mp2-3XwMS7-M9viGOcENq4Vzk_Q71GEMRMqi5bpRrS\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Enter a name and a description for the security group and select the VPC from the dropdown. In the inbound rule, add a new rule and allow TCP on Port 80 with the source shown below. You can change the source as per your requirements.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ScMstDvPZ-xRQXAM6FCiH4wRZBDM82CAchy7Rvz99K83BDOq-V-9YO3uz7mei7Kz5V1m4kWT5yjWXlq-WRbrudFtOFNhD6Y8_E78XhHOU2nvrRDgMGWSB18tN8XHwVMiS4jCwpvj\" alt=\"\"\/><\/figure>\n\n\n\n<p>Leave the outbound rule as default and click on Create security group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/SxFQRWqo0rIRfZYjP321QIHQV6mUByDkWaJXU2W8DeEebc2rO7i1lxUi8xwfyzgfK0iTP5GVDxAONAE-UhHUmX3M39khvuT2Arm07QsJEHJYbjWDED2dlypzmYUY3t-wZJcOsVTS\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>On success, you will see the message as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ugC10PdeEwBAmbMScMj3Stqc7JGW4Fs1Pe4XWgXo-nCbanVQMVVXHaW_3l27r191jrcK4wKtkEfj8SUmke5Yw-Ah-VRnl2bPmgZpi-ThftScytV75xDe1qT7n7C7m54xWtk4e9_I\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Navigate back to the Load Balancer dashboard. Hit refresh and select the newly created Security group. Click on Create target group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/YhuS-dv3TlXi8tnEeeVbKT9R2V_6T0-lqTRAO8ktsZh1X7oKyV9tHTAaghwyjoggcN8MoWHUQRVttOVf74Iuo6HBWUG9WOh-VfTHCnVtm47ziKrwjefmAfd2zBf-1JprCVzuMW9P\" alt=\"\"\/><\/figure>\n\n\n\n<p>Select Instances for a target type.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Ow6DyJrdpSzejMFrfFK4H7pTr_ZDWWjCpaDOuSfTe5goJ2DO-9R-gbq1AMYw5NRxwIRgQSWUtI5AykMRnFjipUMtI7zy_cublULejjkqwn3yYqzKENLoBUUPurk1KI3zo6W4Wm43\" alt=\"\"\/><\/figure>\n\n\n\n<p>Enter a target group name and select the other options as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/ajsQEMYfd_i3FOBIidko2LQ2bWt2xTXk5gugA9UQ8D1dTjJ-WO-mJJIEiLEQ5aaFhME0n4yP6kMr3XIJX5BwagHME0EY0-iwz5kt_zXXC_-ZTW8ZmCSjihilh7eE0FLeqZhJ4McO\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Expand health check settings and choose the options as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/dcIG9W9O8RRad2A-A2-uk4xtxI-BaHDH6eRoOUuezAJ5RMKfbcdY-oORqM5_EA7PzYGcoilaSblrpmk7a4ZCrATJdnuKtO0zvACmNLe4YEXyFqIfL9sgArf2HfaR_90PAahMaoBU\" alt=\"\"\/><\/figure>\n\n\n\n<p>Scroll down making the changes for the configuration and click on Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/k3xaBO5GgEk0k4alQLsLM9OR_2sPdS1DaFELILXARCnYUGmRyE1LHmabyvENl_psJ_fcVcBn-P2KMMkLA0UAFpFslTTKyrid9C790s5zfuFtPa_RpWc220lBtJUGvW1eKrvrvKmi\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>In Step 2, keep the default settings and scroll down to the bottom.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/GC0pooGF1wXVY-kUBF4wdwwM26R-AYhQFVzV7Z6bmWyNQfCjNjJ64VN1qQw7D3yhyqg_-GI2K9ykLonjQ6f6dU05BvExdW1PSrR0Fk8nWniSToh40Wwh4ihjpAdVBibB_Htn5s4W\" alt=\"\"\/><\/figure>\n\n\n\n<p>Click on Create target group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Vo6FSMHYZ_oKHWcHL8_VCUvnzY5doiKyMyJlBiqkiVnFLZe6s5KhZeW6eiPfEFZQQhdB8_e-9x6VqxZuXJJBmGHnKFN03Mu2GTNANu9dqht3S8CyueIheSurXYjF4J8D06eiGhik\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the message as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/tCWgIyiUx3AJVDLFzeiAp9ZhvktbFJMCNR7gIocHX9gi60ioN4zrma9Cp6jrlwYu8zL__gRSB9lcr9sL2bdmDW5hYIpjf43Iw_1MyZq1L2oJZ0dmeOc-Z53SlUSsQAPlZl1_TNaS\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Navigate back to the Load Balancer configuration page, click on refresh and select the target group from the dropdown.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/jVA1K3beOW8mKijQ4OoBJGrUR9furILezbSqWKIFPhzxnUZ9X3CM77_OFAy9hCrwEwQPyWn8PZxpLYZa6-LyIS6ONMvfcQRMVdverFvNJaZgrooGD0uRn0Q_JSMqb0hR0kEvQ9fw\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Scroll down to the bottom and click on Create load balancer.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/Jpvo2zualNXUObj98U2jp6-pcSC7kNa1Vr3bzxuToxHO_dndMqYdqBEz20ao6TtxOBRLco5HlatoBQxWCtz9Ly6PUmfigtXAZrjcmJUIdsy5LKIvqxX2EgvtjeGGhmOJinvjeBZ2\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Once done, you will see the newly created load balancer. Now search for the AutoScaling group and navigate to the dashboard for the same and click on Create Auto Scaling group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/5fA_aWeW0DDB2BSlus5U777AM4xE1KGQKDKIvG_d2_gKhGwZR51ndgQPN9mH_bxJj6iI70pvBcxXbLBV6L_cZ4uWVSrSaPBbjjlKnt8lyEIJKJNy___ighYPA96OZ4e2drFo_7Ue\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Enter a name for the group. Click on Create a Launch template.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/JTigecz5ln48zJPNcih_pvjhafTfth25WUHBgUYp3iDO982RrenVODad_S6E7vCQFSTmAiHBMfZRMJN1TxgYc0KaLgtuiqVTPiYCgqdvFSRp9s6ozFy4h4SRVDsg1jGB-G-_myGZ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Enter a name for the Launch Template. Scroll down to the Network settings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/bZrfUHwb4NIM2qTyFGvbz_efFv5fNrxKxcRoRyfBL0stCT6O6hiPdbXZeUy-CD-LlTFetPQcyroG58JBOy562--sPUBEzChmzvueAfFkMWBaO73svaR5n5wIwiLwtbxCr98W39F2\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Select VPC and the security group that you created above.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/s21XoJnLDgMRM68xMh5B7nE1dTMlcz_Ki-_nDl2V9BQ0WFjvcTTna6ZnLUIk-8dXzlzxIzEymKnZXByI7-CLLExn0Oq5TvAbp87CmodWn9dTj-4WV-kvXSAI3PHA2vPS0n-3JidY\" alt=\"\"\/><\/figure>\n\n\n\n<p>Scroll down to the User data input box and add the following code in it.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\nyum install httpd -y\nsystemctl start httpd\nsystemctl stop firewalld\ncd \/var\/www\/html\necho &quot;this is my test site and the instance-id is &quot; &gt; index.html\ncurl http:\/\/169.254.169.254\/latest\/meta-data\/instance-id &gt;&gt; index.html\n<\/pre><\/div>\n\n\n<p>Once done, click on Create launch template.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/TEaL5p4FwFSQmXTdOBUYbAZNfUlrZZeh5B-YSgrNB4oXSjU__kHdZuEiTIAa1o60pgEa2OG6L-YOKpSIwe-J-Ar3Lya9ixfAt9u_ypQcKRCmk0eaIBZHiaFvlLacpGiEYPtaceNQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see a message as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/sFYBShqpobUfdjEbi3ZXFS_Q1faqJKq_2-eg62937kwSXnVEF8hIS1qLx8q2H70v1W04XhhaPF7qmJWg7JRonNGsr3SIOb4_mrYCXtJ7WAZ6_QqkbvIWHK-nIcPRQNQJjM_krTQs\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hit refresh and from the dropdown, select the newly created template.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/JTigecz5ln48zJPNcih_pvjhafTfth25WUHBgUYp3iDO982RrenVODad_S6E7vCQFSTmAiHBMfZRMJN1TxgYc0KaLgtuiqVTPiYCgqdvFSRp9s6ozFy4h4SRVDsg1jGB-G-_myGZ\" alt=\"\"\/><\/figure>\n\n\n\n<p>For the version, select Latest (1) from the dropdown. Click on Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/J9lwCiA83PljU0TGQefYw-MvVeljLB-JlJgxIQz7hxPpGgI7czFke8GAHKnMxUcpCH4MPJkArGP3S_4sUsRnkAj8eAV8QVUJWfwPHeE9ABKjFJCuZlqFUZksXPibnPGSfT-xYaE4\" alt=\"\"\/><\/figure>\n\n\n\n<p>Make the changes in Step 2 as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/UaxsbddsHq-NVL6aQpZiu3KdSyRgLL9nmG3EUok5RocOxGGjNIDgZcuQClxdCU_gOpLH0p9Ry2AE1Zb10-3cicQ3yG_fubH2rh8llBm-L5kNGtz1qX3fv3lqDIaY17Amt49jrcU0\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Under Instance Types, select a primary instance type.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/Pnj1zhnRItJbXoTKFQA7vOk30_BdSUAtI4qtBhpGVfJRC3Tu2TbDhUsH01SDdMUpH87kI1414BLRWZROxBd1HAbMUgQDJ347M7SmAb3t-AFuj7yCpwv9ShJZUqBlb3SeOCH8dCKx\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Under the Network section, select the VPC and all the subnets inside the VPC. Click on Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/zZLVbHQRHSVl3AOOfiF9T3hpF9N3NZqtbcIUiGO4B9SFUKznhWojNwWnYNPcHcsIFUJkCS6u6SXK9w7NTDXXjfpsJnHFUYGaRd9aBgoy__t-7imv_c5XCrnCi_7Hog6s2yQecXal\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">In the next step, select Attach to an existing load balancer and select the newly created target group from the dropdown.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/xmR5smQXV1TMAH6U55BH-_GLNnaZPxa5zpJu1G8PS4Z10crEpdxa6moWYnnhVGC6OSrDJhEpxykDZtoVnmGkwcE256GGEO3BFxR7NIpM85JBTt6Wc9YOQ28UM1FTcxTulcif8VWz\" alt=\"\"\/><\/figure>\n\n\n\n<p>Under Health checks, make the changes as shown in the image below and click on Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/DF_dcrfAvEz6sJW-lC6r80Hd9t4NiC-mARoHXKQHmsL3rPauqR-zFTlgDlO0BJ-JzRN0yLSzqaeLWsDKwgnwvoUQZ10muf5YmBk9m-Y4AvpjdTDt4JvfZu-4SsRi7Wk2-mKc74uX\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Change the group size configurations as per your requirements.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/vF_se3O6r1B-PwEhAYYfaWJO7_9srkBTiKaR4Qp5ycCw0r0PN3UZaqI_Yu1AnhxMMxyYj4ZmqY3sAK7QRub6bEn2EUK6Sq1NYz6X_D1y_9_TgBzV3YppljG8MWr0yEW3DETDQ0Mq\" alt=\"\"\/><\/figure>\n\n\n\n<p>For Scaling Policies, select Target tracking scaling policy and leave the other settings as it is.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/D60yworx1UvwNyuwcUzRjzEjLR0qG9p6myu9b2ReFfSkaI8w96G3UFURSvRyFA8YD-29FkuL2QJkE7xUzkU74z3k5GBtP5l3Boc5MEvGMMAKvxYzoKloXxB6Mbpk3xrfFSTdUdy5\" alt=\"\"\/><\/figure>\n\n\n\n<p>Scroll to the bottom and click on Skip to review.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/AB0RLex7aSz605dfrD1pdBQxAvZ1I9J1vbyMqpAt0V_0ANk2uI6td2rfrhEvDadQjtPFMqVsANfy5uD8po0RH97ySIsy3gD2H2vSPl2cHT4VMyRL68lm6uXeoTRv9a9NiNk7okDD\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Review all the configuration settings and scroll to the bottom and click on Create Auto Scaling group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/T_yaqJjN1O07F_mezVO7JN2wpriXNliiv9Ti_HmlexQypNBfrIWUmqj0gERtTz-rryWN3LnPhECMCYoQJm6VLp6hj5bJgHfpH4DuLllkOYaCyy501xPxOwN2pM5WUOr1b1CZlFOD\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">On success, you will see the message as shown in the image below. Click on the newly created AutoScalingGroup.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/-vI_taOh1O3yBhH-xmnAphv2hGYjtulBPGp68oiCQu8bFRmEKnMcQgpsxYbznkvtpAfpxSN6i1KbtswW-RVCj0iaP7whft8H8-77zl1UY7zBRK5BbKrtVMGQJV5m5oxLcj_zNIer\" alt=\"\"\/><\/figure>\n\n\n\n<p>You can view the details for the created group. Navigate to the Activity tab.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/yBQ_S3vDy9GSuFppl8r6GcW_OfPOwGXGTbyE6Ks8byUzHR7-K5StyMTZbcpzwH9hwjIwGcLFcDk-7ReOX9W3mwfNvQV0DdJ2ajqudXn8BoIYHal0GmC6VENbEHWFSvNpfXnX_zBt\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Under Activity History, you will see the instance creation history. Now these are the spot instances being created on demand.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/ZVYQgeXNnYP1_hTcTvlw0cHpeEFGhN3atdgbLatIhJkJRFbQNGRB47DmhIOOhFEe3fOenr2x4a4HhDtaCzNAz_Mgq7YUh4JLlO2GSnrOkC2KPPwYgGhX4JuNsGD9ZyG-LB_Ywsxl\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Navigate to the Instance Management tab and you will see all the instances being created. These instances are random and based on availability. Thus, they are called the Spot instances.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/erQKjTCrptm24Fz96Az4z22e7Fa-KuHU4Tu76dE4ctZgg3FdZJ1TT7bNjd3JJNvhjuUuaOIctBZeSLGtRGscXBihFYqnXXraIanc8uvfkzQOtznyVlnCWHYFOpSuUy5n8ahtqvOV\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p>Navigate to the EC2 instance dashboard and you will see the newly created spot instances.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/6w7zqtNndFaN5r7jpJjk5MH0esl12Ox76IgpOYLYXBGenLQHKpyumxAnF2In0wMb_0rasfwuTbqdwHsSEK9Mat7Uj-cA0zln5nbQCH9X1_RhHY02EKmJalkxteQ-HDdnMAKR0I8S\" alt=\"\"\/><\/figure>\n\n\n\n<p>Terminate a few of the newly created instances.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/SpRta5klRgbmbClnVS148xn8ykZZVzNgbwNcnju_weqmbV5EYFY-xUuWiWWcJyrqMTz6lQgOyE25jmQHn49yXRGw_D-qTcIHPMCtWZBCOKsfb8cEWxjafc3upVZSgKr_Bw1QB8hc\" alt=\"\"\/><\/figure>\n\n\n\n<p>The instances will start shutting down.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ZhnbpdY8-nCwA_pt7bLH6E46UgaxMZlERGxeilOL6Fddli5sXELqgDOAyMNs480evzNlRngqyTVArLd1AvrMFEnCOkiWhSN0_cSIUudI5hyoufiNwgaB8MqYEx1QtcmYM4ZtnboK\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Navigate back to the EC2 Auto Scaling group and under the Activity History, you will be able to see the recent activity as shown in the image below and new spot instances will be created to replace the terminated ones because of the Auto Scaling group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/zAzSt95dTbjAW6Oxn9jogc4GKWaOMCZ5uB00ukSdrrZxK4Cjo1Qh_tsCoyx9PH0qHOgwnb-7PQLivo9KbER5nXYRQPgZv9QfZHQmhEEznsnWTxJaLJrRm8Yw4C4Iw6Xpd-Lz8crf\" alt=\"Spot Instances\"\/><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we saw how we can make use of Amazon EC2 Auto Scaling with launch templates, AWS Application Load Balancer, and Amazon EC2 Spot instances to create a stateless, fault-tolerant workload requesting for Spot Instances on termination of a few instances. We created an AWS Application Load Balancer and used it in concert with Amazon EC2 Auto Scaling to add and remove spot instances as needed. We also used launch templates and the capacity-optimized allocation strategy to automatically provision EC2 Spot Instances from the most-available Spot Instance pools by analyzing capacity metrics. We will discuss more use cases for the services used in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.<\/p>\n\n\n\n<p>Meanwhile \u2026<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you\u2019re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at<a href=\"https:\/\/www.workfall.com\/partner\/\"> workfall.com\/partner<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> A Spot Instance is a virtual machine that runs on spare EC2 capacity that is offered at a lower price than the On-Demand price. Spot Instances allow you to request unused EC2 instances at great discounts, allowing you to dramatically reduce your Amazon EC2 expenditures. A Spot Instance&#8217;s hourly pricing is known as a Spot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":656,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[2],"tags":[222,3,4,11,205,13,62,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-11T12:22:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-28T06:16:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png\",\"width\":1200,\"height\":628,\"caption\":\"Launch EC2 Spot Instances - AWS\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage\",\"url\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/\",\"name\":\"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage\"},\"datePublished\":\"2021-11-11T12:22:07+00:00\",\"dateModified\":\"2023-04-28T06:16:03+00:00\",\"description\":\"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.\",\"breadcrumb\":{\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)?\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)?\",\"datePublished\":\"2021-11-11T12:22:07+00:00\",\"dateModified\":\"2023-04-28T06:16:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage\"},\"wordCount\":1830,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png\",\"keywords\":[\"autoscaling\",\"AWS\",\"Cloud\",\"ec2\",\"EC2 Spot Instances\",\"ec2instance\",\"Elastic Load Blancer\",\"workfall\"],\"articleSection\":[\"AWS Cloud Computing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog","description":"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/","og_locale":"en_US","og_type":"article","og_title":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog","og_description":"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.","og_url":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2021-11-11T12:22:07+00:00","article_modified_time":"2023-04-28T06:16:03+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png","width":1200,"height":628,"caption":"Launch EC2 Spot Instances - AWS"},{"@type":"WebPage","@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage","url":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/","name":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)? - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage"},"datePublished":"2021-11-11T12:22:07+00:00","dateModified":"2023-04-28T06:16:03+00:00","description":"Spot Instances are used for a variety of stateless, fault-tolerant, with large data, containerized workloads, CI\/CD etc.","breadcrumb":{"@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)?"}]},{"@type":"Article","@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#article","isPartOf":{"@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"How to launch EC2 Spot Instances using Amazon EC2 Auto Scaling and AWS Application Load Balancer (Part 2)?","datePublished":"2021-11-11T12:22:07+00:00","dateModified":"2023-04-28T06:16:03+00:00","mainEntityOfPage":{"@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#webpage"},"wordCount":1830,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/ec2-18-141-20-153.ap-southeast-1.compute.amazonaws.com\/learning\/blog\/how-to-launch-ec2-spot-instances-using-amazon-ec2-auto-scaling-and-aws-application-load-balancer-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png","keywords":["autoscaling","AWS","Cloud","ec2","EC2 Spot Instances","ec2instance","Elastic Load Blancer","workfall"],"articleSection":["AWS Cloud Computing"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-2-1.png","jetpack-related-posts":[{"id":621,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-run-fault-tolerant-workloads-for-up-to-90-off-using-amazon-ec2-spot-instances\/","url_meta":{"origin":651,"position":0},"title":"How to run fault-tolerant workloads for up to 90% off using Amazon EC2 Spot Instances?","date":"November 11, 2021","format":false,"excerpt":"Understanding cloud bills and how to get the most out of the budget on AWS is becoming increasingly important as enterprises migrate more applications and services to the cloud and a larger portion of IT budgets is diverted to cloud providers. With specialized tools, economic models, and best practices, AWS\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Cost Optimization with EC2 Spot Instances","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/spot.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":467,"url":"https:\/\/learning.workfall.com\/learning\/blog\/15-awsome-years-of-amazon-ec2-and-still-going-strong\/","url_meta":{"origin":651,"position":1},"title":"15 AWSome years of Amazon EC2 and still going strong!","date":"November 9, 2021","format":false,"excerpt":"This year marks the 15th anniversary of Amazon EC2(Amazon Elastic Compute Cloud), marking a landmark milestone for both the firm and the computing industry it serves. The EC2 instance is at the heart of the AWS cloud platform, allowing users to rent storage, network connectivity, and computation resources. It's difficult\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWSome 15 Years of Amazon EC2","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/ec2_15yrs.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":164,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-deploy-amazon-ec2-p4d-instances-in-ec2-ultraclusters-to-get-highest-performance-for-ml-training-and-hpc-in-the-cloud\/","url_meta":{"origin":651,"position":2},"title":"How to deploy Amazon EC2 P4d instances in EC2 UltraClusters to get highest performance for ML training and HPC in the Cloud?","date":"October 27, 2021","format":false,"excerpt":"Amazon EC2 P4d instances deliver the highest performance for machine learning (ML) training and high-performance computing (HPC) applications in the cloud. Amazon EC2 P4d instances are deployed in hyperscale clusters called EC2 UltraClusters that comprise the high-performance compute, networking, and storage in the cloud. Each EC2 UltraCluster of P4d instances\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"EC2 UltraClusters of P4d Instances","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/VPC.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":399,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-and-mount-an-amazon-efs-file-system-using-amazon-ec2-launch-instance-wizard\/","url_meta":{"origin":651,"position":3},"title":"How to create and mount an Amazon EFS file system using Amazon EC2 Launch Instance Wizard?","date":"November 3, 2021","format":false,"excerpt":"Sizing, configuring, and deploying AWS resources for third-party applications, such as SAP or SQL server is always challenging for you. Are you looking for a wizard who can help you with these challenging tasks?\u00a0 AWS Launch Wizard can help you in simplifying these tasks by offering a guided way of\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"How to create and mount an Amazon EFS file system using Amazon EC2 Launch Instance Wizard","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/Launch-Wizard.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":215,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","url_meta":{"origin":651,"position":4},"title":"How to install and run Docker Containers on Amazon EC2 Instance?","date":"October 27, 2021","format":false,"excerpt":"While running Docker on AWS, developers and admins can build, ship, and run highly reliable distributed applications at any scale.\u00a0\u00a0In this blog, we will demonstrate how to install, build and run docker containers on Amazon EC2 instances. Refer to Part 1 of the blog here: How To Install And Run\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Insrall and Run Docker on Amazon EC2 - Workfall","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":456,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-run-commands-remotely-on-an-ec2-instance-using-aws-systems-manager\/","url_meta":{"origin":651,"position":5},"title":"How to run commands remotely on an EC2 instance using AWS Systems Manager?","date":"November 9, 2021","format":false,"excerpt":"If you are a System administrator and assigned a task to upgrade the packages for one application running on an EC2 instance, but due to some security restrictions, you are not permitted to access production instances via SSH or bastion host. In this situation, you can use AWS Systems Manager\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS Systems Manager","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/Systemsmanager.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/651"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":5,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":1802,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/651\/revisions\/1802"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/656"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}