Skip to main content

Compute Cost Savings

EC2, ECS, EKS, Fargate, Lambda

EC2

  • Use reserved instances or savings plans to reduce the hourly rate for your EC2 instances, saving up to 75% compared to on-demand pricing.
  • Use Amazon EC2 Auto Scaling to automatically adjust the number of instances based on traffic and demand.
  • Utilize Amazon Elastic Block Store (EBS) snapshots and lifecycle policies to automatically transition data to lower-cost storage tiers, reducing storage costs over time.
  • Use AWS Trusted Advisor to identify idle and underutilized EC2 instances, identify and terminate unused resources and save on costs.
  • Use AWS cost allocation tags to track and manage costs by application, environment, and business unit, optimize resource allocation and avoid overages.
  • Use EC2 Spot Instances for non-critical, fault-tolerant workloads to save up to 90% compared to on-demand pricing.
  • Use Amazon EBS Provisioned IOPS SSD (io1) volumes only when needed, as they have a higher hourly rate than other EBS volume types.
  • Use the AWS Instance Scheduler to automatically start and stop EC2 instances on a schedule, enabling you to optimize resource allocation and avoid over-provisioning.
  • Use Amazon EC2 T4g instances for burstable workloads that don't require sustained high performance, as they have a lower hourly rate than other instance types.
  • Use Amazon EC2 Auto Scaling with Spot Instances to automatically scale up and down the number of Spot Instances based on demand

There are several metrics for EC2 instances that can be improved to decrease costs:

  • Instance type
    • Choose the right instance type based on your workload requirements and optimize the balance between compute, memory, storage, and network resources to avoid over-provisioning.
  • Instance utilization
    • Monitor the instance utilization metrics like CPU utilization, network traffic, and disk I/O, and optimize the instance utilization to avoid over-provisioning and idle instances that incur unnecessary costs.
  • Instance size
    • Choose the appropriate instance size for your workload and optimize the instance size based on the workload's changing demands to avoid over-provisioning and underutilization.
  • Spot instances
    • Use Spot instances for non-critical, fault-tolerant workloads to save up to 90% compared to on-demand pricing.
  • Reserved instances
    • Use Reserved instances or Savings Plans to reduce the hourly rate for your EC2 instances, saving up to 75% compared to on-demand pricing.

ECS

  • Use Amazon ECS Fargate for serverless container deployments to save on EC2 instance costs and reduce operational overhead.
  • Optimize task placement strategies and utilize the AWS Fargate Spot option to reduce EC2 instance usage and save on costs.
  • Utilize Elastic Load Balancing to distribute traffic to your ECS tasks and reduce the number of instances needed to handle traffic spikes.
  • Use Amazon ECS task definitions to optimize container memory and CPU usage, run more containers on fewer instances and save on costs.
  • Use Amazon ECS Cluster Auto Scaling to automatically adjust the number of instances in a cluster based on demand, optimize resource allocation and avoid over-provisioning.

There are several metrics for Amazon Elastic Container Service (ECS) that can be improved to decrease costs:

  • Task placement strategies
    • Optimize the task placement strategies to minimize the number of instances and containers needed to handle the workload, and use AWS Fargate Spot option to reduce EC2 instance usage and save on costs.
  • Container resource utilization
    • Monitor the container resource utilization metrics like CPU and memory usage.
  • Task definition optimization
    • Optimize the task definition to reduce the CPU and memory requirements and reduce the number of containers needed to handle the workload.
  • Load balancing
    • Use Elastic Load Balancing to distribute traffic to your ECS tasks and reduce the number of instances needed to handle traffic spikes, allowing you to optimize resource allocation and save on costs.
  • Auto Scaling
    • Use Amazon ECS Cluster Auto Scaling to automatically adjust the number of instances in a cluster based on demand, allowing you to optimize resource allocation and avoid over-provisioning.

EKS

  • Use Amazon EKS Fargate for serverless Kubernetes deployments to save on EC2 instance costs and reduce operational overhead.
  • Use Kubernetes Horizontal Pod Autoscaling (HPA) to automatically adjust the number of pods based on demand, enabling you to optimize resource allocation and avoid over-provisioning.
  • Utilize Elastic Load Balancing to distribute traffic to your EKS pods and reduce the number of instances needed to handle traffic spikes.
  • Use Kubernetes Pod resource requests and limits to optimize CPU and memory usage, enabling you to run more pods on fewer instances and save on costs.
  • Use AWS cost allocation tags to track and manage costs by application, environment, and business unit.

Fargate

  • Use Amazon ECS Fargate or Amazon EKS Fargate for serverless container deployments to save on EC2 instance costs and reduce operational overhead.
  • Optimize task placement strategies and utilize the AWS Fargate Spot option to reduce EC2 instance usage and save on costs.
  • Utilize Elastic Load Balancing to distribute traffic to your Fargate tasks and reduce the number of instances needed to handle traffic spikes.
  • Use AWS cost allocation tags.

Lambda

  • Use AWS Lambda for serverless function deployments to save on EC2 instance costs and reduce operational overhead.
  • Runtime Architecture can be cheaper with ARM64.
  • Use AWS Lambda provisioned concurrency to reduce cold starts and improve performance.
  • Utilize Amazon API Gateway caching to reduce the number of requests to your Lambda functions and save on data transfer costs.
  • Optimize your Lambda function code and memory allocation to reduce execution time and improve performance.
  • Use AWS cost allocation tags.
  • Use Amazon API Gateway caching to reduce the number of requests to your Lambda functions and save on data transfer costs.
  • Use AWS Lambda's VPC networking features only when needed, as it increases the cost per invocation and can impact performance.
  • Consider using AWS Lambda with AWS Step Functions to create serverless workflows and orchestrate multiple Lambda functions, reducing the number of function invocations and saving on costs.
  • Memory allocation
    • AWS Lambda pricing is based on the amount of memory allocated to a function and the duration of its execution, so optimizing the memory allocation can reduce the execution time and save on costs.
  • Function code optimization: Optimizing the function code to reduce its execution time can also reduce the duration of the function and save on costs.
  • Cold start time
    • Cold starts occur when a function is invoked for the first time or when it hasn't been invoked for a while, resulting in longer execution times and higher costs. Using Provisioned Concurrency can reduce cold start times and improve performance while saving on costs.
  • Function duration
    • AWS Lambda pricing is based on the duration of function execution, so optimizing the function duration can save on costs. This can be achieved by optimizing the code or using services like Amazon API Gateway caching to reduce the number of invocations.
  • Function concurrency
    • AWS Lambda pricing is based on the number of concurrent function executions, so optimizing the concurrency can save on costs. This can be achieved by using Amazon API Gateway throttling and queuing to limit the number of requests or by using AWS Step Functions to orchestrate multiple Lambda functions and reduce the number of concurrent executions.

AWS Step Functions

  • AWS Step Functions Express Workflows for high-performance, event-driven workflows with a low per-state cost.
  • AWS Step Functions Asynchronous Express Workflows for long-running workflows that require low per-state costs and can tolerate some level of event loss.
  • AWS Lambda with AWS Step Functions to create serverless workflows and orchestrate multiple Lambda functions.
  • AWS Step Functions Map State to iterate over a collection of items and execute a state machine for each item.
  • AWS Step Functions Choice State to route workflow executions based on specific conditions.
  • AWS Step Functions Wait State to introduce delays in workflow executions and avoid over-provisioning, reducing costs and improving resource utilization.
  • AWS cost allocation tags
  • AWS Step Functions with AWS Batch to create scalable, cost-effective batch processing workflows.
  • Utilize AWS Step Functions Parallel State to execute multiple state machines in parallel and optimize resource utilization.
  • AWS Step Functions with AWS Lambda Destinations to create resilient and cost-efficient workflows that can handle failure scenarios.