68
Kaleido 비긴스: 세계 최초 데이터 타입 기반의 동기화 Back-end as a Service 노현걸 PaaS

[243]kaleido 노현걸

Embed Size (px)

Citation preview

Kaleido 비긴스: 세계 최초 데이터타입 기반의 동기화 Back-end as a Service

노현걸PaaS

CONTENTS

1. 멀티 디바이스 동기화 @ Back-end

2. 데이터 접근 개념

3. Kaleido 데모

4. Kaleido 비긴스

5. Kaleido Data Types

6. 동기화 프레임워크

7. 어디에 쓸 수 있을까?

8. Kaleido 현재와 미래

1. 멀티 디바이스 동기화 @ back-end

멀티 디바이스 동기화

Object /file Storage

데이터 스토리지 & 서버 준비

Front-end Back-end

Servers

Database

Object /file Storage

원하는 것은

양단 간의 데이터 동기화

Front-end Back-end

SynchronizationServers

Database

Database

Object /file Storage

이 것 저 것 신경 쓸 게…

Front-end Back-end

Global distribution

Account /access control

SynchronizationServers

Security

그래서,

Front-end Back-end

이제

SDK에 의한 대부분의 앱 logic 구현

Front-end Back-end

SDK에 의한 Serverless 동기화

그러므로

2. 데이터 접근 개념을 달리해봅시다

데이터는 수집(collect)하여

검색(query)하는 것

DBsave/update data

query

snapshot

서버가 필요한 이유?

DB

save/update data

query snapshot

notify changes

Server

데이터가 복제(replicated)되고

연결(connected) 되어 있다면…

exchange changes

data1data1

data1

data2

data2

data2

data2

3. Kaleido가 뭔가요?

Kaleido

공동 경로 앱

공동 경로 문제

서울

부산

대구

광주

대전

서울

부산

대구

광주

대전

서울

부산

대구

대전

서울

대구

광주

대전

서울

대구

대전

Client #1

Client #2

동기화

동기화

단일 경로 구현

(1) 터치 위치를 LinkedList에 최대 n개까지 저장한다.

(2) LinkedList를 iteration하면서 그린다.

공동 경로 구현

4.Kaleido 비긴스

시작은 Mobile DB

LevelDB, Couchbase, Cloudant Sync-android, JasDB,RocksDB, LMDB,OrientDB, MapDB, TSDocDB, waspdb, BananaDB, SynchronizedDB…

“이미 잘나가고 있는 제품을쫓아갈 필요가 있을까?”

차별화가 필요해!

결론은 데이터 동기화!

“Mobile – Cloud간의 데이터 동기화”

개발 시간단축

앱 품질향상

어떻게 동기화 할 것인가?

Conflict-free Replicated Data Types

CRDT model

읽기

쓰기

쓰기op

• 쓰기가 빠르다. (로컬리모트)

• 쓰기 Operation을 통해 변경된 값만 교환

• 읽기가 빠르다. (No network)

• Offline에서도 동작한다.

• 또는 Replicated Abstract Data Types 연구

• Replicated-connected 모델

• Operation 기반의 동기화

local first, remote later

• Eventual consistencydata type

data type

data type

data type

data type

무엇을 만들어야 하는가?

Mobile DB↔ Server DB

동기화

Data type 기반의동기화 플랫폼

Data type 기반의 동기화 플랫폼

“Client의 데이터 타입을 서버를 통해 동기화“

서버는 cache, offline에서도 문제 없이 동작

“동기화 방식도 개발자가 선택할 수 있도록”

“변경 사항을 재생(replay) 할 수 있도록”

Serverless 앱 개발!

“누가 Parse로 채팅앱을 일주일 만에 개발했대!”

User / ACL(authorization)

Cloud code

“Data type 기반의 동기화플랫폼 BaaS”

Permanent storage

nBase-arc(redis cluster)

Analytics

𝐾𝑎𝑙𝑒𝑖𝑑𝑜 = න𝑀𝑜𝑏𝑖𝑙𝑒𝐷𝐵

𝐶𝑙𝑜𝑢𝑑

𝐶𝑅𝐷𝑇𝑠

= Back-end as a Servicefor data type-based synchronization

5.Kaleido Data Types

Kaleido Data Type == CRDTs• Operations

• Eventual consistency

Client #1 Client #2Server

0 0 0

inc(5) = 5dec(2) = -2

= inc(-2)

inc(-2) = 3

inc(5) = 3

multi(2) = 6

= inc(3)

inc(3) = 4

div(2) = 1

= inc(-2)

inc(-2) = 4

4 44

Counter

Array

Variable

HashMap

LinkedList

KaleidoData Types Counter

Write opinc(), dec(), multi(), div()

Read op get()

최종 값에 대한 사칙연산 지원

• 정수형(32bits)

• 실수형(64bits)

• 유한한 element들의 array

• Element에 대한 iteration 지원

• Newer Operation Wins on each element

Counter

Array

Variable

HashMap

LinkedList

Array<E>

Write op set(int i, E e)

Read op get(int i)

HashMap<K,V>

Write op put(K k, V v), remove(K k)

Read op get(K k)

• Key에 대해 Value를 mapping

• Key, value set에 대한 iteration 지원

• Newer Operation Wins on each key

Variable<V>

Write op set(V v)

Read op get()

• 하나의 value를 저장

• Newer Operation Wins

• V, E : boolean, integer, long, double, String, byte[], Date, JSON

• K: boolean, integer, long, double, String, byte[], Date, JSON

KaleidoData Types

Client #1 Client #2Server

Newerset(“X”) Older

set(“Y”)

Counter

Array

Variable

HashMap

LinkedList

“X” “X”

Newer Operation Wins

Last writer wins?

KaleidoData Types

• element들의 list로 순서를 정하여 삽입/제거

할 수 있는 데이터 타입

• position은 다양한 방법으로 제공(iterator,

integer index 등)

Client #1 Client #2Server

[1,2] [1,2]

ins(next to “1”, “X”) [1, X, 2]

ins(next to “2”, “Y”)

[1, 2, Y]

del(“2”) [1, X]

ins(next to “1”, “Z”)

[1, Z, 2, Y]

ins(next to “2”, “Y”)

[1, X, Y]

ins(next to “1”, “Z”)

[1, X, Z, Y]

ins(next to “1”, “X”) [1, X, Z, 2, Y]

del(“2”) [1, X, Z, Y]

LinkedList<E>

Write opins(Pos p, E e), del(Pos p), set(Pos p, E e)

Read op get(Pos p)

Counter

Array

Variable

HashMap

LinkedList

KaleidoData Types

More CRDTs…

Set, Graph, Tree, Text,Document,…

구현난이도

<CRDTsClient 동기화

프레임워크(동작방식+API)

전송프로토콜

Server < <

6.동기화 프레임워크

• 2011. 06 출시• 2013. 04 Facebook 인수• 2016. 01 parse.com 종료 발표(`17. 01)

open-source 전환

Amazon Cognito

디바이스 간의 계정 정보 동기화• 2014. 07 공개

출처: Google I/O 2016 https://www.youtube.com/watch?v=tb2GZ3Bh4p8

• 2016. 05 renewal @ google I/O

• 2011. 09 출시• 2014. 10 Google 인수

비교 대상

Map<String, String>

지원하는 데이터 형태는?

JSON document ( uniqueId + counter, set field)

JSON document ( + push)

DB의 데이터를 접근하는 방식

• Collect-query 시스템

• Client는 query; stateless

Client

CREATE

CRUD model

Database

Data

READ

UPDATE

DELETE

객체(Object)를 읽으려면(Read)질문(Query)을 하세요

Object stateful replica?

객체가 업데이트 되는 방식: 단방향 전송

character

uniqueId S50WnnG6k

name 조조

war 96

power 72

intelli 91

politics 94

charisma 96

exp 1

skills[“상업”, “치안“,“논파”]

character.put(“power”, 82);

character.inc(“exp”);

character

uniqueId S50WnnG6k

name 조조

war 96

power 72

intelli 91

politics 94

charisma 96

exp 1

skills[“상업”, “치안“,“논파”]

character.put(“war”, 62);

character.inc(“exp”);

Client Server

변경 사항만 전송 or 전체 값 전송?

객체가 업데이트 되는 방식: 양방향 전송

dataset

K1 V1

K2 V2

K3 V3

Client Server

dataset

K1 V1

K2 V2

K3 V3

dataset.put(“K2”, “V2b”);dataset.put(“K2”, “V2a”);

Client’s changes

Conflicts

Client’s resolutions

conflict.resolveWithLocalRecord()

conflict.resolveWithRemoteRecord()

conflict.resolveWithLastWriterWins()

conflict.resolveWithValue("newValue")

Conflict-not-free

실시간 DB: 데이터의 변화 event

Client #1Server

“A”

“C”

“D”

dataRef.addValueEventListener()

dataRef.setValue()

“C”

“D”dataRef.removeEventListener()

dataRef.setValue()“E”

Client #2

“B”

동기화를 위한 세가지 선택 사항?

Statelessor

Stateful objects

Unidirectional snapshot or

Bidirectional changes

Conflict-not-freeor

Conflict-free

• Attach: 데이터타입의 생성 및 Push-Pull 을 등록

• Push-Pull: client / server 간에 operation들을

교환

• Detach: 데이터타입을 Push-Pull을 해제

Connect replicated objects

APPD model

Kaleido

Data TypeClient

ATTACH

DETACH

PUSH-PULL

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST KaleidoServer

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LISTClient (SQLite)

Attach

some of them

3

4

5

6

7

8

9

Snapshot

4

5

6

7

8

operations

+

operations

KaleidoClient Client DB of attached data type

데이터 타입객체 관리

동기화

Conflict-free, but I know what you did last operations

3

4

5

6

7

8

9

3

4

5

6

7

pulledops

pushedops8

9

10

11

Client Server

3

4

5

6

7

8

9

3

4

5

6

7

Client ServerNewly

generated ops

Newly arrived

opsPushPull

8 9

PushPull

동일한 상태에서

sync?

client

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LISTKaleidoServer

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST

COUNTER

VARIABLE

ARRAY

HASH MAP

LINKED LIST

push

pull

WebSocket

HTTP

동기화 방식 골라서 하세요.

Replay

Client (SQLite)Snapshot

4

5

6

7

8

operations

+

Operation들이 너무 많으면…

1 2 3 4 5 6 7 8 9 10 Snapshot@10

Client #1 Server

1 2 3

Snapshot@10

Snapshot@10

1 2 3 4 5 7 8 9 10

7 8 9 10 11 12

11 12+

Snapshot@10

6

cutoff

Snapshot@12

얼마나 많은 PushPull을 “동시에” 처리 할 수 있는가?

서버 성능

PushPulls

data1

data2

data3

data4

data5

data6

dataX

d1d1d1d1

d2d2

d4

d5d5

7.어디에 쓸 수 있을까?

협업 툴 / 게임의 복잡한 동기화

• 빠른 로컬 반응

• 과정 재현 가능

Dynamic config / Distributed cacheserverList {

“10.11.12.13” : Date(20161017T132959),“10.11.12.14” : Date(20161017T132954),“10.11.12.15” : Date(20161017T132953),“10.11.12.16” : Date(20161016T211959),“10.11.12.17” : Date(20161017T132934),…

}

gas_suji {“주유소A”:1368, “주유소B”:1436,“주유소C”:1425,“주유소D”:1417,“주유소E”:1455, …

}

8.Kaleido 현재와 미래

• SDKs : 언어의 특성에 맞춘 구현

• Java/Android, C++ SDK

• iOS SDK

• JavaScript

• Authentication

• For serverless 동기화

• Authorization (User/ACL)

• Cloud code

• Analytics

• …

현재

완료

beta

진행중

완료

예정

• Naver 앱에 발굴 적용

• Open to public?

미래

Cognito

이제 시작

Sync your data through Kaleido,

Think more something else.

Q&A

Thank You