8 Best Practices To Reduce Your AWS Bill for Kubernetes | DevsDay.ru

IT-блоги 8 Best Practices To Reduce Your AWS Bill for Kubernetes

DZone DevOps 20 апреля 2021 г. Vito Clover

If your AWS Kubernetes bill went way over your budget this month, it’s not your fault. Typically, companies go over their cloud budgets by 23% (Flexera). 

Cloud providers aren’t exactly helping here. The bills are long, complicated, and hard to understand. AWS has 150+ types of EC2 instances available so how are you supposed to make sense of it all?

This article is packed with tips for reducing your AWS costs, no matter if you run K8s on your own or use EKS.

Article Outline

  • A quick guide to AWS pricing
  • Start by understanding your AWS Kubernetes bill
  • 8 best practices to reduce your AWS bill
    1. Define your requirements
    2. Choose the right instance type
    3. Verify storage transfer limitations
    4. Check if your workload is spot-ready
    5. Cherry-pick spot instances
    6. Bid your price on the spot
    7. Use mixed instances
    8. Make multiple availability zones work for you
  • Or just automate it

Note: While writing this article, AWS introduced changes to its offer. We will be updating it on a regular basis.

A Quick Guide to AWS Pricing

Saving money with AWS pricing

On-demand instances

How it works: In this pay-as-you-go model, you only pay for the resources that you actually use. For example, AWS charges you for every hour of computing capacity used by your team. You face no long-term binding contracts or upfront payments, so you’re not overcommitting to any budgets. And you get to increase or reduce your usage just-in-time. 

What to watch out for:

  • It’s the most expensive option, so overrunning your budget is a real risk here.
  • The flexible on-demand instances work great for unpredictable workloads that experience fluctuating traffic spikes. Otherwise, you should look into alternatives.

Reserved Instances 

How it works: In theory, everything sounds great. You can buy capacity upfront in a given availability zone for a really low price when compared to on-demand instances. The larger your upfront payment, the bigger the discount. In AWS, you’re looking at commitments of 1 to 3 years.

What to watch out for:

  • In most scenarios, you’ll be committing to a specific instance or family—and changing it later isn’t an option. This could become a problem if your requirements change later. 

Savings Plans 

How it works: This model is very similar to Reserved instances, but here you’re committing to using a given amount of computing power over 1 or 3 years (measured as usage per hour). So, you get on this plan and all usage up to your commitment will be covered. Anything extra is billed using the on-demand rate. 

What to watch out for:

  • Sure, you’re committing to consistent usage, not specific instance types and configurations like in Reserved instances.

For both reserved instances and savings plans, you’re still running the risk of locking yourself in with the cloud vendor. Also, you’re committing to pay for resources that might make little sense for your company in 1 or 3 years. 

Consider this: When your computing requirements change, you need to either commit even more or you’re stuck with unused capacity.

Reserved instances remove any flexibility of scaling, seasonality, or ability to easily configure multi-region/zone distribution.

Spot Instances

How it works: This is a very cost-effective pricing model. You bid on resources CSPs aren’t using at the moment and get to save up to 90% off the on-demand pricing. But it comes with limited availability. AWS can pull the plug with a 2-minute warning. That’s still better than Azure or Google Cloud that give you only 30 seconds. 

What to watch out for:

  • The savings are amazing, so spot instances are definitely worth your attention.
  • Just make sure that you pick them for workloads that can handle interruptions—for example, stateless application components like microservices or replicable applications. 

Dedicated Host 

How it works: This is a physical server with an instance capacity that is exclusively for you. You can use your own licenses for cost reductions but still get the resiliency and flexibility of AWS. A good choice for businesses that need to achieve compliance and avoid sharing hardware with other tenants for extra security.

What to watch out for:

  • When setting up a Dedicated host, you pick a configuration that identifies the type and number of instances you can run on it.
  • Note that you’re billed hourly for every active Dedicated host, not each instance running. Still, this is a pricey option. 

Note: Don’t forget about the extra charges

All cloud providers charge for extra things—think egress traffic, load balancing, block storage, IP addresses, or premium support. AWS is no exception. Consider these expenses when comparing different pricing options and setting your cloud budget.

Start By Understanding Your AWS Kubernetes Bill

AWS bills are long, complex, and hard to understand. Just take a look at this bill here:

Breakdown of Kubernetes Bill

Each service in your bill comes with its own billing metric. Some services in the AWS Simple Storage Service are charged by requests, while others use GB.  To understand your usage and start analyzing costs, you need to look into various areas in the AWS console. Checking the AWS Billing and Cost Management Dashboard alone won’t be enough.

You need a more granular view, and for that, you need to visit the Cost Explorer. To make billing more transparent, it’s a good idea to group and report on costs by specific attributes (like region or service). 

As you can imagine, this is very time-consuming.

But you need to get started somewhere with. And the best starting point is the AWS suite of cost management tools.

AWS Cost Management Tools—They’re Worth Exploring

  • AWS Cost Explorer: This is where you can visualize and manage your costs and usage over time. Start by creating some custom reports, analyzing your data from a bird’s eye view, and identifying any cost drivers or anomalies.
  • AWS Budgets: Use this handy tool to set custom budgets and track your costs/usage for different use cases. You can set an alert for when the actual or forecasted cost goes over your budget threshold. The tool can also alert you when your actual Reserved instances or Savings Plan utilization/coverage drops below the threshold you’ve set for it. 
  • AWS Cost & Usage Report:  This report gives you a comprehensive overview of your costs and usage together with some extra metadata on AWS pricing, services, Reserved instances, and Savings Plans. You can see all that at different levels of granularity and organize everything further with Cost Allocation tags and Cost Categories.

Multiple Teams Using One AWS Account—How To Deal With That

If several teams or departments contribute to your AWS cloud bill, you need a method to make sense of it (or at least give a helping hand to the CFO).

Fortunately, AWS provides mechanisms for categorizing expenses by accounts, organizations, or projects. You can use them to keep teams from spending too much.  

  • Organizations: Use this feature to centrally manage and govern your environment while scaling AWS resources. Create a new AWS account, allocate resources, organize workflows by grouping accounts, and then apply budgets and policies to the accounts or groups. You can make billing simpler by using a single payment method.
  • Tagging resources: When you tag resources directly, they’re not going to land on your bill. You need to break data down by tags manually. To do that, write a report in the Cost Explorer or download data from S3 and use it directly (don’t expect this to be an easy task). Entire companies exist just to build tools for expressing and representing bills. Note that some services/components/resources cannot be tagged.

Alternatively, you can use resource tags in the AWS Cost Explorer. The usual practice is to create tags for each team, environment, application, service, and even feature. Then turn on cost grouping for those tags and you can create reports in the AWS billing console.

3 Techniques on How To Forecast Cloud Costs

Cloud bills fluctuate depending on usage, so forecasting them is painful. But it’s worth your time. Understanding your future resource requirements helps to keep costs in check. 

Here are three techniques for forecasting costs towards AWS cost optimization:

  1. Analyze your usage reports: First thing's first, you need to achieve clear visibility of your cloud expenses. Monitor the resource usage reports regularly. Set up email and other alerts to keep your bill in check. 
  2. Model your cloud expenses: How do you calculate the total cost of ownership of your cloud resources? Start by analyzing the AWS pricing models and plan capacity requirements over time to forecast costs. It’s smart to also measure application or workload-specific costs to develop an application-level cost plan. You need one location for aggregating—this is how you understand expenses better.
  3. Detect peak resource usage scenarios: Use periodic analytics and run reports on your usage data to identify these scenarios. You can use other data sources—for example, the seasonal customer demand patterns. If you spot that these patterns correlate with your peak resource usages, you can now identify them in advance (and prepare for it accordingly).

8 Best Practices To Reduce Your AWS Kubernetes Bill

Choosing the Right VM Instance Type

1. Define Your Requirements

Order only what your workload needs across the compute dimensions: 

  • CPU count and architecture
  • memory
  • storage
  • network 

An affordable instance might look tempting, but what happens if you start running a memory-intensive application and end up with performance issues affecting your brand and customers?

Pay attention when choosing between CPU and GPU dense instances. If you’re developing a machine learning application, you probably need a GPU dense instance type because training models on it are much faster. 

2. Choose the Right Instance Type 

There’s no denying that computing resources are the biggest line item on your bill. Picking the right VM instance type can save you even 50% of your bill (we actually tested it).

AWS offers many different instance types matching a wide range of use cases, with entirely different combinations of CPU, memory, storage, and networking capacity. Every type comes in one or more sizes, so you can scale your resources easily.

But know this: Cloud providers roll out different computers for their VMs and the chips in those computers have different performance characteristics. So you might pick an instance type with a strong performance that you don’t actually need (and you don’t even know it).

Understanding and calculating all of this is hard. AWS offers more than 150 different instance types. 

The best way to verify a VM’s capabilities is by benchmarking: by dropping the same workload on every machine type and checking its performance. We actually did that; take a look here.

3. Verify Storage Transfer Limitations

Data storage is another cost optimization aspect worth your time. Each application out there comes with its unique storage needs. Make sure that the VM you pick has the storage throughput your workloads need. 

Also, avoid expensive drive options like premium SSD unless you’re planning to use them to the fullest.

Spot Instances

4. Check That Your Workload Is Spot-Ready

Spot instances are a great way to save up on your AWS Kubernetes bill, even by 90% off the on-demand pricing! But before jumping on the spot bandwagon, you need to decide how aggressive you’re going to be about implementing them.

Here are a few questions to get you a step closer:

  • How much time does your workload need to finish the job? 
  • Is it mission- and time-critical?
  • Can it handle interruptions? 
  • Is it tightly coupled between instance nodes? 
  • What tools are you going to use to move your workload when AWS pulls the plug? 

5. Cherry-pick Your Spot Instances

When choosing spot instances, pick the slightly less popular instances because they’re less likely to get interrupted. Once you pick an instance, check its frequency of interruption (the rate at which this instance reclaimed capacity during the trailing month). 

You can see it the AWS Spot Instance Advisor in ranges of <5%, 5-10%,10-15%,15-20%, and >20%:

Spot Instance Advisor

Don’t shy away from using spot instances for more important workloads.

AWS offers a type of spot instance that gives you an uninterrupted time guarantee for up to 6 hours (in hourly increments). You pay just a little more for it and still achieve a discount of 30-50% off the on-demand pricing.

6. Bid Your Price on the Spot

Once you find the right instance, it’s time to set the maximum price you’re ready to pay for it. The instance will only run when the marketplace price is below or equal to your bid. 

Here’s a rule of thumb: Set the maximum price to one that equals the on-demand price. Otherwise, you risk getting your workloads interrupted once the price goes higher than what you set.

To boost your chances of snatching spot instances, you can set up groups of spot instances (AWS Spot Fleets) and request multiple instance types at the same time.

You will be paying the maximum price per hour for the entire fleet rather than a specific spot pool (a group of instances with the same type, OS, availability zone, and network platform).

But to make it work, you’re facing a huge amount of configuration, setup, and maintenance tasks. 


7. Use Mixed Instances

So far, I didn’t really talk about anything related exclusively to Kubernetes, so here’s one good point.

A mixed-instance strategy gets you great availability and performance at a reasonable cost. You basically pick different instance types since some are cheaper and just good enough, but might not be suitable for high-throughput, low-latency workloads.

Depending on your workloads, you can often pick the cheapest machines and make it all work.

Or you could have a smaller number of machines with higher specs. This can help slash your AWS Kubernetes bill because each node requires Kubernetes to be installed on it and adds a little overhead.

But mixed instances present some scaling challenges.

In a mixed-instance scenario, each instance uses a different type of resource. While you can scale up the instances in your autoscaling groups using metrics like CPU and network utilization, you’ll get inconsistent metrics. 

Cluster Autoscaler helps here by allowing you to mix instance types in a node group. However, your instances must have the same capacity in terms of CPU and memory. 

8. Make Multiple Availability Zones Work For You

Instances spanning across several availability zones increase your availability. But AWS recommends doing this:

  • Configure multiple node groups
  • Scope each of them to a single Availability Zone
  • And then enable the –balance-similar-node-groups feature.

If you create only one node group, you can scope that node group to span across multiple Availability Zones.

Optimize Your AWS Kubernetes Bill Intelligently 

All of those tips apply regardless of your infra type, whether you handle clusters on your own or use AWS EKS. 

But to seriously reduce your AWS bill, you need an intelligent platform that can choose the right instance size from various instance types spanning on-demand, spot, and reserved, all the while helping you to manage infrastructure dependencies.  

Источник: DZone DevOps

Наш сайт является информационным посредником. Сообщить о нарушении авторских прав.

devops aws kubernetes k8s aws cost cloud optimization cloud compute

Читайте также

Практики DevOps: от магии к инструментам. 11 спикеров и одно интервью конференции DUMP

Разработка habr.com 11 мая 2021 г. 19:41
За несколько лет DevOps из экзотики превратился в набор практик и технологий, который помогает эффективно решать прикладные задачи и приносит компаниям осязаемую пользу.В этом году на конференции мы решили сфокусироваться на реальных кейсах, которые...... читать далее
Блог компании IT-People Конференции Интервью конференция спикер devops доклад

Use Shared Packages From an Azure DevOps Feed in a Maven Project

DevOps DZone DevOps 11 мая 2021 г. 14:58
Introduction While building multiple apps, you will come across reusable code. This common code can be packaged, versioned, and hosted so that it can be reused within the organization.  Azure DevOps Artifacts is a service that is part of the Azu...... читать далее
devops azure devops azure artifacts

Разработка dev.to 11 мая 2021 г. 12:56

Photo by Yancy Min on Unsplash Howdy DEV clan? We've all heard of the recommendation and best practice: "Use a version control for your project." While this is true, it might save you from F*CK-ups, not many blogs proclaiming the use of version co...... читать далее

devops todayilearned beginners codenewbie

SEO texterra.ru 11 мая 2021 г. 10:55

Поговорили с HR-специалистами из разных сфер и узнали, какие профессии актуальны сегодня и что станет трендом в ближайшие 5-10 лет. Статья будет полезна как для тех, кто только начинает свой карьерный путь, так и для тех, кто уже давно в профессии и...... читать далее


Разработка dev.to 11 мая 2021 г. 9:09

Experience is always a crucial factor for employers to hire a candidate for a particular job role. Just like any of the roles in software development companies, employers also put forth varying experience requirements depending on the type of positio...... читать далее

magento software devops

Разработка dev.to 11 мая 2021 г. 8:47

The idea behind b00t is a framework to build a startup properly and provide tooling & infrastructure, devops pipeline, vs code environments, "startup kit", mostly python & typescript with optional libraries such as ai, crypto, ecommerce, etc...... читать далее

Разработка dev.to 11 мая 2021 г. 8:05

You probably already heard of Kubernetes, a powerful orchestrator that will ease deployment and automatically manage your applications on a set of machines, called a Cluster. With great power comes great complexity, even in the eyes of Google. Thus,...... читать далее

devops kubernetes cloud tutorial

Популярные темы

новости (401) javascript (383) ux (380) design (347) headline (300) python (286) devops (251) ubuntu (233) ux-design (225) tutorial (215) security (210) programming (206) новость (204) web dev (196) webdev (159) working in tech (152) seo (152) дайджесты вакансий от new.hr (150) статьи (143) ui (135) testing roundup (122) software testing (121) user-experience (116) css (113) java (113) react (109) дизайн (102) google (100) product-design (94) игровые проекты (90) beginners (88) ui-design (88) design-thinking (85) technology (83) php (82) productivity (81) прочее (80) primary (80) движки и конструкторы игр (78) api5 (76) технологии (76) cloud (76) job hunting (75) бизнес (73) windows 10 (73) docker (71) laravel (70) debian (68) bash programming (68) uncategorized (68) tutorials (67) hardware (67) android (66) news (60) мероприятия (60) linux mint (59) обучение (58) kubernetes (56) работа (56) linux (55) games (54) art (54) networking (53) ios (53) machine learning (53) angular (52) инструкции (52) español (51) web design and applications (50) ux-research (50) case-study (50) aws (50) covid-19 (50) разработчики (50) api (49) обзоры (49) cybersecurity (49) data (49) apple (49) chrome (48) engineering (48) html (48) inspiration (47) турбо-страницы (47) git (46) linux commands (46) job skills (46) web (46) home page stories (45) publication (45) typescript (45) dotnet (44) node (44) mobile (44) powershell (44) c++ (43) навыки алисы (43) tools (43) testing (41) mysql mariadb (41)