Transcript
Page 1: SDEC2011 Arcus NHN memcached cloud

Arcus:����������� ������������������  NHN����������� ������������������  Memcached����������� ������������������  Cloud����������� ������������������  

박준현/NHN����������� ������������������  

Page 2: SDEC2011 Arcus NHN memcached cloud

2 / SDEC 2011 발표자료

ARCUS����������� ������������������  

Page 3: SDEC2011 Arcus NHN memcached cloud

3 / SDEC 2011 발표자료

ARCUS����������� ������������������  개발����������� ������������������  배경����������� ������������������  

•  웹����������� ������������������  서비스����������� ������������������  •  Read����������� ������������������  >>����������� ������������������  Write����������� ������������������  

•  기존����������� ������������������  서비스들의����������� ������������������  강한����������� ������������������  DB����������� ������������������  의존도����������� ������������������  

•  Throughput����������� ������������������  •  Response����������� ������������������  Time����������� ������������������  •  Scalability����������� ������������������  

M����������� ������������������  

S1����������� ������������������   S3����������� ������������������  S2����������� ������������������  

S4����������� ������������������   S6����������� ������������������  S5����������� ������������������  

DB����������� ������������������  Group����������� ������������������  

Service����������� ������������������  Applications����������� ������������������  

Write����������� ������������������   Read����������� ������������������  

Page 4: SDEC2011 Arcus NHN memcached cloud

4 / SDEC 2011 발표자료

ARCUS����������� ������������������  개발����������� ������������������  배경����������� ������������������  

•  DB����������� ������������������  의존도����������� ������������������  및����������� ������������������  ����������� ������������������  Load����������� ������������������  경감����������� ������������������  

•  Explicit����������� ������������������  Read-����������� ������������������  Through����������� ������������������  Cache����������� ������������������  

M����������� ������������������   S1����������� ������������������   S3����������� ������������������  S2����������� ������������������  

DB����������� ������������������  Group����������� ������������������  

Service����������� ������������������  Applications����������� ������������������  

Write����������� ������������������   Read����������� ������������������  

Cache����������� ������������������  Miss����������� ������������������  

Arcus����������� ������������������  Get����������� ������������������  

Arcus����������� ������������������  Set����������� ������������������  (DB����������� ������������������  Query)����������� ������������������  

Arcus����������� ������������������  Cache����������� ������������������  Cloud����������� ������������������  

Page 5: SDEC2011 Arcus NHN memcached cloud

5 / SDEC 2011 발표자료

ARCUS����������� ������������������  Cache����������� ������������������  Cloud����������� ������������������  

•  Memcached����������� ������������������  Based����������� ������������������  Cache����������� ������������������  Cloud����������� ������������������  •  Horizontally����������� ������������������  Scalable����������� ������������������  •  Consistent����������� ������������������  Hashing����������� ������������������  •  Easy����������� ������������������  cache����������� ������������������  node����������� ������������������  addition/removal����������� ������������������  •  Automatic����������� ������������������  Failover����������� ������������������  •  Server����������� ������������������  Resource����������� ������������������  Monitoring����������� ������������������  

Page 6: SDEC2011 Arcus NHN memcached cloud

6 / SDEC 2011 발표자료

Memcached����������� ������������������  

•  http://www.memcached.org/����������� ������������������  ����������� ������������������  •  Simple����������� ������������������  key-value����������� ������������������  memory����������� ������������������  store����������� ������������������  •  Use����������� ������������������  event-driven����������� ������������������  network����������� ������������������  I/O����������� ������������������  framework����������� ������������������  (libevent)����������� ������������������  •  Slab����������� ������������������  memory����������� ������������������  allocator����������� ������������������  &����������� ������������������  per-slab����������� ������������������  LRU����������� ������������������  list����������� ������������������  •  Used����������� ������������������  by����������� ������������������  Facebook,����������� ������������������  LiveJournal,����������� ������������������  Twitter,����������� ������������������  YouTube,����������� ������������������  Wikipedia,����������� ������������������  ⋯����������� ������������������  

Page 7: SDEC2011 Arcus NHN memcached cloud

7 / SDEC 2011 발표자료

Memcached����������� ������������������  Operations����������� ������������������  

•  Operation����������� ������������������  Cost����������� ������������������  •  O(1)����������� ������������������  

•  Atomic����������� ������������������  Operation����������� ������������������  •  Numerous����������� ������������������  Language����������� ������������������  API����������� ������������������  •  C,����������� ������������������  Java,����������� ������������������  PHP,����������� ������������������  Python,����������� ������������������  Ruby,����������� ������������������  Perl,����������� ������������������  ⋯����������� ������������������  

Commands����������� ������������������  

Storage����������� ������������������   set,����������� ������������������  add,����������� ������������������  replace,����������� ������������������  append,����������� ������������������  ����������� ������������������  prepend,����������� ������������������  delete����������� ������������������  

Fetch����������� ������������������   get, gets(multiple get)����������� ������������������  

Counter����������� ������������������   incr, decr����������� ������������������  

Misc����������� ������������������   CAS (compare &����������� ������������������  swap), stats����������� ������������������  

Page 8: SDEC2011 Arcus NHN memcached cloud

8 / SDEC 2011 발표자료

Memcached����������� ������������������  Operation����������� ������������������  Examples����������� ������������������  

•  Text����������� ������������������  Protocol����������� ������������������  set  <key>  <flags>  <exptime>  <bytes>  [noreply]\r\n  <value>\r\n    get  <key>\r\n����������� ������������������  

[jhpark@XXXX]$  telnet  localhost  11211  Trying  127.0.0.1...  Connected  to  localhost.localdomain  (127.0.0.1).  Escape  character  is  '^]'.    set  sample_key  0  0  12  sample_value  STORED    get  sample_key  VALUE  sample_key  0  12  sample_value  END  

Page 9: SDEC2011 Arcus NHN memcached cloud

9 / SDEC 2011 발표자료

Memcached����������� ������������������  Performance����������� ������������������  

0

50000

100000

150000

200000

250000

Throughput (TPS)

0

100

200

300

400

500

600

700

800

Response Time (microsec)

•  한����������� ������������������  서버에서의����������� ������������������  memcached����������� ������������������  성능����������� ������������������  

Page 10: SDEC2011 Arcus NHN memcached cloud

10 / SDEC 2011 발표자료

32bit����������� ������������������  continuum����������� ������������������  

(2^32����������� ������������������  hash����������� ������������������  points)����������� ������������������  

Consistent����������� ������������������  Hashing����������� ������������������  

Node 0

Node 1

Node 2

Key x

Key y

Key z

•  Mapping����������� ������������������  of����������� ������������������  keys����������� ������������������  to����������� ������������������  cache����������� ������������������  nodes����������� ������������������  

Leave (Failure)

Remapped to Node 1

Node 3

Join Remapped to Node 3

•  Node����������� ������������������  Addition/Removal����������� ������������������  •  K����������� ������������������  /����������� ������������������  n����������� ������������������  keys����������� ������������������  remapped����������� ������������������  

Page 11: SDEC2011 Arcus NHN memcached cloud

11 / SDEC 2011 발표자료

Consistent����������� ������������������  Hashing����������� ������������������  

Node 0

Node 1 Node 2

•  Mapping����������� ������������������  of����������� ������������������  keys����������� ������������������  to����������� ������������������  cache����������� ������������������  nodes����������� ������������������  •  Load����������� ������������������  Balancing����������� ������������������  

•  Hash����������� ������������������  points����������� ������������������  per����������� ������������������  node����������� ������������������  •  =>����������� ������������������  Not����������� ������������������  just����������� ������������������  one����������� ������������������  •  =>����������� ������������������  Some����������� ������������������  hundred����������� ������������������  

Node 2

Node 1

Node 0

Node 0

Node 2

Node 1

Node 2

Node 1

Node 0 Node 2

Node 0

Node 1

Page 12: SDEC2011 Arcus NHN memcached cloud

12 / SDEC 2011 발표자료

Arcus����������� ������������������  1.5����������� ������������������  Architecture����������� ������������������  

Clients Cache Nodes

Java & C Smart Client + Local caching (Java)

Consistent hashing

Unified Cloud Admin (Zookeeper ensemble)

Page 13: SDEC2011 Arcus NHN memcached cloud

13 / SDEC 2011 발표자료

Zookeeper����������� ������������������  Integration����������� ������������������  

•  Zookeeper����������� ������������������  •  http://zookeeper.apache.org/����������� ������������������  •  Developed����������� ������������������  by����������� ������������������  Yahoo����������� ������������������  (written����������� ������������������  in����������� ������������������  Java)����������� ������������������  •  Coordination����������� ������������������  Service����������� ������������������  for����������� ������������������  Distributed����������� ������������������  Applications����������� ������������������  •  Used����������� ������������������  by����������� ������������������  Yahoo,����������� ������������������  HBase,����������� ������������������  Neo4j,����������� ������������������  Kafka,����������� ������������������  Solr,����������� ������������������  Hedwig,����������� ������������������  Norbert,����������� ������������������  ⋯����������� ������������������  

•  Arcus����������� ������������������  Uses����������� ������������������  Zookeeper����������� ������������������  •  Maintain����������� ������������������  Cache����������� ������������������  Node����������� ������������������  List����������� ������������������  (shared����������� ������������������  by����������� ������������������  Clients)����������� ������������������  •  Automatic����������� ������������������  Failover����������� ������������������  

Page 14: SDEC2011 Arcus NHN memcached cloud

14 / SDEC 2011 발표자료

Zookeeper����������� ������������������  Integration����������� ������������������  

Clients Cache Nodes

Zookeeper Ensemble

Cache Node List ------------------ Node 1 IP:Port Node 2 IP:Port Node 3 IP:Port Node 4 IP:Port

Cache Node 구동

Zookeeper 세션 연결 Ephemeral Node 수동 생성

Cache Node List Maintenance

Page 15: SDEC2011 Arcus NHN memcached cloud

15 / SDEC 2011 발표자료

Arcus����������� ������������������  1.5����������� ������������������  Memcached����������� ������������������  

•  Pluggable����������� ������������������  Engine����������� ������������������  Architecture����������� ������������������  of����������� ������������������  Membase����������� ������������������  •  In-house����������� ������������������  Development����������� ������������������  (Many����������� ������������������  Features)����������� ������������������  

Memcached Core

Community Engine

Default Engine

Arcus Engine

ZK Client

Page 16: SDEC2011 Arcus NHN memcached cloud

16 / SDEC 2011 발표자료

Collection����������� ������������������  개발����������� ������������������  배경����������� ������������������  

•  SNS(Social����������� ������������������  Network����������� ������������������  Services)����������� ������������������  ����������� ������������������  •  Event����������� ������������������  Delivery����������� ������������������  ­–����������� ������������������  친구글����������� ������������������  배달,����������� ������������������  구독글����������� ������������������  배달����������� ������������������  ����������� ������������������  

•  Redis����������� ������������������  (1.2.0)����������� ������������������  검토����������� ������������������  ­–����������� ������������������  List,����������� ������������������  Set,����������� ������������������  Sorted����������� ������������������  Set����������� ������������������  •  Sorted����������� ������������������  Set����������� ������������������  ­–����������� ������������������  Range����������� ������������������  Scan����������� ������������������  ����������� ������������������  

•  No����������� ������������������  [offset,����������� ������������������  count]����������� ������������������  option����������� ������������������  •  No����������� ������������������  capped����������� ������������������  collection����������� ������������������  •  Not����������� ������������������  enough����������� ������������������  cache����������� ������������������  statistics����������� ������������������  •  Cannot����������� ������������������  control����������� ������������������  memory����������� ������������������  use����������� ������������������  

•  Memcached����������� ������������������  기반����������� ������������������  자체����������� ������������������  개발����������� ������������������  -����������� ������������������  ����������� ������������������  맞춤형����������� ������������������  기능����������� ������������������  제공����������� ������������������  

Page 17: SDEC2011 Arcus NHN memcached cloud

17 / SDEC 2011 발표자료

Collection����������� ������������������  개요����������� ������������������  

•  Collection����������� ������������������  in����������� ������������������  Arcus����������� ������������������  •  LIST����������� ������������������  ­–����������� ������������������  Doubly-linked����������� ������������������  list����������� ������������������  •  SET����������� ������������������  -����������� ������������������  Unordered����������� ������������������  set����������� ������������������  of����������� ������������������  unique����������� ������������������  data����������� ������������������  

•  Membership����������� ������������������  check����������� ������������������  용도에����������� ������������������  적합����������� ������������������  •  B+TREE����������� ������������������  ­–����������� ������������������  a����������� ������������������  sorted����������� ������������������  series����������� ������������������  of����������� ������������������  unique����������� ������������������  data����������� ������������������  items����������� ������������������  

•  <64bit����������� ������������������  integer����������� ������������������  key(bkey),����������� ������������������  value>����������� ������������������  형태로����������� ������������������  저장����������� ������������������  •  bkey����������� ������������������  range����������� ������������������  scan����������� ������������������  (ascending����������� ������������������  &����������� ������������������  descending)����������� ������������������  

•  offset,����������� ������������������  count����������� ������������������  기능����������� ������������������  포함����������� ������������������  •  Limiting����������� ������������������  the����������� ������������������  max����������� ������������������  #����������� ������������������  of����������� ������������������  elements����������� ������������������  ����������� ������������������  

•  Violates����������� ������������������  memcached����������� ������������������  O(1)����������� ������������������  philosophy����������� ������������������  ����������� ������������������  •  But,����������� ������������������  O(small����������� ������������������  N)����������� ������������������  ����������� ������������������  

Page 18: SDEC2011 Arcus NHN memcached cloud

18 / SDEC 2011 발표자료

Collection����������� ������������������  저장����������� ������������������  구조����������� ������������������  

header����������� ������������������   key����������� ������������������   value����������� ������������������  

k/v����������� ������������������  item����������� ������������������  

set item����������� ������������������  

header����������� ������������������   key����������� ������������������   set����������� ������������������  info����������� ������������������  

... value1����������� ������������������  

value4����������� ������������������  

value3����������� ������������������  

value2����������� ������������������  

value5����������� ������������������  

Hash Table For Uniqueness Checking

b+tree item����������� ������������������  

header����������� ������������������   key����������� ������������������   b+tree����������� ������������������  info����������� ������������������  

...

bkey1����������� ������������������  -------����������� ������������������  value����������� ������������������  

bkey2����������� ������������������  -------����������� ������������������  value����������� ������������������  

bkey17����������� ������������������  -------����������� ������������������  value����������� ������������������  

bkey75����������� ������������������  -------����������� ������������������  value����������� ������������������  

bkey76����������� ������������������  -------����������� ������������������  value����������� ������������������  

bkey91����������� ������������������  -------����������� ������������������  value����������� ������������������  

...

...

Forward/Backward Range Scan

Page 19: SDEC2011 Arcus NHN memcached cloud

19 / SDEC 2011 발표자료

NAVER����������� ������������������  Me����������� ������������������  Collection����������� ������������������  활용����������� ������������������  사례����������� ������������������  

구독관계����������� ������������������  및����������� ������������������  구독글����������� ������������������  목록����������� ������������������  정보를����������� ������������������  Collection으로����������� ������������������  저장����������� ������������������  

카페����������� ������������������   블로그����������� ������������������  

정보����������� ������������������  콘텐츠����������� ������������������  on����������� ������������������  네이버����������� ������������������  

etc����������� ������������������  ...����������� ������������������  

뉴스����������� ������������������   웹툰����������� ������������������  

책����������� ������������������   뮤직����������� ������������������  

지식인����������� ������������������  

Page 20: SDEC2011 Arcus NHN memcached cloud

20 / SDEC 2011 발표자료

NAVER����������� ������������������  Me����������� ������������������  Collection����������� ������������������  활용����������� ������������������  사례����������� ������������������  •  구독글����������� ������������������  모아보기����������� ������������������  ­–����������� ������������������  DB����������� ������������������  질의����������� ������������������  

SELECT  *    FROM  messages  WHERE  feedid  in  (feedID1,  feedID2,  …,  feedIDn)                      AND  create_time  <  sysdate()  ORDER  BY  create_time  DESC  LIMIT  20;����������� ������������������  

•  이슈)����������� ������������������  FeedID����������� ������������������  List가����������� ������������������  클수록����������� ������������������  ����������� ������������������  •  질의����������� ������������������  응답����������� ������������������  성능이����������� ������������������  급격히����������� ������������������  느려짐����������� ������������������  ����������� ������������������  •  수십����������� ������������������  msec����������� ������������������  ~����������� ������������������  수십����������� ������������������  sec����������� ������������������  (MySQL)����������� ������������������  

•  대부분����������� ������������������  SNS에����������� ������������������  동일/유사����������� ������������������  이슈����������� ������������������  존재����������� ������������������  

Page 21: SDEC2011 Arcus NHN memcached cloud

21 / SDEC 2011 발표자료

NAVER����������� ������������������  Me����������� ������������������  Collection����������� ������������������  활용����������� ������������������  사례����������� ������������������  

•  기본����������� ������������������  해결����������� ������������������  방안����������� ������������������  ����������� ������������������  •  빠른����������� ������������������  Arcus����������� ������������������  이용����������� ������������������  ����������� ������������������  •  사용자별����������� ������������������  Inbox����������� ������������������  구현����������� ������������������  ­–����������� ������������������  B+Tree����������� ������������������  Collection����������� ������������������  사용����������� ������������������  

User Inbox 1

User Inbox 2

User Inbox N

Push Delivery

Feed 1

Feed M

Page 22: SDEC2011 Arcus NHN memcached cloud

22 / SDEC 2011 발표자료

NAVER����������� ������������������  Me����������� ������������������  Collection����������� ������������������  활용����������� ������������������  사례����������� ������������������  

구독관계����������� ������������������  Cache����������� ������������������  (SET����������� ������������������  type)����������� ������������������  

Feed����������� ������������������  -����������� ������������������  구독자����������� ������������������  관계����������� ������������������  

사용자별����������� ������������������  ����������� ������������������  구독글����������� ������������������  목록����������� ������������������  Cache����������� ������������������  (B+Tree����������� ������������������  type)����������� ������������������  

*bkey:����������� ������������������  create����������� ������������������  time����������� ������������������  *data:����������� ������������������  message����������� ������������������  id����������� ������������������  

구독글����������� ������������������  내용����������� ������������������  Cache����������� ������������������  (K/V����������� ������������������  type)����������� ������������������  구독글ID����������� ������������������  -����������� ������������������  내용����������� ������������������  

글����������� ������������������  조회����������� ������������������  

1.����������� ������������������  구독����������� ������������������  관계를����������� ������������������  저장����������� ������������������  

구독신청����������� ������������������  

글����������� ������������������  작성����������� ������������������   3.����������� ������������������  구독자����������� ������������������  Inbox로����������� ������������������  1����������� ������������������  :����������� ������������������  N����������� ������������������  Delivery����������� ������������������  

2.����������� ������������������  구독글����������� ������������������  내용����������� ������������������  조회����������� ������������������  

Page 23: SDEC2011 Arcus NHN memcached cloud

23 / SDEC 2011 발표자료

Bulk����������� ������������������  Insert����������� ������������������  

•  High����������� ������������������  Speed����������� ������������������  Event����������� ������������������  Delivery����������� ������������������  

•  Bulk����������� ������������������  Insert����������� ������������������  유형����������� ������������������  •  여러����������� ������������������  collection에����������� ������������������  하나의����������� ������������������  value를����������� ������������������  insert����������� ������������������  •  하나의����������� ������������������  collection에����������� ������������������  여러����������� ������������������  value를����������� ������������������  insert����������� ������������������  

•  Behind����������� ������������������  Technology����������� ������������������  •  Server-side����������� ������������������  command����������� ������������������  pipelining����������� ������������������  

Page 24: SDEC2011 Arcus NHN memcached cloud

24 / SDEC 2011 발표자료

Sequential����������� ������������������  Command����������� ������������������  Execution����������� ������������������  

•  Collection����������� ������������������  insert����������� ������������������  •  ~����������� ������������������  40����������� ������������������  usec����������� ������������������  on����������� ������������������  server����������� ������������������  •  Response����������� ������������������  time����������� ������������������  on����������� ������������������  client����������� ������������������  :����������� ������������������  1����������� ������������������  ~����������� ������������������  2����������� ������������������  msec����������� ������������������  

•  Reasons����������� ������������������  •  Data����������� ������������������  (de)serialization����������� ������������������  •  Network����������� ������������������  round-trip����������� ������������������  time����������� ������������������  

•  ����������� ������������������  1000����������� ������������������  inserts����������� ������������������  per����������� ������������������  1����������� ������������������  sec����������� ������������������  

1 ms

0 ms

2 ms

3 ms

Client Server

40 usec

40 usec

40 usec

Page 25: SDEC2011 Arcus NHN memcached cloud

25 / SDEC 2011 발표자료

Server-side����������� ������������������  Command����������� ������������������  Pipelining����������� ������������������  

1.x ms

0 ms

Client Server

120 usec

•  N����������� ������������������  requests����������� ������������������  ­–����������� ������������������  1����������� ������������������  response����������� ������������������  •  Keep����������� ������������������  the����������� ������������������  result����������� ������������������  of����������� ������������������  ����������� ������������������  each����������� ������������������  request����������� ������������������  

•  At����������� ������������������  the����������� ������������������  end,����������� ������������������  respond����������� ������������������  with����������� ������������������  all����������� ������������������  results.����������� ������������������  

•  네이버Me����������� ������������������  구독하기����������� ������������������  ����������� ������������������  •  Event����������� ������������������  Delivery에서����������� ������������������  20배����������� ������������������  성능����������� ������������������  향상����������� ������������������  

Page 26: SDEC2011 Arcus NHN memcached cloud

26 / SDEC 2011 발표자료

Other����������� ������������������  Features����������� ������������������  

•  Sticky����������� ������������������  Items����������� ������������������  (Not����������� ������������������  Expired����������� ������������������  &����������� ������������������  Not����������� ������������������  Evicted)����������� ������������������  •  Delete����������� ������������������  By����������� ������������������  Prefix����������� ������������������  •  Transparent����������� ������������������  Java����������� ������������������  Client����������� ������������������  Caching����������� ������������������  •  New����������� ������������������  Memory����������� ������������������  Allocator����������� ������������������  •  Replication����������� ������������������  ����������� ������������������  •  기타..����������� ������������������  

Requirements New Technology New Idea & Features New Products

Page 27: SDEC2011 Arcus NHN memcached cloud

27 / SDEC 2011 발표자료

Arcus����������� ������������������  and����������� ������������������  Membase����������� ������������������  

Memcached 기반 Elastic data cloud

기술 협조, 공동 개발

Page 28: SDEC2011 Arcus NHN memcached cloud

28 / SDEC 2011 발표자료

Q����������� ������������������  &����������� ������������������  A����������� ������������������  


Top Related