클라우드 비용 최적화
클라우드 비용은 방치하면 계속 늘어납니다. 사용하지 않는 리소스 제거 → Right-sizing → 구매 방식 최적화 순서로 접근하면 30~60% 절감이 가능합니다.
비용 절감 우선순위
Section titled “비용 절감 우선순위”1순위: 미사용 리소스 제거 (즉시 효과, 리스크 없음)2순위: Right-sizing (과잉 스펙 축소)3순위: Reserved / Savings Plans 구매4순위: Spot 인스턴스 전환항상 위 순서대로 진행하세요. 아직 불필요한 리소스가 남아있는데 Reserved를 구매하면 낭비입니다.
미사용 리소스 제거
Section titled “미사용 리소스 제거”# AWS — 연결되지 않은 EBS 볼륨 찾기aws ec2 describe-volumes \ --filters Name=status,Values=available \ --query 'Volumes[*].[VolumeId,Size,CreateTime]'
# 사용하지 않는 Elastic IP 찾기aws ec2 describe-addresses \ --query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]'
# 오래된 스냅샷 찾기 (90일 이상)aws ec2 describe-snapshots --owner-ids self \ --query 'Snapshots[?StartTime<=`2024-01-01`].[SnapshotId,StartTime,VolumeSize]'Right-sizing
Section titled “Right-sizing”CPU/메모리 사용률 확인
Section titled “CPU/메모리 사용률 확인”# AWS CloudWatch — 최근 2주 평균 CPU 사용률aws cloudwatch get-metric-statistics \ --metric-name CPUUtilization \ --namespace AWS/EC2 \ --dimensions Name=InstanceId,Value=i-1234567890abcdef0 \ --start-time 2024-01-01T00:00:00Z \ --end-time 2024-01-15T00:00:00Z \ --period 86400 \ --statistics AverageRight-sizing 기준:
| 평균 CPU | 조치 |
|---|---|
| < 10% | 즉시 다운사이징 |
| 10~30% | 한 단계 축소 검토 |
| 30~70% | 적정 수준 |
| > 70% | 업사이징 또는 스케일 아웃 검토 |
Kubernetes Right-sizing
Section titled “Kubernetes Right-sizing”VPA의 권장값을 requests에 반영합니다.
# VPA 권장값 확인kubectl describe vpa <vpa-name> | grep -A 10 "Recommendation"
# 실제 사용률 대비 requests 비율 확인kubectl top pods --containers | awk '{print $1, $2, $3}'Reserved Instances / Savings Plans
Section titled “Reserved Instances / Savings Plans”운영 환경의 베이스라인 트래픽은 Reserved로 구매하는 것이 유리합니다.
| 구매 옵션 | 할인율 | 조건 |
|---|---|---|
| On-Demand | 0% | 언제든 중단 가능 |
| 1년 Reserved (선불 없음) | ~30% | 1년 약정 |
| 1년 Reserved (전액 선불) | ~40% | 1년 약정, 선불 |
| 3년 Reserved (전액 선불) | ~60% | 3년 약정, 선불 |
| Savings Plans (Compute) | ~66% | 유연한 인스턴스 패밀리 |
구매 전 확인:
최근 3개월 On-Demand 사용량 → 항상 사용되는 최솟값 → 그 값만큼만 Reserved 구매Spot 인스턴스
Section titled “Spot 인스턴스”On-Demand 대비 최대 90% 저렴하지만, 언제든 중단될 수 있습니다.
적합한 워크로드:
- 배치 처리 (데이터 분석, 이미지 변환)
- CI/CD 빌드 서버
- 부하테스트 실행 환경
- Stateless 웹 서버 (중단 허용 시)
# Terraform — Spot 인스턴스 설정resource "aws_instance" "batch_worker" { instance_type = "c5.2xlarge"
instance_market_options { market_type = "spot" spot_options { max_price = "0.10" # 시간당 최대 입찰가 instance_interruption_behavior = "terminate" } }}개발/스테이징 환경 자동 종료
Section titled “개발/스테이징 환경 자동 종료”업무 시간 외 개발 환경을 자동으로 종료합니다.
import boto3import datetime
def stop_dev_instances(event, context): ec2 = boto3.client('ec2')
# 태그가 env=dev인 인스턴스 종료 instances = ec2.describe_instances( Filters=[ {'Name': 'tag:env', 'Values': ['dev', 'staging']}, {'Name': 'instance-state-name', 'Values': ['running']} ] )
instance_ids = [ i['InstanceId'] for r in instances['Reservations'] for i in r['Instances'] ]
if instance_ids: ec2.stop_instances(InstanceIds=instance_ids) print(f"Stopped {len(instance_ids)} dev instances")AWS Lambda + EventBridge로 평일 오후 8시에 실행하면 됩니다.
비용 모니터링
Section titled “비용 모니터링”AWS Cost Explorer:- 서비스별, 태그별 비용 분석- 비정상적인 비용 급증 알림 (Anomaly Detection)
월별 예산 알림 설정:# AWS Budget 알림 — 예산 80% 초과 시 이메일aws budgets create-budget \ --account-id 123456789012 \ --budget '{ "BudgetName": "monthly-cost-alert", "BudgetLimit": {"Amount": "1000", "Unit": "USD"}, "TimeUnit": "MONTHLY", "BudgetType": "COST" }'비용 태깅 규칙:
필수 태그: env: prod / staging / dev team: backend / frontend / data service: api / batch / db태그 없이는 어디서 비용이 발생하는지 파악이 불가능합니다.
이 가이드를 내 서비스에 직접 적용해 보세요.
TestForge 무료 스캔 시작 →