More Related Content Similar to 국내 미디어 고객사의 AWS 활용 사례 - POOQ서비스 그리고 마이크로서비스 아키텍처, 콘텐츠연합플랫폼 - 박명순부장, 콘텐츠연합플랫폼 :: AWS Summit Seoul 2019 (20) More from Amazon Web Services Korea (20) 국내 미디어 고객사의 AWS 활용 사례 - POOQ서비스 그리고 마이크로서비스 아키텍처, 콘텐츠연합플랫폼 - 박명순부장, 콘텐츠연합플랫폼 :: AWS Summit Seoul 20191. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
국내 미디어 고객사의 AWS 활용 사례
POOQ 서비스 그리고 마이크로서비스
아키텍처
콘텐츠연합플랫폼㈜ 박명순
2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
발표 순서
• POOQ
• 도입 이전
• 도입 준비
• 도입 이후
• 향후 계획
3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
POOQ
• 지상파 방송사가 만든 유료사용자 기반 OTT 서비스
• 약 80개의 Live 채널과, 20만 여개의 VOD 콘텐츠
5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
아키텍처 변화
• 2017년 1분기 AWS 기반으로 전체 서비스 이전
• 2018년 1분기 Kubernetes 기반으로 마이크로 서비스 운영 시작
Auto Scale
CloudFront
CloudColocation Microservice
2012년 2014년 2017년 2018년
6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
시스템 구성
• 서비스 내용에 따라 Platform 과 Headend 시스템으로 구분
• Platform 부분에 Kubernetes 기반 Microservice 사용 중
Platform
(API)
Headend
(Streaming)
CloudFrontKubernetesEC2DB
CloudFrontEC2
Spot
S3
7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
중앙집중 구조
• 메인 API 서버에 Monolithic Architecture 사용
• Github + Jenkins 구조의 CI/CD 구성 사용
GitHub JenkinsDeveloper IIS .NET
Admin
9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
배포 이슈
• 어플리케이션 상호간의 의도하지 않은 영향으로 매번 전체 QA 진행
• 기능 및 서버 대수가 늘어나면서 배포와 원복 시간 증가
ZZZ
XML
DLL
10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling 이슈
• 서비스 이용량 변화속도가 Auto Scaling Group 속도보다 빠름
• CPU 사용량 기반 Auto Scaling 대신 Scheduled Scaling 사용
On Air Users
10분 미만 5분 미만
Scheduled Scaling
11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
버전 관리 이슈
• 다양한 디바이스 지원을 위해서 다양한 버전의 API 서비스 유지 필요
• 다양한 버전의 API 유지로 인한 운영 비용 증가
12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
마이크로 서비스 솔루션 선정
• T2 Unlimited + Auto scaling group 사용 검토
ü T2 무제한 사용으로 비용절감
ü 복잡한 Instance 관리와, 독자적인 CI/CD 개발 및 구성 필요
• Docker Swarm
ü Docker 에 내장되어 쉽고 편리 함
ü Service Discovery 별도 구성 필요
• Kubernetes
ü 가상 서버, Docker, Service Discovery 관리 일괄 제공
ü Kops는 Kubernetes를 AWS환경에서 쉽게 사용하게 함
14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
API Gateway
• API 서비스 개수를 200개 이상으로 분리 및 API Gateway 사용
• 복수의 정규 표현식 지원으로 경로에 따른 API 서비스 구분
• GET/POST와 같은 HTTP Method 구분 지원
• CI/CD에서의 자동화를 위한 HTTP REST API 지원
200+ /a/(.*)/b/(.*) {REST}GET/POST
15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
API Gateway 솔루션 선정
• AWS API Gateway
ü REST API 로 설정 가능
ü 서비스별로 ELB / Security Group 생성 필요
• Nginx
ü 별도 EC2 기반으로 구성 후 NginX 설치 운영
ü NginX Unit 사용해서 동적 설정 가능
• Nginx ingress
ü Kubernetes 기본 포함된 기능
ü HTTP Method 미지원
• Kong
ü REST API 로 정규표현식 설정 가능
ü HTTP Method 지원
16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
API 구분 및 연동 구조
• 보안 강화를 위해 WAF + Shield Advanced 를 CloudFront 와 같이 사용
• 외부 API 와 내부 API을 나누어서 역할 분리 및 보안강화
CloudFront
WAF
Shield Advanced
외부
ELB
외부
API Gateway
외부
API
내부
API Gateway
내부
API
DB
CloudFront 평균 응답속도 40msec
내부
ELB
17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
콘텐츠 데이터 이용 구조
• Kettle을 이용 사전에 분산된 Collection 생성으로 RDBMS 부하 감소
• Redis Cache 사용으로 반응속도 향상 및 MongoDB 부하 감소
Redis
B
API
MongoDB
Collection B
MongoDB
Collection A
Redis
A
Kettle
A
Kettle
B
DBMS
18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
메시징 시스템 사용
• 다양한 이벤트 메시지를 Json 형식으로 Kafka 를 거쳐서 전달
• Kafka 사용으로 서비스 가용성과 확장성 확보
Kafka
API A
(Producer Topic A)
API B
(Consumer Group B)
API C
(Consumer Group C)
19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
소스 관리 및 CI/CD
• 프로젝트 개수가 증가하면서 Github + Jenkins 구조 개선 필요
• Gitlab Pipeline은 개발자가 직접 배포하는 CI/CD 환경에 적합
Github Jenkins Kubernetes Gitlab Gitlab Runner Kubernetes
AWS VPC AWS VPC
20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CI/CD 작업 흐름 설계
• POOQ CI/CD CLI로 Kong 과 Kubernetes 서비스 생성 및 변경
• 자동 배포, 수동 배포, Canary 배포가 가능한 구조 필요
Kubernetes
Deployment / Pod Auto Scale
Create/Modify
Kong Service
Create/Modify
Gitlab
Server
Gitlab
Runner Docker
Gitlab
Container
Registry
POOQ CI/CD CLI
Docker
AWS S3
(Docker Images)
gitlab-ci.yml gitlab-ci.yml
21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Staging 환경 구성
• Staging 용도 별도 DNS 서버 구축 및 Kube DNS에 Custom DNS로 등록
• NginX Proxy로 CloudFront 동작 구성
DNS Cache
(dnsmasq)
kube-dns
(*.cluster.local)
Custom DNS
(*.internal.local,
api.pooq.co.kr)
Upstream DNS
(AWS DNS)
kube-dns
API
Nginx Proxy
(api.pooq.co.kr)
RDBMS, MongoDB,
Cassandra, kafka,..
(*.internal.local)
22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
여유 Node 준비
• Node 증설에는 5~10분이 소요되어서 미리 여유 있는 Node 필요
• 낮은 우선순위를 가지는 Pod를 이용해서 Overprovisioning 구성
기존 Node
신규 Node
기존 Node
기존 Node
기존 Node
신규 Node기존 Node
High Priority Pod
Scale Out Node
Scale Out
Low Priority Pod
Scale In
Low Priority Pod
Scale Out
여유 Node
부족
23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Log 수집 및 분석
• ELK ( Elasticsearch + Logstash + Kibana ) 구성해서 사용
• Elasticsearch API를 통한 API 모니터링, Kibana를 통한 GUI 모니터링 구성
Kubernetes
Nodes
Logstash Elasticsearch Kibana Admin/Developer
Web UI
Rest API
Prometheus
24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
기타 구성에서의 문제 해결
• Kops의 GitHub 프로젝트 문서를 최대한 따름
• 그래도 의도한 동작을 안 하면 Security Group, DNS 확인
troubleshoot
25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
관제 포인트
• Kubernetes Deployment의 Pod 목표 수량과 현재 수량의 불일치
• API Gateway 에서 502 Bad Gateway 응답코드 발생 건수 감시
Deployment Prometheus
관리자
Elasticsearch
replica
mismatch
502
bad gateway
27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pod 자원할당 변경
• 고용량/소수의 POD 사용에서, 저용량/다수의 POD 사용으로 변경
• 순간적인 대량의 요청에도 빠른 응답속도와, 빠른 Scale Out
1s CPU - 1G MEM
50% Auto Scale
100msec CPU – 256M MEM
50% Auto scale
Node Node Node Node
28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2 모델 변경
• 초기 높은 CPU 사용을 예상하고 컴퓨팅 최적화 C 타입 모델 사용
• 운영 모니터링 결과, 메모리 최적화 R 타입 모델로 변경 결정
• Node의 최대 개수는 100개가 넘지 않도록 함
C5 컴퓨팅 최적화 R5 메모리 최적화
29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DNS 사용 개선
• 내부 API Gateway 연결에 Kubernetes Cluster Domain 사용 구조로 변경
• 내부 ELB 및 Route53 미사용으로 응답속도 및 안정성 향상
외부
ELB
외부
API Gateway
외부
API
내부
API Gateway
내부
API
*.defaults.svc.cluster.local
내부
ELB
30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Deployment
Pod 생성 실패 이슈
• Gitlab Group 변경 Deployment의 신규 Pod 생성 실패
ü Container 빌드 및 Deployment 재 배포
• Node.JS Deployment 신규 Pod 생성 실패
• npm start 명령어를 node index.js 로 변경 후 재 배포
ImagePullBackOff
또는
Error
Running Running Running
31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Kubernetes 업그레이드
• 신규 Kubernetes Cluster를 구성 및 QA 진행
• CloudFront의 Origin 변경, 서비스 무정지로 업그레이드 진행
Kubernetes 기존버전
Kubernetes 신규버전
CloudFront
New ELB
Old ELB
MongoDB
RDBMS
Kafka
…
32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS 도입
• 신규 기능 사용을 위해 최신 버전 사용
• Kubernetes Cluster Network와 AWS VPC 라우팅 통합
• Kubernetes 기술지원 체계 구축
현재버전
Kubernetes v1.14
EKS v1.12
Kops v1.11
CNI Plugin
172.x.x.x 10.x.x.x
Technical support
33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Istio 도입
• API Gateway, 향상된 Canary 배포 및 A/B 테스트
• 모든 서비스 API 입력과 출력에 대한 상태 수집 및 제어
Istio
Envoy Envoy Envoy
Envoy
Envoy
API
API
API
35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
쉬운 장애 분석
• Istio를 이용해서 API 사이 통신에 Tag 추가 및 모니터링
• 서비스 장애 발생시 관계된 API 확인 간소화
외부 API 내부 API
!!!
36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling 조건 다양화
• CPU 증가 없이, POD 응답이 지연되는 상황이 존재
• 메모리 사용, 요청건수, 응답시간, 에러율 반영하는 Pod 수량 관리 필요
PrometheusIstio
CreatingRunning Running
Deployment
요청수
응답시간
기본 Pod
개수 변경
37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
StatefulSets 운영 분리
• StatefulSets 과 Stateless 서비스의 Node 분리로 유연한 운영
• 외부 Service Discovery 사용해서 Cluster 분리 검토
38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Node 운영 방법 변경
• EC2 RI(Reserved Instance) + On-demand 운영은 유연성이 떨어짐
• AWS Fargate, Spot 를 같이 사용해서 운영의 유연성 확보
Fargate
Container
Spot
Instance
Reserved
Instance
39. 여러분의 피드백을 기다립니다!
#AWSSummit 해시태그로
소셜미디어에 여러분의
행사소감을 올려주세요.
AWS Summit Seoul 2019
모바일 앱과 QR코드를 통해
강연평가 및 설문조사에
참여하시고 재미있는 기념품을
받아가세요.
내년 Summit을 만들 여러분의
소중한 의견 부탁 드립니다.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.