Background: 성공적 서비스
• Economist Intelligence 에 의한 국제적 조사
• (293개 기업 CIO, 조사국가: 미국 39%, 영국 31%, 호주 30%)에 의하면,
• 서비스의 제공 방식의 변화로 가장 많은 40% 로 대답한 것은 바로 ‘구독형 서
비스(Subscription Service)’의 도입
3
DevOps: Issues
Continuous Delivery
5
Company Deploy Frequency Deploy Lead Time Reliability Customer
Responsiveness
Amazon 23,000 / day Minutes High High
Google 5,500 / day Minutes High High
Netflix 500 / day Minutes High High
Facebook 1 / day Hours High High
Twitter 3 / week Hours High High
Typical enterprise Once every 9 months Months or quarters Low / Medium Low / Medium
출처: 도서 The Phoenix Project
Amazon, Google, Netflix, Facebook, Twitter는 얼마나 자주 배포할까요?
6
4. Canary를 통해서 확신 갖기
• Canary란? 실제 production 환경에서 small subset에서 새로운 코드를 돌려보고 옛
날 코드와 비교해서 새로운 코드가 어떻게 돌아가는 지 보는 것
• Canary 분석 작업(HTTP status code, response time, 실행수, load avg 등이 옛날 코
드랑 새로운 코드랑 비교해서 어떻게 다른 지 확인하는 것)은 1000개 이상의 metric
을 비교해서 100점 만점에 점수를 주고 일정 점수일 경우만 배포할 수 있음.
출처: http://techblog.netflix.com/2013/08/deploying-netflix-api.html
Supporting Continuous Delivery
Netflix
출처 : 2010 architecting for the cloud (http://www.slideshare.net/simone.brunozzi/2010-architecting-for-the-cloud-4719195)
DevOps: Issues
Managing Scalability
7
성공적 서비스로의 여정
운영자동화
• Business Continuity
• Zero-downtime
수익화
• Subscription Business
구현
• Mashups
• Multi-tenancy
• Self-Serviced
마이크로 서비스
• Separation of Concerns
8
Micro Service Architecture
Contract based, Polyglot Programming
Separation of Concerns, Parallel Development, Easy Outsourcing
Written in Java
Written in Node
Written in PHP
15
Level 0: Swamp of POX
• Use as a RPC, returns full serialized document
18
<openSlotList>
<slot start = "1400" end = "1450">
<doctor id = "mjones"/>
</slot>
<slot start = "1600" end = "1650">
<doctor id = "mjones"/> </slot> </openSlotList>
Level 1: Resources
Level 1 tackles the question of handling complexity
by using divide and conquer, breaking a large service
endpoint down into multiple resources.
19
<openSlotList>
<slot _link = ”http://openslots/1234"/>
<slot _link = ”http://openslots/1235"/>
</openSlotList>
# http://openslots/1234
<slot start = "1400" end = "1450">
<doctor id = "mjones"/>
</slot>
# http://openslots/1235
<slot start = "1600" end = "1650">
<doctor id = "mjones"/> </slot>
Level 2: HTTP Verbs
Level 2 introduces a standard set of verbs so that we
handle similar situations in the same way, removing
unnecessary variation.
20
Operation HTTP / REST
Create PUT / POST
Read (Retrieve) GET
Update (Modify) PUT / PATCH
Delete (Destroy) DELETE
# http://openslots/1234
<slot start = "1400" end = "1450">
<doctor id = "mjones"/>
</slot>
Level 3: Hypermedia Controls
21
<appointment>
<slot id = "1234" doctor = "mjones" start = "1400" end = "1450"/>
<patient id = "jsmith"/>
<link rel = "/linkrels/appointment/cancel" uri =
"/slots/1234/appointment"/>
<link rel = "/linkrels/appointment/addTest" uri =
"/slots/1234/appointment/tests"/>
<link rel = "self" uri = "/slots/1234/appointment"/>
<link rel = "/linkrels/appointment/changeTime" uri =
"/doctors/mjones/slots?date=20100104@status=open"/>
<link rel = "/linkrels/appointment/updateContactInfo" uri =
"/patients/jsmith/contactInfo"/>
<link rel = "/linkrels/help" uri = "/help/appointment"/>
</appointment>
Level 3 introduces discoverability, providing a way of making a protocol more
self-documenting.
Level 3: In another words, HATEOAS
• Hypermedia As The Engine Of Application State
• A RESTful API can be compared to a website. As a
user, I only know the root URL of a website. Once I
type in the URL (or click on the link) all further
paths and actions are defined by other links. Those
links may change at any moment, but as a user, all I
need to know is the root URL and I’m still able to
use the website.
22
Tip: monolithic and MSA
26
monolithic MSA
Aggregation
(데이터 통합)
Backend 가 주도 Front 가 주도
Database 통합 데이터베이스 서비스 별 데이터베이스
필수 환경 WAS DevOps, PaaS (Grid Engine)
서비스 굵기 업무 비즈니스 기능별 구현 팀별, 10000 라인 이
하로?, 관심사별
Front 기술 JSP, Struts 등 Server-side
rendering
MVVM, AJAX 등 Client-side
rendering
Container / Packaging WAS / WAR Spring-Boot, Docker
Conclusion
• MSA 는 성공적인 SaaS 의 디자인 패턴:
• Single-Page Application
• Client-Side UI Composition
• Front-End Data Aggregation
• Back-end API 설계가 중요
• REST MM Level 3 – HATEOAS
• Aggregation of data from multi micro-services
• Multi-tenant Data Aggregation
30
• UI Framework for MSA
• AngalarJS
• React
• Polymer
• VueJS
• API Gateway
• APIGee (Commercial)
• Kong
• OCE Gateway
• Amazon Cognito (Public)
• Spring Cloud
• IAM
• Amazon IAM (Public)
• Spring Cloud
• OCE IAM
• Metering / Billing
• Exem’s Metering Framework – BigData based
• OCE Billing
Micro Service Architecture
Platforms for MSA
Front-end
Image Server
(Python)
Business
Logic Server
(Java)
Extended Role of Front-end in Cloud Applications
Aggregator for multiple (polyglot programmed) micro-services
Component
Service
(C)
AJAX, RESTful
Concurrent Cloud Applications are composed of multiple Micro
Services and front-end serves as an aggregator of the services
33
Writing One Page Web App
Problems: One Page Web App Low Cohesion and High Coupling
<style>
style for A
style for B
style for C
</style>
<html>
element for A
element for B
element for C
</html>
<script>
script for A
script for B
script for C
</script>
34
W3C Web Components
<style>
style for A
style for B
style for C
</style>
<html>
element for A
element for B
element for C
</html>
<script>
script for A
script for B
script for C
</script>
#A.html
<style>
style for A
</style>
<html>
element for A
</html>
<script>
script for A
</script>
#B.html
<style>
style for B
</style>
<html>
element for B
</html>
<script>
script for B
</script>
#C.html
<style>
style for C
</style>
<html>
element for C
</html>
<script>
script for C
</script>
#index.html
<A> <A>
<B> <B> <B>
<C>
35
Web Components : Implementations
• Provides Cohesive Component Model
• Component Composition by HTML markup
• Dynamic Data Binding
• Responsive Web by Material Design
• Standard
Polymer VueJS
36
Why vue.js
Angular and React are not a STANDARD
While Polymer is heavy and needs Polyfill
But Vue.js is
1. Fastest (compared with React and Angular)
2. Light (low dependencies)
3. Usable with jQuery or existing .js libraries,
웹 브라우저
Client-driven Data Aggregation
API GW (ZUUL)
Service
기타 연동
어플리케이
션들
모니터링IAM
CRUD
Data
Sync via REST REST Call
Service Service
Service
Process
Service
Worklist
Definition
Service Container Part
Issue Token
ID/PWD
Collect
Usage
MSA Reference Architecture: BPM
DevOps Portal
EUREKA
63
Running Sample App - login
68
Default login id / pw is
jyjang@uengine.org / test
Login will be processed through the IAM server:
http://iam.uengine.io:8080
Generated Entity Classes (JPA)
• All Entity Codes are POJO Classes that are described with Java Annotations meaning entity field descriptions
and relationships.
75
Entity, Resource, Service 선택 우선순위
• DDD(Domain Driven Design) 분석 기법 적용한 최적의 생산성
도메인 용어 기반
도메인 클래스 후보 도출
도메인 클래스가
Entity 유형인가?
Spring Data Rest 사용
@Entity 로 선언, JPA 매핑,
Repository 생성
빠른 CRUD / REST MM 3 Level 의
구현 (라인수 매우 적음)
Resource
Model로 만들 수
있는가?
서비스로 개발
직접 Spring MVC 를 사용하여
RequestMapping 구현
(라인수 매우 많음)
Spring Hateoas 프레임워크만
사용, Resource 로 포장
Resource를 서비스로 Expose
(라인 수 중간)
각 도메인 클래스에 대하여
(최대한 지양)
N N
Y Y
DDD 적용 예시: Entity, Value Object,
Aggregation Root
• DDD(Domain Driven Design) 분석 기법 적용한 최적의 생산성
Source: https://www.slideshare.net/madvirus/ddd-final
The Length of Code
81
323Lines
For Developing Full-CRUD, RESTful, MSA-based, Material-
Designed, Responsive, Grid+Form, Multi-tenant and Self-
Served Application:
• Number of fields of the entity: 10
• Total lines of code per an entity:
92 for front-end,
215 for domain class,
16 lines for repository.
How it works
Common Metadata
Domain Model
Classes
Class model for tenant1
ORM for tenant1
Common class model
Metadata of
Tenant1
Metadata of
Tenant2
Metadata of
Tenant3
Class model for tenant2
ORM for tenant2
Class model for tenant3
ORM for tenant3
Override by tenantID
Multi-tenant / Self service Support
Self service
Self service
portal
• Add new attribute
• Attributes can be String, number,
Data from referenced class (table)
• Change the title, order of attributes
• Hide/Show attribute
Design factors on developing cloud
applications
1.Don't code your application directly to a specific
topology
2.Do not assume the local file system is permanent
3.Don't keep session state in your application
4.Don't log to the file system
5.Don't assume any specific infrastructure dependency
6.Don't use infrastructure APIs from within your
application
7.Don't use obscure protocols
8.Don't rely on OS-specific features
9.Don't manually install your application
86
프로젝트 구성
• APIs-and-Domain
• 공통 API Contracts
• 공통 도메인 클래스
• 나머지 서비스들이 모두 이를 import
함
• Definition-Service
• 프로세스 정의 보존
• 프로세스 정의 열람
• 프로세스 정의 배포/수정
• 프로세스 정의 버전관리
• Process Service
• 프로세스 실행과 관련한 모든 서비스
• Workspace Service
• 워크아이템 처리
• 업무 화면 연계
87
서비스의 호출 방식 2가지
• 프론트-엔드 에서
• 마이크로 서비스 간
(inter-microservice call)
HTTPClient 로 REST 호출
Feign 을 사용, @Autowired 로
proxy 객체리턴
Ribbon 이 Eureka 를 통하여
직접 마이크로 서비스가
로드밸런싱 된 대상을 선택
AJAX 로 REST 호출
Hybind 를 사용,
자바스크립트객체와 Resource
바인딩
Zuul 을 경유하여 Eureka 에서
발견된 path 에 따른 서비스가
라우팅
88
Inter-microservices Call
웹 브라우저
API GW (ZUUL)
Process Worklist
Definition
EUREKA
/definition/**
/instance/**
/role-mapping/**
/variables/**
/work-item/**
Definition: ip1, ip2
Instance: ip3
Worklist: ip4, ip5
Ribbon Ribbon
Zuul 을 경유하지 않고 직접
내부 IP 로 접근
92
공통 참조 모듈
• Bounded
Context
도메인
클래스들
• Service
Contract 들
93
공통 참조 모듈: Service Contract
---- Service Id
이걸로, Autowired
시에 식별됨
94
각 Service 들의 설정
spring:
application:
name: bpm
server:
port: 8090
servletPath: /
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9090/eureka/
healthcheck:
enabled: true
instance:
statusPageUrlPath: ${server.servletPath}info
healthCheckUrlPath: ${server.servletPath}health
내가 누구다 (serviceId=bpm)
부트업 되면서 출생신고할
동사무소(유레카) 주소
95
각 Service 들의 설정
@SpringCloudApplication
@EnableEurekaClient
@EnableFeignClients(basePackageClasses = {DefinitionService.class})
public class uEngine5Application extends Metaworks4BaseApplication {
protected uEngine5Application(DataSource dataSource, JpaProperties properties,
ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers);
}
public static void main(String[] args) {
SpringApplication.run(uEngine5Application.class, args);
}
}
유레카에 등록시켜달라
인터-마이크로서비스간
호출할 대상 서비스 목록
96
Lab time: Running Registry and Proxy
1. 가장 먼저 실행할 것은 Registry (Eureka 서버) 임. [동사무소]
2. 다음으로 실행할 것은 Proxy (Zuul 서버) 임. [이정표 서비스]
$ cd uengine-proxy-server/
$ mvn spring-boot:run
$ cd uengine-registry-server/
$ mvn spring-boot:run
100
Lab time: Running Micro Services
1. Run and test Definition Service
2. Run and test Process Service
$ cd definition-service/
$ mvn spring-boot:run
–Dserver.port=8088
-Drun.arguments="--spring.profiles.active=msa"
Launch another shell and confirm server is up:
$ http localhost:8088/definition
$ cd process-service/
$ mvn spring-boot:run
–Dserver.port=8089
-Drun.arguments="--spring.profiles.active=msa"
Launch another shell and check the server is up:
$ http localhost:8089/instance
101
Lab time: Building docker images
$ cd definition-service
$ mvn package -B
$ docker build –t uengine-five-definition .
$ cd ../process-service
$ mvn package -B
$ docker build –t uengine-five-process .
$ cd ../uengine-proxy-server
$ mvn package -B
$ docker build –t uengine-proxy-server .
$ cd ../uengine-registry-server
$ mvn package -B
$ docker build –t uengine-registry-server .
$ docker images
REPOSITORY TAG IMAGE ID
definition latest fc1db168d69d
process latest 61bcb1e489f0
registry latest 12e06df7a34a
proxy latest 53efac1deda3
107
Lab time: Using docker-maven-plugin
$ cd definition-service
$ mvn package docker:build –B
$ cd ../process-service
$ mvn package docker:build –B
$ cd ../uengine-proxy-server
$ mvn package docker:build –B
$ cd ../uengine-registry-server
$ mvn package docker:build –B
$ docker images
REPOSITORY TAG IMAGE ID
uengine-five-definition latest fc1db168d69d
uengine-five-process latest 61bcb1e489f0
uengine-registry-server latest 12e06df7a34a
uengine-proxy-server latest 53efac1deda3
108
Lab time: Starting up the stack
$ docker stack deploy -c docker-compose.yml uengine
Creating network uengine_webnet
Creating service uengine_definition-api
Creating service uengine_process-api
Creating service uengine_registry
Creating service uengine_proxy
$ docker service ls
$ docker stack rm uengine
109
프라이빗 PaaS 구축하기
• 상용 제품 구매 vs. 오픈소스로 구축
• 대기업 / 중견기업 / 스타트업 별 상황
• 프로젝트 성격
• 제공자로서
• 퍼블릭 PaaS 플랫폼 제공자인 경우 – 오픈소스로 구축
• E.g. 블루믹스의 경우 최초 Pivotal 의 도움을 받아 구축
• 사용자로서
• 빠른 시장 진입 – 퍼블릭 PaaS
• But, 적당한 PaaS 가 존재하지 않거나 시장에서 독자적인
DevOps 환경이 필요할 때
• – uEngine 의 케이스
127
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
Open Cloud Engine: A Private PaaS
128
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
: Workload Distribution Engine – Mesosphere’s DCOS
DCOS:
• Proven and
• Powerful
129
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
: CI/CD Tool - GitLab
130
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
: Microservice Chassis – Spring Boot
131
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
: Microservice API G/W and Registry – Spring Cloud / Netflix OSS
132
Open Cloud Engine
Client-driven Data Aggregation
API GW (ZUUL)
Service
3rd Party Apps
BillingIAM
Data
Sync via REST REST Call
Service Container Part
Issue Token
ID/PWD
Collect
Usage
DevOps Portal
EUREKA
Service Service Service
: Front-End – Vue JS, Hybind and Spring Data Rest
133