Upload
gunhee-lee
View
1.138
Download
11
Embed Size (px)
Citation preview
/114
Microservice architecture (바로알기)
이거 걍 하믄 되는거 아님?
http://facebook.com/gunlee01
1
/114
들어가기 전에..
2
Slidesahre, Facebook, 각종 블로그, 사이트등을 통해 얻은 다양한 자료를 정리해 볼까하며 개인적으로 끄적거리는 중인 자료입니다.
간단한 세미나에서 공유하고 잘 완성해 공유하려다 근래 잉여력이 바닥인지라 ... 그냥 투척합니다. 요즘 아몰랑...... 하고 마구 투척하는 것도 유행인듯하니... ㅋㅋ
다양한 클라우드플랫폼, CI/CD의 성숙, DDD, 오픈소스.. 등등등 Micro service architecture를 이야기하기에 기술적인 환경은 어느 정도 준비가 되었다고 봅니다.
여기서는 이러한 부분에 대한 내용을 다루며
조직이나 커뮤니케이션에 대한 부분은 이야기 하지 않습니다 ^^;
저도 답을 찾아 방황하는 중이에요~~~ +_+
/114
Microservice architecture
3
/114
Microservice architecture
이런 것?
Ref. http://eugenedvorkin.com/seven-micro-services-architecture-advantages/ 4
/114
Microservice architecture
혹은 이런 것?
Ref. http://martinfowler.com/articles/microservices.html 5
/114
Microservice architecture
MSA는 앞서 연구하여 정의된 아키텍처가 아닌...
문제를 해결하기 위해 결과로서 스스로 정의된 아키텍처 이며...
한가지 일을 잘하는 작은 서비스들로 이루어진...
Vendor가 아닌 개발자 주도의 SOA 사상으로...
그리고 .... Bla bla... 6
/114
Microservice architecture
네 ~ 맞습니다.
7
/114
Microservice architecture
네 ~ 맞습니다.
그럼 장점은?
8
/114
Key benefits
1)Technology Heterogeneity
9
/114
Key benefits
1)Technology Heterogeneity
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media 10
/114
Key benefits
1)Technology Heterogeneity
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
각 비즈니스에 최적화된 기술 적용
Time to Market 11
/114
Key benefits
2)Optimizing for Replaceability
12
/114
Key benefits
2)Optimizing for Replaceability
- Small size, small risk
13
/114
Key benefits
2)Optimizing for Replaceability
- Small size, small risk
- Too big, too risky !
14
/114
Key benefits
2)Optimizing for Replaceability
- Small size, small risk
- Too big, too risky !
차세대 없이는 어찌 해볼 도리가 없다...
차세대의 교훈 ! 차세대도 어렵다.
15
/114
Key benefits
2)Optimizing for Replaceability
- Small size, small risk
- Too big, too risky !
차세대 없는 점진적 진화 !
16
/114
Key benefits
3)Resilience
17
/114
Key benefits
3)Resilience
A service fails, Everything stops working
18
/114
Key benefits
3)Resilience
A service fails, Everything stop working A service fails,
the service stops working 19
/114
Key benefits
4)Scailing
20
/114
Key benefits
4)Scailing
21
/114
Key benefits
4)Scailing
We have to scale everything together.
22
/114
Key benefits
4)Scailing
Scaling at just those microservices that need it
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
필요한 Biz에 선별적 확장 가능
23
/114
Key benefits
& Ease of Deployment Organizational Alignment Composability
24
/114
Key benefits
& more 이론적으로 제한 없는 선형적 성능 확장 장애는 항상 국소적 Simple
25
/114
Key benefits
굉장하군!
26
/114
Key benefits
But...
27
/114
But
But...
MSA is no free lunch or silver bullet.
28
/114
But
Complexities of distributed systems
Scaling은 MSA 만으로 되지 않는다 분산 시스템으로 인한 (개발/운영) 복잡도 증가 실제로는 하나의 서비스가 전체 장애가 된다 - 오히려 장애율이 더 높을 수 있다.
29
/114
But
Complexities of distributed systems
Fallacies of distributed computing
30
/114
But
Complexities of distributed systems
Fallacies of distributed computing The network is reliable. Latency is zero. Bandwidth is infinite. The network is secure. Transport cost is zero. ...
Ref. http://en.wikipedia.org/wiki/Fallacies_of_distributed_computing 31
/114
But
Complexities of distributed systems
성능은? 모니터링은? 운영은? 보안은? ...
32
/114
But
Ref. Dante And Virgil In Hell (1850) / by William-Adolphe Bouguereau (1825-1905)
Complexities of distributed systems
준비되지 않았다면
Hell ~~!
33
/114
Basic Strategies
극복 방안 !
34
/114
Basic Strategies
Scaling
Scaling Database
Caching
Asynchronous
35
Basic Strategies for MSA
/114
Basic Strategies
1)Scaling
36
/114
Basic Strategies
1)Scaling
Splitting
37
POST
Friends
Pictures
/114
Basic Strategies
1)Scaling
38
Splitting
Spreading
/114
Basic Strategies
1)Scaling
39
Splitting
Spreading
Load balancing
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
Customer Service
Instance 1
Load balancer
Customer Service
Instance 2
Customer Service
Instance 3
/114
Basic Strategies
1)Scaling
40
Splitting
Spreading
Load balancing
Worker based
Customer Service Worker1
Customer Service Worker2
Customer Service Worker3
dispatcher
Queue
/114
Basic Strategies
2)Scaling Database
41
/114
Basic Strategies
2)Scaling Database
Scaling for read
42 Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
Replication
/114
Basic Strategies
2)Scaling Database
Scaling for read
43 Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
/114
Basic Strategies
2)Scaling Database
Scaling for read
44
CP? AP ?
/114
Basic Strategies
2)Scaling Database
Scaling for read
45 Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
Sacrificing availability
Sacrificing Consistency - BASE
CP? AP ?
/114
Basic Strategies
2)Scaling Database
Scaling for read
Scaling for write
46
1 4 7
2 5 8
3 6 9
Sharding Customer
Customer
Customer
/114
Basic Strategies
2)Scaling Database
Scaling for read
Scaling for write
47
1 4 7
2 5 8
3 6 9
Sharding Customer
Customer
Customer
Shard Key ?
Rebalancing ?
/114
Basic Strategies
2)Scaling Database
Scaling for read
Scaling for write
48
Sharding & replication
/114
Basic Strategies
2)Scaling Database
49
Products... NoSQLs.... & NHN Cubrid shard Twitter Gizzard Spoke Proxy Spider storage Engine CONNECT storage Engine
/114
Basic Strategies
3)Caching
50
/114
Basic Strategies
3)Caching
51
Performance optimization
/114
Basic Strategies
3)Caching
52
Performance A RAM is faster
than a HDD !
Client Memory (Cache)
Disk (origin)
1)Request for cache entry
2)on cache miss, Get fresh data from the origin
3)Update cache entry
/114
Basic Strategies
3)Caching
53
Local Cache
Global cache
Distributed cache
Cache
Cache
Cache Cache Cache
Cache Cache
/114
Basic Strategies
3)Caching
54
Performance, 공유저장소,
그리고 보통 DB의 읽기 부하 분산...
/114
Basic Strategies
3)Caching
55
Performance, 공유저장소,
그리고 보통 DB의 읽기 부하 분산...
그런데 !!!
Cache가 죽으니 DB가 죽더라...
/114
Basic Strategies
3)Caching
56
How to hide the origin
Client Cache
Origin (DB or others)
Sync. Request for cache entry
Async. Event fired in event of cache miss update
Fail fast on cache miss
/114
Basic Strategies
3)Caching
57
Products... Redis Memcached Redis Cluster Infinispan Hazelcast Coherence
/114
Basic Strategies
4)Asynchronous
58
/114
Basic Strategies
4)Asynchronous
59
스타벅스는 비동기?
Ref. http://www.eaipatterns.com/ramblings/18_starbucks.html / Gregor Hohpe
Starbuks Does Not Use 2PC.
- Hotto Cocoa o Kudasai.
/114
Basic Strategies
4)Asynchronous
60
/114
Basic Strategies
4)Asynchronous
61
스타벅스는 비동기?
주문
데스크
바리스타
바리스타
바리스타
바리스타
/114
Basic Strategies
4)Asynchronous
62
스타벅스는 비동기?
고객이 주문하고 기다릴 필요가 없다. - 웹서핑을 하던지, 수다를 떨던지...
Loosely Coupled !
/114
Basic Strategies
4)Asynchronous
63
스타벅스는 비동기?
주문을 지속적으로 받을 수 있다. - 커피 머신이 잠시 고장나더라도...
Resilience !
/114
Basic Strategies
4)Asynchronous
64
스타벅스는 비동기?
비슷한 음료는 한번에 만들 수도.. - 반드시 순서대로 작업할 필요가 없다... - 여러 고객의 커피류를 한번에 만든다...
Performance !
/114
Basic Strategies
4)Asynchronous
65
Loosely coupled
Resilience
Performance
Client Service
Worker
Worker
Worker
Message Queue
/114
Basic Strategies
4)Asynchronous
66
Orchestration vs Choreography
지휘 vs 안무구성
/114
Basic Strategies
4)Asynchronous
67
Orchestration vs Choreography Choreographed approach is more loosely coupled, flexible and amenable to change.
/114
Basic Strategies
4)Asynchronous
68
Orchestration vs Choreography
Orchestration
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
/114
Basic Strategies
4)Asynchronous
69
Orchestration vs Choreography
Choreography
Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
/114
Basic Strategies
Scaling
Scaling Database
Caching
Asynchronous
70
Basic Strategies for MSA
/114
Real World
71
실제로는 훨씬 더 복잡하다
어떻게
하라는 거임?
/114
Real World
72
더 필요한 것들
/114
Real World
1)Dynamic Service Registry
73
/114
Real World
1)Dynamic Service Registry
74
Service discovery
Health check between instances
Service versioning
/114
Real World
1)Dynamic Service Registry
75
Client Service Registry
Service A
Where is the service A?
Service Service Service
Service Service Service Service
I’m here.
I’m alive!
OK
/114
Real World
1)Dynamic Service Registry
76
Zookeeper Apache
Consul
Eureka Netflix
/114
Real World
2)Antifragile
77
A resilience is free?
Absolutely Not!
/114
Real World
2)Antifragile
78
Cascading failure
Ref. https://github.com/Netflix/Hystrix/wiki
/114
Real World
2)Antifragile
79 Ref. https://github.com/Netflix/Hystrix/wiki
Cascading failure
/114
Real World
2)Antifragile
80 Ref. https://github.com/Netflix/Hystrix/wiki
Cascading failure
/114
Real World
2)Antifragile
81
Bulkhead
Cascading failure
/114
Real World
2)Antifragile
82
Timeout
Client Service request over N/W
Wait for some seconds
Check time out
Do failure scenarios
Cascading failure
/114
Real World
2)Antifragile
83
Throttle & quick failure
Client Service request over N/W
Quick failure (if exceed max allowed req.)
Cascading failure
/114
Real World
2)Antifragile
84
Retry
Client Service request over N/W
If error or timeout,
Retry
Cascading failure
/114
Real World
2)Antifragile
85
Idempotency
Cascading failure
Ref. https://github.com/Netflix/Hystrix/wiki
/114
Real World
2)Antifragile
86
Circuit breaker
Cascading failure
Ref. https://github.com/Netflix/Hystrix/wiki
/114
Real World
2)Antifragile
87
Cascading failure
/114
Real World
2)Antifragile
88
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
/114
Real World
2)Antifragile
89
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
/114
Real World
2)Antifragile
90
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
/114
Real World
2)Antifragile
91
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue Bad
Message
/114
Real World
2)Antifragile
92
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
/114
Real World
2)Antifragile
93
Catastrophic Failover
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
/114
Real World
2)Antifragile
94
Catastrophic Failover
Failure queue
Client Service
Worker
Worker
Worker
Message Queue
Bad Message
Failure Queue
Bad Message Bad
Message
/114
Real World
3)Monitoring
95
/114
Real World
3)Monitoring
96
Cross service Tracing
/114
Real World
3)Monitoring
97
Cross service Tracing
It’s not my fault!
/114
Real World
3)Monitoring
98
Google Dapper
Cross service Tracing
Ref. http://static.googleusercontent.com/media/research.google.com/ko//pubs/archive/36356.pdf
/114
Real World
3)Monitoring
99
Google Dapper
Cross service Tracing
/114
Real World
3)Monitoring
100
Pinpoint – open source https://github.com/naver/pinpoint
/114
Real World
3)Monitoring
101
Zipkin – twitter
/114
Real World
3)Monitoring
102
App Dynamics – on premise, SASS
Flow map Business Activity Monitoring Cross-service tracing Self-leaning
/114
Real World
3)Monitoring
103
New Relic
Transaction Breakdown Cross App Tracing Support any language on any hosting Browser side insight
/114
Real World
3)Monitoring
104
Scouter – Open source
https://github.com/scouter-project
/114
Real World
105
이것들 말고 더 있다...
1) Dynamic Service Registry (or Service Discovery or API Gateway ... )
2) Antifragile 3) Monitoring
/114
Real World
106
And More ...
Deployment
/114
Real World
107
And More ...
Deployment
Continuous delivery
Blue Green deployments
Canary deployments
Ref. https://devcentral.f5.com/articles/programmability-in-the-network-canary-deployments
Ref. http://andreas-simon.blogspot.kr/2014/02/zero-downtime-deployment-for-grails.html
/114
Real World
108
And More ...
Security – Trust between services API Token Client Certificate HMAC (hash message authentication code)
Ref. http://en.wikipedia.org/wiki/Hash-based_message_authentication_code
/114
Real World
109
And More ...
Testing
Ref. http://martinfowler.com/articles/microservice-testing/#conclusion-summary
/114
Real World
110
And More ...
Ref. http://www.slideshare.net/saltynut/whitebase
White Base – SK Planet
API Gateway
Easy to instantiate MSs in development env.
Solving resource problems on developer’s PC.
Testing
/114
Real World
111
And More ...
Ref. http://www.slideshare.net/saltynut/whitebase
Testing
White Base
/114
결국... 기술적인 부분도 더 고민해야 할 것이 많다.
112
Scaling Caching
Service Discovery (API Gateway)
Monitoring Asyncronous
Antifragile Security Testing
Deployment Maturity bar
Optimizing
Defined
Initial
/114
References
http://eugenedvorkin.com/seven-micro-services-architecture-advantages/ http://martinfowler.com/articles/microservices.html http://martinfowler.com/bliki/CatastrophicFailover.html http://martinfowler.com/articles/microservice-testing http://www.appdynamics.co.kr http://newrelic.com/application-monitoring https://github.com/Netflix/Hystrix/wiki http://martinfowler.com/bliki/PolyglotPersistence.html http://static.googleusercontent.com/media/research.google.com/ko//pubs/archive/36356.pdf https://github.com/naver/pinpoint http://www.slideshare.net/saltynut/whitebase https://devcentral.f5.com/articles/programmability-in-the-network-canary-deployments http://andreas-simon.blogspot.kr/2014/02/zero-downtime-deployment-for-grails.html http://en.wikipedia.org/wiki/Hash-based_message_authentication_code Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media
114