114
/114 Microservice architecture (바로알기) 이거 하믄 되는거 아님? 이건희 [email protected] http://facebook.com/gunlee01 1

Microservice architecture 바로 알기

Embed Size (px)

Citation preview

Page 1: Microservice architecture 바로 알기

/114

Microservice architecture (바로알기)

이거 걍 하믄 되는거 아님?

이건희 [email protected]

http://facebook.com/gunlee01

1

Page 2: Microservice architecture 바로 알기

/114

들어가기 전에..

2

Slidesahre, Facebook, 각종 블로그, 사이트등을 통해 얻은 다양한 자료를 정리해 볼까하며 개인적으로 끄적거리는 중인 자료입니다.

간단한 세미나에서 공유하고 잘 완성해 공유하려다 근래 잉여력이 바닥인지라 ... 그냥 투척합니다. 요즘 아몰랑...... 하고 마구 투척하는 것도 유행인듯하니... ㅋㅋ

다양한 클라우드플랫폼, CI/CD의 성숙, DDD, 오픈소스.. 등등등 Micro service architecture를 이야기하기에 기술적인 환경은 어느 정도 준비가 되었다고 봅니다.

여기서는 이러한 부분에 대한 내용을 다루며

조직이나 커뮤니케이션에 대한 부분은 이야기 하지 않습니다 ^^;

저도 답을 찾아 방황하는 중이에요~~~ +_+

Page 3: Microservice architecture 바로 알기

/114

Microservice architecture

3

Page 4: Microservice architecture 바로 알기

/114

Microservice architecture

이런 것?

Ref. http://eugenedvorkin.com/seven-micro-services-architecture-advantages/ 4

Page 5: Microservice architecture 바로 알기

/114

Microservice architecture

혹은 이런 것?

Ref. http://martinfowler.com/articles/microservices.html 5

Page 6: Microservice architecture 바로 알기

/114

Microservice architecture

MSA는 앞서 연구하여 정의된 아키텍처가 아닌...

문제를 해결하기 위해 결과로서 스스로 정의된 아키텍처 이며...

한가지 일을 잘하는 작은 서비스들로 이루어진...

Vendor가 아닌 개발자 주도의 SOA 사상으로...

그리고 .... Bla bla... 6

Page 7: Microservice architecture 바로 알기

/114

Microservice architecture

네 ~ 맞습니다.

7

Page 8: Microservice architecture 바로 알기

/114

Microservice architecture

네 ~ 맞습니다.

그럼 장점은?

8

Page 9: Microservice architecture 바로 알기

/114

Key benefits

1)Technology Heterogeneity

9

Page 10: Microservice architecture 바로 알기

/114

Key benefits

1)Technology Heterogeneity

Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media 10

Page 11: Microservice architecture 바로 알기

/114

Key benefits

1)Technology Heterogeneity

Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media

각 비즈니스에 최적화된 기술 적용

Time to Market 11

Page 12: Microservice architecture 바로 알기

/114

Key benefits

2)Optimizing for Replaceability

12

Page 13: Microservice architecture 바로 알기

/114

Key benefits

2)Optimizing for Replaceability

- Small size, small risk

13

Page 14: Microservice architecture 바로 알기

/114

Key benefits

2)Optimizing for Replaceability

- Small size, small risk

- Too big, too risky !

14

Page 15: Microservice architecture 바로 알기

/114

Key benefits

2)Optimizing for Replaceability

- Small size, small risk

- Too big, too risky !

차세대 없이는 어찌 해볼 도리가 없다...

차세대의 교훈 ! 차세대도 어렵다.

15

Page 16: Microservice architecture 바로 알기

/114

Key benefits

2)Optimizing for Replaceability

- Small size, small risk

- Too big, too risky !

차세대 없는 점진적 진화 !

16

Page 17: Microservice architecture 바로 알기

/114

Key benefits

3)Resilience

17

Page 18: Microservice architecture 바로 알기

/114

Key benefits

3)Resilience

A service fails, Everything stops working

18

Page 19: Microservice architecture 바로 알기

/114

Key benefits

3)Resilience

A service fails, Everything stop working A service fails,

the service stops working 19

Page 20: Microservice architecture 바로 알기

/114

Key benefits

4)Scailing

20

Page 21: Microservice architecture 바로 알기

/114

Key benefits

4)Scailing

21

Page 22: Microservice architecture 바로 알기

/114

Key benefits

4)Scailing

We have to scale everything together.

22

Page 23: Microservice architecture 바로 알기

/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

Page 24: Microservice architecture 바로 알기

/114

Key benefits

& Ease of Deployment Organizational Alignment Composability

24

Page 25: Microservice architecture 바로 알기

/114

Key benefits

& more 이론적으로 제한 없는 선형적 성능 확장 장애는 항상 국소적 Simple

25

Page 26: Microservice architecture 바로 알기

/114

Key benefits

굉장하군!

26

Page 27: Microservice architecture 바로 알기

/114

Key benefits

But...

27

Page 28: Microservice architecture 바로 알기

/114

But

But...

MSA is no free lunch or silver bullet.

28

Page 29: Microservice architecture 바로 알기

/114

But

Complexities of distributed systems

Scaling은 MSA 만으로 되지 않는다 분산 시스템으로 인한 (개발/운영) 복잡도 증가 실제로는 하나의 서비스가 전체 장애가 된다 - 오히려 장애율이 더 높을 수 있다.

29

Page 30: Microservice architecture 바로 알기

/114

But

Complexities of distributed systems

Fallacies of distributed computing

30

Page 31: Microservice architecture 바로 알기

/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

Page 32: Microservice architecture 바로 알기

/114

But

Complexities of distributed systems

성능은? 모니터링은? 운영은? 보안은? ...

32

Page 33: Microservice architecture 바로 알기

/114

But

Ref. Dante And Virgil In Hell (1850) / by William-Adolphe Bouguereau (1825-1905)

Complexities of distributed systems

준비되지 않았다면

Hell ~~!

33

Page 34: Microservice architecture 바로 알기

/114

Basic Strategies

극복 방안 !

34

Page 35: Microservice architecture 바로 알기

/114

Basic Strategies

Scaling

Scaling Database

Caching

Asynchronous

35

Basic Strategies for MSA

Page 36: Microservice architecture 바로 알기

/114

Basic Strategies

1)Scaling

36

Page 37: Microservice architecture 바로 알기

/114

Basic Strategies

1)Scaling

Splitting

37

POST

Friends

Pictures

Page 38: Microservice architecture 바로 알기

/114

Basic Strategies

1)Scaling

38

Splitting

Spreading

Page 39: Microservice architecture 바로 알기

/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

Page 40: Microservice architecture 바로 알기

/114

Basic Strategies

1)Scaling

40

Splitting

Spreading

Load balancing

Worker based

Customer Service Worker1

Customer Service Worker2

Customer Service Worker3

dispatcher

Queue

Page 41: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

41

Page 42: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

Scaling for read

42 Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media

Replication

Page 43: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

Scaling for read

43 Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media

Page 44: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

Scaling for read

44

CP? AP ?

Page 45: Microservice architecture 바로 알기

/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 ?

Page 46: Microservice architecture 바로 알기

/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

Page 47: Microservice architecture 바로 알기

/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 ?

Page 48: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

Scaling for read

Scaling for write

48

Sharding & replication

Page 49: Microservice architecture 바로 알기

/114

Basic Strategies

2)Scaling Database

49

Products... NoSQLs.... & NHN Cubrid shard Twitter Gizzard Spoke Proxy Spider storage Engine CONNECT storage Engine

Page 50: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

50

Page 51: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

51

Performance optimization

Page 52: Microservice architecture 바로 알기

/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

Page 53: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

53

Local Cache

Global cache

Distributed cache

Cache

Cache

Cache Cache Cache

Cache Cache

Page 54: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

54

Performance, 공유저장소,

그리고 보통 DB의 읽기 부하 분산...

Page 55: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

55

Performance, 공유저장소,

그리고 보통 DB의 읽기 부하 분산...

그런데 !!!

Cache가 죽으니 DB가 죽더라...

Page 56: Microservice architecture 바로 알기

/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

Page 57: Microservice architecture 바로 알기

/114

Basic Strategies

3)Caching

57

Products... Redis Memcached Redis Cluster Infinispan Hazelcast Coherence

Page 58: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

58

Page 59: Microservice architecture 바로 알기

/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.

Page 60: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

60

Page 61: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

61

스타벅스는 비동기?

주문

데스크

바리스타

바리스타

바리스타

바리스타

Page 62: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

62

스타벅스는 비동기?

고객이 주문하고 기다릴 필요가 없다. - 웹서핑을 하던지, 수다를 떨던지...

Loosely Coupled !

Page 63: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

63

스타벅스는 비동기?

주문을 지속적으로 받을 수 있다. - 커피 머신이 잠시 고장나더라도...

Resilience !

Page 64: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

64

스타벅스는 비동기?

비슷한 음료는 한번에 만들 수도.. - 반드시 순서대로 작업할 필요가 없다... - 여러 고객의 커피류를 한번에 만든다...

Performance !

Page 65: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

65

Loosely coupled

Resilience

Performance

Client Service

Worker

Worker

Worker

Message Queue

Page 66: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

66

Orchestration vs Choreography

지휘 vs 안무구성

Page 67: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

67

Orchestration vs Choreography Choreographed approach is more loosely coupled, flexible and amenable to change.

Page 68: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

68

Orchestration vs Choreography

Orchestration

Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media

Page 69: Microservice architecture 바로 알기

/114

Basic Strategies

4)Asynchronous

69

Orchestration vs Choreography

Choreography

Ref. Building Microservices Designing Fine-Grained Systems / By Sam Newman / O’Reilly Media

Page 70: Microservice architecture 바로 알기

/114

Basic Strategies

Scaling

Scaling Database

Caching

Asynchronous

70

Basic Strategies for MSA

Page 71: Microservice architecture 바로 알기

/114

Real World

71

실제로는 훨씬 더 복잡하다

어떻게

하라는 거임?

Page 72: Microservice architecture 바로 알기

/114

Real World

72

더 필요한 것들

Page 73: Microservice architecture 바로 알기

/114

Real World

1)Dynamic Service Registry

73

Page 74: Microservice architecture 바로 알기

/114

Real World

1)Dynamic Service Registry

74

Service discovery

Health check between instances

Service versioning

Page 75: Microservice architecture 바로 알기

/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

Page 76: Microservice architecture 바로 알기

/114

Real World

1)Dynamic Service Registry

76

Zookeeper Apache

Consul

Eureka Netflix

Page 77: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

77

A resilience is free?

Absolutely Not!

Page 78: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

78

Cascading failure

Ref. https://github.com/Netflix/Hystrix/wiki

Page 79: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

79 Ref. https://github.com/Netflix/Hystrix/wiki

Cascading failure

Page 80: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

80 Ref. https://github.com/Netflix/Hystrix/wiki

Cascading failure

Page 81: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

81

Bulkhead

Cascading failure

Page 82: Microservice architecture 바로 알기

/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

Page 83: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

83

Throttle & quick failure

Client Service request over N/W

Quick failure (if exceed max allowed req.)

Cascading failure

Page 84: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

84

Retry

Client Service request over N/W

If error or timeout,

Retry

Cascading failure

Page 85: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

85

Idempotency

Cascading failure

Ref. https://github.com/Netflix/Hystrix/wiki

Page 86: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

86

Circuit breaker

Cascading failure

Ref. https://github.com/Netflix/Hystrix/wiki

Page 87: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

87

Cascading failure

Page 88: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

88

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue

Bad Message

Page 89: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

89

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue

Bad Message

Page 90: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

90

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue

Bad Message

Page 91: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

91

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue Bad

Message

Page 92: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

92

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue

Bad Message

Page 93: Microservice architecture 바로 알기

/114

Real World

2)Antifragile

93

Catastrophic Failover

Client Service

Worker

Worker

Worker

Message Queue

Bad Message

Page 94: Microservice architecture 바로 알기

/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

Page 95: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

95

Page 96: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

96

Cross service Tracing

Page 97: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

97

Cross service Tracing

It’s not my fault!

Page 98: Microservice architecture 바로 알기

/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

Page 99: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

99

Google Dapper

Cross service Tracing

Page 100: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

100

Pinpoint – open source https://github.com/naver/pinpoint

Page 101: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

101

Zipkin – twitter

Page 102: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

102

App Dynamics – on premise, SASS

Flow map Business Activity Monitoring Cross-service tracing Self-leaning

Page 103: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

103

New Relic

Transaction Breakdown Cross App Tracing Support any language on any hosting Browser side insight

Page 104: Microservice architecture 바로 알기

/114

Real World

3)Monitoring

104

Scouter – Open source

https://github.com/scouter-project

Page 105: Microservice architecture 바로 알기

/114

Real World

105

이것들 말고 더 있다...

1) Dynamic Service Registry (or Service Discovery or API Gateway ... )

2) Antifragile 3) Monitoring

Page 106: Microservice architecture 바로 알기

/114

Real World

106

And More ...

Deployment

Page 107: Microservice architecture 바로 알기

/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

Page 108: Microservice architecture 바로 알기

/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

Page 109: Microservice architecture 바로 알기

/114

Real World

109

And More ...

Testing

Ref. http://martinfowler.com/articles/microservice-testing/#conclusion-summary

Page 110: Microservice architecture 바로 알기

/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

Page 111: Microservice architecture 바로 알기

/114

Real World

111

And More ...

Ref. http://www.slideshare.net/saltynut/whitebase

Testing

White Base

Page 112: Microservice architecture 바로 알기

/114

결국... 기술적인 부분도 더 고민해야 할 것이 많다.

112

Scaling Caching

Service Discovery (API Gateway)

Monitoring Asyncronous

Antifragile Security Testing

Deployment Maturity bar

Optimizing

Defined

Initial

Page 113: Microservice architecture 바로 알기

/114 113

Thank you !

Q&A or later

[email protected]

http://facebook.com/gunlee01

Page 114: Microservice architecture 바로 알기

/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