KEMBAR78
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017 | PDF
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
윤석찬, AWS 테크에반젤리스트 · 이상현, Vingle 개발팀
마이크로서비스를 위한 AWS
아키텍처 패턴 및 모범 사례
의 서버리스 마이크로서비스 전환 사례
본 강연에서 다룰 내용
• 왜 마이크로서비스를? 모놀리식 vs. 마이크로서비스
• AWS 기반 마이크로서비스 아키텍처 패턴
• 마이크로서비스에 대한 7가지 모범 사례
• 빙글 고객 사례
왜 마이크로서비스를?
releasetestbuild
개발 및 배포
모놀리식 앱
개발자
Shared libraries
Shared data
“Monolith 앱” 개발 배포 및 아키텍처
성장하는 서비스에서 “Monolith 앱”의 단점
장기 개발 사이클
(다수개발자 공동 참여)
운영의 어려움
(특정 모듈 장애시)
애플리케이션
확장성 애로
신규 출시에
몇 달이 걸림
신규 기능
추가에 어려움
아키텍처 유지
진화의 어려움
혁신
저해
고객
불만족
민첩성
저해
마이크로서비스로의 전이
Netflix embraces a fine-grained Service Oriented Architecture as
the underpinning of its Cloud based deployment model.
Currently, we run hundreds of such fine grained services that
are collectively responsible in handling the customer facing
requests via a few "Edge Services" such as the Netflix API
Service. A lightweight REST based protocol is the choice for inter
process communication amongst these services.
http://techblog.netflix.com/2013/01/announcing-ribbon-tying-netflix-mid.html
“service-oriented
architecture
composed of
loosely coupled
elements
that have
bounded contexts”
Adrian Cockcroft (VP of Cloud Architecture @
AWS, former Cloud Architect at Netflix)
마이크로 서비스란?
다른 서비스의 내부
구조를 알지 못해도, 내
서비스 코드를 업데이트
할 수 있다.
서비스들이 네트워크를
통해 서로 통신한다.
서비스는 독자적으로
업데이트하며, 서로
영향을 주지 않는다.
“service-oriented
architecture
composed of
loosely coupled
elements
that have
bounded contexts”
Adrian Cockcroft (VP of Cloud Architecture @
AWS, former Cloud Architect at Netflix)
Public API
POST /restaurants
GET /restaurants
Application/Logic
(code, libraries, etc)
Data Store
(eg, RDS, DynamoDB
ElastiCache, ElasticSearch)
하나의 마이크로서비스 구성 패턴
Drivers
micro-services
Payments
micro-service Location
micro-services
Ordering
micro-services
Restaurant
micro-service
다양한 마이크로서비스 단위 구성
Amazon.com의 사례
= 연간 5천만회 배포 (2014년)
수 천개 팀 (자율적 DevOps팀)
× 마이크로서비스 아키텍처
× 지속적 배포 (CD)
× 다양한 개발 환경
(시간당 5708 회, 또는 0.63 초)
Amazon.com의 사례
Werner Vogels (CTO, Amazon.com, 2015)
AWS 기반 마이크로 서비스 활용 사례
Building a Microservices
Gaming Platform for
Turbine Mobile Games
(2016)
From Monolithic to
Microservices Evolving
Architecture Patterns in
the Cloud (2016)
Developing Mobile Apps and
Serverless Microservices for
Enterprises using AWS
(2016)
Pure Play Video OTT- A
Microservices Architecture
(2015)
Nike's Journey into
Microservices (2014)
A Journey to
Microservices (2015)
국내 AWS 고객사 아키텍처 변신 사례
마이크로서비스 기반 모바일
서비스 마이그레이션 (2016)
마이크로 서비스 아키텍처로 방송
서비스 진화 (2016)
AWS 기반
마이크로서비스 아키텍처 패턴
전통적인 클라우드 서비스 아키텍처
Clients
RDS
HTTP
REST
EC2
Instance
Auto Scaling Group
AZ-A
AZ-B
Min > 1
Elastic Load
Balancing
EC2
Instance
AWS Elastic
Beanstalk
좀더 스마트하게…
.
다양한 마이크로서비스 구조 진화
S3
CloudFront
RDS
ElastiCache
EC2
Elastic Load
Balancing
EC2
Elastic Load
Balancing
Static
Content
Content
Delivery
API
Layer
Application
Layer
Persistency
Layer
Auto Scaling
Group
Auto Scaling
Group
다양한 마이크로서비스 구조 진화
CloudFront
RDS
ElastiCacheEC2
Elastic Load
Balancing
Static
Content
Content
Delivery
Application
Layer
Persistency
Layer
Auto Scaling
Group
API
Gateway
S3
API
Layer
다양한 마이크로서비스 구조 진화
S3
CloudFront
RDS
ElastiCache
EC2
Application
Load
Balancing
Static
Content
Content
Delivery
API
Layer
Application
Layer
Persistency
Layer
API
Gateway
EC2 Container
Service
Auto Scaling
Group
다양한 마이크로서비스 구조 진화
S3
CloudFront
EC2
Application
Load
Balancing
Static
Content
Content
Delivery
API
Layer
Application
Layer
Persistency
Layer
API
Gateway
EC2 Container
Service
Auto Scaling
Group
DynamoDB
다양한 마이크로서비스 구조 진화
S3
CloudFront
Static
Content
Content
Delivery
API
Layer
Application
Layer
Persistency
Layer
API
Gateway
DynamoDBAWS
Lambda
Amazon API
GatewayClients
HTTP
REST
Amazon
EC2
AWS
Lambda
Lambda
Blueprints
다양한 마이크로서비스 구조 진화
Elastic Load
Balancing
Amazon ECS
마이크로서비스 전환 사례
iOS / Frontend / Backend
Technical Leader
kurt@vingle.net
https://github.com/breath103
이상현 Kurt Lee
서비스 소개
Elastic
Load Balancer
AWS Opsworks
www.vingle.net
api1.vingle.net
EC2
.
.
.
DB / Cache
EC2
EC2
External
Services
Vingle 서비스 인프라 구조
Web server /
Background Worker /
REST API /
ORM /
Business logic
….
Feed
Search
Card Writing
Admin
Spam
….
Unit test - 30분
Deployment - 30분
Vingle 서비스 및 코드 개발 현황
기술적으로 자유로운 사고가 어려움
생산성 저하
1. 언제나 모든 서비스를 함께 Deploy / Scale
2. 새로운 기술 도입이 어려움
기존 개발 환경의 문제점
Small Autonomous
Services
that Work Together,
modeled around a
business domain
MicroserviceIdeal Goals
1. Independent Scaling
2. Independent Deployment
3. Independent Stack
4. Independent Development
5. Independent Testing &
Monitoring
API
Gateway
Lambda DB / Cache
• 모든 Infrastructure를 Code로 관리
• 사실상 무한, 자동 스케일링
• Code를 Upload만 하면 무중단 배포
서버리스 기반 단위별 신규 아키텍처
API Gateway
Lambda
DynamoDB
(List of spam keywords)
POST /api/validates
Body: {
data: “ABCDEFG”
}
예) 스팸 필터 마이크로 서비스 구조
1. 주어진 Short URL https://goo.gl/12345 -> https://some.spam.url 으로 가는지 확인
2. URL을 추출해서 Redirect를 따라가며 Spam URL 체크하는 코드와 테스트 코드 작성
3. Git Push
• Unit Test
• Staging Deploy (1~2분)
4. Rails를 거치지 않고, Spam Service만 독립적으로 테스트
curl -H "Content-Type: application/json"
-X POST
-d ‘{“data”: “Some Text https://goo.gl/12345“}'
http://spam-filter.vingle.net/stage/validate
5. Production Deploy (1~2분)
총 소요시간: 20~30분
코드 작성 / 테스트 이외 모든것이 자동화
(입사한지 3일 된 사람 기준)
예) 스팸 필터 마이크로 서비스 구조
예) 스팸 필터 마이크로 서비스 구조
기존 모놀리식 아키텍처
Search
Feed
Tracking
SpamStat Updater
서버리스 마이크로서비스 아키텍처
Vingle API
6개월 뒤…
• Netflix와 같은 Strangler Pattern
Architecture
• 모든 요청을 받는 기존 API서버가
있고, 해당 API서버에서 필요로
하는 마이크로서비스를 REST
HTTP기반 통신으로 사용
• 모니터링을 위해 Cloudwatch를
사용하여 알림 자동화
• 서비스들 간의 Dependency를
모니터링 툴을 만들어 관리
• 각 서비스를 독립적으로
개발 / 배포 / 모니터링
Lesson Learned - Microservice Migration
1. 새로 추가/변경 필요한 기능부터 분리
• 잘 돌아가고 있는 오래된 기능을 재작성은 리스크
높고, 이득도 적음
• 리스크가 작은 것부터 시작해서 팀 단위 운영/개발 노
하우 쌓아야 함
2. Business Domain 단위 서비스 구성
• Cache (X), DB (X)
• Feed (O), Notification(O)
3. 서비스 존재 목적은 사용 되어지는 것
• 다른 개발자 / 시스템에서 쓰기 쉽도록 인터페이스를
갖춰야 함
• REST API라면 Swagger등을 통해 적극적으로 문서화
1. AWS에서 제공하는 Fully-managed service 적극 활용
• Search Microservice -> Lambda + Cloudsearch
• Feed Microservice -> Lambda + DynamoDB + Kinesis Stream
2. Infrastructure-as-a-Code (AWS CloudFormation)
• 시간이 조금만 지나면, AWS내 많은 리소스 관리하기 어려워짐
• AWS CloudFormation을 통해 리소스들을 코드화 / 데이터화
Lesson Learned - Cloud Infrastructure
We’re hiring! https://careers.vingle.net
마이크로서비스 7가지 모범 사례
모범 사례 1
API 기반 서비스
인터페이스 및 하위
호환성 유지
“Contracts” by NobMouse. No alterations other than cropping.
https://www.flickr.com/photos/nobmouse/4052848608/
Image used with permissions under Creative Commons license 2.0, Attribution
Generic License (https://creativecommons.org/licenses/by/2.0/)
Micro-service A Micro-service B
public API public API
API를 통한 서비스별 인터페이스
storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, arbitrary_metadata)
addReview (restaurantId, rating, comments)
storeRestaurant (id, name, arbitrary_metadata)
addReview (restaurantId, rating, comments)
Version 1.0.0
Version 1.1.0
Version 2.0.0
public API
Micro-service A
각 서비스는 타 서비스 API를 참조!
서비스 진화에 따라 API 하위 호환성 지원 가능
AWS Lambda: 버전 기능
• Immutable 함수 버전 기능
• 버전별 설정 및 Cloudwatch 통계
• Cloudwatch Logs에 버전 속성 포함
• 버전 출시에 따라 “label” 처리 가능
• $LATEST 최신 버전
$LATEST(95) STABLE TESTING
94 X
93 X
92
Amazon API Gateway: 스테이지 기능
Amazon API Gateway: 스테이지 변수
API Gateway Lambda Custom Domain
/prod/Resources FunctionName:stable https://api.example.com
/qa/Resources FunctionName:qa https://qa.example.com
/dev/Resources FunctionName:$LATEST https://dev.example.com
스테이지 변수에 따라 테스트 환경 설정
“Tools #2” by Juan Pablo Olmo. No alterations other than cropping.
https://www.flickr.com/photos/juanpol/1562101472/
Image used with permissions under Creative Commons license 2.0, Attribution
Generic License (https://creativecommons.org/licenses/by/2.0/)
모범 사례 2
각기 다른 폴리그랏
개발 및 운영 환경
public API public API
DynamoDB
Micro-service A Micro-service B
워크로드별 최적 개발 환경 구성
폴리글랏(Polyglot) 접근 방식을 통한 서비스 아키텍처 선택
Amazon
Elasticsearch
Service
RDS
Aurora
폴리글랏 마이크로서비스의 특징
• 개별적인 데이터 스토어 구성
• 각 데이터 스토어 스키마
변경에 따른 영향이 적음
• 빠르고 독자적인 확장성 제공 account-svccart-svc
DynamoDB RDS
user-svc
ElastiCache
RDS
ERROR
만약 트랜잭션 중
문제가 발생한다면?
해결 방법 1: Correlation ID 활용
09-02-2015 15:03:24 ui-svc INFO [uuid-123] ……
09-02-2015 15:03:25 catalog-svc INFO [uuid-123] ……
09-02-2015 15:03:26 checkout-svc ERROR [uuid-123] ……
09-02-2015 15:03:27 payment-svc INFO [uuid-123] ……
09-02-2015 15:03:27 shipping-svc INFO [uuid-123] ……
ui-svc
catalog-
svc
checkout-
svc
shipping-
svc
payment-
svc
request correlation id:
“uuid-123”
correlation id:
“uuid-123”
해결 방법 2: 서비스별 자체 롤백 제공
• 모든 마이크로서비스는 각자의 롤
백 기능을 가져야 한다.
• 롤백이 필요할 경우, 알림이나
특정 액션에서 롤백 기능 제공
• Correrlation ID를 기반으로 롤백
알림 호출
Microservice
Function 1
Rollback
Commit
(optional)
AWS Step Functions
시각적 워크플로를 사용해 분산 앱 및
마이크로서비스 구성 요소 조정 및 실행
• 자동으로 각 단계를 트리거 및 추적하고
오류가 발생할 경우 재시도하므로
애플리케이션이 의도대로 정상적으로 실행
• 앱을 단계별로 배열 및 시각화할 수 있는
그래픽 콘솔 제공
• 각 단계의 상태를 기록하여, 잘못된 경우
빠르게 문제를 진단하고 디버깅 가능
상태 변경이 일어나는 경우만 과금
AWS Step Functions 실행 방식
샘플 미디어 공유 서비스 - Amazon AI 연계
https://github.com/awslabs/lambda-refarch-imagerecognition
상태 머신
실행
사진 메타
데이터 추출
사진 메타
데이터 저장
이미지 인식
서비스 호출
샘플 미디어 공유 서비스 - Amazon AI 연계
순차 + 분기 + 병렬 방식
샘플 미디어 공유 서비스 - Amazon AI 연계
순차 + 분기 + 병렬 방식
데모: 샘플 미디어 공유 서비스 - Amazon AI 연계
File:Cgs01053 - Flickr - NOAA Photo Library.jpg
https://commons.wikimedia.org/wiki/File:Cgs01053_-_Flickr_-_NOAA_Photo_Library.jpg
모범 사례 3
지속적인 마이크로
서비스 모니터링
지속적인 마이크로 서비스 모니터링
• API 외부적인 요소 모니터링
• Latency, RPS, Error rate
• API 내부적인 요소 모니터링
• CloudWatch, OS, Application
•AWS 기반 모니터링 및 분석 도구 활용
• CloudWatch 및 CloudWatchLogs
Amazon
CloudWatch Logs
AWS
Lambda
Amazon
Elasticsearch Kibana
실시간 로그 대시보드 구성
Amazon API
Gateway
Amazon
ECS
Amazon
EC2
데이터 리포팅 및 시각화
Amazon
ECS
Amazon
EC2
AWS
Lambda
Amazon API
Gateway
Amazon
Redshift
Amazon
QuickSight
Amazon
EMR
Amazon
S3
Amazon
Athena
AWS Lambda 코드 에러의 경우,
• Lambda 함수 실행 오류가 나는 경우
• Cloudwatch Logs 통해 디버깅 가능
• 직접 Transaction Manager 함수를
별도로 만들어 Cloudwatch Logs
Metric Filter 를 통해 에러 검출
ui-svc
Cloudwatch
Logs
Cloudwatch
Alarm
Transaction
Manager
Function
AWS X-Ray
• 완전 관리형 분산 애플리케이션 성능
추적 서비스
• 마이크로서비스 시작과 끝에 대한
디버깅 및 추적
ü 서비스에 대한 시각적 토폴로지 제공
ü 개별 요청에 대한 로그 추적
ü 성능 이슈 및 오류 발생 원인에 대한 확인
및 문제 해결
AWS Node.JS (SDK)
Amazon ECS (Docker)
“security” by Dave Bleasdale. No alterations other than cropping.
https://www.flickr.com/photos/sidelong/3878741556/
Image used with permissions under Creative Commons license 2.0,
Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
모범 사례 4
마이크로서비스별
보안 강화
• 서비스 수준별 방어
• 네트워크 레벨
(e.g. VPC, Security Groups, TLS)
• 서버/콘테이너/앱 레벨
(e.g WAF, Shield)
• API Gateway (“Front door”)
• API Throttling
• API 키 관리
• S3 버킷 정책 + KMS + IAM
• 오픈 소스 도구 (e.g. Vault,
Keywhiz)
API	Gateway
마이크로 서비스별 보안에 유의하라!
“Lamington National Park, rainforest” by Jussarian. No alterations other than cropping.
https://www.flickr.com/photos/kerr_at_large/87771074/
Image used with permissions under Creative Commons license 2.0,
Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
모범 사례 5
API 생태계 확산을
통한 비지니스 창출
혹시 회사에
레스토랑 정보를
공개 API로 제공해
주실 수 있나요?
피드백 감사드립니다.
필요하신 경우를 알려
주시면, 공개로 API를
열어 드리고 향후
비지니스 협력도 같이 할
수 있을 것 같네요!
Micro-service A Micro-service B
public API public API
API 서비스를 통한 생태계 확산
API 서비스를 통한 생태계 확산
https://aws.amazon.com/ko/blogs/compute/generate
-your-own-api-gateway-developer-portal/
https://aws.amazon.com/ko/blogs/compute/monetize-your-
apis-in-aws-marketplace-using-api-gateway/
API Gateway Developer Portal
Serverless Application Model (SAM) 기반의
오픈 소스 키 발급 및 관리 백엔드
API Monetization in Marketplace
AWS Marketplace를 통해 API 서비스 판매 및
수익화 가능
“rowing on the river in Bedford” by Matthew Hunt. No alterations other than cropping.
https://www.flickr.com/photos/mattphotos/19189529/
Image used with permissions under Creative Commons license 2.0,
Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
모범 사례 6
기술 너머 조직 변화
“Any organization that designs a system
will inevitably produce a design whose
structure is a copy of the organization’s
communication structure.”
Melvin E. Conway, 1967
Conway’s Law
Image	from	Martin	Fowler’s	article	on	microservices, at
http://martinfowler.com/articles/microservices.html
No	alterations	other	than	cropping.
Permission to reproduce: http://martinfowler.com/faq.html
기술 너머 조직의 변화
Non-pizza	image	from	Martin	Fowler’s	article	on	microservices, at
http://martinfowler.com/articles/microservices.html
No	alterations	other	than	cropping.
Permission to reproduce: http://martinfowler.com/faq.html
기술 너머 조직의 변화
기능별 조직에서 자율성 높은 책임 조직으로
Two-Pizza Team(Amazon)
“Robot”	by	Robin Zebrowski.	No	alterations	other	than	cropping.
https://www.flickr.com/photos/firepile/438134733/
Image used	with	permissions	under	Creative		Commons	license	2.0,
Attribution	Generic	License	(https://creativecommons.org/licenses/by/2.0/)
모범 사례 7
자동화! 자동화!
(Automation)
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
2-pizza team delivery pipeline service
자동화! 자동화!
자동화! 자동화! - AWS 각종 데브옵스 자동화 도구
AWS
CloudFormation
AWS
CloudTrail
AWS
Config
AWS Trusted
Advisor
Amazon
Glacier
Amazon
S3
AWS
CodePipelineAWS KMSACM
Amazon
CloudWatch
AWS
Lambda
AWS
CodeDeploy
17:20-18:00 Track 2 효율적인 데브옵스를 위한 AWS 개발 도구 활용하기 (200)
16:20-17:00 Track 4 인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 (300)
마이크로서비스 7 가지 모범 사례
1. API 기반 서비스 인터페이스 및 하위 호환성 유지
2. 각기 다른 폴리그랏 개발 및 운영 환경
3. 지속적인 마이크로 서비스 모니터링
4. 서비스별 보안에 유의하라
5. API 생태계 확산을 통한 비지니스 가치 창출
6. 기술 너머 조직의 변화
7. 자동화! 자동화!
빠른
빌드/테스트/배포
가능
명확한 오너쉽 및
자율적 운영
개별 마이크로
서비스 확장
가능
몇 분만에
배포 가능
신규 기능
빠르게
추가 가능
빠른 운영 및
개선
빠른 혁신
고객 만족
높은
민첩성
마이크로 서비스의 이점
본 강연이 끝난 후…
• AWS 마이크로서비스 기술 백서 및 아키텍처
• Microservices on AWS
• Microservices without the Servers
• Microservices with ECS
• AWS 마이크로서비스 고객 사례
• Building a Microservices Gaming Platform for Turbine Mobile Games (2016)
• From Monolithic to Microservices Evolving Architecture Patterns in the Cloud (2016)
• Developing Mobile Apps and Serverless Microservices for Enterprises using AWS (2016)
• Pure Play Video OTT- A Microservices Architecture (2015)
• Developing Mobile Apps and Serverless Microservices for Enterprises using AWS (2016)
• A Journey to Microservices (2015)
• Nike's Journey into Microservices (2014)

마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017

  • 1.
    © 2016, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 윤석찬, AWS 테크에반젤리스트 · 이상현, Vingle 개발팀 마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 의 서버리스 마이크로서비스 전환 사례
  • 2.
    본 강연에서 다룰내용 • 왜 마이크로서비스를? 모놀리식 vs. 마이크로서비스 • AWS 기반 마이크로서비스 아키텍처 패턴 • 마이크로서비스에 대한 7가지 모범 사례 • 빙글 고객 사례
  • 3.
  • 4.
    releasetestbuild 개발 및 배포 모놀리식앱 개발자 Shared libraries Shared data “Monolith 앱” 개발 배포 및 아키텍처
  • 5.
    성장하는 서비스에서 “Monolith앱”의 단점 장기 개발 사이클 (다수개발자 공동 참여) 운영의 어려움 (특정 모듈 장애시) 애플리케이션 확장성 애로 신규 출시에 몇 달이 걸림 신규 기능 추가에 어려움 아키텍처 유지 진화의 어려움 혁신 저해 고객 불만족 민첩성 저해
  • 6.
  • 7.
    Netflix embraces afine-grained Service Oriented Architecture as the underpinning of its Cloud based deployment model. Currently, we run hundreds of such fine grained services that are collectively responsible in handling the customer facing requests via a few "Edge Services" such as the Netflix API Service. A lightweight REST based protocol is the choice for inter process communication amongst these services. http://techblog.netflix.com/2013/01/announcing-ribbon-tying-netflix-mid.html
  • 8.
    “service-oriented architecture composed of loosely coupled elements thathave bounded contexts” Adrian Cockcroft (VP of Cloud Architecture @ AWS, former Cloud Architect at Netflix) 마이크로 서비스란?
  • 9.
    다른 서비스의 내부 구조를알지 못해도, 내 서비스 코드를 업데이트 할 수 있다. 서비스들이 네트워크를 통해 서로 통신한다. 서비스는 독자적으로 업데이트하며, 서로 영향을 주지 않는다. “service-oriented architecture composed of loosely coupled elements that have bounded contexts” Adrian Cockcroft (VP of Cloud Architecture @ AWS, former Cloud Architect at Netflix)
  • 10.
    Public API POST /restaurants GET/restaurants Application/Logic (code, libraries, etc) Data Store (eg, RDS, DynamoDB ElastiCache, ElasticSearch) 하나의 마이크로서비스 구성 패턴
  • 11.
  • 12.
  • 13.
    = 연간 5천만회배포 (2014년) 수 천개 팀 (자율적 DevOps팀) × 마이크로서비스 아키텍처 × 지속적 배포 (CD) × 다양한 개발 환경 (시간당 5708 회, 또는 0.63 초) Amazon.com의 사례 Werner Vogels (CTO, Amazon.com, 2015)
  • 14.
    AWS 기반 마이크로서비스 활용 사례 Building a Microservices Gaming Platform for Turbine Mobile Games (2016) From Monolithic to Microservices Evolving Architecture Patterns in the Cloud (2016) Developing Mobile Apps and Serverless Microservices for Enterprises using AWS (2016) Pure Play Video OTT- A Microservices Architecture (2015) Nike's Journey into Microservices (2014) A Journey to Microservices (2015)
  • 15.
    국내 AWS 고객사아키텍처 변신 사례 마이크로서비스 기반 모바일 서비스 마이그레이션 (2016) 마이크로 서비스 아키텍처로 방송 서비스 진화 (2016)
  • 16.
  • 17.
    전통적인 클라우드 서비스아키텍처 Clients RDS HTTP REST EC2 Instance Auto Scaling Group AZ-A AZ-B Min > 1 Elastic Load Balancing EC2 Instance AWS Elastic Beanstalk 좀더 스마트하게… .
  • 18.
    다양한 마이크로서비스 구조진화 S3 CloudFront RDS ElastiCache EC2 Elastic Load Balancing EC2 Elastic Load Balancing Static Content Content Delivery API Layer Application Layer Persistency Layer Auto Scaling Group Auto Scaling Group
  • 19.
    다양한 마이크로서비스 구조진화 CloudFront RDS ElastiCacheEC2 Elastic Load Balancing Static Content Content Delivery Application Layer Persistency Layer Auto Scaling Group API Gateway S3 API Layer
  • 20.
    다양한 마이크로서비스 구조진화 S3 CloudFront RDS ElastiCache EC2 Application Load Balancing Static Content Content Delivery API Layer Application Layer Persistency Layer API Gateway EC2 Container Service Auto Scaling Group
  • 21.
    다양한 마이크로서비스 구조진화 S3 CloudFront EC2 Application Load Balancing Static Content Content Delivery API Layer Application Layer Persistency Layer API Gateway EC2 Container Service Auto Scaling Group DynamoDB
  • 22.
    다양한 마이크로서비스 구조진화 S3 CloudFront Static Content Content Delivery API Layer Application Layer Persistency Layer API Gateway DynamoDBAWS Lambda
  • 23.
  • 24.
  • 25.
    iOS / Frontend/ Backend Technical Leader kurt@vingle.net https://github.com/breath103 이상현 Kurt Lee
  • 26.
  • 27.
    Elastic Load Balancer AWS Opsworks www.vingle.net api1.vingle.net EC2 . . . DB/ Cache EC2 EC2 External Services Vingle 서비스 인프라 구조
  • 28.
    Web server / BackgroundWorker / REST API / ORM / Business logic …. Feed Search Card Writing Admin Spam …. Unit test - 30분 Deployment - 30분 Vingle 서비스 및 코드 개발 현황
  • 29.
    기술적으로 자유로운 사고가어려움 생산성 저하 1. 언제나 모든 서비스를 함께 Deploy / Scale 2. 새로운 기술 도입이 어려움 기존 개발 환경의 문제점
  • 30.
    Small Autonomous Services that WorkTogether, modeled around a business domain MicroserviceIdeal Goals 1. Independent Scaling 2. Independent Deployment 3. Independent Stack 4. Independent Development 5. Independent Testing & Monitoring
  • 31.
    API Gateway Lambda DB /Cache • 모든 Infrastructure를 Code로 관리 • 사실상 무한, 자동 스케일링 • Code를 Upload만 하면 무중단 배포 서버리스 기반 단위별 신규 아키텍처
  • 32.
    API Gateway Lambda DynamoDB (List ofspam keywords) POST /api/validates Body: { data: “ABCDEFG” } 예) 스팸 필터 마이크로 서비스 구조
  • 33.
    1. 주어진 ShortURL https://goo.gl/12345 -> https://some.spam.url 으로 가는지 확인 2. URL을 추출해서 Redirect를 따라가며 Spam URL 체크하는 코드와 테스트 코드 작성 3. Git Push • Unit Test • Staging Deploy (1~2분) 4. Rails를 거치지 않고, Spam Service만 독립적으로 테스트 curl -H "Content-Type: application/json" -X POST -d ‘{“data”: “Some Text https://goo.gl/12345“}' http://spam-filter.vingle.net/stage/validate 5. Production Deploy (1~2분) 총 소요시간: 20~30분 코드 작성 / 테스트 이외 모든것이 자동화 (입사한지 3일 된 사람 기준) 예) 스팸 필터 마이크로 서비스 구조
  • 34.
    예) 스팸 필터마이크로 서비스 구조
  • 36.
  • 37.
  • 38.
    6개월 뒤… • Netflix와같은 Strangler Pattern Architecture • 모든 요청을 받는 기존 API서버가 있고, 해당 API서버에서 필요로 하는 마이크로서비스를 REST HTTP기반 통신으로 사용 • 모니터링을 위해 Cloudwatch를 사용하여 알림 자동화 • 서비스들 간의 Dependency를 모니터링 툴을 만들어 관리 • 각 서비스를 독립적으로 개발 / 배포 / 모니터링
  • 39.
    Lesson Learned -Microservice Migration 1. 새로 추가/변경 필요한 기능부터 분리 • 잘 돌아가고 있는 오래된 기능을 재작성은 리스크 높고, 이득도 적음 • 리스크가 작은 것부터 시작해서 팀 단위 운영/개발 노 하우 쌓아야 함 2. Business Domain 단위 서비스 구성 • Cache (X), DB (X) • Feed (O), Notification(O) 3. 서비스 존재 목적은 사용 되어지는 것 • 다른 개발자 / 시스템에서 쓰기 쉽도록 인터페이스를 갖춰야 함 • REST API라면 Swagger등을 통해 적극적으로 문서화
  • 40.
    1. AWS에서 제공하는Fully-managed service 적극 활용 • Search Microservice -> Lambda + Cloudsearch • Feed Microservice -> Lambda + DynamoDB + Kinesis Stream 2. Infrastructure-as-a-Code (AWS CloudFormation) • 시간이 조금만 지나면, AWS내 많은 리소스 관리하기 어려워짐 • AWS CloudFormation을 통해 리소스들을 코드화 / 데이터화 Lesson Learned - Cloud Infrastructure
  • 41.
  • 42.
  • 43.
    모범 사례 1 API기반 서비스 인터페이스 및 하위 호환성 유지 “Contracts” by NobMouse. No alterations other than cropping. https://www.flickr.com/photos/nobmouse/4052848608/ Image used with permissions under Creative Commons license 2.0, Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
  • 44.
    Micro-service A Micro-serviceB public API public API API를 통한 서비스별 인터페이스
  • 45.
    storeRestaurant (id, name,cuisine) storeRestaurant (id, name, cuisine) storeRestaurant (id, name, arbitrary_metadata) addReview (restaurantId, rating, comments) storeRestaurant (id, name, arbitrary_metadata) addReview (restaurantId, rating, comments) Version 1.0.0 Version 1.1.0 Version 2.0.0 public API Micro-service A 각 서비스는 타 서비스 API를 참조! 서비스 진화에 따라 API 하위 호환성 지원 가능
  • 46.
    AWS Lambda: 버전기능 • Immutable 함수 버전 기능 • 버전별 설정 및 Cloudwatch 통계 • Cloudwatch Logs에 버전 속성 포함 • 버전 출시에 따라 “label” 처리 가능 • $LATEST 최신 버전 $LATEST(95) STABLE TESTING 94 X 93 X 92
  • 47.
    Amazon API Gateway:스테이지 기능
  • 48.
    Amazon API Gateway:스테이지 변수
  • 49.
    API Gateway LambdaCustom Domain /prod/Resources FunctionName:stable https://api.example.com /qa/Resources FunctionName:qa https://qa.example.com /dev/Resources FunctionName:$LATEST https://dev.example.com 스테이지 변수에 따라 테스트 환경 설정
  • 50.
    “Tools #2” byJuan Pablo Olmo. No alterations other than cropping. https://www.flickr.com/photos/juanpol/1562101472/ Image used with permissions under Creative Commons license 2.0, Attribution Generic License (https://creativecommons.org/licenses/by/2.0/) 모범 사례 2 각기 다른 폴리그랏 개발 및 운영 환경
  • 51.
    public API publicAPI DynamoDB Micro-service A Micro-service B 워크로드별 최적 개발 환경 구성 폴리글랏(Polyglot) 접근 방식을 통한 서비스 아키텍처 선택 Amazon Elasticsearch Service RDS Aurora
  • 52.
    폴리글랏 마이크로서비스의 특징 •개별적인 데이터 스토어 구성 • 각 데이터 스토어 스키마 변경에 따른 영향이 적음 • 빠르고 독자적인 확장성 제공 account-svccart-svc DynamoDB RDS user-svc ElastiCache RDS ERROR 만약 트랜잭션 중 문제가 발생한다면?
  • 53.
    해결 방법 1:Correlation ID 활용 09-02-2015 15:03:24 ui-svc INFO [uuid-123] …… 09-02-2015 15:03:25 catalog-svc INFO [uuid-123] …… 09-02-2015 15:03:26 checkout-svc ERROR [uuid-123] …… 09-02-2015 15:03:27 payment-svc INFO [uuid-123] …… 09-02-2015 15:03:27 shipping-svc INFO [uuid-123] …… ui-svc catalog- svc checkout- svc shipping- svc payment- svc request correlation id: “uuid-123” correlation id: “uuid-123”
  • 54.
    해결 방법 2:서비스별 자체 롤백 제공 • 모든 마이크로서비스는 각자의 롤 백 기능을 가져야 한다. • 롤백이 필요할 경우, 알림이나 특정 액션에서 롤백 기능 제공 • Correrlation ID를 기반으로 롤백 알림 호출 Microservice Function 1 Rollback Commit (optional)
  • 55.
    AWS Step Functions 시각적워크플로를 사용해 분산 앱 및 마이크로서비스 구성 요소 조정 및 실행 • 자동으로 각 단계를 트리거 및 추적하고 오류가 발생할 경우 재시도하므로 애플리케이션이 의도대로 정상적으로 실행 • 앱을 단계별로 배열 및 시각화할 수 있는 그래픽 콘솔 제공 • 각 단계의 상태를 기록하여, 잘못된 경우 빠르게 문제를 진단하고 디버깅 가능 상태 변경이 일어나는 경우만 과금
  • 56.
    AWS Step Functions실행 방식
  • 57.
    샘플 미디어 공유서비스 - Amazon AI 연계 https://github.com/awslabs/lambda-refarch-imagerecognition 상태 머신 실행 사진 메타 데이터 추출 사진 메타 데이터 저장 이미지 인식 서비스 호출
  • 58.
    샘플 미디어 공유서비스 - Amazon AI 연계 순차 + 분기 + 병렬 방식
  • 59.
    샘플 미디어 공유서비스 - Amazon AI 연계 순차 + 분기 + 병렬 방식
  • 60.
    데모: 샘플 미디어공유 서비스 - Amazon AI 연계
  • 61.
    File:Cgs01053 - Flickr- NOAA Photo Library.jpg https://commons.wikimedia.org/wiki/File:Cgs01053_-_Flickr_-_NOAA_Photo_Library.jpg 모범 사례 3 지속적인 마이크로 서비스 모니터링
  • 62.
    지속적인 마이크로 서비스모니터링 • API 외부적인 요소 모니터링 • Latency, RPS, Error rate • API 내부적인 요소 모니터링 • CloudWatch, OS, Application •AWS 기반 모니터링 및 분석 도구 활용 • CloudWatch 및 CloudWatchLogs
  • 63.
    Amazon CloudWatch Logs AWS Lambda Amazon Elasticsearch Kibana 실시간로그 대시보드 구성 Amazon API Gateway Amazon ECS Amazon EC2
  • 64.
    데이터 리포팅 및시각화 Amazon ECS Amazon EC2 AWS Lambda Amazon API Gateway Amazon Redshift Amazon QuickSight Amazon EMR Amazon S3 Amazon Athena
  • 65.
    AWS Lambda 코드에러의 경우, • Lambda 함수 실행 오류가 나는 경우 • Cloudwatch Logs 통해 디버깅 가능 • 직접 Transaction Manager 함수를 별도로 만들어 Cloudwatch Logs Metric Filter 를 통해 에러 검출 ui-svc Cloudwatch Logs Cloudwatch Alarm Transaction Manager Function
  • 66.
    AWS X-Ray • 완전관리형 분산 애플리케이션 성능 추적 서비스 • 마이크로서비스 시작과 끝에 대한 디버깅 및 추적 ü 서비스에 대한 시각적 토폴로지 제공 ü 개별 요청에 대한 로그 추적 ü 성능 이슈 및 오류 발생 원인에 대한 확인 및 문제 해결 AWS Node.JS (SDK) Amazon ECS (Docker)
  • 67.
    “security” by DaveBleasdale. No alterations other than cropping. https://www.flickr.com/photos/sidelong/3878741556/ Image used with permissions under Creative Commons license 2.0, Attribution Generic License (https://creativecommons.org/licenses/by/2.0/) 모범 사례 4 마이크로서비스별 보안 강화
  • 68.
    • 서비스 수준별방어 • 네트워크 레벨 (e.g. VPC, Security Groups, TLS) • 서버/콘테이너/앱 레벨 (e.g WAF, Shield) • API Gateway (“Front door”) • API Throttling • API 키 관리 • S3 버킷 정책 + KMS + IAM • 오픈 소스 도구 (e.g. Vault, Keywhiz) API Gateway 마이크로 서비스별 보안에 유의하라!
  • 69.
    “Lamington National Park,rainforest” by Jussarian. No alterations other than cropping. https://www.flickr.com/photos/kerr_at_large/87771074/ Image used with permissions under Creative Commons license 2.0, Attribution Generic License (https://creativecommons.org/licenses/by/2.0/) 모범 사례 5 API 생태계 확산을 통한 비지니스 창출
  • 70.
    혹시 회사에 레스토랑 정보를 공개API로 제공해 주실 수 있나요? 피드백 감사드립니다. 필요하신 경우를 알려 주시면, 공개로 API를 열어 드리고 향후 비지니스 협력도 같이 할 수 있을 것 같네요! Micro-service A Micro-service B public API public API API 서비스를 통한 생태계 확산
  • 71.
    API 서비스를 통한생태계 확산 https://aws.amazon.com/ko/blogs/compute/generate -your-own-api-gateway-developer-portal/ https://aws.amazon.com/ko/blogs/compute/monetize-your- apis-in-aws-marketplace-using-api-gateway/ API Gateway Developer Portal Serverless Application Model (SAM) 기반의 오픈 소스 키 발급 및 관리 백엔드 API Monetization in Marketplace AWS Marketplace를 통해 API 서비스 판매 및 수익화 가능
  • 72.
    “rowing on theriver in Bedford” by Matthew Hunt. No alterations other than cropping. https://www.flickr.com/photos/mattphotos/19189529/ Image used with permissions under Creative Commons license 2.0, Attribution Generic License (https://creativecommons.org/licenses/by/2.0/) 모범 사례 6 기술 너머 조직 변화
  • 73.
    “Any organization thatdesigns a system will inevitably produce a design whose structure is a copy of the organization’s communication structure.” Melvin E. Conway, 1967 Conway’s Law
  • 74.
  • 75.
    Non-pizza image from Martin Fowler’s article on microservices, at http://martinfowler.com/articles/microservices.html No alterations other than cropping. Permission toreproduce: http://martinfowler.com/faq.html 기술 너머 조직의 변화 기능별 조직에서 자율성 높은 책임 조직으로 Two-Pizza Team(Amazon)
  • 76.
  • 77.
  • 78.
    자동화! 자동화! -AWS 각종 데브옵스 자동화 도구 AWS CloudFormation AWS CloudTrail AWS Config AWS Trusted Advisor Amazon Glacier Amazon S3 AWS CodePipelineAWS KMSACM Amazon CloudWatch AWS Lambda AWS CodeDeploy 17:20-18:00 Track 2 효율적인 데브옵스를 위한 AWS 개발 도구 활용하기 (200) 16:20-17:00 Track 4 인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 (300)
  • 79.
    마이크로서비스 7 가지모범 사례 1. API 기반 서비스 인터페이스 및 하위 호환성 유지 2. 각기 다른 폴리그랏 개발 및 운영 환경 3. 지속적인 마이크로 서비스 모니터링 4. 서비스별 보안에 유의하라 5. API 생태계 확산을 통한 비지니스 가치 창출 6. 기술 너머 조직의 변화 7. 자동화! 자동화!
  • 80.
    빠른 빌드/테스트/배포 가능 명확한 오너쉽 및 자율적운영 개별 마이크로 서비스 확장 가능 몇 분만에 배포 가능 신규 기능 빠르게 추가 가능 빠른 운영 및 개선 빠른 혁신 고객 만족 높은 민첩성 마이크로 서비스의 이점
  • 81.
    본 강연이 끝난후… • AWS 마이크로서비스 기술 백서 및 아키텍처 • Microservices on AWS • Microservices without the Servers • Microservices with ECS • AWS 마이크로서비스 고객 사례 • Building a Microservices Gaming Platform for Turbine Mobile Games (2016) • From Monolithic to Microservices Evolving Architecture Patterns in the Cloud (2016) • Developing Mobile Apps and Serverless Microservices for Enterprises using AWS (2016) • Pure Play Video OTT- A Microservices Architecture (2015) • Developing Mobile Apps and Serverless Microservices for Enterprises using AWS (2016) • A Journey to Microservices (2015) • Nike's Journey into Microservices (2014)