Skip to content

opensite-ai/opensite-skills / aws-billing-and-cost-management

aws-billing-and-cost-management

Verified

Analyze AWS costs, find savings, manage budgets, evaluate Savings Plans and Reserved Instances, right-size EC2/Lambda/RDS/EBS with Compute Optimizer, look up service pricing, query CUR with Athena, detect cost anomalies, scope costs to billing views, and monitor Free Tier usage. Triggers on: AWS bill, cost analysis, reduce spend, savings plan, reserved instance, right-size, budget alert, cost optimization, pricing, free tier, cost anomaly, CUR, cost audit, billing view, billing view ARN.

references/lambda-optimization.md

View on GitHub
# Lambda Optimization

> **Pricing note:** All prices shown are us-east-1 approximate as of early 2026. Prices vary by region and may change. Always verify current pricing via the Price List API before reporting to users.

## Memory-CPU Relationship

Lambda allocates CPU proportional to memory:
- 1,769 MB = 1 full vCPU
- 10,240 MB = 6 vCPUs

Over-provisioning memory gives more CPU, which can reduce duration enough to lower total cost. Cost = Invocations × Duration(ms) × Memory(GB) × Price/GB-ms + Request charges.

## Compute Optimizer for Lambda

**Requirements:** ≤1,792 MB memory AND ≥50 invocations in the lookback period.

Metrics analyzed: Invocations, Duration, Errors, Throttles, Memory Utilization. The engine simulates candidate memory sizes, projects duration, and selects the size that finishes within timeout and produces greatest monthly savings.

Findings: `NotOptimized` (can be improved), `Optimized`, `Unavailable` (insufficient data). Note: Lambda and EC2 use different finding value sets. Lambda: `NotOptimized`/`Optimized`/`Unavailable`. EC2: `Overprovisioned`/`Underprovisioned`/`Optimized`/`NotOptimized`.

```bash
aws compute-optimizer get-lambda-function-recommendations \
  --filters Name=Finding,Values=NotOptimized
```

## Optimization Levers

| Strategy | Savings | Effort |
|----------|---------|--------|
| Switch to arm64 (Graviton) | ~20% cost + ~10-15% faster | Low — config change |
| Right-size memory with Power Tuning | 10-50% | Medium |
| Use SnapStart (Java/Python/.NET) | Eliminates provisioned concurrency cost | Low |

```bash
# Switch to arm64
aws lambda update-function-configuration \
  --function-name my-function --architectures arm64
```

## Gotchas

- arm64 not available in all regions; native compiled dependencies need arm64 builds
- Reserved concurrency (free) ≠ Provisioned concurrency (paid) — most common Lambda cost confusion
- Provisioned concurrency costs ~$0.015/GB-hour even when idle — use SnapStart instead where possible
- Lambda needs 14 days of CloudWatch metrics before Compute Optimizer generates recommendations
- Use `alexcasalboni/aws-lambda-power-tuning` Step Functions state machine for systematic memory optimization
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall