Moving to the cloud offers businesses many advantages over managing their own infrastructure. Cost savings is the primary benefit for companies that make the leap to the cloud. However, there are still many opportunities for cutting costs even after the initial migration. If unchecked, these missed opportunities could silently be costing your business money that is better spent elsewhere. Periodically reviewing your cloud usage is a great way to spot these opportunities for additional savings. In this post, we’ll show you three ways to cut your EC2 costs on Amazon Web Services (AWS) by exploring cost optimizing techniques available for their core compute service: Elastic Compute Cloud (EC2).
What is EC2?
Elastic Compute Cloud (EC2) provides infrastructure as a service (IaaS). It allows users to launch virtual machines known as “instances” that can be used to perform any kind of function that your business requires without worrying about servers, networking, and other hardware. With EC2, you can create, launch, and terminate these instances as needed and only pay for what you use. You have full control over the geographical location where the instances are provisioned, and you can take advantage of resiliency by deploying into different availability zones within each of the regions.
Many AWS users are familiar with the free tier, which allows you to use several services for free with some restrictions in your first year. In EC2, the popular t2.micro instance type is eligible for free tier use. But what about after your free tier eligibility runs out or when you need more powerful instances? EC2 provides several pricing models, each with their own sweet spots. Let’s take a look.
A popular choice in AWS, on-demand pricing provides the most flexibility in launching instances as you please. This model is best suited for unpredictable workloads that can’t be interrupted, and for early development and prototyping. On-demand instances are charged by the hour, rounded up to the nearest hour. This implies that if you terminate and launch an instance multiple times in a single hour, you will be billed for multiple hours. You also pay the price for the freedom of launching instances without any commitment. On-demand pricing is the most expensive option for EC2 in most situations.
When you have established a steady-state or when you know your EC2 usage requirements in advance, you should consider using reserved instances. Depending on the configuration, reserved instances can save you up to 75% versus on-demand pricing. This pricing model locks you in for a one- or three-year contract with payment upfront, partially upfront, or no upfront. If you have predictable recurring demand patterns, you can make use of scheduled reserved instances, which reserve capacity only when you need it. The contracts come in standard and convertible flavors depending on how flexible you need to be for switching instance families, operating systems, etc.
If you think that you might end up having buyer’s remorse after locking in a reserved instance, there are a few things that you should know:
- You are allowed to change availability zone, instance size (for Linux OSes), and networking type for all reserved instance contracts.
- You can sell your unused standard reserved instance contracts if you no longer need them. The Reserved Instance Marketplace is provided by AWS for connecting buyers and sellers for third party reserved instance contracts. The contracts will often be for a shorter duration than the standard one- or three-year contract and for a lower price.
- You can continue to use your reserved instance while it is for sale in the marketplace. If a reserved instance contract sells while in use, you will be charged at the on-demand price.
Spot instances offer the potential of saving 90% over on-demand instances but come with some unique caveats. The price of spot instances is market-driven. This means that the demand for instances within AWS regions and availability zones determine the price. You submit bids for instances and as long as the bid is above the current spot price, your bid will be fulfilled. However, market conditions can change in an instant. Your instance can be terminated, potentially without any warning, once your bid is surpassed by the market price. If this is the case, you won’t be charged for the partial hour in which your instance was terminated due to increases in market price. The image below illustrates the fluctuations in spot prices across different availability zones in the us-west-2 region:
There are a few more ways to bid on instances instead of the single instance bid described. You can bid on groups of spot instances using spot fleets. Spot fleet requests provide a convenient way to submit multiple spot instance bids at once. Your spot fleet request may be fully, partially, or not fulfilled at all depending on the market conditions and your spot fleet request.
You can also specify an allocation strategy as part of your spot fleet request. Two allocation strategies are currently supported: lowest price and diversified. Lowest price will fulfill the request in a way that minimizes your costs. Diversified adds more concern to your application availability. It will attempt to balance instances across requested instance types and availability zones instead of only considering cost.
Spot blocks are another way to request spot instances. Spot blocks allow you to make reservations of a fixed duration between one and six hours regardless of how the spot market price fluctuates after your request is fulfilled. This provides a balance between cost savings using the spot market and ensuring your instance will not be terminated for a set amount of time. With spot blocks, you can expect to save around 30% to 45% compared to on-demand pricing. But beware. While rare, it is possible for spot block instances to be terminated in certain circumstances. If there is a large enough increase in demand for the instance type, AWS can terminate the instance but would provide a two-minute warning.
You may be able to tolerate unprompted termination in many situations. You can also make use of strategies to avoid having your instances terminated. Our new Cloud Academy lab Using EC2 Spot Instancesteaches you the ins and outs of using spot instances hands-on. As the lab demonstrates, spot pricing can be combined with the next cost saving opportunity: auto scaling.
Scaling to meet demand
When a new service gets developed, the load profile for it is unknown — this is a common scenario. To develop the service quickly, a couple of EC2 instances are spun up to provide high availability for the service. Before long, the developers get busier and the service becomes more popular.
To handle the load, larger instances are used or more instances get added. From a cost perspective, this is not optimal because the load is very likely to fluctuate over different days of the week and different hours of the day. You could be paying to service peak load 24/7 when in reality your peak loads happen at various intervals—and not 24/7. Avoiding this kind of operational inefficiency is probably one reason why you moved to the cloud in the first place.
AWS provides auto-scaling to meet the dynamic demands of your applications with minimal operational overhead. When there is a large load, auto-scaling will launch more instances and vice versa for when load decreases. This can lead to significant savings when using on-demand or spot instances. This type of auto scaling is called dynamic scaling.
Here is another scenario. Let’s say that there is a delay between when the change in load is detected, when the instance launches, and when the instance is available for use. This can be unsatisfactory for handling spikes in load. If you want to be more proactive but still save on costs, you can use scheduled scaling. With scheduled scaling, you can choose the time and days that you would like to add more instances so you are ready but also not paying for off-peak hours.
There is no additional charge to use auto-scaling. Charges are simply for the underlying instance hours according to the pricing model that is in effect. Each of the previously described pricing models are available here.
If your company has enterprise licenses, for example, Windows, SQL Servers, or Red Hat Enterprise Linux, you can bring them to the AWS cloud and free yourself from the hardware and maintenance costs by using EC2 Dedicated Hosts.
Dedicated Hosts provide you with a physical server that is not shared with other cloud customers. This is not to be confused with Dedicated Instances, which offer the same benefit. In addition to isolation from other customers, Dedicated Hosts provide more control over how instances are placed on the host. For example, if you restart a Dedicated Instance, it could end up on a different host, which would not play well with a license attached to a specific host.
Dedicated Hosts can be charged using on-demand or reserved pricing. If you only need the security of being isolated from other customers, you can use Dedicated Instances that can be charged using all three pricing models discussed earlier, giving you more opportunities to save. AWS provides tables that make it easy for you to compare Dedicated Instance pricing options and Dedicated Host pricing options .
For Microsoft users, in particular, you can consider additional cost saving opportunities. If you prefer to have AWS handle the Microsoft licenses for EC2 instances, that’s no problem. But keep in mind that the same instance running Windows will cost twice as much as if the instance were running Linux, and even more if running SQL Server on top. With SQL Server 2017 running on Linux and Microsoft .NET Core allowing applications to run on Linux, now is as good a time as any to consider the question of operating system dependence and how it impacts your bottom line.
Remember, cost savings do not end after cloud migration. There are many opportunities to optimize costs throughout the lifetime of your cloud operations. If you’re looking to reduce your current EC2 bill, try these three options:
- Consider your pricing model options. Spot instances offer up to 90% savings over on-demand while reserved instances offer up to 75% savings.
- Make use of auto-scaling to automatically allocate just enough EC2 instances.
- Think creatively about your options for cutting back on enterprise license costs that are included in your EC2 bill.
These options all play well with one another and can work together to give you the most value in the cloud.
To get started with implementing savings on EC2, our hands-on labs for spot instances and auto-scaling will guide you every step of the way.
- Using EC2 Spot Instances will show you the ins and outs of using EC2 spot instances in AWS. We’ll cover everything from a one-time spot instance request to strategies for dealing with unprompted instance termination and maintaining auto scaling spot fleets.
- For auto scaling, start with our hands-on lab Working with Amazon EC2 Auto Scaling Groups to learn the basics of auto scaling in AWS, then move on to Creating Your First Auto Scaling Group to scale the Amazon EC2 capacity up or down automatically according to the defined conditions.
Refer Main Article at