Professional Documents
Culture Documents
Web REST
Main-
Frame
Client /
Server
SOA
2
AS-IS: Pain-points
3
Agile Delivery
Amazon, Google, Netflix, Facebook, Twitter는 얼마나 자주 배포할까요?
배포 주기 배포 지연 시간 안정성 고객 요구 응답성
Company
Deploy Frequency Deploy Lead Time Reliability Customer Responsiveness
구글 5,500 / 일 몇 분 (Minutes) 높음 높음
4
Agile 의 정의
Planning is Agility is
important! important
- 성장 마인드셋
- 계획 중심
- Fail Cheap, Fail Fast,
- 실패는 나쁜 것 Fail Often
- 비용 중심 사고 - 고객 중심 사고
5
애플리케이션 개발 애플리케이션 배포 애플리케이션
수개월,
일 또는 수년
에
애자일 N-티어 가상 서버 데이터 센터
필 수개월,
또는 몇주
요
한 데브옵스 마이크로서비스 컨테이너 클라우드
몇주,
것 또는 몇일
들 6
제프베조스의 의무사항
1. All teams will henceforth expose their data and functionality through service interfaces.
2. Teams must communicate with each other through these interfaces.
마이크로서비스
Web REST Microservice
Main-
Frame
Client /
Server
SOA
8
마이크로서비스가 아닌 것: 모노리틱 아키텍처
(A Monolithic Architecture)
An Enterprise Application or Suite
모노리틱 애플리케이션
주문접수
Order
고객관리 Capture
Customer
Mgmt
주문배송
처리
Fulfillment 지불
Payment
재고관리 영업기회
Inventory 관리
Mgmt Opportunity
Mgmt
데이터베이스
9
모노리틱 아키텍처의 분석
상호 데이터 참조가 용이하여 빨리 개발하기 위한 초기 아키텍처로 적합
Opportunity
그러나, 쉬운 상호연동은 상호의존성을 높힘 Customer Mgmt
Mgmt
But, ease of interaction results in many inter-
dependencies
Order
시간이 갈수록, 커플링(의존성)은 강해지고 강해짐 Capture
Over time, coupling becomes tighter and tighter Payment
Payment
• Separate Servers running any Fulfillment
Fulfillment Payment
technology
12
Microservice Architecture
Isolation is the name of the game
Order
• Interaction only through Payment
Capture
HTTP/REST
Customer
• Or asynchronous streaming / Mgmt
messaging
Inventory
Fulfillment
Data Stream topic Mgmt
13
Principles of Microservices
Isolation is the name of the game
14
HTTP/REST 를 이용한 약결합 연동
(Loosely-Coupled Interaction via HTTP/REST)
REST APIs must be stable and hide internals
수 있으면서 연동 Order
Client-oriented REST APIs hide the internal Capture out-bound 재고량을 요청 (Request) In-bound
implementation of the service adaptor adaptor
Internal
상대의 수신을 기다리지 않는 비동기식 메시징
Database In-bound
Asynchronous messaging(streaming) adaptor
Structure
Customer
Mgmt out-bound
•
In-bound
Publish-Subscribe adaptor
준실시간으로 동작함
adaptor
• Order
• Decouples “timing” = Capture out-bound
adaptor
Non-blocking
Data streams hide the internal implementation Data Stream topic
of the service
Client ignore parts of the stream they don’t
understand In-bound
adaptor
Representation
16
Microservice Architecture benefits
Smaller is better
In-bound
Options for scaling
out-bound
adaptor adaptor
Customer
18
Drawbacks of a Microservice Architecture
Distributed computing adds complexity and slow down initial development
20
넷플릭스 OSS
넷플릭스는 수백개의 마이크로서비스를 운영하고 있는 것으로 유명하다. 각 마이크로서비스간에
는 REST 방식의 호출을 통하여 연동되며 이들간의 자동화된 식별과 동적 연동을 위하여 자체적
인 플랫폼을 구축했고 이를 Netflix OSS 라는 이름으로 오픈소스화 하였다.
21
마이크로서비스 전환 사례
IoT Service
Serverless Microservices
Gaming Platform
22
당근마켓
https://youtu.be/mLIthm96u2Q?t=50
23
• 가장 작고 독립적인 서비스로 부터 마이그래이션
• 순차적 레거시의 마이크로서비스 전환을 위한 API GW 적용
한 “스트랭글러 패턴” 적용
• 서비스 폴백 테스트 및 자동화가 필수 조건
24
• 새로 추가/변경 필요한 기능부터 분리
• 안정된 레거시는 가능한 손대지 않음
• 적은 리스크 업무 영역부터
• 기술보다 노하우와 팀의 문화 정립 우선시
• Business Domain 단위 서비스구성
• 팀단위 분리 X, 기술적 단위 분리 X
• 비즈니스 서브 도메인 단위로의 구성
→ Separation of Concerns
• 응집도
• 서비스 존재 목적은 재사용되어지는 것
• 표준화된 API I/F
• 자동화된 문서화
25
Tip: 10 Attributes of Cloud Native Applications
https://thenewstack.io/10-key-attributes-of-cloud-native-applications/
26 26
Quiz
마이크로서비스간에 코드를 공유
하는 것은 좋은 사례이다
YN
or
27
Quiz
마이크로서비스가 실패할 때는 독립적으로 실패해야
한다
Y N or
28
Quiz
• 왜 단일 Database 접근은 마이크로서비스에서 안티-패
턴 (하지 말아야 할 접근) 인가?
29
Microservice and
Table of content Event-storming-Based
DevOps Project
30
Target Domain
: Online Shopping Mall (12 STREET)
31
Organization & KPI Definition - 창업시기
12 Street Team
Front-end Team
Backend Team
주문 처리 상품 관리
Database Team
Front-end
높은 주문 상품 품절 재구
배송관
성공율 로 인한 매비
련 질의,
(예외율, 배 주문 취소 율증
불만 요
Backend 송문제 등 율 0% 달성 청수최 가 블랙컨슈
최소화) 상품 머 최소화
소화
추천
재입고 성공
창고
Database 시, 율
비용
구매 성
최소화
공율
Core Supporting 33
User Stories 와 책임소재 → 너무 많은 Concerns
1. The customer enters the number of products to order and clicks
프론트엔드팀
the order button.
2. When an order is placed, the delivery team arranges for delivery
of the product.
3. As the order or cancellation is completed, the product stock is
changed(+/-).
백엔드팀
4. Customers can also purchase products that are out of stock and
This can be resolved after registering products later
Front-end
높은 주문 상품 품절
성공율 로 인한 재구
배송관 매비
(예외율, 배 주문 취소
련 질의, 율증
Backend 송문제 등 율 0% 달성
불만 요
블랙컨슈
최소화) 가 상품 머 최소화
청수최
추천
소화
성공
재입고 창고
Database 율
시, 비용
구매 성 최소화
공율
Core Supporting 35
책임소재 – 중요한 것과 덜 중요한 것의 분리
• The customer enters the number of products to order and clicks
코어팀 the order button.
• When an order is placed, the delivery team arranges for delivery
of the product.
• As the order or cancellation is completed, the product stock is
changed(+/-).
Front-end
높은 주문 상품 품절
성공율 로 인한 재구
배송관 매비
(예외율, 배 주문 취소
련 질의, 율증
Backend 송문제 등 율 0% 달성
불만 요
블랙컨슈
최소화) 가 상품 머 최소화
청수최
추천
소화
성공
재입고 창고
Database 율
시, 비용
구매 성 최소화
공율
Core Supporting 37
책임소재 – 자치성과 동기부여
• The customer enters the number of products to order
and clicks the order button.
배송관리팀
• When an order is placed, the delivery team arranges
for delivery of the product.
• As the order or cancellation is completed, the product
상품관리팀
stock is changed(+/-).
• Customers can also purchase products that are out of
stock and This can be resolved after registering
주문/결제관리팀 products later
• A notification is sent to the customer whenever the
delivery status changes.
고객센터팀 • Customers who repeat orders and cancellations
frequently are blacklisted, and customers with high
order purchase rates are whitelisted.
마케팅팀
• The marketing team mails recommendation products
tailored to the customers at 9 am daily.
38
목표수준 수립과 비용
39
Microservice and
Table of content Event-storming-Based
DevOps Project
40
Approach #1 : Micro Service Architecture
Contract based, Polyglot Programming
→ Separation of Concerns, Parallel Development, Easy Outsourcing
[ Limitation ]
Written in
Java
1. Code Coupling 해소
Written in
PHP 41
Approach #2 : Event Driven Architecture
Shipping
Orders
Subscribes
Publishes
Marketing
• No point-to-point integrations.
• High performance and highly scalable Time-decoupled
Order
systems. Placed
• Components can remain autonomous, Subscribes
being capable of coupling and decoupling
into different networks in response to
different events. Open in extensibility
• Advanced analytics can be done using
complex event processing.
42
Approach #2 : Event Driven Architecture
Polyglot-persistence
주문팀 이벤트
상품팀 배송팀
Publish 이벤트 선호도수집
Subscribe 선호도수집
주문들어옴 재고변경 배송준비 선호도수집 추천상품
새벽 2시
(PO. No: 1, TV, (TV, 5) (No: 1) 저장
주문 5개, 홍길동) 상품발송함
상태 (주번:1)
변경 File-System
주문들어옴 배송준비
재고변경 user category cnt
주문 (PO. No: 2, TV, (No: 2) Id
(TV, 0) 재입고됨 오전 추천상품
9시 이
상태 5개, 아무개) 상품발송함 1 홍길동 Electronic 1
5
주문예약 (TV, 10개)
변경 고객에게 (주번:2) 2 아무개 Electronic
Camping 21 메일 발송
추가 입고
통보 Data Join 기
주문 주문취소됨 재고변경 배송수거 능 요구
상태 (PO. No:1) (TV, 15개) (No: 3) 마이페이지 - CQRS
변경 상품수거됨
(주번:1) 주문정보 배송상태
배송상태
주문정보
주문취소 배송수거
주문들어옴 수집
주문정보 변경정보수집
변경정보수집
수집
정보수집 정보수집
(PO. No.: 3, 캠 재고수정 배송준비 (PO. No:1)
수집 (PO.
(PO. No:1)
(PO.
(PO.No:2) (PO. No:2)
No:1)
핑버너, 2개, 아 (Radio, 8) 가격변경 (No: 3) (PO.No:1)
No:3)
무개) (TV, 4만원)
id
id User
User Item
Item Qty
Qty prc o-stat
prc o-stat d-stat
d-stat
ID User Item
User Item Qty
Qty status
Qty status
status ID Addr PO-id Qty Status 001 홍길동
001 홍길동 TV
TV 55 25,000
40,000 cancel
50,000
50,000 cancel Returne
order Delivery
Order Returne
ID Item Stock
1 홍길동
홍길동 TV
TV
TV 555 ordered
Returne
Cancelle
Delivery 1 강동구 1 5 Return
Started HTML dd
Started
MySQL dd
Started 1 TV 0
5
10
15 Redis
2 아무개 TV 5 ordered MongoDB
2 강서구 2 5 ed
Started 002 아무개 TV
TV 55 40,000 order
50,000
50,000 order Delivery
Delivery
2 아무개
아무개 TV
TV 55 Delivery
Delivery
ordered 2 Radio 10
8 Started
Started
2 강서구 2 5 Started
Started
Started RADIO
003 아무개 RADIO 2 20,000 order
3 강서구 3 2 prepar 44
3 아무개 버너 2 ordered e
45
Event Driven MSA Architecture
E E
https://tv.naver.com/v/11212897
47
Approach #3: BizDevOps Process & Infra
48
서비스를 죽지 않게 하려면…
49 49
항상성이
(Self-Healing)
자동으로
유지되면
어떨까?
50
Kubernetes Workers
Master
51
Outer & Inner Architecture
1
4
1. API Gateway : API를 사용하여 통신하는 모든 서비스들의 인증 및 제어, 트래픽 모니터링 등 수행
2. Managed Container System : 서비스들의 중앙 관리 및 인증, 라우팅등의 기능 수행
3. Backing Services : 스토리지(Block, Object), Cache, Message Queue 등의 기능 영역
4. Observability Services : 서비스들의 이벤트 모니터링 및 알림, 로그 취합, 진단 등 수행
52
Container Orchestration – Self Healing Mechanism
53
Container Orchestration – Scale out
Need to
Scale out
desired=6
desired=5
actual=5
actual=6
54
Container Orchestrator – Zero Down Time Deploy
Router
Version 2
Is good?
ver1 ver1 ver1 ver1 ver1 ver2 ver2 ver2 ver2 ver2
55
적용 아키텍처
프론트엔드
프론트엔드
IAM Gateway
상 주 배 마
상품 주문 배송 품 문 송 케
팅
(Java/ (Java/
Tomcat) Spring) (.NET) (python)
No
RDB RDB RDB
데이터베이스 SQL
모놀리식
Message Channel
56
효과 – 장애 최소화
프론트엔드
프론트엔드
상품 주문 배송 상품 주문 배송
상 주 배 마
마 품 문 송 케
상품 주문 배송 케 팅
팅 (Java/ (Java/
Tomcat) Spring) (.NET) (python)
Java/J2EE
No
RDB RDB RDB
SQL
스키마
데이터베이스 체인지
상 주 배 마
마 품 문 송 케
상품 주문 배송 케 팅
팅 (Java/ (Java/
Tomcat) Spring) (.NET) (python)
Java/J2EE
No
RDB
RDB SQL
스키마
데이터베이스 체인지
상 주 배
품 문 송 마
마케
상품 주문 배송 케
팅
팅
주문결제
데이터베이스
60
Microservice and
Table of content Event-storming-Based
DevOps Project
61
DDD Patterns
62
Domain-Driven Design & MSA
• Context Mapping
→ 서비스를 어떻게 결합할 것인가?
• Domain Events
→ 어떤 비즈니스 이벤트에 의하여 마이크로 서비스들이 상호 반응하는가?
63
Bounded Context
(한정된 맥락)
Ubiquitous Language
(도메인 언어)
64
Bounded Context and Ubiquitous Language
SW CONSTRUCTION
A Project
An Architecture
A Developer
65
In Monolith :
Single Deployment Unit
Front Store
(core) (supporting)
Order Order
66
In Microservices :
Front Store
(core) (supporting)
Anti-
Order Order
corruption
layer
67
In Microservices :
Front Store
(core) (supporting)
OrderPlaced
Order Order
Accept order
68
마이크로 서비스간의 서열과 역학관계
“ 무엇을 우선적으로 챙길 것인가? ”
69
Ref : Relation types between services
• Shared Kernel
ㅇ Designate a subset of the domain model that the two teams agree to share.
• Customer/Supplier
ㅇ Make the downstream team play the customer role to the upstream team.
• Conformist
ㅇ Eliminate the complexity of translation between bounded contexts by slavishly
adhering to the model of the upstream team.
• Separate Ways
ㅇ Declare a bounded context to have no connection to the others at all. The feat
ures can still be organized in middleware or the UI layer.
Customer/
주문 상품 Supplier 상품추천
(core) (core) (Supporting)
Conformist
Anti-corruption
배송 SaaS
(general,
외부서비스)
Request-Response
ACID TX
(with CB)
주문 (shared DB) 상품 상품추천
(core) (core) or (Supporting)
UI Mashup
Pub/Sub 배송
배송기사가 없다고 주문을 안받을 것인가? 상품 추천이 안된다고 주문버튼을 안보여줄 것인가?
Core Domain 간에는 강결합이 요구되는 경우가 생길 수 있다.
하지만 우선순위가 떨어지는 비즈니스 기능을 위해 강한 트랜잭션을 연결할 이유는 하등에 없다.
72
마이크로 서비스간의 서열과 역학관계
“ 손님이 많이 와서 집이 좁아졌다.. 무엇을 우선적으로 줄일 것인가? ”
주문
주문 주문 배송 주문
주문 주문 주문
상품 상품
배송 주문
추천 추천
업무 중요도와 자치성 기술 아키텍처가 상이한 트랜잭션 모형이 변경시 동반되어 유틸리티 성격의
모듈 다른 수정되어야 하는 영역 서비스
→ Core/Supporing
→ 데이터베이스, 플랫폼, → ACID or
KPI → But,
언어가 상이한 Eventual
→ 마이크로서비스에서 마이크로서비스에서는
Consistency?
일순위 분리 관점 후순위 분리 관점
75
Event Storming : DDD 를 쉽게 하는 방법
• 이벤트스토밍은 시스템에서 발생하는 이벤트를 중심 (Event-First) 으로 분석하는 기법으로 특히 Non-blocking, Event-driven 한 MSA 기반 시스템
을 분석에서 개발까지 필요한 도메인에 대한 탁월하게 빠른 이해를 도모하는데 유리하다.
• 기존의 유즈케이스나 클래스 다이어그래밍 방식과 다르게 별다른 사전 훈련된 지식과 도구 없이 진행할 수 있다.
• 진행과정은 참여자 워크숍 방식의 방법론으로 결과는 스티키 노트를 벽에 붙힌 것으로 결과가 남으며, 오랜지색 스티키 노트들의 연결로 비즈니스
프로세스가 도출되며 이들을 이후 BPMN과 UML 등으로 정재하여 전환할 수 있다.
vs
76
Event Storming : Prepare
• 큰 종이 시트 및 종이 시트를
여러 장 붙일 수 있는 충분한 벽
이 있는 넓은 공간
• 여러 종류의 색깔 스티커, 검은
색 펜, 검은색 or 파란색 테이프
• 서서 하는 방식으로 의자 필요
없음.
77
Type of stickers
Domain 발생한 사실, 결과, Output 사용자, 페르소나, 스테이크 홀더 정의
Event 도메인 전문가가 정의 도메인에 대한 용어 등의
유저 인터페이스를 통해 데이터를 Definition
(Orange) 이벤트 퍼블리싱 소비하고 명령을 실행하여 시스템 설명,기술
Actor 과 상호 작용
78
Examples order
Order
Command
Customer Product
Policy Search
Order
Placed
Actor
Domain Delivery
Delivery
Event Start
Start
Read Model
Delivery
External Delivery
System Started
Command, Policy 도출
(업무전문가)
Aggregate 도출
주도
Inputs Outputs
• 노란색 스티커 사용
Create Account
• 같은 Entity를 사용하는 연관 있는 도메인 Account Created
이벤트들의 집합
Delete Account
Account Deleted
82
Bounded Contexts 도출 다같이
- Domain Boundary
- Transaction Boundary
- Technical Stack Payment
… Marketing
Account
Created
84
Lab Time – Policy 도출
상품등록됨 상품재고 주문생성됨 주문정보 배송준비됨 배송출발함
변경됨 변경됨
홍보 입고 배송정보 알림메일
배송생성 배송지시
메일발송 메일발송 변경 발송
재고변경 재고변경
알림메일
배송취소 회수지시
발송
재고변경
85
Lab Time – Command 도출 (의사결정)
상품등록 재고변경 결제클릭 정보변경
홍보 입고 배송정보 알림메일
메일발송 메일발송 배송생성 배송지시 발송
변경
재고변경 재고변경
MD MD 사용자 사용자
정보변경 상품삭제 주문취소 주문취소 완료수신 주문취소
수신
상품정보 상품삭제됨 주문취소됨 주문상태 배송완료됨
배송취소
변경됨 변경됨
요청됨
알림메일
배송취소
발송 회수지시
재고변경
87
Lab Time – Aggregate 도출
상품 상품등록됨 결제 주문생성됨 주문생성 배송준비됨
등록 클릭 수신
배송생성 배송지시
MD
홍보 사용자 시스템
메일발송 재고변경
출발 배송출발함
정보 주문정보 수신
재고 상품재고 변경
됨 변경 변경됨 알림메일
변경
상품 발송
재입고 배송정보 시스템 배송
MD (Product) 사용자 주문 변경
메일발송 (Delivery)
(Order)
재고변경 완료 배송완료됨
수신
정보 상품정보 주문 주문취소됨 알림메일
변경 변경됨 취소 발송
시스템
MD 배송취소
사용자 재고변경
상품 상품삭제됨 주문취소 배송취소
삭제 수신 요청됨
주문 주문상태
MD 취소 변경됨 회수지시
시스템
사용자
도메인 이벤트가 발생하는 데는, 어떠한 도메인 객체의 변화가 발생했기 때문이다. 88
하나의 ACID 한 트랜잭션에 묶여 변화되어야 할 객체의 묶음을 도출하고, 그것들을 커맨드, 이벤트와 함께 묶는다.
Lab Time – Bounded Context 도출
상품관리 주문관리 배송관리
Orchestration Choreography
사용자
주문취소 주문취소됨
상품관리 사용자
주문취소 주문취소됨
상품관리
배송취소
91
Microservice Implementation Pattern (1)
도메인 언어 영역
Inbound adapter
• Hexagonal Architecture (Ubiquitous language)
Inbound adapter
Create your service to be independent of eit Some
her UI or database and to provide adapters f Controller Message
or different input/output sources such as GUI, class consumer
DB, test harness, RESTful resource, etc.
Foo
Message
Implement the publish-and-subscribe messa
분리
service
비즈니스 broker
ging pattern: As events arrive at a port, an ad
로직
apter (a.k.a. service agent) converts it into a p Domain
rocedure call or message and passes it to the Event
application. When the application has someth
ing to publish, it does it through a port to an a Repository Message
dapter, which creates the appropriate signals interface producer
needed by the receiver.
https://alistair.cockburn.us/Hexagonal+architecture
기술적 구현영역 DAO Outbound port
Database
92
Applying Hexagonal Architecture
외부 도메인이벤
트
Browser
DOMAIN MODEL
Message
주문 Controller consumer
주문정보 Message
입력 주문
주문정보 broker
입력 (Order)
주문이
발생함
주문
Repository
(Order) interface Message
producer
커맨드
주문이
발생함 DAO
Database
93
Applying MSA Chassis
외부 도메인이벤
Spring Data 트
Rest
Browser
DOMAIN MODEL
Message
Spring Boot / Cloud Controller consumer
과정정보 Message
입력 주문 broker
Spring Boot
(Order)
주문이
발생함
Spring Data Rest
Repository
interface Message
JPA producer
SpringData
Spring Cloud Stream Rest DAO
JPA 도메인이벤트
Database
94
이벤트 스토밍 결과에서 구현 기술 연동
요소 구현체 미들웨어/프레임워크
바운디드
• 마이크로 서비스 (후보) • Spring Boot
컨텍스트
95
분석/설계 (Sticker)
96
Command ☞ CRUD 에 해당하면? Repository Pattern 으로 자동생성
주문수정
Command ☞ Repository Pattern 이 안될시에 MVC 패턴으로 구현
(PATCH)
@Service
public interface ProductService {
@RequestMapping(method = RequestMethod.GET,
주문삭제 path=/myservice/{productId}/")
Resources getProduct(@PathVariable(”productId") Long productId);
(DELETE) }
97
분석/설계 (Sticker) 개발 (POJO) 실행 (JSON)
• timestamp
98
Event ☞ POJO Class 와 이벤트 발사로직
Order
@Entity
• orderId public class Order {
…
• productId
• userId @PostPersist // 주문이 저장된 후에
private void publishOrderPlaced() {
• price OrderPlaced orderPlaced = new OrderPlaced(); // 주문이 들어온 사실을
• quantity 이벤트로 작성
• Telephone orderPlaced.setOrderId(id);
…
99
실습 예제
Food Delivery Service
https://github.com/msa-ez/example-food-delivery
100
Context: Food Delivery App – Front
https://github.com/msa-ez/example-food-delivery
101
Context: Food Delivery App - Store
https://github.com/msa-ez/example-food-delivery
102
Context: Food Delivery App - Customer
https://github.com/msa-ez/example-food-delivery
103
분석/설계
“배달의 민족” MSA 로 설계/구현하기
104
시나리오
1. 고객이 메뉴를 선택하여 주문한다.
2. 고객이 결제한다.
3. 주문이 되면 주문 내역이 입점상점 주인에게 전달된다.
4. 상점주인이 확인하여 요리해서 배달 출발한다.
5. 고객이 주문을 취소할 수 있다.
6. 주문이 취소되면 배달이 취소된다.
7. 고객이 주문상태를 중간중간 조회한다.
8. 주문상태가 바뀔 때 마다 카톡으로 알림을 보낸다.
105
창업시기 조직구조 – Horizontal
서비스 이익률,
신규고객창출, 상점 친화
Business 이미지 ….
CEO
예쁘고 편리한 UI
UI Developer
안정된 서버 시스템
Backend Developer
안정된 데이터베이스
시스템
DBA
106
조직구조 – Vertical 24시간
주문/결제
입점상인의
편익 대변
고객만족도
향상
PO
CEO UI Developer
Backend Developer
CTO
DBA
https://byline.network/2020/12/17-108/
107
https://www.youtube.com/watch?v=BnS6343GTkY
비기능적 요구사항
1. 트랜잭션
1. 결제가 되지 않은 주문건은 아예 거래가 성립되지 않아야 한다 → Sync 호출
2. 장애격리
1. 상점관리 기능이 수행되지 않더라도 주문은 365일 24시간 받을 수 있어야 한다 → Async
(event-driven), Eventual Consistency
2. 결제시스템이 과중되면 사용자를 잠시동안 받지 않고 결제를 잠시후에 하도록 유도한다 →
Circuit breaker, fallback
3. 성능
1. 고객이 자주 상점관리에서 확인할 수 있는 배달상태를 주문시스템(프론트엔드)에서 확인할 수
있어야 한다 → CQRS
2. 배달상태가 바뀔때마다 카톡 등으로 알림을 줄 수 있어야 한다 → Event driven
108
이벤트스토밍 - Event
상점에
메뉴가 결제버튼이
주문됨 결제승인됨 주문정보 배달시작됨
선택됨 클릭됨
전달됨
주문취소됨 배달취소됨
109
이벤트스토밍 – 비적격 이벤트 제거
주문취소됨 배달취소됨
110
이벤트스토밍 – Actor, Command
점주
고객
주문 결제 배달시작
주문됨 결제승인됨 배달시작됨
고객
주문취소됨 배달취소됨
주문취소
111
이벤트스토밍 – Aggregate
점주
주문 주문됨
결제
고객 배달시작됨
배달시작
주문 결제이력
주문처리
주문취소 주문취소됨 결제승인됨
배달취소됨
112
이벤트스토밍 – Bounded Context
app
store
주문 주문됨 점주
고객
주문
배달시작됨
주문취소
주문취소
됨
배달시작
주문처리
pay
결제
배달취소됨
결제이력
결제승인됨
113
이벤트스토밍 – Policy (괄호 - 수행주체)
app
store
주문 주문됨 점주
고객 결제요청
(app)
주문
배달시작됨
주문취소
주문취소 주문상태
됨
배달취소 배달시작 변경
(store) (app)
주문처리
pay
배달취소됨
결제
주문상태
결제이력 변경
요리시작 (app)
(store)
결제승인됨
114
이벤트스토밍 – Policy 를 수행 주체로 이동
app
주문상태
변경
주문 주문됨 store
점주
고객 결제요청
주문
배달시작됨
주문취소
주문취소
됨
배달시작
주문처리
요리시작
pay
배달취소
결제 배달취소됨
결제이
력
결제승인됨
115
기능 요구사항 Coverage
1. 요구사항별로 모든 나래이션이
가능한지 검증함
2. 기능 요구사항별로 패스 표시
116
시나리오 Coverage Check (1)
1. 고객이 메뉴를 선택하여 주문
한다
2. 고객이 결제한다
3. 주문이 되면 주문 내역이 입
점상점주인에게 전달된다
4. 상점주인이 확인하여 요리해
서 배달 출발한다
117
시나리오 Coverage Check (2)
5. 고객이 주문을 취소할 수 있다
6. 주문이 취소되면 배달이 취소된
다 ➔ 배달취소는?
7. 고객이 주문상태를 중간중간 조
회한다
8. 주문상태가 바뀔 때 마다 카톡으
로 알림을 보낸다 ➔ ?
118
모델 업그레이드 – 요구사항 커버 확인
5. 고객이 주문을 취소할 수 있다
6. 주문이 취소되면 배달이 취소
된다
7. 고객이 주문상태를 중간중간
조회한다
8. 주문상태가 바뀔 때 마다 카톡
으로 알림을 보낸다
119
비기능 요구사항 Coverage
1. 주문에 대해서는 결제가
처리되어야만 주문
처리하고 장애격리를 위해
CB를 설치함 (트랜잭션 > 1, 2
장애격리 > 2)
2. 결제승인 이벤트를 3
수신하여 상점의 주문정보 1
변경을 수행함
(장애격리 > 1)
121
구현
(Impelmentation)
122
• Unit Microservice Implementation
• Spring Boot
• Inter-microservice Communication
• Publish-Subscribe (Saga)
• Event Sourcing
• Correlation
• Compensation
• Request-Response (RPC)
• Service Registry
• Circuit Breaker
• Client-Server Communication
• API Gateway
• Front-end Development
123
운영
(Operation & Monitoring)
124
Biz-Dev-Ops
분석 >Bounded Contexts 구현> Spring Boot Projects 구현> Container Images 운영> K8S Deployments
125
K8S deploy model for Food-Delivery
126
지속적 개선
간섭없는 개발 조직의 추가
127
KPI:
마케팅팀의 추가
신규고객유
입률
PO
CEO UI Developer
Backend Developer
CTO
DBA
128
시나리오 – 마케팅 팀
• 우수고객에게 쿠폰을 발행한다
• 자주 주문하는 상품에 대한 유사 제품을 홍보한다
129
130
헥사고날 아키텍처
분산 이벤트 스트림 (Kafka)
마케팅팀
REST Kafka
Kafka Listener
Adaptor Listener 이벤트
REST Kafka Kafka 리스너
Adaptor app
app Kafka
publiser
pay Publishe
r
store Publisher
customer
customer
(python)
REST
Invoker
JPA JPA JPA
Filesystem 131
THANKS!
Any Question?
jyjang@uengine.org
https://github.com/jinyoung
https://github.com/TheOpenCloudEngine
132
• Overall MSA Design patterns:
https://www.manning.com/books/microservices-patterns
133
github.com/msa-ez
github.com/msa-ez
Reference
MSA Projects
134
msaschool.io
MSA School
135