Some quick and easy cost control techniques in AWS

BLOG ARTICLE

Anything big happening in the world? The recent governmental response to COVID-19 has  significantly affected the Australian to US financial exchange rate. A downside of the government stimulus and effects on the global supply chain is that your AWS bill has just increased by 15% over the past month!

Here are some simple and useful techniques to make your AWS spend go further.

Implement a shutdown tool for non production environments

One simple way to reduce run costs is to ensure that all non production environments are only used during development and testing and production size is always available.

One tool that I have the most success with is using Cloud Custodian. The configuration is turn-key and with minimal setup, I can make a big dent into the cost.

Autoscale down instances at 6pm. This policy is useful if you have full account separation between development and production.

policies:

   - name: turn-down-asg-at-6pm
     
resource: asg
     
comments: |
      Daily stoppage at 6pm
    filters:
      – type: offhour
        tag: custodian_downtime
        offhour: 18
    actions:
      – suspend

   
– name: turn-up-asg-at-10am
     resource: asg
     comments: |
        Daily start at 10am
     filters:
        – type: onhour
          tag: custodian_downtime
          onhour: 10
     actions:
        – resume

I like to power my resources by CloudFormation and I also like to ensure I can tear down stacks at the end of the day in non-production environments. If I tag all of my CloudFormation stacks by environment then I can use Cloud Custodian to tear down instances at the end of the day.

policies:

   – name: delete-non-prod-stacks-at-end-of-day
     description: |
         This task cloudformation delete stacks all developer stacks at the end of the day
         filters:
             – type offhour
             – “tag:prod”: absent
         actions:
             – delete
         filters:
             – type: cross-account
         actions:
             – delete

Clean up any unused EBS volumes

If you are doing lots of image building it can be possible to accrue lots of unattached EBS volumes. Using the same cloud custodian tool you can look for unattached EBS volumes that are left lying around and can be cleaned up.

policies:
    - name: delete-unattached-volumes
      resource: ebs
      filters:
        - Attachments: []
        - State: available
        – “tag:prod”: absent
        – “tag:retain”: absent
      actions:
        – delete

Enable Compute Optimizer for right sizing recommendations

Another measure that can help optimise your costs is to right size your EC2 instances based on resource metrics. Previously AWS customers would have to implement a custom solution or deploy AWS Right Size quick starts to enable this capability. With the recent AWS release of the Compute Optimizer service, a free AWS service that provides EC2 right-size recommendations, you can now opt-in and receive right-size recommendations based on 14 days of Cloudwatch metrics. By installing a cloudwatch agent on your instances, you can enhance the right-size recommendations to include memory metrics. Note that additional charges may apply to the use of this feature.

Simply navigate to your Compute Optimizer console and Opt-in to set-up it up for your account. You can also choose to use the AWS CLI to opt-in.

aws compute-optimizer update-enrollment-status –status Active 

If applying this from your Master account, you can use the following option to opt-in all member accounts.

–include-member-accounts

Look at spot instances

Using spot instances instead of standard compute for non-production environments is another way to save a significant cost within all dev test workloads. There is minimal overhead in wiring spot instances into your non -production infrastructure. As a rule of thumb, set the spot instance to bet 75% of the on-demand cost and go from there. If you’re right and the instance launches, you’ve immediately saved yourself 25% – if not, just adjust up the spot price.

Cost Visibility

Cost Optimisation efforts begin with Expenditure Awareness through Cost Visibility. If you can’t see what you are spending and where you are spending it, it’s difficult to know where you should focus your efforts. Luckily there are some tools available and at your disposal to quickly view and manage your AWS charges. Cost Explorer is a free AWS tool that allows you to report on your usage charges over time across a number of dimensions including by Service, Account, Tags and many others. AWS Budgets enables you to configure budget alerts to proactively manage your spend. A good practice is to set-up budgets at different thresholds to receive continuous alerts throughout the month. Eg. setup budget alerts at 25%, 50%, 75% and 100% to receive alerts across the month. If you receive a 25% threshold alert on day 2, it’s an early indicator that you’ll exceed your forecast for that month, enabling early investigation. Resource Tags can be applied to the majority of your AWS resources to provide intra account cost granularity where you have multiple teams sharing an account.

Look at what Cevo can do for you

Here are some other cost saving techniques that Cevo can do for you

     Move your auto scaling instances to spot fleet

     Implement right sizing of your infrastructure

     Implement an RDS stopinator

     Implement most aggressive Cloud Custodian rulesets for your environment

     Propose an insurance homogenisation strategy and purchase reserved instances

     And many more – contact us to find out how