mirror of
https://github.com/ktds-dg0501/kt-event-marketing.git
synced 2025-12-06 17:26:23 +00:00
✨ 주요 기능 - Azure 기반 물리아키텍처 설계 (개발환경/운영환경) - 7개 마이크로서비스 물리 구조 설계 - 네트워크 아키텍처 다이어그램 작성 (Mermaid) - 환경별 비교 분석 및 마스터 인덱스 문서 📁 생성 파일 - design/backend/physical/physical-architecture.md (마스터) - design/backend/physical/physical-architecture-dev.md (개발환경) - design/backend/physical/physical-architecture-prod.md (운영환경) - design/backend/physical/*.mmd (4개 Mermaid 다이어그램) 🎯 핵심 성과 - 비용 최적화: 개발환경 월 $143, 운영환경 월 $2,860 - 확장성: 개발환경 100명 → 운영환경 10,000명 (100배) - 가용성: 개발환경 95% → 운영환경 99.9% - 보안: 다층 보안 아키텍처 (L1~L4) 🛠️ 기술 스택 - Azure Kubernetes Service (AKS) - Azure Database for PostgreSQL Flexible - Azure Cache for Redis Premium - Azure Service Bus Premium - Application Gateway + WAF 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
255 lines
8.4 KiB
Plaintext
255 lines
8.4 KiB
Plaintext
-- =====================================================
|
|
-- AI Service Redis 캐시 설정 스크립트
|
|
-- =====================================================
|
|
-- 설명: AI Service는 PostgreSQL을 사용하지 않고
|
|
-- Redis 캐시만을 사용하는 Stateless 서비스입니다.
|
|
-- 이 파일은 Redis 설정 가이드를 제공합니다.
|
|
-- =====================================================
|
|
|
|
-- =====================================================
|
|
-- 1. Redis 서버 설정 (redis.conf)
|
|
-- =====================================================
|
|
|
|
-- 메모리 설정
|
|
-- maxmemory 1gb
|
|
-- maxmemory-policy volatile-lru
|
|
|
|
-- 영속성 설정 (선택사항: 캐시 복구용)
|
|
-- save 900 1
|
|
-- save 300 10
|
|
-- save 60 10000
|
|
|
|
-- 네트워크 설정
|
|
-- bind 0.0.0.0
|
|
-- port 6379
|
|
-- timeout 0
|
|
-- tcp-keepalive 300
|
|
|
|
-- 보안 설정
|
|
-- requirepass your-strong-password-here
|
|
-- rename-command FLUSHDB ""
|
|
-- rename-command FLUSHALL ""
|
|
-- rename-command CONFIG ""
|
|
|
|
-- =====================================================
|
|
-- 2. Redis 키 네임스페이스 정의
|
|
-- =====================================================
|
|
|
|
-- 캐시 키 패턴:
|
|
-- ai:recommendation:{eventId} - AI 추천 결과 (TTL: 3600초)
|
|
-- ai:job:status:{jobId} - 작업 상태 (TTL: 86400초)
|
|
-- ai:trend:{industry}:{region} - 트렌드 분석 (TTL: 86400초)
|
|
|
|
-- =====================================================
|
|
-- 3. Redis 초기화 명령 (Redis CLI)
|
|
-- =====================================================
|
|
|
|
-- 3.1 기존 캐시 삭제 (개발 환경 초기화)
|
|
-- redis-cli -h localhost -p 6379 -a your-password FLUSHDB
|
|
|
|
-- 3.2 샘플 데이터 삽입 (테스트용)
|
|
|
|
-- 샘플 AI 추천 결과
|
|
-- SETEX ai:recommendation:123e4567-e89b-12d3-a456-426614174000 3600 '{
|
|
-- "eventId": "123e4567-e89b-12d3-a456-426614174000",
|
|
-- "trendAnalysis": {
|
|
-- "industryTrends": [
|
|
-- {"keyword": "친환경", "relevance": 0.95, "description": "지속가능성 트렌드"}
|
|
-- ],
|
|
-- "regionalTrends": [
|
|
-- {"keyword": "로컬 맛집", "relevance": 0.88, "description": "지역 특산물 선호"}
|
|
-- ],
|
|
-- "seasonalTrends": [
|
|
-- {"keyword": "겨울 따뜻함", "relevance": 0.82, "description": "따뜻한 음식 선호"}
|
|
-- ]
|
|
-- },
|
|
-- "recommendations": [
|
|
-- {
|
|
-- "optionNumber": 1,
|
|
-- "concept": "따뜻한 겨울 이벤트",
|
|
-- "title": "겨울 특선 메뉴 프로모션",
|
|
-- "description": "겨울철 인기 메뉴 할인",
|
|
-- "targetAudience": "20-40대 직장인",
|
|
-- "duration": {"recommendedDays": 14, "recommendedPeriod": "평일 점심"},
|
|
-- "mechanics": {"type": "DISCOUNT", "details": "메인 메뉴 20% 할인"},
|
|
-- "promotionChannels": ["instagram", "naver_blog"],
|
|
-- "estimatedCost": {"min": 500000, "max": 1000000, "breakdown": {"promotion": 300000, "discount": 700000}},
|
|
-- "expectedMetrics": {
|
|
-- "newCustomers": {"min": 50.0, "max": 100.0},
|
|
-- "revenueIncrease": {"min": 15.0, "max": 25.0},
|
|
-- "roi": {"min": 150.0, "max": 200.0}
|
|
-- },
|
|
-- "differentiator": "지역 특산물 사용으로 차별화"
|
|
-- }
|
|
-- ],
|
|
-- "generatedAt": "2025-10-29T10:00:00",
|
|
-- "expiresAt": "2025-10-29T11:00:00",
|
|
-- "aiProvider": "CLAUDE"
|
|
-- }'
|
|
|
|
-- 샘플 작업 상태
|
|
-- SETEX ai:job:status:job-001 86400 '{
|
|
-- "jobId": "job-001",
|
|
-- "status": "PROCESSING",
|
|
-- "progress": 50,
|
|
-- "message": "트렌드 분석 중...",
|
|
-- "createdAt": "2025-10-29T10:00:00"
|
|
-- }'
|
|
|
|
-- 샘플 트렌드 분석
|
|
-- SETEX ai:trend:음식점:강남구 86400 '{
|
|
-- "industryTrends": [
|
|
-- {"keyword": "프리미엄 디저트", "relevance": 0.92, "description": "고급 디저트 카페 증가"},
|
|
-- {"keyword": "건강식", "relevance": 0.88, "description": "샐러드/저칼로리 메뉴 선호"}
|
|
-- ],
|
|
-- "regionalTrends": [
|
|
-- {"keyword": "강남 핫플", "relevance": 0.95, "description": "신사동/청담동 중심 핫플 형성"},
|
|
-- {"keyword": "고소득층", "relevance": 0.85, "description": "높은 구매력의 고객층"}
|
|
-- ],
|
|
-- "seasonalTrends": [
|
|
-- {"keyword": "겨울 음료", "relevance": 0.80, "description": "따뜻한 음료 수요 증가"}
|
|
-- ]
|
|
-- }'
|
|
|
|
-- =====================================================
|
|
-- 4. Redis 캐시 조회 명령 (디버깅용)
|
|
-- =====================================================
|
|
|
|
-- 4.1 모든 AI 서비스 키 조회
|
|
-- KEYS ai:*
|
|
|
|
-- 4.2 특정 패턴의 키 조회
|
|
-- KEYS ai:recommendation:*
|
|
-- KEYS ai:job:status:*
|
|
-- KEYS ai:trend:*
|
|
|
|
-- 4.3 키 존재 확인
|
|
-- EXISTS ai:recommendation:123e4567-e89b-12d3-a456-426614174000
|
|
|
|
-- 4.4 키의 TTL 확인
|
|
-- TTL ai:recommendation:123e4567-e89b-12d3-a456-426614174000
|
|
|
|
-- 4.5 캐시 데이터 조회
|
|
-- GET ai:recommendation:123e4567-e89b-12d3-a456-426614174000
|
|
|
|
-- 4.6 캐시 데이터 삭제
|
|
-- DEL ai:recommendation:123e4567-e89b-12d3-a456-426614174000
|
|
|
|
-- =====================================================
|
|
-- 5. Redis 모니터링 명령
|
|
-- =====================================================
|
|
|
|
-- 5.1 서버 정보 조회
|
|
-- INFO server
|
|
-- INFO memory
|
|
-- INFO stats
|
|
-- INFO keyspace
|
|
|
|
-- 5.2 실시간 명령 모니터링
|
|
-- MONITOR
|
|
|
|
-- 5.3 느린 쿼리 로그 조회
|
|
-- SLOWLOG GET 10
|
|
|
|
-- 5.4 클라이언트 목록 조회
|
|
-- CLIENT LIST
|
|
|
|
-- 5.5 메모리 사용량 상세
|
|
-- MEMORY STATS
|
|
-- MEMORY DOCTOR
|
|
|
|
-- =====================================================
|
|
-- 6. Redis 성능 최적화 명령
|
|
-- =====================================================
|
|
|
|
-- 6.1 메모리 최적화
|
|
-- MEMORY PURGE
|
|
|
|
-- 6.2 만료된 키 즉시 삭제
|
|
-- SCAN 0 MATCH ai:* COUNT 1000
|
|
|
|
-- 6.3 데이터베이스 크기 확인
|
|
-- DBSIZE
|
|
|
|
-- 6.4 키 스페이스 분석
|
|
-- redis-cli --bigkeys
|
|
-- redis-cli --memkeys
|
|
|
|
-- =====================================================
|
|
-- 7. 백업 및 복구 (선택사항)
|
|
-- =====================================================
|
|
|
|
-- 7.1 현재 데이터 백업
|
|
-- BGSAVE
|
|
|
|
-- 7.2 백업 파일 확인
|
|
-- LASTSAVE
|
|
|
|
-- 7.3 백업 파일 복구
|
|
-- 1. Redis 서버 중지
|
|
-- 2. dump.rdb 파일을 Redis 데이터 디렉토리에 복사
|
|
-- 3. Redis 서버 재시작
|
|
|
|
-- =====================================================
|
|
-- 8. Redis Cluster 설정 (프로덕션 환경)
|
|
-- =====================================================
|
|
|
|
-- 8.1 Sentinel 설정 (고가용성)
|
|
-- sentinel monitor ai-redis-master 127.0.0.1 6379 2
|
|
-- sentinel down-after-milliseconds ai-redis-master 5000
|
|
-- sentinel parallel-syncs ai-redis-master 1
|
|
-- sentinel failover-timeout ai-redis-master 10000
|
|
|
|
-- 8.2 Cluster 노드 추가
|
|
-- redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \
|
|
-- 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1
|
|
|
|
-- 8.3 Cluster 정보 조회
|
|
-- CLUSTER INFO
|
|
-- CLUSTER NODES
|
|
|
|
-- =====================================================
|
|
-- 9. 보안 설정 (프로덕션 환경)
|
|
-- =====================================================
|
|
|
|
-- 9.1 ACL 사용자 생성 (Redis 6.0+)
|
|
-- ACL SETUSER ai-service on >strongpassword ~ai:* +get +set +setex +del +exists +ttl
|
|
-- ACL SETUSER readonly on >readonlypass ~ai:* +get +exists +ttl
|
|
|
|
-- 9.2 ACL 사용자 목록 조회
|
|
-- ACL LIST
|
|
-- ACL GETUSER ai-service
|
|
|
|
-- 9.3 TLS/SSL 설정 (redis.conf)
|
|
-- tls-port 6380
|
|
-- tls-cert-file /path/to/redis.crt
|
|
-- tls-key-file /path/to/redis.key
|
|
-- tls-ca-cert-file /path/to/ca.crt
|
|
|
|
-- =====================================================
|
|
-- 10. 헬스 체크 스크립트
|
|
-- =====================================================
|
|
|
|
-- 10.1 Redis 연결 확인
|
|
-- redis-cli -h localhost -p 6379 -a your-password PING
|
|
-- 응답: PONG
|
|
|
|
-- 10.2 캐시 키 개수 확인
|
|
-- redis-cli -h localhost -p 6379 -a your-password DBSIZE
|
|
|
|
-- 10.3 메모리 사용량 확인
|
|
-- redis-cli -h localhost -p 6379 -a your-password INFO memory | grep used_memory_human
|
|
|
|
-- 10.4 연결 상태 확인
|
|
-- redis-cli -h localhost -p 6379 -a your-password INFO clients | grep connected_clients
|
|
|
|
-- =====================================================
|
|
-- 참고사항
|
|
-- =====================================================
|
|
-- 1. 이 파일은 PostgreSQL 스크립트가 아닌 Redis 설정 가이드입니다.
|
|
-- 2. Redis CLI 명령은 주석으로 제공되며, 실제 실행 시 주석을 제거하세요.
|
|
-- 3. 프로덕션 환경에서는 Redis Sentinel 또는 Cluster 구성을 권장합니다.
|
|
-- 4. TTL 값은 application.yml에서 설정되며, 필요시 조정 가능합니다.
|
|
-- 5. 백업 전략은 서비스 요구사항에 따라 수립하세요 (RDB/AOF).
|
|
-- =====================================================
|