---
description: >-
  Learn how Sedai autonomously optimizes AWS ECS clusters and services for
  performance improvements and cost savings.
---

# ECS

Sedai autonomously optimizes ECS clusters (**Fargate** and **EC2**) to improve cost and resource efficiency. This is achieved by:

1. **Rightsizing Tasks & Containers:** Sedai determines optimal CPU and memory for tasks and containers and then allocates resources accordingly to prevent excessive costs.
2. **Optimizing Compute Configurations**: Sedai optimizes [Spot Instance](#spot-instance-recommendations) configurations for Fargate in ECS clusters by automatically identifying and configuring Spot-friendly applications.
3. **Optimizing Cluster Configurations:** Sedai optimizes container instances' CPU & memory configurations for both Fargate and EC2 clusters to improve performance, scalability, and overall efficiency.
4. **Configuring** [**Auto Scaling**](#auto-scaling)**:** Sedai uses ECS Cluster Auto Scaling to dynamically adjust the number of container instances within a cluster, optimizing resource allocation and ensuring efficient performance based on workload demands. Additionally, Sedai utilizes ECS Service Auto Scaling to determine a service's task range and intelligently optimizes Target Tracking Scaling Policies for optimal performance.&#x20;

{% hint style="info" %}
To view optimization opportunities for AWS ECS, go to Optimization > Opportunities and select the Compute tab.&#x20;
{% endhint %}

***

### Auto Scaling

Sedai’s intelligent and continuous **horizontal scaling** and **vertical scaling** increase performance efficiency, allow for greater scalability, and ultimately improve overall reliability.

Sedai auto-selects and updates the best scaling policies for ECS Service Auto Scaling to ensure services run at peak efficiency. Sedai also utilizes ECS Cluster Auto Scaling to adjust the number of instances within a cluster, which you can see in the [Timeline](../../../activity#timeline) page by applying a **Configure ECS Cluster Autoscaler** action filter.

***

### Spot Instance Recommendations

Sedai optimizes Spot Instance configurations for Fargate, allowing savings of up to 90% compared to On-Demand costs. Spot Instances are significantly cheaper because they utilize AWS's unused compute capacity, which can be reclaimed at any time, offering lower prices for the trade-off of potential interruptions. Because AWS can revoke these instances at any point, it's essential to determine which applications can handle interruptions without negative impact and restart smoothly before allocating to Spot Instances.

Sedai reduces the burden of identifying suitable applications for Spot Instances by indicating ideal candidates for you. Through an analysis of restart time, traffic, and development/production flags, Sedai generates recommendations for applications suitable for Spot. Beyond identifying Spot-friendly applications, recommendations include an optimal weight breakdown of Spot versus On-Demand for applications to ensure you achieve the lowest possible costs without increasing risk of service disruptions or data loss.

To view these recommendations:

1. Navigate to **Optimization > Opportunities**.
2. Select an ECS cluster containing Fargate.
3. Under the **Service Optimization** tab, select a Fargate service.
4. View the recommended configuration under **Compute Configuration.** This configuration will indicate whether Fargate Spot should be used as a capacity provider and, if so, the appropriate weight distribution.

Sedai’s proactive approach guarantees optimized Spot Instance configurations without the manual overhead. By leveraging Sedai’s compute optimization capabilities, you can effectively utilize AWS Spot Instances for your Fargate applications, ensuring cost efficiency without risking significant service reliability.

{% hint style="info" %}
Spot Instance recommendations for ECS running on EC2, EKS running on EC2, and EKS on Fargate coming soon
{% endhint %}

***

### Cluster Scale-down Schedules

In addition to optimizing resource allocations, Sedai also saves costs and prevents over-provisioning through [Cluster Scale-down Schedules](#cluster-scale-down-schedules). These schedules allow you to define periods to automatically scale down clusters, ensuring resource allocation aligns with actual demand.&#x20;
