nosql afternoon in japan kumofs & messagepack

58
Sadayuki Furuhashi Kumofs MessagePack Project #msgpack @frsyuki Distributed key-value store and e

Upload: sadayuki-furuhashi

Post on 09-May-2015

4.544 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: NoSQL afternoon in Japan Kumofs & MessagePack

Sadayuki Furuhashi

Kumofs

MessagePackProject

#msgpack @frsyuki

Distributed key-value store

and e

Page 2: NoSQL afternoon in Japan Kumofs & MessagePack

About me:

Sadayuki Furuhashi (@frsyki)

Diskless network systemVIVER

kumofsDistributed key-value store

MessagePackCross-language communication library

University of Tsukuba

Master’s cource in Computer Science

supported by “Mitoh” project run by IPA, Information-technology Promotion Agancy, Japan

Projects:

Page 3: NoSQL afternoon in Japan Kumofs & MessagePack

About me:

Sadayuki Furuhashi

Diskless network systemVIVER

kumofsDistributed key-value store

MessagePackCross-language communication library

University of Tsukuba

Master’s cource in Computer Science

supported by “Mitoh” project run by IPA, Information-technology Promotion Agancy, Japan

Projects:

Page 4: NoSQL afternoon in Japan Kumofs & MessagePack

kumofs

kumo = 雲 = cloud

Page 5: NoSQL afternoon in Japan Kumofs & MessagePack

What’s kumofs?

• Distributed key-value store

• Get, Set, Delete and CAS (Compare-And-Swap)

• Linear scalability as servers added

• both read and write throughput scales-out

• dynamic rebalancing without any impacts on applications

• Optimized for read-latency

• always zero-hop

• No SPOF

Page 6: NoSQL afternoon in Japan Kumofs & MessagePack

http://itpro.nikkeibp.co.jp/article/COLUMN/20090617/331953/

“memcachedを超える成果も、Interopで若手技術者がクラウドを支える技術を競う”

Page 7: NoSQL afternoon in Japan Kumofs & MessagePack

http://gihyo.jp/dev/serial/01/alpha-geek/0041“小飼弾のアルファギークに逢いたい♥”

Page 8: NoSQL afternoon in Japan Kumofs & MessagePack

Shows and manages hundreds of photos smoothly> gives lots of accesses on metadata servers

http://yapcasia2009.ficia.com/pl/album/7BF0E66A-A35F-11DE-966B-860A873069EA

Page 9: NoSQL afternoon in Japan Kumofs & MessagePack

Why kumofs?

• Need to manage heavy random reads and writes

• Need low latency for user-experience

• Need elastic scalability

• builds small cluster at the first

• enlarges it when number of users increases

• “I won’t wakeup at midnight!”

• Systems that have SPOF rushes administrators to recover crashed servers even if it’s at midnight.

Page 10: NoSQL afternoon in Japan Kumofs & MessagePack

Archtectureof

kumofs

Page 11: NoSQL afternoon in Japan Kumofs & MessagePack

Manager

Gateway

kumo-manager:Watches kumo-servers to detect/detach crashed severs

Archtecture of kumofs

kumo-server:Stores and replicates data

kumo-gateway:Relays requests from applications to kumo-servers

Server

Page 12: NoSQL afternoon in Japan Kumofs & MessagePack

Application

ServerManager

Gateway

Manager

Duplicated(HA)

Server

Server

Server

Server

Server

Application

GatewayApplication

Gateway

Replication

Archtecture of kumofs Tokyo CabinetTokyo Cabinet

Page 13: NoSQL afternoon in Japan Kumofs & MessagePack

hash(key1)

Server A

Server B

Server C

Server D

Consistent Hashing

Page 14: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

coordinated by Server B

Page 15: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

coordinated by Server B

Server C

Server D

Server A

Page 16: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

set

Replicate

Replication mechanism

Page 17: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

getHigh-availability

Page 18: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

getHigh-availability

Page 19: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

getHigh-availability

Page 20: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

coordinated by Server B

Server CServer D

Server A

Adding nodes dynamically

Page 21: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

coordinated by Server B

Server C

Server A

Server E

Copies data

Adding nodes dynamically

Page 22: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

Server E

Data are moving...

Adding nodes dynamically

Page 23: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

Server E

setget

Adding nodes dynamically

Page 24: NoSQL afternoon in Japan Kumofs & MessagePack

Server A

Server B

Server C

Server D

Server E

setget

Adding nodes dynamically

Page 25: NoSQL afternoon in Japan Kumofs & MessagePack

getset

Consistent Hashing for Reading

Consistent Hashing for Writing

Dynamic rebalacing algorithm of kumofs(double-hash-space)

Page 26: NoSQL afternoon in Japan Kumofs & MessagePack

Application

Gateway

Gateway

Application

Server Server Server

memcached protocol

MessagePack-RPC

・Hides cluster configuration from applications. “memcached server on localhost”

localhost:11211 Asynchronous RPC library

Page 27: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack-RPC

Server Server Server

Tools

Administrator

Manager

Gets cluster configuration

Asynchronous RPC library

Page 28: NoSQL afternoon in Japan Kumofs & MessagePack

Tools

Written in Ruby

> automates operation tasks

> easy to implement

> easy to customize

kumoctl

kumostat

kumotop

MessagePack-RPCAsynchronous RPC libraryCross-language RPC

Page 29: NoSQL afternoon in Japan Kumofs & MessagePack

Tools

Written in Ruby

> automates operation tasks

> easy to implement

> easy to customize

kumoctl

kumostat

kumotop

MessagePack-RPCAsynchronous RPC libraryCross-language RPC

MessagePack

Page 30: NoSQL afternoon in Japan Kumofs & MessagePack

What’s MessagePack?

• Binary-based object serialization format

• fast and small

• Cross-language

• Java, C++, Ruby, Python, Erlang, Haskell, ...

• Dynamic typing like JSON, Avro, etc. (Unlike Thrift)

• type-system is compatible with JSON

• Streaming deserialization

Page 31: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack?

{“msgpack”:“json”, “hello”:“world”}

24% compact

MessagePack26 bytes

JSON34 bytes

“It's like JSON, but very fast and small.”

Page 32: NoSQL afternoon in Japan Kumofs & MessagePack

“It's like JSON, but very fast and small.”MessagePack?

Faster!

MessagePack for Java

Page 33: NoSQL afternoon in Japan Kumofs & MessagePack

require 'msgpack' # gem install “msgpack"

msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"

MessagePack.unpack(msg) #=> [1,2,3]

MessagePack?“It's like JSON, but very fast and small.”

Page 34: NoSQL afternoon in Japan Kumofs & MessagePack

require 'msgpack' # gem install “msgpack"

u = MessagePack::Unpacker.new($stdin)

u.each do |obj|

puts obj.to_json

end

MessagePack?“It's like JSON, but very fast and small.”

Page 35: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack?Annotation + dynamic code generation in Java

@MessagePackMessagepublic static class MyClass { public String str; public double num;

@MessagePackOptional public int flag = 0;}

Page 36: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack

• C++> Sadayuki Furuhashi

• Ruby> Sadayuki Furuhashi

• Java> Muga Nishizawa

• Python> INADA Naoki

• Haskell> Hideyuki Tanaka

• Lua> Nobuyuki Kubota

• Perl> tokuhirom, gfx, ...

• Erlang> UENISHI Kota

• Node.JS> Peter Griess

• JavaScript> uupaa

• PHP> advect

• D> repeatedly

Authors

Page 37: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack-RPC?

Rails app

C++ serverJava app

MessagePack-RPC

“Cross-language messaging library”

Page 38: NoSQL afternoon in Japan Kumofs & MessagePack

What’s MessagePack-RPC?

• Cross-language messaging library

• Java, C++, Ruby, Python, Erlang, Haskell, ...

• Simple protocol

• 3 messages: Request, Response and Notify

Page 39: NoSQL afternoon in Japan Kumofs & MessagePack

What’s MessagePack-RPC?

• Asynchronous RPC with parallel pipelining

• Concurrent communication over multiple servers

• Connection pooling

• omits overheads of reconnecting

• Concept of Future

• hides complicated event-driven I/O

• Concept of Session

• hides transport connections

• Dynamic typing

Page 40: NoSQL afternoon in Japan Kumofs & MessagePack

ProtocolMessagePack-RPC protocol

[0, msgid, method, params]

[1, msgid, error, result]

[2, method, params]

Request

Response

Notify

Message ID→Parallel Pipelining

Page 41: NoSQL afternoon in Japan Kumofs & MessagePack

Pipelining

Client Server PipeliningSends one request after another before receiving responses to speed-up.

Examples:・HTTP/1.1 pipelining・Thrift・SOAP

Page 42: NoSQL afternoon in Japan Kumofs & MessagePack

Client Server

Pipelining

“heavy” task“light” task

Examples:・HTTP/1.1 pipelining・Thrift・SOAP

“Heavy” task may keep “light” tasks waiting

> makes parallelism worse

must besorted

Page 43: NoSQL afternoon in Japan Kumofs & MessagePack

Client Server

Parallel pipelining

Example:・MessagePack-RPC

MessagePack-RPC doesn’t require responses to be sorted.

> Returns “light” tasks faster

Faster

“heavy” task“light” task

Page 44: NoSQL afternoon in Japan Kumofs & MessagePack

FutureClient Server1 Server2

call_async(method1)

call_async(method2)

future1

future2

Page 45: NoSQL afternoon in Japan Kumofs & MessagePack

Event-driven I/OServer-side event-driven I/O

Dispatcher

ServerClient

Client

Loop

multi-threaded event-driven I/O(C++, Java)

Servers deals with many clients efficiently.

Page 46: NoSQL afternoon in Japan Kumofs & MessagePack

Event-driven I/O

Client

Session Loop Server

Client

ServerSession Loop

Client-side event-driven I/O

Page 47: NoSQL afternoon in Japan Kumofs & MessagePack

Event-driven I/O

sharedevent loop

Client

Client

Server

Server

Loop

Session

Session

Client-side event-driven I/O

communications concurrently

Page 48: NoSQL afternoon in Japan Kumofs & MessagePack

Event-driven I/O

Session PoolServer

Server

pools these connectionsLoop

Session

Session

connection

Client-side event-driven I/O

Page 49: NoSQL afternoon in Japan Kumofs & MessagePack

Dispatcher

Event-driven I/O

sharedevent loop

Client

Server

Server

Loop

Session

Session

Client-side event-driven I/O

Client

Page 50: NoSQL afternoon in Japan Kumofs & MessagePack

sharedevent looptimer, signal handler,

other protocol, etc...

Dispatcher

Event-driven I/O

Client

Server

Loop

Session

Client-side event-driven I/O

Client

Page 51: NoSQL afternoon in Japan Kumofs & MessagePack
Page 52: NoSQL afternoon in Japan Kumofs & MessagePack

MessagePack-RPC

• C++ - Sadayuki Furuhashi• Erlang - UENISHI Kota• Haskell - Hideyuki Tanaka• Java - Muga Nishizawa• PHP - h0x10• Python - INADA Naoki• Ruby - Sadayuki Furuhashi

Authors

Page 53: NoSQL afternoon in Japan Kumofs & MessagePack

Users

• Ameba Now

• Microblog service; 18 million posts per month

• Apache Solr + MessagePack for realtime search

• Sedue

• Commercial distributed search engine

Page 54: NoSQL afternoon in Japan Kumofs & MessagePack

http://sedue.sc/Sedue Cloud Search: 簡単に使える高性能検索エンジン・レコメンドエンジンクラウドサービス

Page 55: NoSQL afternoon in Japan Kumofs & MessagePack
Page 56: NoSQL afternoon in Japan Kumofs & MessagePack

Conclusion

• Kumofs - Distributed key-value store> Optimized for low latency always zero-hop> No SPOF> Scales-out without any impacts on applications Gateway hides cluster configuration Consistency control algorithm

Page 57: NoSQL afternoon in Japan Kumofs & MessagePack

Conclusion

• MessagePack> Cross-language object serialization library> Supports optional fields

• MessagePack-RPC> Cross-language messaging library> Server/client-side event-driven I/O> Asynchronous RPC with parallel pipelining> Concept of Future and Session> Connection pooling

Page 58: NoSQL afternoon in Japan Kumofs & MessagePack

http://msgpack.org/

http://kumofs.sourceforge.net/