Upload
terry-cho
View
7.437
Download
0
Embed Size (px)
Citation preview
2
목차
● 마이크로서비스아키텍쳐의개념
● 마이크로서비스아키텍쳐설계패턴
● 구글앱앤진
● 데모
Google Cloud Platform 3Google Cloud Platform 3
Micro Service Architecture 의기본개념
Google Cloud Platform 4
전통적인아키텍쳐스타일
• 모노리틱아키텍쳐 (통서버)
• 하나의서버에모든비지니스로직이들어가있는형태
• 하나의중앙집중화된데이타베이스에모든데이타가저장됨
Google Cloud Platform 5
전통적인아키텍쳐스타일의장단점
• 단점
• 여러개의기술을혼용해서사용하기어려움 (node.js , Ruby, Python etc)
• 배포및재기동시간이오래걸림
• 수정이용이하지않음 (타컴포넌트의존성)
• 장점
• 기술단일화
• 관리용이성
Google Cloud Platform 6
마이크로서비스아키텍쳐란?
• 시스템을여러개의독립된서비스로나눠서, 이서비스를조합함으로서기능을제공하는아키텍쳐
디자인패턴
• SOA의경량화버전 (실패한다면실패하는이유도같음)
서비스란?
– 단일된기능묶음으로개발된서비스컴포넌트
– REST API등을통하여기능을제공
– 데이타를공유하지않고독립적으로가공저장
사용자관리 인터페이스• REST
• Thrift,Protocol buffer
• AMQP
• :사용자데이타
Google Cloud Platform 7
서비스조합
• 하나의기능을구현하는데, 여러개의서비스를조합하여기능을제공
예) 주문하기 : 사용자정보조회, 상품정보조회, 신규주문생성
사용자관리
상품관리
주문관리
쇼핑몰웹
API CALL
사용자정보
상품정보
주문정보
사용자관리 상품관리 주문관리
사용자정보 상품정보 주문정보
쇼핑몰웹
API CALL
모노리틱아키텍쳐
마이크로서비스아키텍쳐
Google Cloud Platform 8
기술스택
• 마이크로서비스아키텍쳐는서비스별로다른기술스택을사용할수있음
사용자관리(JAVA)
상품관리(node.js)
주문관리(JAVA)
사용자정보(Cassandra)
상품정보(MySQL)
주문정보(CouchBase)
쇼핑몰웹
API CALL
장점일까?
• 운영관점에서여러가지기술을동시에다뤄야함(Devops – You build, You run)
• 사람이떠나면보수불가(Product not a project)
단점일까?
• 적절한기술을적절하게배치가능o 복잡한데이타 RDBMS, 양이많은고속데이타 NoSQL
o C10K NoSQL, 빠른개발스크립트언어, 튼튼한시스템은자바 …
Google Cloud Platform 9
팀모델
• 컨웨이의법칙
• 뼈저리게느낌
“소프트웨어의구조는그소프트웨어를만드는팀의구조와일치한다.”
설계백날잘해야소용없음제대로된팀구조를만드는것이설계 (그다음은알아서됨 ?)
• 친한팀컴포넌트끼리는개발이잘됨. 그러다보니그쪽으로기능이몰림
• 잘하는팀한테자꾸중요기능이몰림
서비스컴포넌트들이균등하게디자인되지않음
Google Cloud Platform 10
팀모델
• 분산형거버넌스 (각팀이알아서. 적합한기술, 스스로하기)
• You build & You run!!
• Self Organized Team
• Product vs Project
• Cross functional team
• Alignment (소통!!)
Google Cloud Platform 1111
Functional team
모바일앱
백앤드
웹페이지 관리도구
댓글 포스팅 댓글 포스팅
앱개발팀 프론트개발팀
백앤드개발팀
• 기술에따른분류
Google Cloud Platform 1212
Cross functional team (제품기반)
• 제품에따라팀을분류
Google Cloud Platform 13
팀모델
• 팀간조율이핵심
• 새로운조율자 ROLE이요구됨
프로그램메니져 : 팀간일정조율치프아키텍트 : 서비스간흐름정의, 표준정의, 에러추적/처리방법정의
Google Cloud Platform 1414
Cross functional team (기능기반)
• 기능에따라팀을분류
제품에걸쳐일관된기능경
험을제공
• aka. Featured team model
(by Spotify)
Google Cloud Platform 15
MSA Reference Architecture
Google Cloud Platform 16
마이크로서비스아키텍쳐토폴로지
• 일반적인마이크로서비스아키텍쳐스택구조
API gateway
Service orchestration
(mediation, aggregation)
Co
mm
on A
PIs
Co
mm
on A
PIs
Co
mm
on A
PIs
Co
mm
on A
PIs
Co
mm
on A
PIs
Co
mm
on A
PIs
생략가능영역• API 게이트웨이 : API의 single end point
• Common APIs : 범용 API
• Orchestration : 여러 API를묶어서, 요구사항에맞는로직을구현
• Service Orchestration
규모가커질수록추가되는계층들 (오케스트레이션, API 게이트웨이)
1단계2단계
3단계
Google Cloud Platform 17
쇼핑몰 API
서버
서비스오케스트레이션계층의활용
사용자관리 상품관리 주문관리
사용자정보 상품정보 주문정보
앱또는자바스크립트클라이언트
API CALL
사용자관리 상품관리 주문관리
사용자정보 상품정보 주문정보
API CALL
클라이언트
API CALL
클라이언트에서직접서비스를조합하는방식
별도의조합계층(Orchestration or Mediation)
을넣는방식
다른프로토콜사용가능ex)내부 PB, 외부 REST
• API가범용적으로 잘짜야있어야함• 클라이언트팀이모든컴포넌트팀과
조율이필요
규모가크지않은구조에서효과적
• 중간에 API를커스터마이제이션 또는조합하는계층을별도로둠
• 클라이언트팀은 조합 API 개발팀과커뮤니케이션만하면됨
• 클라이언트요구사항에기민하게대처• 그러나계층은하나더늘어남 (성능,디버
깅,배포)
일정규모이상. 특히클라이언트가여러개인구조에효과적
Google Cloud Platform 18
API 게이트웨이
• 클라이언트와 API 서버앞에서일종
의프록시처럼위치하여다양한기
능을수행함
• API 인증/인가
• 로깅
• 라우팅
• 메시지변환
• 메시지프로토콜변환
:
API 서버 API 서버 API 서버
데이타 데이타 데이타
API 게이트웨이
Google Cloud Platform 19
API 게이트웨이
• SOA ESB (Enterprise Service Bus)의단순화버전
• 있으면좋음. 없어도됨
• 만들수있는실력있으면, 쓰는게좋음
• 잘못쓰면망하는지름길
Google Cloud Platform 20
API 게이트웨이를이용한설계패턴 #1
• 인증,인가의단일화
IDM
(계정관리)
API 토큰관리
클라이언트
API
게이트웨이
API
서버
1. API 토큰발급요청
2. 사용자인증/인가
3. API 호출
5. API 호출
4. API 토큰인증
Google Cloud Platform 21
API 게이트웨이를이용한설계패턴 #2
• 멀티앤드포인트와멀티프로토콜제공
<그림. 다양한디바이스로부터정보를수집하는 IOT시스템에타입별앤드포인트제공하는예제>
Google Cloud Platform 22
API 게이트웨이를이용한설계패턴 #3
• 오케스트레이션
• ESB 기반 SOA 프로젝트가실패한대부
분의원인 (안하는게좋음)
• 오케스트레이션서버를별도로두는게
좋음
Google Cloud Platform 23
API 게이트웨이를이용한설계패턴 #4
• 메세지기반라우팅
• 글로벌배포시스템에유용함
• 멀티버전시스템 (레거시업그레이드)에유용
Google Cloud Platform 24
API 게이트웨이를이용한설계패턴 #5
• Cross Cutting Concern (공통기능) 처리
• 인증,로깅등공통기능처리
• API 개발팀은비지니스로직에집중할수있도록해줌
Google Cloud Platform 25
API 게이트웨이를이용한설계패턴 #6
• 다중 API 게이트웨이패턴
• 내부,외부용 API 게이트웨이분리
Google Cloud Platform 26
API 게이트웨이를이용한설계패턴 #7
• API 호출용엔드포인트와스트리밍 (파일)용엔드포인
트분리
Google Cloud Platform 27
API 게이트웨이를이용한설계패턴 #6
• 비기능요소제어
• QoS 제어
• Metering & Charging (상용 API 서비스과금)
• API 모니터링
Google Cloud Platform 28
분산트렌젝션의추적
• 여러개의서비스컴포넌트를조합하여움직이는
트렌젝션에대한추적디자인패턴
• 원리 (XA 분산트렌젝션과유사)
• 초기 API에서 GTXID와 LTXID를생성
• 서버를넘어갈때마다같은 GTXID를사용, LTXID는하
나씩증가
• 구현시
• 서버간에는 HTTP 헤더로 TXID 전달
• 서버내에서는 Thread Local (Java)등의컨택스트변수
활용
→ 초기표준설계가중요함
Google Cloud Platform 29Google Cloud Platform 29
Google cloud computing services
30
VM 기반의 IaaS 서비스
Compute Engine
도커 & Kubernetes 기
반컨테이너엔진
Container Engine
운영이필요없는
(zeo ops) 백앤드
PaaS 플랫폼
App Engine
Compute on Google Cloud Platform
31
Google App Engine
애플리케이션개발에최적화된매니지드서비스
● 개발자는코드개발에만주력, 인프라관리, 클러스터링, 서버관리
에서자유로움
● Building quickly and time to market are highly valued
● 빠르게백앤드서비스를개발
● 복잡한인프라구성없이, HA 기반의고가용성제공A flexible, zero ops
platform for building
highly available apps
App Engine
32
오픈소스 Kubernetes 기반의도커서비스
● VM 기반의 Kubernetes 클러스터를자동생성및관리
● 컨테이너기반의배포 (한 VM에여러컨테이너를자동배포)
● 자동로드밸런싱, 페일오버
● 인프라에대한관리가필요없음 (컨테이너만배포)
Google Container Engine
Cluster manager and
orchestration engine
built on Google’s
container experience
Container Engine
33
Google Compute Engine
구글클라우드의 VM 기반의 IaaS 서비스
● 인프라에대한풀컨트롤제공 (모든컨트롤이필요할경우사용)
● 커널레벨체인지가능
● 컨테이너화가어려운개발에사용
Virtual machines
with industry-leading
price/performance
Compute Engine
34
운영이필요없는
(zeo ops) 백앤드
PaaS 플랫폼
App Engine
Compute on Google Cloud Platform
35
= $$$$$사람이제일비싸
다
36
돈으로해결 !!
37Confidential & ProprietaryGoogle Cloud Platform 37
ZeroOpswith PaaS (appEngine)
38
Powerful built-in services
Managed services, such as Task Queues, Memcache and the Users API, let you build any application.
Deploy at Google scale
You can scale up to 7 billion requests per day and automatically scale down when traffic subsides.
Focus on your code
Let Google worry about database administration, server configuration, sharding & load balancing.
Popular languages & frameworks
Write applications in some of the most popular programming languages, use existing frameworks and
integrate with other familiar technologies.
App
Engine
Familiar development tools
Use the tools you know, including Eclipse, IntellIJ, Maven, Git, Jenkins, PyCharm & more.
Multiple storage options
Choose the storage option you need: a traditional MySQL database using Cloud SQL, a schemaless NoSQL
datastore, or object storage using Cloud Storage.
39
Service & Versioning
https://instance-dot-version-dot-service-dot-app-id.appspot.com
http://instance.version.service.my-custom-domain.com
https://version-dot-service-dot-app-id.appspot.com
http://version.service.my-custom-domain.com
https://service-dot-app-id.appspot.com
http://service.my-custom-domain.com
40
Focus on code, not managing infrastructure. Fully managed by Google site reliability engineers.
운영이필요없음 (Zero Ops)
41
구글앱앤진 1세대 (Standard Environment)
(Cache)
Memcached
Document Search
Security Scan
Time Scheduler
MySQL
NoSQL (JSON)
DataStore
NoSQL (Column)
BigTable
BigQuery
Dataflow
Pub/Sub
Python 2.7, Java 7, PHP, Go
Application Server Managed Service Database BigData Platform
App Engine (PaaS) Shared Service
42
구글앱앤진 1세대 (Standard Environment)
● Ultra fast server start up & scaling (mili second)
● Easy deployment & roll back
● Built in managed service
• Document Search API
• Memcached
• Scheduler (Timer)
• Security scans
43
쉬운배포와롤백
● 복잡한배포툴이나프로세스가필요없음배포
롤백
44
트래픽분할을통한카날리테스팅 (& AB 테스팅)
● 버전별트래픽분할 (V2 : 30%, V1 : 10%)
45
그런데.. PaaS의한계
● 로컬디스크를쓰고싶다
● 더큰인스턴스를쓰고싶다
● 디버깅을위해 SSH로로그인을하고싶다
● 모니터링에이전트를깔고싶다
● node.js 를쓰고싶은데..
● 나만의 PaaS 를만들수는없을까?
● 몽고DB와 REDIS를쓰고싶다( 외부매니지드서비스사용, 또는 IaaS에설치후 PublicIP를통해접근)
46
2세대앱앤진
Appengine Flexible
Environment
BETA
47
Flex Environment (BETA)
● 도커기반
● Standard environment 에비해서배포가느립니다.
• Standard : 밀리세컨드단위
• Flex : 분단위
48
But!!
● 로컬디스크를쓰고싶다
● 더큰인스턴스를쓰고싶다
● 디버깅을위해 SSH로로그인을하고
싶다
● 모니터링에이전트를깔고싶다
● node.js 를쓰고싶은데..
● 나만의 PaaS 를만들수는없을까?
● 몽고DB와 REDIS를쓰고싶다
→로컬디스크마운트가능
→ 32 CPU, 208 GB
→ SSH 로그인가능
→ Custom Image
→ Java,Go,Ruby,Python,PHP, node
→ Custom Image
→ GCE와 Private Network로연결, VPN지
원
49
다양한프로그래밍언어와, 프레임웍지
원Build your application with any language, framework, library
Google-managed stacks:
Languages + frameworks
Node.js, Python, Java, PHP, Go
Add your own third-party components
Add New Relic, App Dynamics, 3rd party app server
Use any language runtime
Use any language runtime -- such as Ruby or Scala -- or dependency
Developer tool support
Eclipse, IntelliJ, PyCharm, Jenkins
Web Module
Version #1
Load B
ala
ncer
Auto
Scale
r
App
Instance
Relational
Storage
Queues
Version #2
App
Instance
Web Module
Version #1
App
Instance
Version #2
App
Instance
Blob Storage
Caching
Non-relational
Storage
GAE
AppEngine Standard 네트워킹
- Centralized PaaS
- Siloed from the rest of GCP
- App Engine or nothing
- Customers quickly outgrew
- Doesn’t keep up with Open
Source innovation
Web Module
Version #1
Load B
ala
ncer
Auto
Scale
r
App
Instance
Relational
Storage
Queues
GCE/GKE
Private IP:
10.x.x.x
Version #2
App
Instance
Redis
Replica
RabbitMQ
Replica
Private IP:
10.x.x.x
...
Replica Blob Storage
Caching
Non-relational
Storage
GAE
AppEngine Flex 네트워킹
Web Module
Version #1
App
Instance
Version #2
App
Instance
MongoDB
Replica
...
Replica
...
Replica
...
Replica
...
Replica
53
I have
PaaS !!
I have
IaaS !!
54
Ah~~ I have IPaaS
(IaaS + PaaS = Hybrid architecture)
node.js / GAE
python / GAE
:
GCS
Static contents
API servers (AppEngine)
mongoDB / GCE
Redis / GCE
Data base (GCE)
private IP
Same network
api.com/users
api.com/products
PaaS IaaS
Static contents
API calls
55
Standard Environment vs Flex Environment
Standard environment Flexible environment What Flexible means for you
Runtime environment 구글전용런타임환경 (호환성없음)Python 2.7, Java 7, PHP, Go
도커컨테이너위에서동작Java,Go,Ruby,Python,PHP,node.JS 등대부분의백앤드언어지원가능+ Custom Runtime
FlexibilityAny language, framework or library
PerformanceUp to 32 vCPUs and 208GB of memory
Networking stack 전용네트워크 구글클라우드네트워크Private IP를통해서 GCE, GKE 등과연동이가능. 기타 VPN, Carrier 네트워크등옵션사용가능
One networkConnect App Engine to Compute Engine on private network
VPN, direct peering & carrier connect options
Load balancerAutoscaler
전용로드밸런서 구글클라우드로드밸런서구글클라우드 Auto Scaler 사용가능
More control사용자레벨에서조금더세밀한컨트롤이가능
Managed runtime support Java, PHP, Python & Go Managed Node.js, Ruby, Python 3, Java, PHP & Go environments, and bring your own via Docker
Mix and match runtimesRun each microservice with the runtime and environment that best fits
Instance start up time millisecond Minutes
56Confidential & ProprietaryGoogle Cloud Platform 56
DEMO
57
DEMO
version
version
users service
:
version
version
products service
:
internal load balancer
http://api.com/users http://api.com/prodcuts
node.js
runtime
node.js
runtime
dispatch:
- url: "*/users/*"
module: users
- url: "*/products/*"
module: products
58
DEMO
1. 코드확인
2. 롤백
3. 트래픽분산
4. 새버전배포
59Confidential & ProprietaryGoogle Cloud Platform 59
Customer references
60
Customers using
App Engine
61
700 million
“App Engine enabled us to focus on developing the application. We wouldn’t have gotten here without the ease of development that App Engine gave us.”
Bobby Murphy, CTO
Snapchat sends
photos and videos each day Google App Enginescaled seamlesslyduring growth to
millions of users
Small team is ableto innovate quickly
and expand
globally
62
63
New customer experience powered by App Engine & Cloud Storage
Top 5 40%online retailer
in North Americaperformance improvement
“Google Cloud Platform made it possible to bring our new My Print Center to market faster with enhanced capabilities and improved usability.”
64
100 million reduced IT overhead scaled 10x fast time
to marketNumber of daily transactions
on Compute Engine and
App Engine
Eliminated the need to build a
10-person ops team to keep
the back end running
Automatically scaled when
users increased from 10,000
users to 100,000
Launched the platform fast and
immediately focused on
developing new features
“Without Google Cloud Platform, we would never have been able to launch so fast. We
were able to capture users and keep developing new features. That head start was
invaluable.”
65
3M players 200 RPS 0 downtime 2TB
Voodoo Quiz Run is the most-
played mobile quiz app in
France, and has ~3 million
players in France, Germany and
United States
Processes millions
of requests, with spikes
of 200 requests per second,
with no errors and low latency
Zero downtime during 3 years
on App Engine
Serves 2 terabytes
of data monthly
“Our users currently play about one million turns daily. App Engine handles millions of
requests, with spikes of 200 requests per second, with no errors and low latency. We
have had zero downtime in our three years on App Engine.”
Confidential & ProprietaryGoogle Cloud Platform 66
Standard
Flex(ible)
● GA product that has been in market for years
● Java 7, Python 2.7, Go, and PHP language support
● ...
● Built on top of core GCP components (containers + VMs)
● Industry standard (and OSS) language runtimes
○ Java 8, Python 3, Node.js, Ruby, Go, PHP
● Completely flexible, customizable, and extensible
● More options in terms of CPU and memory (32 cores, 200 GB)
● Integrated with GCE’s Andromeda network, enables GAE ⇔ GCE
secure communication
● Access to lower-level infrastructure, such as Load Balancer policies
and configuration
● Built-in Load Balancing, Auto Scaling, Logging, Monitoring
● Microservice, versioning, and traffic splitting support
● No need for Docker (we build the underlying container for you)
● 99.95% SLA (coming)
● Note: Formerly known as “Manage VMs”