AWS Cost Optimization Strategies(1) VGNSHLVNZ AWS Cost Optimization Strategies(1)

NAME

VGNSHLVNZ - cloud-native unix manual pages

AWS Cost Optimization Strategies

2025-01-14

NAME

aws-cost-optimization - strategies for running lean cloud infrastructure

SYNOPSIS

aws-cost-optimization [--aggressive] [--monitoring] [--lifecycle]

DESCRIPTION

Running applications on AWS doesn't have to be expensive. With careful architecture and strategic use of free tiers, you can host production applications for just a few dollars per month.

This post outlines the strategies used to keep vgnshlv.nz running for under $2/month while serving thousands of visitors.

OPTIONS

--aggressive-caching

The most impactful cost reduction strategy is aggressive caching:

  • CloudFront TTL: 7 days default, 1 year maximum
  • Browser Cache: 1 day minimum for HTML
  • S3 Standard-IA: Archive content after 90 days

Impact: Reduces CloudFront costs by 80-90%

--free-tier-maximization

AWS provides generous free tiers:

Service Free Tier Strategy
Lambda 1M requests Use for APIs, analytics
CloudWatch 5GB logs Centralize logging
DynamoDB 25GB storage Metadata storage
S3 5GB storage Content storage

Impact: $0 cost for compute and storage within limits

--client-side-processing

Move processing to the client:

  • Search: Pagefind (client-side) instead of Elasticsearch (~$50/month savings)
  • Analytics: CloudWatch + Lambda@Edge instead of third-party (~$10/month savings)
  • Rendering: Static HTML instead of server-side (~$20/month savings)

Impact: Eliminates most API costs

--lifecycle-policies

Implement S3 lifecycle rules:

lifecycle_rules:
  - After 90 days: Standard → Standard-IA (50% cheaper)
  - After 180 days: Standard-IA → Glacier IR (75% cheaper)
  - After 365 days: Delete preview builds

Impact: 40-50% reduction in storage costs

--regional-optimization

Use appropriate AWS regions:

  • CloudFront: PriceClass_100 (US, CA, EU only)
  • S3: Single region (us-east-1 for CloudFront)
  • Lambda@Edge: Minimal memory (128MB)

Impact: 30% reduction in transfer costs

COST TRACKING

Implement monitoring to catch cost anomalies:

# Daily cost check
aws ce get-cost-and-usage \
  --time-period Start=2025-01-01,End=2025-01-31 \
  --granularity DAILY \
  --metrics BlendedCost

# Budget alerts
aws budgets create-budget \
  --budget-name monthly-limit \
  --budget-limit Amount=10,Unit=USD \
  --notifications threshold=80

REAL-WORLD RESULTS

For vgnshlv.nz with:

  • 5GB content
  • 50 blog posts
  • 10k pageviews/month
  • Full-text search
  • Real-time analytics

Monthly cost: $1.47

Breakdown:

S3 Storage:      $0.12 (5GB)
CloudFront:      $0.85 (10k requests, 90% cache hit)
Route53:         $0.50 (hosted zone)
Lambda:          $0.00 (within free tier)
CloudWatch:      $0.00 (within free tier)

ANTI-PATTERNS

Avoid these cost traps:

  1. NAT Gateways - $35/month minimum, use public subnets
  2. ElastiCache - $15/month minimum, use client-side caching
  3. RDS - $15/month minimum, use DynamoDB or static files
  4. OpenSearch - $50/month minimum, use Pagefind
  5. Load Balancers - $17/month, use CloudFront directly

SEE ALSO

AUTHOR

vgnshlvnz - Running production on pennies since 2025