DEV Community

Maya Lee
Maya Lee

Posted on

초기 단계에서 CloudFront와 ALB 없이 ECS + RDS만으로 운영해도 괜찮을까요?

ECS Apps + RDS 직접 구성

가능한 시나리오

1. ECS에서 직접 HTTP 서빙

# ECS Task Definition
services:
  app:
    image: your-nextjs-app
    ports:
      - "80:3000"  # Next.js 기본 포트
    environment:
      - DATABASE_URL=postgresql://user:pass@rds-endpoint:5432/db
Enter fullscreen mode Exit fullscreen mode

2. Route 53으로 도메인 직접 연결

your-domain.com → ECS 퍼블릭 IP
Enter fullscreen mode Exit fullscreen mode

3. ECS Service에서 퍼블릭 IP 할당

# ECS Service 설정
network_configuration:
  subnets:
    - subnet-public-1a
    - subnet-public-1b
  security_groups:
    - sg-web-app
  assign_public_ip: ENABLED  # 중요!
Enter fullscreen mode Exit fullscreen mode

장점

단순함

  • 인프라 복잡도 최소화
  • 비용 절약 ($200-400/월)
  • 빠른 배포와 테스트

개발 편의성

  • 로컬과 동일한 구조
  • 디버깅 쉬움
  • 설정 최소화

단점과 한계

보안

❌ SSL 인증서 직접 관리 필요
❌ DDoS 보호 없음
❌ 방화벽 설정 복잡
Enter fullscreen mode Exit fullscreen mode

성능

❌ CDN 없어서 정적 파일 느림
❌ 단일 리전만 서빙
❌ 캐싱 레이어 없음
Enter fullscreen mode Exit fullscreen mode

확장성

❌ 트래픽 급증시 대응 어려움
❌ 로드 밸런싱 수동 설정
❌ Health Check 제한적
Enter fullscreen mode Exit fullscreen mode

실제 구성 예시

1. ECS Cluster 생성

# Fargate 클러스터
aws ecs create-cluster --cluster-name academy-cms
Enter fullscreen mode Exit fullscreen mode

2. Task Definition

{
  "family": "academy-cms-task",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "1024",
  "memory": "2048",
  "containerDefinitions": [
    {
      "name": "web-app",
      "image": "your-account.dkr.ecr.region.amazonaws.com/academy-cms:latest",
      "portMappings": [
        {
          "containerPort": 3000,
          "protocol": "tcp"
        }
      ],
      "environment": [
        {
          "name": "DATABASE_URL",
          "value": "postgresql://user:pass@rds-endpoint:5432/academy"
        },
        {
          "name": "NODE_ENV",
          "value": "production"
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

3. Service 생성

aws ecs create-service \
  --cluster academy-cms \
  --service-name web-service \
  --task-definition academy-cms-task \
  --desired-count 2 \
  --launch-type FARGATE \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx],assignPublicIp=ENABLED}"
Enter fullscreen mode Exit fullscreen mode

추후 확장 경로

1단계: 현재

ECS Apps ← → RDS
Enter fullscreen mode Exit fullscreen mode

2단계: 로드밸런서 추가

ALB ← → ECS Apps ← → RDS
Enter fullscreen mode Exit fullscreen mode

3단계: CDN 추가

CloudFront ← → ALB ← → ECS Apps ← → RDS
Enter fullscreen mode Exit fullscreen mode

주의사항

1. SSL/TLS 설정

// Next.js에서 HTTPS 리다이렉트
module.exports = {
  async redirects() {
    return [
      {
        source: '/(.*)',
        has: [
          {
            type: 'header',
            key: 'x-forwarded-proto',
            value: 'http',
          },
        ],
        destination: 'https://yourdomain.com/$1',
        permanent: true,
      },
    ];
  },
};
Enter fullscreen mode Exit fullscreen mode

2. Health Check

// pages/api/health.js
export default function handler(req, res) {
  res.status(200).json({ 
    status: 'healthy',
    timestamp: new Date().toISOString(),
    uptime: process.uptime()
  });
}
Enter fullscreen mode Exit fullscreen mode

3. 환경변수 보안

# AWS Parameter Store 사용 권장
aws ssm put-parameter \
  --name "/academy-cms/database-url" \
  --value "postgresql://..." \
  --type "SecureString"
Enter fullscreen mode Exit fullscreen mode

결론

ECS + RDS만으로도 1000명 정도는 충분히 처리 가능합니다. 다만 트래픽이 늘어나면 CloudFront와 ALB를 점진적으로 추가하는 것을 권장합니다.


클로드가 준 답변 어느정도 신뢰 할 수 있을까요?

Top comments (0)