ECS Task Cost Optimizer
What this skill does
Translates an ECS task or service's runtime posture into a concrete
cost-optimization recommendation with a dollar-denominated savings
estimate. The verdict reflects the highest-leverage action across seven
dimensions — launch type, architecture, right-sizing, capacity provider
strategy, Savings Plan coverage, task placement, and auto-scaling —
applied in priority order. Always pairs the recommendation with exact
CLI commands or infrastructure-as-code snippets.
Quick navigation
| Section |
What it covers |
When to jump here |
| Quick start |
Four headline rules and the cost formula |
First read |
| Mindset |
Why launch type is the #1 lever |
Understanding the approach |
| Quick reference — verdict thresholds |
Decision matrix at a glance |
Classifying a service |
| Pre-flight data gate |
Container Insights, Cost Explorer |
Before any recommendation |
| Step 0 non-obvious behaviours |
Fargate billing, Graviton compat, SP scoping |
Edge cases |
| Step 1 Launch type |
Fargate vs EC2 crossover at ~30% |
Always-on vs bursty |
| Step 2 Architecture (Graviton2) |
arm64 20% discount + compat check |
Cross-cutting savings |
| Step 3 Task right-sizing |
CPU/memory from Container Insights |
The headline savings dimension |
| Step 4 Capacity provider strategy |
spot base + on-demand top |
Spot savings |
| Step 5 Savings Plan coverage |
Compute SP for Fargate + EC2 |
Commitment discount |
| Step 6 Task placement & scheduling |
binpack, spread, daemon, standalone |
EC2 density |
| Step 7 Auto-scaling tuning |
target tracking, scheduled scaling |
Over-provisioning |
| Step 8 Impact estimation |
The cost formula and worked math |
Every recommendation |
| Output format |
VERDICT block + worked examples |
Emitting the result |
| Anti-Patterns — NEVER |
Common misclassifications |
Self-check before emit |
| Pre-flight safety checks |
CONFIRM gate, canary deploy |
Before any apply CLI |
Quick start
Quick-start headline rules and the cost formula moved verbatim to references/advanced-patterns.md.
Load on demand for the Fargate/EC2 crossover rule, cost formulas, Graviton 20%, and spot strategy headline rules.
Mindset
Mindset prose and the four guiding principles moved verbatim to references/advanced-patterns.md.
Load on demand when framing a recommendation (crossover, compounding right-sizing, commitment stacking, spot as strategy).
Quick reference — verdict thresholds
| Observation (14-30 day window) |
Verdict |
Recommendation |
| Launch type = FARGATE AND steady utilization > 30% AND always-on service |
FURTHER_OPTIMIZATION_AVAILABLE (launch type) |
Step 1 — migrate to EC2-backed capacity provider |
| Launch type = EC2 AND steady utilization < 15% AND bursty/ephemeral workload |
FURTHER_OPTIMIZATION_AVAILABLE (launch type) |
Step 1 — migrate to Fargate |
| Architecture = x86_64 AND application is arm64-compatible (interpreted lang, arm64 native libs) |
FURTHER_OPTIMIZATION_AVAILABLE (architecture) |
Step 2 — migrate to arm64 (Graviton2) |
| CPUUtilization avg < 30% of allocated CPU AND task CPU > 256 (0.25 vCPU) |
FURTHER_OPTIMIZATION_AVAILABLE (right-size) |
Step 3 — reduce CPU allocation |
| MemoryUtilization avg < 30% of allocated memory AND task memory > 512 MB |
FURTHER_OPTIMIZATION_AVAILABLE (right-size) |
Step 3 — reduce memory allocation |
| No spot capacity provider configured AND workload is stateless/fault-tolerant |
FURTHER_OPTIMIZATION_AVAILABLE (spot) |
Step 4 — add spot base capacity provider |
| No Savings Plan covering ECS spend AND monthly ECS charge > $2,000 (steady) |
FURTHER_OPTIMIZATION_AVAILABLE (commitment) |
Step 5 — purchase Compute Savings Plan |
| EC2 cluster with spread placement AND avg instance utilization < 60% |
FURTHER_OPTIMIZATION_AVAILABLE (placement) |
Step 6 — switch to binpack placement |
| All dimensions verified AND architecture on arm64 AND task right-sized AND SP coverage in place |
OPTIMIZED |
None — continue monitoring |
| Container Insights metrics absent or window < 14 days |
NEED_MORE_INFO |
Enable Container Insights, wait 14 days |
| All dimensions verified AND a change was applied and confirmed this session |
OPTIMIZED |
Emit post-state verification |
Pre-flight: data gate (run before any optimization decision)
Optimization decisions are only as good as the underlying data. Pull
these metrics before any recommendation. Full CLI sequences are in
references/ecs-pricing-and-capacity-providers.md.
Required data sources (summarized — see reference for full CLI):
Required data-source listing moved verbatim to references/diagnostic-commands.md.
Load on demand when pulling service config, Container Insights metrics, capacity providers, Savings Plan coverage, and Cost Explorer data.
Data-quality short-circuits
| Condition |
Effect on optimization |
CPUUtilization metric absent (Container Insights not enabled) |
NEED_MORE_INFO. Enable: aws ecs update-cluster-settings --settings name=containerInsights,value=enabled. |
| Metrics window < 14 days |
NEED_MORE_INFO. Minimum 14 days; 30 days preferred. |
RunningTaskCount Sum = 0 over 14 days |
Emit OPTIMIZED with note "dormant service." |
Service desiredCount = 0 |
Skip optimization; surface as dormant. |
| Cost Explorer breakdown absent |
Proceed with Fargate pricing formula; mark MEDIUM confidence. |
| Savings Plan coverage API returns empty |
No SP in place; use on-demand pricing. |
| Service uses external deployment controller |
Verify controller before recommending changes. |
When Container Insights and Cost Explorer disagree, Cost Explorer is
the ground truth for actual charges — metrics inform the optimization
lever, Cost Explorer confirms the dollar impact.
Process — Optimization logic (apply in order)
Step 0: Non-obvious behaviours that change the recommendation
These billing-model and operational gotchas route a recommendation away
from the obvious choice:
Step 0 non-obvious billing and operational behaviours moved verbatim to references/advanced-patterns.md.
Load on demand when a recommendation depends on a non-obvious behaviour (per-second billing, SP scoping, Container Insights cost, EFS vs EBS, daemon scheduling).
Step 1: Launch type selection — Fargate vs EC2 (the #1 lever)
Launch type is the primary cost lever because Fargate charges a 30-50%
premium over EC2 for always-on workloads, while EC2 requires capacity
management overhead.
Step 1 crossover math moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when justifying a launch-type migration with dollar math.
Decision tree:
Is the workload always-on (24/7 steady-state)?
├── NO (batch, cron, event-driven) → Fargate. Per-second billing wins.
└── YES → Is steady utilization > 30%?
├── NO → Fargate. You're paying for idle EC2 capacity.
└── YES → Is the team willing to manage EC2 capacity (ASG, AMI, patching)?
├── NO → Fargate with Savings Plan (accept the premium for simplicity).
└── YES → EC2-backed with capacity provider strategy. Save 30-50%.
Step 1 capacity-provider creation CLI moved verbatim to references/diagnostic-commands.md.
Load on demand when migrating a service to an EC2-backed capacity provider.
Step 2: Architecture migration — Graviton2 (arm64)
Graviton2 (arm64) delivers ~20% cost reduction on both Fargate and EC2.
For Fargate, arm64 pricing is lower per vCPU and GB. For EC2, Graviton
instances (c7g, m7g, r7g) have lower hourly rates.
Step 2 Fargate x86_64 vs arm64 pricing block moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when quantifying the Graviton2 discount.
Step 2 ARM64 compatibility table moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when verifying an application's arm64 risk before recommending migration; the full matrix is in the same file.
Step 2 arm64 migration CLI (register-task-definition + update-service) moved verbatim to references/diagnostic-commands.md.
Load on demand when applying an architecture migration.
See references/ecs-pricing-and-capacity-providers.md for the full
runtime ARM64 compatibility matrix.
Step 3: Task definition right-sizing
Right-sizing is the second multiplier. An over-provisioned task wastes
money proportional to the over-allocation. Container Insights provides
CPU and memory utilization metrics for sizing decisions.
The right-sizing decision gate:
| Metric (14-30 day window) |
Finding |
Action |
| CPUUtilization avg < 20% AND allocated CPU > 256 (0.25 vCPU) |
Over-provisioned |
Reduce CPU to p90 × 1.5 (safety margin) |
| CPUUtilization avg > 80% sustained |
Under-provisioned |
Increase CPU (performance issue, not cost) |
| MemoryUtilization avg < 30% AND allocated memory > 512 MB |
Over-provisioned |
Reduce memory to p90 × 1.5 |
| MemoryUtilization avg > 85% |
Under-provisioned |
Increase memory (OOM risk) |
| CPUUtilization p95 > 70% with spikes to 100% |
Near ceiling |
Increase CPU or add tasks (scale out) |
Step 3 right-sizing math and the partial CPU/memory combination table moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when computing right-sizing savings or choosing a valid Fargate size.
Fargate CPU and memory must be compatible. See the reference for the
full valid-combination table.
Step 4: Capacity provider strategy (spot + on-demand)
Capacity providers define the infrastructure backing for EC2-launched
ECS tasks. A spot base + on-demand top strategy saves 30-70% for
fault-tolerant workloads.
Capacity provider strategy patterns:
| Pattern |
Cost |
When to use |
| 100% on-demand |
Baseline (no discount) |
Stateful, single-instance, cannot tolerate interruption |
| Spot base (70%) + on-demand top (30%) |
30-50% saving |
Stateless web services, microservices, workers |
| 100% spot |
70% saving |
Batch jobs, queue workers, fault-tolerant CI/CD |
| Spot + Fargate fallback |
Mixed |
Hybrid approach for critical periods |
Step 4 spot capacity provider CLI moved verbatim to references/diagnostic-commands.md.
Load on demand when applying a spot base + on-demand top strategy.
Step 4 spot interruption handling notes moved verbatim to references/advanced-patterns.md.
Load on demand when recommending spot capacity (stopTimeout, SIGTERM handling, on-demand fallback).
Step 5: Savings Plan coverage
Compute Savings Plans apply to both Fargate and EC2-backed ECS. They
commit to a $/hour spend in exchange for a discount (up to 54% for
1-year commitment, up to 72% for 3-year).
Step 5 SP-vs-RI comparison table moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when choosing a commitment vehicle.
Step 5 SP coverage and utilization CLI moved verbatim to references/diagnostic-commands.md.
Load on demand when measuring Savings Plan coverage.
Decision gate for SP purchase:
| Monthly ECS spend (on-demand) |
Steady (>12 months)? |
Recommendation |
| > $5,000 |
YES |
1-year Compute SP at 50-70% coverage |
| > $10,000 |
YES |
1-year Compute SP at 70-90% coverage (or 3-year for max discount) |
| < $2,000 |
Any |
SP overhead is not worth the commitment tracking |
| Any |
NO (growing/shrinking fast) |
Delay SP until spend stabilizes |
Step 6: Task placement and scheduling strategy
Task placement strategy determines how tasks distribute across EC2
instances in an EC2-backed cluster. This affects instance density and
therefore cost.
Placement strategy comparison:
| Strategy |
Effect |
Cost impact |
When to use |
spread (default) |
Distributes tasks across all instances |
Lower density (more instances needed) |
High-availability, fault-isolation |
binpack |
Packs tasks onto fewest instances |
Higher density (fewer instances) |
Cost optimization for stateless |
random |
No strategy |
Unpredictable |
Testing only |
Scheduling strategy comparison:
| Strategy |
Effect |
Cost impact |
REPLICA (service) |
Maintains desired count; auto-restarts |
Always-on cost |
DAEMON (service) |
One task per instance |
Scales with fleet size (use for agents) |
| Standalone task |
Run once, no auto-restart |
Per-invocation cost (batch jobs) |
Step 6 bin-pack placement CLI moved verbatim to references/diagnostic-commands.md.
Load on demand when increasing EC2 placement density.
Step 7: Auto-scaling target tracking
Auto-scaling adjusts the desired task count based on a CloudWatch metric
target. Poorly tuned scaling policies cause over-provisioning (too many
tasks) or under-provisioning (SLO violations).
Target tracking tuning:
| Metric |
Recommended target |
Notes |
| ECS CPUUtilization |
50-65% |
Lower = more tasks = more cost; higher = SLO risk |
| ECS MemoryUtilization |
60-75% |
Memory doesn't compress — tune to app behavior |
| ALB RequestCountPerTarget |
App-specific |
Better for latency-driven scaling than CPU |
| Custom metric (queue depth) |
App-specific |
Best for batch/queue-driven workloads |
Step 7 scheduled scaling CLI moved verbatim to references/diagnostic-commands.md.
Load on demand for predictable traffic patterns.
Step 8: Impact estimation
Step 8 impact estimation formula and assumptions moved verbatim to references/ecs-pricing-and-capacity-providers.md.
Load on demand when computing monthly and annual savings.
Step 9: Final verdict
- Any dimension recommends a change → FURTHER_OPTIMIZATION_AVAILABLE.
- All dimensions pass AND architecture on arm64 AND task right-sized AND
SP coverage in place → OPTIMIZED.
- Change applied and verified this session → OPTIMIZED (post-state).
- Data insufficient (Container Insights absent, window < 14 days) →
NEED_MORE_INFO.
Never emit FURTHER_OPTIMIZATION_AVAILABLE without first discharging
every NEED_MORE_INFO/BLOCKED gate.
Output format
TARGET: <service-name or task-definition>
VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE
REASON: <1-2 sentences naming the recommendation and the supporting data>
RECOMMENDATION:
Current: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>
Proposed: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>
Dimensions changed: <launch-type | architecture | right-size | spot | savings-plan | placement | autoscaling>
Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>
ESTIMATED_SAVINGS:
Monthly: $<amount>
Annual: $<amount>
Assumptions: <list (task count, pricing region, etc.)>
MIGRATION_STEPS:
1. <specific action with CLI command>
2. <verification step>
CONFIRM: Before executing any state-changing CLI, emit and await operator
approval: "CONFIRM: About to <action> on <service-name> in <cluster>.
Proceed? (yes/no)"
Full worked examples (launch type migration, Graviton2, right-sizing,
spot capacity provider, already-optimized, NEED_MORE_INFO, end-to-end
walkthrough) are in references/worked-examples.md.
STRICT output contract
The rules below are hard constraints. Violating any one produces a
misclassification or an arithmetic contradiction that breaks downstream
FinOps automation. Self-check EVERY emitted block against these rules
before returning the response.
Required output structure
Every response MUST be a single block using these literal labels, in this
order. Do NOT substitute markdown headings, camelCase, or bold variants.
TARGET: <service-name or task-definition>
VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE
REASON: <1-2 sentences naming the recommendation and the supporting data>
RECOMMENDATION:
Current: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>
Proposed: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>
Dimensions changed: <launch-type | architecture | right-size | spot | savings-plan | placement | autoscaling>
Dimensions checked: <list ALL seven, each ✓ (no finding) or → (finding)>
Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>
ESTIMATED_SAVINGS:
Current monthly: $<amount> ← MUST show subtotals (compute, storage, requests if applicable)
Projected monthly: $<amount>
Monthly saving: $<amount> ← MUST equal Current − Projected, 2 decimals
Annual saving: $<amount> ← MUST equal Monthly × 12
MIGRATION_STEPS:
1. <specific action with CLI command>
2. <verification step>
CONFIRM: <confirmation prompt text>
FORBIDDEN output patterns
NEVER emit VERDICT: FURTHER_OPTIMIZATION_AVAILABLE with Monthly saving: $0.00. If every dimension nets zero cost delta, the verdict
MUST be OPTIMIZED.
NEVER show savings math that does not balance.
Current monthly − Projected monthly MUST equal Monthly saving,
rounded to 2 decimal places.
NEVER emit scratch lines ("WAIT — recompute", "Hmm, let me redo",
"corrected:") in the output. Finalize the math before emitting.
NEVER recommend a Graviton2 (arm64) migration without citing the
application's compatibility evidence. The REASON MUST name the
verification source (interpreted runtime, arm64 wheels, multi-arch
container build).
NEVER omit a dimension from the RECOMMENDATION block. The
Dimensions checked line MUST list all seven dimensions, each marked
✓ (no finding) or → (finding).
NEVER recommend spot capacity without warning about interruption
risk and verifying the application handles graceful shutdown.
Surface the fault-tolerance requirement in MIGRATION_STEPS.
NEVER round intermediate formula steps differently from the final
figure. Compute at full precision, round only the displayed result.
Perfect example output — FURTHER_OPTIMIZATION_AVAILABLE with verified math
Every field below is internally consistent. Copy this shape exactly.
TARGET: order-api-prod
VERDICT: FURTHER_OPTIMIZATION_AVAILABLE
REASON: Fargate service at 1024 CPU / 2048 MB with avg CPUUtilization
12% and MemoryUtilization 18% across 8 running tasks. Two findings:
(1) right-size to 512 CPU / 1024 MB (Container Insights confirms
steady p95 utilization under 30% of allocated); (2) migrate from
x86_64 to arm64 (Node.js 20 — full arm64 support, no native deps).
Combined monthly saving: $172.97 (60% compute reduction).
RECOMMENDATION:
Current: FARGATE, 1.0 vCPU, 2.0 GB, x86_64, 8 tasks, on-demand
Proposed: FARGATE, 0.5 vCPU, 1.0 GB, arm64, 8 tasks, on-demand
Dimensions changed: right-size (Step 3) + architecture (Step 2)
Dimensions checked: launch-type ✓ (Fargate, < 30% utilization confirms Fargate)
architecture → (x86 to arm64) right-size → (1.0/2.0 to 0.5/1.0)
spot ✓ (Fargate, no spot) savings-plan ✓ (covered) placement ✓ (Fargate)
autoscaling ✓ (target tracking at 60% CPU)
Confidence: HIGH — Container Insights confirms 30-day avg CPUUtilization
12% and MemoryUtilization 18%; Node.js 20 fully supports arm64;
no native dependencies in container image.
ESTIMATED_SAVINGS:
Current monthly: $288.32
compute: 1.0 vCPU × 8 tasks × 730 hr × $0.04048 = $236.40
memory: 2.0 GB × 8 tasks × 730 hr × $0.004445 = $51.92
Projected monthly: $115.35
compute: 0.5 vCPU × 8 tasks × 730 hr × $0.03238 = $94.55
memory: 1.0 GB × 8 tasks × 730 hr × $0.003561 = $20.80
Monthly saving: $172.97 ($288.32 − $115.35)
Annual saving: $2,075.64
MIGRATION_STEPS:
1. Register new task definition with arm64 + right-sized resources:
aws ecs register-task-definition --family order-api
--runtime-platform cpuArchitecture=ARM64,operatingSystemFamily=LINUX
--cpu 512 --memory 1024 --container-definitions file://containers-arm64.json
2. Deploy via canary (Distributed Map or CodeDeploy):
aws ecs update-service --cluster prod-cluster
--service order-api-prod --task-definition order-api:43
3. Monitor CPUUtilization and MemoryUtilization for 7 days post-change.
4. Verify no OOM kills or throttle events in Container Insights.
CONFIRM: About to update-service on order-api-prod
(1.0 vCPU x86 → 0.5 vCPU arm64, 2.0 GB → 1.0 GB). Monthly saving
$172.97 (60.0%). Proceed? (yes/no)
Self-check before emit:
Verdict semantics
| Verdict |
When to emit |
FURTHER_OPTIMIZATION_AVAILABLE |
At least one dimension has a concrete, savings-bearing recommendation. |
OPTIMIZED |
All dimensions pass (arm64, right-sized, SP coverage, appropriate capacity provider). Also emitted when a change was applied and verified this session. |
NEED_MORE_INFO |
Data gate failed: Container Insights not enabled, metrics absent, window < 14 days. |
BLOCKED |
Hard precondition prevents evaluation: service in a different account, IAM denies ecs:DescribeServices. |
Zero-savings rule: If MONTHLY_SAVING == $0.00 for every dimension,
verdict MUST be OPTIMIZED, never FURTHER_OPTIMIZATION_AVAILABLE.
Exception: a latency or availability improvement without cost change is
surfaced in REASON, not as dollar savings.
Anti-Patterns — NEVER (top 5)
NEVER recommend a Graviton2 migration without verifying application
compatibility. Compiled binaries (C/C++, Go with CGO, Rust inline
assembly) and JNI libraries may fail on arm64. Always require
multi-arch container build verification before recommending.
NEVER recommend spot capacity for stateful single-instance services.
Spot reclamation causes task termination. Stateful services (databases,
caches with no replication) cannot tolerate interruption. Spot is for
stateless, horizontally scalable workloads only.
NEVER right-size a task definition below the application's actual
peak memory usage. Memory is not compressible — an OOM kill is a
production incident. Use p95 MemoryUtilization × 1.5 as the floor.
NEVER recommend migrating Fargate to EC2 without warning about the
operational overhead. EC2-backed ECS requires ASG management, AMI
patching, capacity provider tuning, and instance monitoring. The cost
saving is real but the operational burden is significant.
NEVER recommend a Savings Plan purchase without analyzing utilization
stability. An SP commits to $X/hour for 1-3 years. If the workload
is shrinking or migrating to a different service, the commitment
becomes wasted spend.
Extended anti-patterns in references/ecs-pricing-and-capacity-providers.md.
Pre-flight safety checks (run before any remediation CLI)
Pre-flight safety checks (CONFIRMATION GATE, canary, OOM rollback, SP irreversibility, batch limits) moved verbatim to references/diagnostic-commands.md.
Load on demand before executing any state-changing optimization CLI.
Recent AWS features (2024-2026)
Recent AWS features (2024-2026) moved verbatim to references/advanced-patterns.md.
Load on demand when evaluating Graviton GA, managed scaling enhancements, Container Insights, Service Connect, per-second billing, Graviton4.
References
references/ecs-pricing-and-capacity-providers.md — pricing tables,
Fargate valid CPU/memory combinations, Graviton2 compatibility matrix,
capacity provider configuration, Savings Plan discount tiers, regional
pricing multipliers, cost calculation worked examples.
references/worked-examples.md — full worked examples (launch type
migration, Graviton2, right-sizing, spot capacity provider,
already-optimized, NEED_MORE_INFO, end-to-end walkthrough).
References (load on demand)
- references/diagnostic-commands.md — required data sources, per-step migration CLI, and pre-flight safety checks moved from SKILL.md.
- references/advanced-patterns.md — quick-start rules, mindset, Step 0 billing behaviours, spot interruption handling, and recent AWS features moved from SKILL.md.
- references/ecs-pricing-and-capacity-providers.md — pricing tables, valid CPU/memory combinations, Savings Plan tiers, plus crossover math, compatibility matrix, and impact-estimation formula moved from SKILL.md.
- references/worked-examples.md — full worked examples (launch type migration, Graviton2, right-sizing, spot, already-optimized, NEED_MORE_INFO, end-to-end walkthrough).
Domain
AWS CloudOps / ECS Container Cost Optimization & FinOps.
AWS documentation
1---2name: ecs-task-cost-optimizer3description: 'Optimises Amazon ECS task cost across seven dimensions: launch type selection (Fargate per-second pricing vs EC2 break-even at ~30% steady utilization — EC2 wins for always-on workloads, Fargate wins for bursty or <30% utilization), Graviton2 (arm64) migration for 20% cost reduction with compatibility verification, task definition right-sizing via CloudWatch Container Insights CPU/memory utilization analysis, capacity provider strategy (spot base capacity + on-demand top for 30-70% spot savings), Savings Plan coverage mapping (compute SP applies to both Fargate and EC2-backed ECS), task placement bin-packing strategy (spread vs binpack for EC2 density), and auto-scaling target tracking tuning. Evaluates standalone task vs service scheduling, process vs daemon scheduling, EFS vs EBS persistent storage cost, and service auto-scaling vs scheduled scaling. Emits OPTIMIZED when all dimensions pass, or FURTHER_OPTIMIZATION_AVAILABLE with specific recommendation and estimated savings. Use when reviewing ECS spen...'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline recommendation classification works from pasted CloudWatch Container Insights metrics, task definition configs, and Cost Explorer findings. Live-account optimization uses aws ecs describe-services, aws ecs describe-tasks, aws ecs describe-task-definition, aws ecs describe-capacity-providers, aws cloudwatch get-metric-statistics (CPUUtilization, MemoryUtilization from ECS/ContainerInsights), aws ce...6metadata:7 source: https://skillmd.com/skills/jhkchan/ecs-task-cost-optimizer8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '3'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Compute15 task_type: optimize16 skill_class: capability17 lifecycle_status: active18 verdict_shape: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE19 when_to_use: Optimising ECS task cost, evaluating Fargate vs EC2 launch type crossover, planning a Graviton2 (arm64) task migration, right-sizing task definitions from Container Insights, designing capacity provider strategy (spot + on-demand), mapping Savings Plan coverage to ECS spend, tuning task placement bin-packing for EC2 density, or tuning auto-scaling target tracking for cost.20 when_not_to_use: EKS cost optimization (use eks-cost-optimizer), Fargate standalone cost optimization without ECS (use fargate-cost-optimizer), ECS task troubleshooting (container crashes, deployment failures, task lifecycle issues — use ecs-task-troubleshooter), or ECS task definition security auditing (use ecs-task-definition-auditor). This skill focuses on cost-driven optimization of ECS tasks, not functional debugging.21 activation_triggers: optimise ECS cost, ECS Fargate vs EC2, ECS launch type crossover, ECS Graviton2 migration, ECS arm64 compatibility, ECS task right-sizing, ECS task definition CPU memory, ECS capacity provider strategy, ECS spot capacity provider, ECS Savings Plan coverage, ECS task placement bin-packing, ECS Container Insights cost, ECS auto-scaling target tracking, ECS scheduled scaling, ECS standalone task vs service, ECS EFS vs EBS storage, ECS FinOps, reduce container bill, ECS cost review22 invocation_schema: 'Input: either (a) an ECS service/task identifier + live-account context, (b) a Cost Explorer ECS/Fargate charge breakdown, OR (c) CloudWatch Container Insights metrics (CPUUtilization, MemoryUtilization) with task definition details and at least 14 days of observation. Output: a deterministic TARGET/VERDICT/REASON/RECOMMENDATION/ ESTIMATED_SAVINGS/MIGRATION_STEPS block per service/task, where VERDICT is one of OPTIMIZED, FURTHER_OPTIMIZATION_AVAILABLE.'23 invocation_example: "# Minimal valid input (offline finding classification):\nServiceName: order-api-prod\nLaunchType: FARGATE\nTaskDefinition: order-api:42\nCPU: 1024 (1 vCPU)\nMemory: 2048 MB\nRegion: us-east-1\nArchitecture: x86_64\nMetrics (last 30 days):\n - CPUUtilization avg: 12%, p95: 25%\n - MemoryUtilization avg: 18%, p95: 30%\n - RunningTaskCount avg: 8\nCost (last month): $1,847.00 (Fargate compute)\nEmit the standard optimization block (TARGET, VERDICT, REASON,\nRECOMMENDATION, ESTIMATED_SAVINGS, MIGRATION_STEPS)."24 version: 0.1.025 author: Jacky Chan — AWS Community Builder26 keywords: ECS, Fargate, EC2 launch type, cost optimization, Graviton2, arm64, task definition, right-sizing, capacity provider, spot, on-demand, Savings Plan, bin-packing, task placement, Container Insights, auto-scaling, target tracking, scheduled scaling, EFS, EBS, FinOps, container cost27 tags: ecs, compute, containers, cost-optimization, finops, fargate, graviton, capacity-provider28---2930# ECS Task Cost Optimizer3132## What this skill does3334Translates an ECS task or service's runtime posture into a concrete35cost-optimization recommendation with a dollar-denominated savings36estimate. The verdict reflects the highest-leverage action across seven37dimensions — launch type, architecture, right-sizing, capacity provider38strategy, Savings Plan coverage, task placement, and auto-scaling —39applied in priority order. Always pairs the recommendation with exact40CLI commands or infrastructure-as-code snippets.4142## Quick navigation4344| Section | What it covers | When to jump here |45|---|---|---|46| Quick start | Four headline rules and the cost formula | First read |47| Mindset | Why launch type is the #1 lever | Understanding the approach |48| Quick reference — verdict thresholds | Decision matrix at a glance | Classifying a service |49| Pre-flight data gate | Container Insights, Cost Explorer | Before any recommendation |50| Step 0 non-obvious behaviours | Fargate billing, Graviton compat, SP scoping | Edge cases |51| Step 1 Launch type | Fargate vs EC2 crossover at ~30% | Always-on vs bursty |52| Step 2 Architecture (Graviton2) | arm64 20% discount + compat check | Cross-cutting savings |53| Step 3 Task right-sizing | CPU/memory from Container Insights | The headline savings dimension |54| Step 4 Capacity provider strategy | spot base + on-demand top | Spot savings |55| Step 5 Savings Plan coverage | Compute SP for Fargate + EC2 | Commitment discount |56| Step 6 Task placement & scheduling | binpack, spread, daemon, standalone | EC2 density |57| Step 7 Auto-scaling tuning | target tracking, scheduled scaling | Over-provisioning |58| Step 8 Impact estimation | The cost formula and worked math | Every recommendation |59| Output format | VERDICT block + worked examples | Emitting the result |60| Anti-Patterns — NEVER | Common misclassifications | Self-check before emit |61| Pre-flight safety checks | CONFIRM gate, canary deploy | Before any apply CLI |6263## Quick start6465Quick-start headline rules and the cost formula moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).66Load on demand for the Fargate/EC2 crossover rule, cost formulas, Graviton 20%, and spot strategy headline rules.6768## Mindset6970Mindset prose and the four guiding principles moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).71Load on demand when framing a recommendation (crossover, compounding right-sizing, commitment stacking, spot as strategy).7273## Quick reference — verdict thresholds7475| Observation (14-30 day window) | Verdict | Recommendation |76|---|---|---|77| Launch type = FARGATE AND steady utilization > 30% AND always-on service | **FURTHER_OPTIMIZATION_AVAILABLE** (launch type) | Step 1 — migrate to EC2-backed capacity provider |78| Launch type = EC2 AND steady utilization < 15% AND bursty/ephemeral workload | **FURTHER_OPTIMIZATION_AVAILABLE** (launch type) | Step 1 — migrate to Fargate |79| Architecture = x86_64 AND application is arm64-compatible (interpreted lang, arm64 native libs) | **FURTHER_OPTIMIZATION_AVAILABLE** (architecture) | Step 2 — migrate to arm64 (Graviton2) |80| CPUUtilization avg < 30% of allocated CPU AND task CPU > 256 (0.25 vCPU) | **FURTHER_OPTIMIZATION_AVAILABLE** (right-size) | Step 3 — reduce CPU allocation |81| MemoryUtilization avg < 30% of allocated memory AND task memory > 512 MB | **FURTHER_OPTIMIZATION_AVAILABLE** (right-size) | Step 3 — reduce memory allocation |82| No spot capacity provider configured AND workload is stateless/fault-tolerant | **FURTHER_OPTIMIZATION_AVAILABLE** (spot) | Step 4 — add spot base capacity provider |83| No Savings Plan covering ECS spend AND monthly ECS charge > $2,000 (steady) | **FURTHER_OPTIMIZATION_AVAILABLE** (commitment) | Step 5 — purchase Compute Savings Plan |84| EC2 cluster with spread placement AND avg instance utilization < 60% | **FURTHER_OPTIMIZATION_AVAILABLE** (placement) | Step 6 — switch to binpack placement |85| All dimensions verified AND architecture on arm64 AND task right-sized AND SP coverage in place | **OPTIMIZED** | None — continue monitoring |86| Container Insights metrics absent or window < 14 days | **NEED_MORE_INFO** | Enable Container Insights, wait 14 days |87| All dimensions verified AND a change was applied and confirmed this session | **OPTIMIZED** | Emit post-state verification |8889## Pre-flight: data gate (run before any optimization decision)9091Optimization decisions are only as good as the underlying data. Pull92these metrics before any recommendation. Full CLI sequences are in93`references/ecs-pricing-and-capacity-providers.md`.9495**Required data sources** (summarized — see reference for full CLI):96Required data-source listing moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).97Load on demand when pulling service config, Container Insights metrics, capacity providers, Savings Plan coverage, and Cost Explorer data.9899### Data-quality short-circuits100101| Condition | Effect on optimization |102|---|---|103| `CPUUtilization` metric absent (Container Insights not enabled) | **NEED_MORE_INFO**. Enable: `aws ecs update-cluster-settings --settings name=containerInsights,value=enabled`. |104| Metrics window < 14 days | **NEED_MORE_INFO**. Minimum 14 days; 30 days preferred. |105| `RunningTaskCount` Sum = 0 over 14 days | Emit **OPTIMIZED** with note "dormant service." |106| Service `desiredCount = 0` | Skip optimization; surface as dormant. |107| Cost Explorer breakdown absent | Proceed with Fargate pricing formula; mark MEDIUM confidence. |108| Savings Plan coverage API returns empty | No SP in place; use on-demand pricing. |109| Service uses external deployment controller | Verify controller before recommending changes. |110111When Container Insights and Cost Explorer disagree, Cost Explorer is112the ground truth for actual charges — metrics inform the optimization113lever, Cost Explorer confirms the dollar impact.114115## Process — Optimization logic (apply in order)116117### Step 0: Non-obvious behaviours that change the recommendation118119These billing-model and operational gotchas route a recommendation away120from the obvious choice:121122Step 0 non-obvious billing and operational behaviours moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).123Load on demand when a recommendation depends on a non-obvious behaviour (per-second billing, SP scoping, Container Insights cost, EFS vs EBS, daemon scheduling).124125### Step 1: Launch type selection — Fargate vs EC2 (the #1 lever)126127Launch type is the primary cost lever because Fargate charges a 30-50%128premium over EC2 for always-on workloads, while EC2 requires capacity129management overhead.130131Step 1 crossover math moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).132Load on demand when justifying a launch-type migration with dollar math.133134**Decision tree:**135```136Is the workload always-on (24/7 steady-state)?137├── NO (batch, cron, event-driven) → Fargate. Per-second billing wins.138└── YES → Is steady utilization > 30%?139 ├── NO → Fargate. You're paying for idle EC2 capacity.140 └── YES → Is the team willing to manage EC2 capacity (ASG, AMI, patching)?141 ├── NO → Fargate with Savings Plan (accept the premium for simplicity).142 └── YES → EC2-backed with capacity provider strategy. Save 30-50%.143```144145Step 1 capacity-provider creation CLI moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).146Load on demand when migrating a service to an EC2-backed capacity provider.147148### Step 2: Architecture migration — Graviton2 (arm64)149150Graviton2 (arm64) delivers ~20% cost reduction on both Fargate and EC2.151For Fargate, arm64 pricing is lower per vCPU and GB. For EC2, Graviton152instances (c7g, m7g, r7g) have lower hourly rates.153154Step 2 Fargate x86_64 vs arm64 pricing block moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).155Load on demand when quantifying the Graviton2 discount.156157Step 2 ARM64 compatibility table moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).158Load on demand when verifying an application's arm64 risk before recommending migration; the full matrix is in the same file.159160Step 2 arm64 migration CLI (register-task-definition + update-service) moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).161Load on demand when applying an architecture migration.162163See `references/ecs-pricing-and-capacity-providers.md` for the full164runtime ARM64 compatibility matrix.165166### Step 3: Task definition right-sizing167168Right-sizing is the second multiplier. An over-provisioned task wastes169money proportional to the over-allocation. Container Insights provides170CPU and memory utilization metrics for sizing decisions.171172**The right-sizing decision gate:**173174| Metric (14-30 day window) | Finding | Action |175|---|---|---|176| CPUUtilization avg < 20% AND allocated CPU > 256 (0.25 vCPU) | Over-provisioned | Reduce CPU to p90 × 1.5 (safety margin) |177| CPUUtilization avg > 80% sustained | Under-provisioned | Increase CPU (performance issue, not cost) |178| MemoryUtilization avg < 30% AND allocated memory > 512 MB | Over-provisioned | Reduce memory to p90 × 1.5 |179| MemoryUtilization avg > 85% | Under-provisioned | Increase memory (OOM risk) |180| CPUUtilization p95 > 70% with spikes to 100% | Near ceiling | Increase CPU or add tasks (scale out) |181182Step 3 right-sizing math and the partial CPU/memory combination table moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).183Load on demand when computing right-sizing savings or choosing a valid Fargate size.184185Fargate CPU and memory must be compatible. See the reference for the186full valid-combination table.187188### Step 4: Capacity provider strategy (spot + on-demand)189190Capacity providers define the infrastructure backing for EC2-launched191ECS tasks. A spot base + on-demand top strategy saves 30-70% for192fault-tolerant workloads.193194**Capacity provider strategy patterns:**195196| Pattern | Cost | When to use |197|---|---|---|198| 100% on-demand | Baseline (no discount) | Stateful, single-instance, cannot tolerate interruption |199| Spot base (70%) + on-demand top (30%) | 30-50% saving | Stateless web services, microservices, workers |200| 100% spot | 70% saving | Batch jobs, queue workers, fault-tolerant CI/CD |201| Spot + Fargate fallback | Mixed | Hybrid approach for critical periods |202203Step 4 spot capacity provider CLI moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).204Load on demand when applying a spot base + on-demand top strategy.205206Step 4 spot interruption handling notes moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).207Load on demand when recommending spot capacity (stopTimeout, SIGTERM handling, on-demand fallback).208209### Step 5: Savings Plan coverage210211Compute Savings Plans apply to both Fargate and EC2-backed ECS. They212commit to a $/hour spend in exchange for a discount (up to 54% for2131-year commitment, up to 72% for 3-year).214215Step 5 SP-vs-RI comparison table moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).216Load on demand when choosing a commitment vehicle.217218Step 5 SP coverage and utilization CLI moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).219Load on demand when measuring Savings Plan coverage.220221**Decision gate for SP purchase:**222223| Monthly ECS spend (on-demand) | Steady (>12 months)? | Recommendation |224|---|---|---|225| > $5,000 | YES | 1-year Compute SP at 50-70% coverage |226| > $10,000 | YES | 1-year Compute SP at 70-90% coverage (or 3-year for max discount) |227| < $2,000 | Any | SP overhead is not worth the commitment tracking |228| Any | NO (growing/shrinking fast) | Delay SP until spend stabilizes |229230### Step 6: Task placement and scheduling strategy231232Task placement strategy determines how tasks distribute across EC2233instances in an EC2-backed cluster. This affects instance density and234therefore cost.235236**Placement strategy comparison:**237238| Strategy | Effect | Cost impact | When to use |239|---|---|---|---|240| `spread` (default) | Distributes tasks across all instances | Lower density (more instances needed) | High-availability, fault-isolation |241| `binpack` | Packs tasks onto fewest instances | Higher density (fewer instances) | Cost optimization for stateless |242| `random` | No strategy | Unpredictable | Testing only |243244**Scheduling strategy comparison:**245246| Strategy | Effect | Cost impact |247|---|---|---|248| `REPLICA` (service) | Maintains desired count; auto-restarts | Always-on cost |249| `DAEMON` (service) | One task per instance | Scales with fleet size (use for agents) |250| Standalone task | Run once, no auto-restart | Per-invocation cost (batch jobs) |251252Step 6 bin-pack placement CLI moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).253Load on demand when increasing EC2 placement density.254255### Step 7: Auto-scaling target tracking256257Auto-scaling adjusts the desired task count based on a CloudWatch metric258target. Poorly tuned scaling policies cause over-provisioning (too many259tasks) or under-provisioning (SLO violations).260261**Target tracking tuning:**262263| Metric | Recommended target | Notes |264|---|---|---|265| ECS CPUUtilization | 50-65% | Lower = more tasks = more cost; higher = SLO risk |266| ECS MemoryUtilization | 60-75% | Memory doesn't compress — tune to app behavior |267| ALB RequestCountPerTarget | App-specific | Better for latency-driven scaling than CPU |268| Custom metric (queue depth) | App-specific | Best for batch/queue-driven workloads |269270Step 7 scheduled scaling CLI moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).271Load on demand for predictable traffic patterns.272273### Step 8: Impact estimation274275Step 8 impact estimation formula and assumptions moved verbatim to [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md).276Load on demand when computing monthly and annual savings.277278### Step 9: Final verdict279280- Any dimension recommends a change → **FURTHER_OPTIMIZATION_AVAILABLE**.281- All dimensions pass AND architecture on arm64 AND task right-sized AND282 SP coverage in place → **OPTIMIZED**.283- Change applied and verified this session → **OPTIMIZED** (post-state).284- Data insufficient (Container Insights absent, window < 14 days) →285 **NEED_MORE_INFO**.286287Never emit `FURTHER_OPTIMIZATION_AVAILABLE` without first discharging288every `NEED_MORE_INFO`/`BLOCKED` gate.289290## Output format291292```text293TARGET: <service-name or task-definition>294VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE295REASON: <1-2 sentences naming the recommendation and the supporting data>296RECOMMENDATION:297 Current: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>298 Proposed: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>299 Dimensions changed: <launch-type | architecture | right-size | spot | savings-plan | placement | autoscaling>300 Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>301ESTIMATED_SAVINGS:302 Monthly: $<amount>303 Annual: $<amount>304 Assumptions: <list (task count, pricing region, etc.)>305MIGRATION_STEPS:306 1. <specific action with CLI command>307 2. <verification step>308CONFIRM: Before executing any state-changing CLI, emit and await operator309 approval: "CONFIRM: About to <action> on <service-name> in <cluster>.310 Proceed? (yes/no)"311```312313Full worked examples (launch type migration, Graviton2, right-sizing,314spot capacity provider, already-optimized, NEED_MORE_INFO, end-to-end315walkthrough) are in `references/worked-examples.md`.316317## STRICT output contract318319The rules below are hard constraints. Violating any one produces a320misclassification or an arithmetic contradiction that breaks downstream321FinOps automation. Self-check EVERY emitted block against these rules322before returning the response.323324### Required output structure325326Every response MUST be a single block using these literal labels, in this327order. Do NOT substitute markdown headings, camelCase, or bold variants.328329```text330TARGET: <service-name or task-definition>331VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE332REASON: <1-2 sentences naming the recommendation and the supporting data>333RECOMMENDATION:334 Current: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>335 Proposed: <launch type>, <CPU> vCPU, <memory> GB, <architecture>, <task count>, <capacity provider>336 Dimensions changed: <launch-type | architecture | right-size | spot | savings-plan | placement | autoscaling>337 Dimensions checked: <list ALL seven, each ✓ (no finding) or → (finding)>338 Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>339ESTIMATED_SAVINGS:340 Current monthly: $<amount> ← MUST show subtotals (compute, storage, requests if applicable)341 Projected monthly: $<amount>342 Monthly saving: $<amount> ← MUST equal Current − Projected, 2 decimals343 Annual saving: $<amount> ← MUST equal Monthly × 12344MIGRATION_STEPS:345 1. <specific action with CLI command>346 2. <verification step>347CONFIRM: <confirmation prompt text>348```349350### FORBIDDEN output patterns3513521. **NEVER emit `VERDICT: FURTHER_OPTIMIZATION_AVAILABLE` with `Monthly353 saving: $0.00`.** If every dimension nets zero cost delta, the verdict354 MUST be `OPTIMIZED`.3553562. **NEVER show savings math that does not balance.**357 `Current monthly − Projected monthly` MUST equal `Monthly saving`,358 rounded to 2 decimal places.3593603. **NEVER emit scratch lines** ("WAIT — recompute", "Hmm, let me redo",361 "corrected:") in the output. Finalize the math before emitting.3623634. **NEVER recommend a Graviton2 (arm64) migration without citing the364 application's compatibility evidence.** The REASON MUST name the365 verification source (interpreted runtime, arm64 wheels, multi-arch366 container build).3673685. **NEVER omit a dimension from the RECOMMENDATION block.** The369 `Dimensions checked` line MUST list all seven dimensions, each marked370 ✓ (no finding) or → (finding).3713726. **NEVER recommend spot capacity without warning about interruption373 risk and verifying the application handles graceful shutdown.**374 Surface the fault-tolerance requirement in MIGRATION_STEPS.3753767. **NEVER round intermediate formula steps differently from the final377 figure.** Compute at full precision, round only the displayed result.378379### Perfect example output — FURTHER_OPTIMIZATION_AVAILABLE with verified math380381Every field below is internally consistent. Copy this shape exactly.382383```text384TARGET: order-api-prod385VERDICT: FURTHER_OPTIMIZATION_AVAILABLE386REASON: Fargate service at 1024 CPU / 2048 MB with avg CPUUtilization387 12% and MemoryUtilization 18% across 8 running tasks. Two findings:388 (1) right-size to 512 CPU / 1024 MB (Container Insights confirms389 steady p95 utilization under 30% of allocated); (2) migrate from390 x86_64 to arm64 (Node.js 20 — full arm64 support, no native deps).391 Combined monthly saving: $172.97 (60% compute reduction).392RECOMMENDATION:393 Current: FARGATE, 1.0 vCPU, 2.0 GB, x86_64, 8 tasks, on-demand394 Proposed: FARGATE, 0.5 vCPU, 1.0 GB, arm64, 8 tasks, on-demand395 Dimensions changed: right-size (Step 3) + architecture (Step 2)396 Dimensions checked: launch-type ✓ (Fargate, < 30% utilization confirms Fargate)397 architecture → (x86 to arm64) right-size → (1.0/2.0 to 0.5/1.0)398 spot ✓ (Fargate, no spot) savings-plan ✓ (covered) placement ✓ (Fargate)399 autoscaling ✓ (target tracking at 60% CPU)400 Confidence: HIGH — Container Insights confirms 30-day avg CPUUtilization401 12% and MemoryUtilization 18%; Node.js 20 fully supports arm64;402 no native dependencies in container image.403ESTIMATED_SAVINGS:404 Current monthly: $288.32405 compute: 1.0 vCPU × 8 tasks × 730 hr × $0.04048 = $236.40406 memory: 2.0 GB × 8 tasks × 730 hr × $0.004445 = $51.92407 Projected monthly: $115.35408 compute: 0.5 vCPU × 8 tasks × 730 hr × $0.03238 = $94.55409 memory: 1.0 GB × 8 tasks × 730 hr × $0.003561 = $20.80410 Monthly saving: $172.97 ($288.32 − $115.35)411 Annual saving: $2,075.64412MIGRATION_STEPS:413 1. Register new task definition with arm64 + right-sized resources:414 aws ecs register-task-definition --family order-api415 --runtime-platform cpuArchitecture=ARM64,operatingSystemFamily=LINUX416 --cpu 512 --memory 1024 --container-definitions file://containers-arm64.json417 2. Deploy via canary (Distributed Map or CodeDeploy):418 aws ecs update-service --cluster prod-cluster419 --service order-api-prod --task-definition order-api:43420 3. Monitor CPUUtilization and MemoryUtilization for 7 days post-change.421 4. Verify no OOM kills or throttle events in Container Insights.422CONFIRM: About to update-service on order-api-prod423 (1.0 vCPU x86 → 0.5 vCPU arm64, 2.0 GB → 1.0 GB). Monthly saving424 $172.97 (60.0%). Proceed? (yes/no)425```426427**Self-check before emit:**428- [ ] `Current monthly − Projected monthly == Monthly saving` (2 decimals)?429- [ ] `Monthly saving × 12 == Annual saving`?430- [ ] All seven dimensions listed in `Dimensions checked`?431- [ ] Every `→` dimension has a corresponding MIGRATION_STEPS entry?432- [ ] No scratch/recompute text in the block?433434## Verdict semantics435436| Verdict | When to emit |437|---|---|438| `FURTHER_OPTIMIZATION_AVAILABLE` | At least one dimension has a concrete, savings-bearing recommendation. |439| `OPTIMIZED` | All dimensions pass (arm64, right-sized, SP coverage, appropriate capacity provider). Also emitted when a change was applied and verified this session. |440| `NEED_MORE_INFO` | Data gate failed: Container Insights not enabled, metrics absent, window < 14 days. |441| `BLOCKED` | Hard precondition prevents evaluation: service in a different account, IAM denies ecs:DescribeServices. |442443**Zero-savings rule:** If MONTHLY_SAVING == $0.00 for every dimension,444verdict MUST be `OPTIMIZED`, never `FURTHER_OPTIMIZATION_AVAILABLE`.445Exception: a latency or availability improvement without cost change is446surfaced in REASON, not as dollar savings.447448## Anti-Patterns — NEVER (top 5)4494501. **NEVER recommend a Graviton2 migration without verifying application451 compatibility.** Compiled binaries (C/C++, Go with CGO, Rust inline452 assembly) and JNI libraries may fail on arm64. Always require453 multi-arch container build verification before recommending.4544552. **NEVER recommend spot capacity for stateful single-instance services.**456 Spot reclamation causes task termination. Stateful services (databases,457 caches with no replication) cannot tolerate interruption. Spot is for458 stateless, horizontally scalable workloads only.4594603. **NEVER right-size a task definition below the application's actual461 peak memory usage.** Memory is not compressible — an OOM kill is a462 production incident. Use p95 MemoryUtilization × 1.5 as the floor.4634644. **NEVER recommend migrating Fargate to EC2 without warning about the465 operational overhead.** EC2-backed ECS requires ASG management, AMI466 patching, capacity provider tuning, and instance monitoring. The cost467 saving is real but the operational burden is significant.4684695. **NEVER recommend a Savings Plan purchase without analyzing utilization470 stability.** An SP commits to $X/hour for 1-3 years. If the workload471 is shrinking or migrating to a different service, the commitment472 becomes wasted spend.473474Extended anti-patterns in `references/ecs-pricing-and-capacity-providers.md`.475476## Pre-flight safety checks (run before any remediation CLI)477478Pre-flight safety checks (CONFIRMATION GATE, canary, OOM rollback, SP irreversibility, batch limits) moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).479Load on demand before executing any state-changing optimization CLI.480481## Recent AWS features (2024-2026)482483Recent AWS features (2024-2026) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).484Load on demand when evaluating Graviton GA, managed scaling enhancements, Container Insights, Service Connect, per-second billing, Graviton4.485486## References487488- `references/ecs-pricing-and-capacity-providers.md` — pricing tables,489 Fargate valid CPU/memory combinations, Graviton2 compatibility matrix,490 capacity provider configuration, Savings Plan discount tiers, regional491 pricing multipliers, cost calculation worked examples.492- `references/worked-examples.md` — full worked examples (launch type493 migration, Graviton2, right-sizing, spot capacity provider,494 already-optimized, NEED_MORE_INFO, end-to-end walkthrough).495496## References (load on demand)497498- [references/diagnostic-commands.md](references/diagnostic-commands.md) — required data sources, per-step migration CLI, and pre-flight safety checks moved from SKILL.md.499- [references/advanced-patterns.md](references/advanced-patterns.md) — quick-start rules, mindset, Step 0 billing behaviours, spot interruption handling, and recent AWS features moved from SKILL.md.500- [references/ecs-pricing-and-capacity-providers.md](references/ecs-pricing-and-capacity-providers.md) — pricing tables, valid CPU/memory combinations, Savings Plan tiers, plus crossover math, compatibility matrix, and impact-estimation formula moved from SKILL.md.501- [references/worked-examples.md](references/worked-examples.md) — full worked examples (launch type migration, Graviton2, right-sizing, spot, already-optimized, NEED_MORE_INFO, end-to-end walkthrough).502503## Domain504505AWS CloudOps / ECS Container Cost Optimization & FinOps.506507## AWS documentation508509- **Amazon ECS Developer Guide** — https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html510- **AWS Fargate pricing** — https://aws.amazon.com/fargate/pricing/511- **ECS capacity providers** — https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-capacity-providers.html512- **ECS task definition parameters** — https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html513- **CloudWatch Container Insights** — https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights.html514- **ECS service auto-scaling** — https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html515- **AWS Graviton for ECS** — https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-graviton.html516- **Savings Plans** — https://docs.aws.amazon.com/savingsplans/latest/userguide/517- **AWS CLI ECS reference** — https://docs.aws.amazon.com/cli/latest/reference/ecs/518- **Well-Architected Cost Optimization** — https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/welcome.html