sdec2011 nstore : a new approach for data distribution and scalability
DESCRIPTION
As Personalized Web Environment (PWE) and SNS is growing, NHN has developed a social networking service called NAVER.me which pulls user's data, including event alarms, messages from emails, comments made on any blog or at any social service linked to naver.com, and displays everything at one place in a user friendly way. This personalized service operates enormous data, thus requires scalability and high-availability. At the same time it is necessary to keep support for legacy codes in linked applications, and provide the compatible interface for backend processing system which uses RDBMS. For this purpose, NHN has developed a new distributed storage system called nStore, which takes advantage of both RDBMS and NoSQL. As a result, nStore has the following characteristics:During the load balancing process, the data is distributed by a unit called the Container group.Faster than a traditional RDBMS, but slower than pure memory caching systems like Arcus.Provides unlimited capacity to serve as a permanent storage space.As nStore uses RDBMS as a base storage engine, it supports SQL like query language (nSQL).http://sdec.kr/TRANSCRIPT
ⓒ 2011����������� ������������������ NHN����������� ������������������ CORPORATION
nStore����������� ������������������ A����������� ������������������ new����������� ������������������ approach����������� ������������������ for����������� ������������������ data����������� ������������������ distribution����������� ������������������ and����������� ������������������ scalability����������� ������������������
Hyo����������� ������������������ Kim,����������� ������������������ NHN����������� ������������������ Business����������� ������������������ Platform����������� ������������������
2011.6.27����������� ������������������
����������� ������������������
nStore����������� ������������������ Motivation����������� ������������������ :����������� ������������������ New����������� ������������������ trend����������� ������������������
2����������� ������������������ ����������� ������������������
SNS/CLOUD����������� ������������������
nStore����������� ������������������ Motivation����������� ������������������ :����������� ������������������ millions����������� ������������������ on����������� ������������������ millions����������� ������������������ of����������� ������������������ records����������� ������������������ ����������� ������������������
3����������� ������������������ ����������� ������������������
“G-Dragon이����������� ������������������ 글을����������� ������������������ 쓰면����������� ������������������ 14만����������� ������������������ 명의����������� ������������������ 미친들에게����������� ������������������ 전달해야����������� ������������������ 하는데”����������� ������������������ (14만����������� ������������������ INSERT)����������� ������������������
“미친이����������� ������������������ 7만이����������� ������������������ 넘는����������� ������������������ 산다라박은����������� ������������������ 하루에도����������� ������������������ 글을����������� ������������������ 대엿����������� ������������������ 개씩����������� ������������������ 쓴다는데”����������� ������������������
“네이버Me에����������� ������������������ 로그인하면����������� ������������������ 미투데이,����������� ������������������ 까페����������� ������������������ 등에����������� ������������������ 새����������� ������������������ 글이����������� ������������������ 있는지����������� ������������������ 알려준다.”����������� ������������������
“회원����������� ������������������ 600만의����������� ������������������ 중고나라����������� ������������������ 카페에서����������� ������������������ 알림을����������� ������������������ 발생시키면?”����������� ������������������
“네이버����������� ������������������ 모든����������� ������������������ 컨텐츠들에����������� ������������������ ‘미투하기’����������� ������������������ ����������� ������������������ 버튼이⋯”����������� ������������������
까페����������� ������������������ 새글����������� ������������������ 알림����������� ������������������ :����������� ������������������ 400만����������� ������������������ TPS����������� ������������������
친구����������� ������������������ 관계����������� ������������������ 양:����������� ������������������ 1000만����������� ������������������ 미투����������� ������������������ *����������� ������������������ 100명����������� ������������������ Follower����������� ������������������ =����������� ������������������ 10억����������� ������������������
일����������� ������������������ 미투하기����������� ������������������ 양:����������� ������������������ 500만����������� ������������������ 미투����������� ������������������ *����������� ������������������ 100명����������� ������������������ Follower����������� ������������������ =����������� ������������������ 5억����������� ������������������
What����������� ������������������ is����������� ������������������ nStore?����������� ������������������ Distributed����������� ������������������ High����������� ������������������ Performance����������� ������������������ Storage����������� ������������������
§ Distributed����������� ������������������
• Load����������� ������������������ and����������� ������������������ Data����������� ������������������ Distribution,����������� ������������������ Linear����������� ������������������ Scalability,����������� ������������������ High����������� ������������������ Availability����������� ������������������
§ High����������� ������������������ Performance����������� ������������������
• RDBMS����������� ������������������ ≤����������� ������������������ Distributed����������� ������������������ High����������� ������������������ Performance����������� ������������������ Storage����������� ������������������ <����������� ������������������ Memory����������� ������������������ Cache����������� ������������������
§ Storage����������� ������������������
• Large,����������� ������������������ Persistent,����������� ������������������ Durable����������� ������������������ storage����������� ������������������
Responsible����������� ������������������ for����������� ������������������ data����������� ������������������ &����������� ������������������ load����������� ������������������ distribution,����������� ������������������ replication����������� ������������������ data����������� ������������������ migration����������� ������������������
4����������� ������������������
What����������� ������������������ is����������� ������������������ nStore?����������� ������������������ Characteristics����������� ������������������
§ Replication����������� ������������������ distribution����������� ������������������ via����������� ������������������ hashing����������� ������������������ and����������� ������������������ map����������� ������������������ manage
ment����������� ������������������
§ RDB-like����������� ������������������ tabular����������� ������������������ data����������� ������������������ model����������� ������������������ ����������� ������������������
§ Individual����������� ������������������ storage����������� ������������������ area����������� ������������������ allocation����������� ������������������ (OwFS����������� ������������������ like)����������� ������������������
§ SQL-like����������� ������������������ query����������� ������������������ interface����������� ������������������
§ Local/Global����������� ������������������ table����������� ������������������
5����������� ������������������
nStore����������� ������������������ Comparisons����������� ������������������ among����������� ������������������ NoSQL����������� ������������������ products����������� ������������������
System����������� ������������������ Data����������� ������������������ Model����������� ������������������ An����������� ������������������ Unit����������� ������������������ of����������� ������������������ Distri
bution����������� ������������������ Distribution����������� ������������������ Mo
del����������� ������������������ Replication����������� ������������������
GFS����������� ������������������ GFS����������� ������������������ Chunk����������� ������������������ MDS����������� ������������������ Master-slave����������� ������������������
Big����������� ������������������ table����������� ������������������ Multi-dimensional����������� ������������������
map����������� ������������������ Row����������� ������������������ Index����������� ������������������ GFS-dependent����������� ������������������
Cassandra����������� ������������������ Multi-dimensional����������� ������������������
map����������� ������������������ Row����������� ������������������ Hash/index����������� ������������������ Optional����������� ������������������
MongoDB����������� ������������������ Document����������� ������������������ (JSON)����������� ������������������ Document����������� ������������������ Index����������� ������������������ Master-slave����������� ������������������
CouchDB����������� ������������������ Document����������� ������������������ (BSON)����������� ������������������ Document����������� ������������������ Index����������� ������������������ Master-slave����������� ������������������
Dynamo����������� ������������������ Blob����������� ������������������ Blob����������� ������������������ Hash����������� ������������������ Sloppy����������� ������������������ quorum����������� ������������������
nStore����������� ������������������ Tabular����������� ������������������ Container����������� ������������������ group����������� ������������������ Hash/MDS����������� ������������������ N-replicas����������� ������������������
6����������� ������������������
nStore����������� ������������������ Three����������� ������������������ Components����������� ������������������
Container����������� ������������������ Server����������� ������������������
����������� ������������������
Management����������� ������������������ Server����������� ������������������
����������� ������������������
Application����������� ������������������ (Client)����������� ������������������
Container����������� ������������������ Server����������� ������������������
management����������� ������������������ server����������� ������������������
nStore����������� ������������������ Application����������� ������������������
Storage����������� ������������������ (RDB,����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ )����������� ������������������
REST����������� ������������������ API����������� ������������������
7����������� ������������������
nStore����������� ������������������ Container����������� ������������������ Server����������� ������������������ ���������� ������������������ Container����������� ������������������ Group����������� ������������������ ���������� ������������������ Keyspace����������� ������������������ ���������� ������������������ Container����������� ������������������ ���������� ������������������ Table����������� ������������������
Table����������� ������������������ A����������� ������������������ Table����������� ������������������ B����������� ������������������
Table����������� ������������������ C����������� ������������������
Indexed����������� ������������������ Column����������� ������������������
Indexed����������� ������������������ Column����������� ������������������
Container����������� ������������������ X����������� ������������������
Global����������� ������������������ ����������� ������������������ Table����������� ������������������ G����������� ������������������
Equi-join����������� ������������������
Equi-join����������� ������������������
Table����������� ������������������ A����������� ������������������ Table����������� ������������������ B����������� ������������������
Table����������� ������������������ C����������� ������������������
Indexed����������� ������������������ Column����������� ������������������
Indexed����������� ������������������ Column����������� ������������������
Container����������� ������������������ Y����������� ������������������
Equi-join����������� ������������������
Keyspace����������� ������������������ A����������� ������������������
nStore����������� ������������������
Distribution����������� ������������������ Layer����������� ������������������
Application����������� ������������������
Storage����������� ������������������ (RDB,����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ )����������� ������������������
REST����������� ������������������ API����������� ������������������
8����������� ������������������ ����������� ������������������
Container����������� ������������������ Server����������� ������������������
nStore����������� ������������������ Container����������� ������������������ Server����������� ������������������ :����������� ������������������ Terms����������� ������������������
□ Container����������� ������������������
□ Container����������� ������������������ Group����������� ������������������
□ Container����������� ������������������ Group����������� ������������������ Map����������� ������������������ (CGMAP)����������� ������������������
□ Keyspace����������� ������������������
□ Container����������� ������������������ Server����������� ������������������ (CS)����������� ������������������
§ Embedded����������� ������������������ HTTP����������� ������������������ server����������� ������������������ (libevent)����������� ������������������
§ ����������� ������������������ RPC����������� ������������������ communication����������� ������������������
§ Coordinator����������� ������������������ that����������� ������������������ controls����������� ������������������ replication����������� ������������������ processes����������� ������������������
§ Storage����������� ������������������ layer����������� ������������������ where����������� ������������������ data����������� ������������������ is����������� ������������������ physically����������� ������������������ stored����������� ������������������
□ Migrator����������� ������������������
9����������� ������������������
nStore����������� ������������������ Management����������� ������������������ Server����������� ������������������
□ nStore����������� ������������������ Management����������� ������������������ Server����������� ������������������
§ Check����������� ������������������ the����������� ������������������ health����������� ������������������
§ Change����������� ������������������ the����������� ������������������ status����������� ������������������
§ Configures����������� ������������������ and����������� ������������������ manages����������� ������������������
§ Manages����������� ������������������ CGMAP����������� ������������������
§ Data����������� ������������������ rebalancing����������� ������������������
§ No����������� ������������������ affects����������� ������������������ to����������� ������������������ normal����������� ������������������ operations����������� ������������������ e
ven����������� ������������������ though����������� ������������������ management����������� ������������������ server����������� ������������������
goes����������� ������������������ down!����������� ������������������
management����������� ������������������ ����������� ������������������ server����������� ������������������
rep1����������� ������������������ rep2����������� ������������������ rep3����������� ������������������
CG1����������� ������������������ 1����������� ������������������ 2����������� ������������������ 3����������� ������������������
CG2����������� ������������������ 7����������� ������������������ 5����������� ������������������ 4����������� ������������������
CG3����������� ������������������ 3����������� ������������������ 4����������� ������������������ 1����������� ������������������
CG4����������� ������������������ 7����������� ������������������ 6����������� ������������������ 2����������� ������������������
ID����������� ������������������ IP����������� ������������������ State����������� ������������������
CS1����������� ������������������ 1����������� ������������������ 10.1.1.1:6220����������� ������������������ N����������� ������������������
CS2����������� ������������������ 2����������� ������������������ 10.1.1.2:6220����������� ������������������ N����������� ������������������
CS3����������� ������������������ 3����������� ������������������ 10.1.1.3:6220����������� ������������������ F����������� ������������������
CS4����������� ������������������ 4����������� ������������������ 10.1.1.4:6220����������� ������������������ N����������� ������������������
CS����������� ������������������ list����������� ������������������ CG����������� ������������������ map����������� ������������������
caching����������� ������������������ HB����������� ������������������
10����������� ������������������
nStore����������� ������������������ User����������� ������������������ Interface����������� ������������������
nStore����������� ������������������
client����������� ������������������
C����������� ������������������ API����������� ������������������
CLIENT����������� ������������������
HTTP����������� ������������������ Client����������� ������������������
HTTP����������� ������������������ Server����������� ������������������
CLIENT����������� ������������������
C����������� ������������������ lib����������� ������������������
CS����������� ������������������
MGMT����������� ������������������ C����������� ������������������ API����������� ������������������
HTTP����������� ������������������ Server����������� ������������������
CS����������� ������������������
C����������� ������������������ API����������� ������������������
HTTP����������� ������������������ Server����������� ������������������
CS����������� ������������������
coordinator����������� ������������������
CLIENT����������� ������������������
Java����������� ������������������ lib����������� ������������������
http://<container_server>:<port>/nstore/<keyspace>/����������� ������������������ <method>?ckey=<container_key>&nsql=<query>����������� ������������������
http://xdev006.vpd:80/nstore/ndrive/query?ckey=wendy&nsql=“select����������� ������������������ msg����������� ������������������ from����������� ������������������ noti����������� ������������������ where����������� ������������������ key����������� ������������������ =����������� ������������������ 1”����������� ������������������ ����������� ������������������ {“ret_code”:“0”,����������� ������������������ “result”:����������� ������������������ [{“key”:����������� ������������������ “1”,����������� ������������������ “msg”:“test”},����������� ������������������ {“key”:“2”,����������� ������������������ “msg”:“test2”}]}����������� ������������������
11����������� ������������������
nStore����������� ������������������ Example����������� ������������������
□ Example����������� ������������������ of����������� ������������������ CommucationCast����������� ������������������
§ Each����������� ������������������ user����������� ������������������ is����������� ������������������ allocated����������� ������������������ to����������� ������������������ a����������� ������������������ container����������� ������������������
§ Container����������� ������������������ consists����������� ������������������ of����������� ������������������ two����������� ������������������ tables����������� ������������������
• Whether����������� ������������������ or����������� ������������������ not����������� ������������������ each����������� ������������������ service����������� ������������������ receives����������� ������������������ notification����������� ������������������ :SN_CONF����������� ������������������
• Notification����������� ������������������ information����������� ������������������ :����������� ������������������ SN_MSG����������� ������������������
§ Global����������� ������������������ table����������� ������������������ contains����������� ������������������ service����������� ������������������ configuration����������� ������������������ information����������� ������������������ :����������� ������������������ SN_SVC����������� ������������������
Container����������� ������������������ X����������� ������������������
SN_MSG����������� ������������������
key����������� ������������������ :����������� ������������������ msg_id����������� ������������������
code����������� ������������������
⋯����������� ������������������
SN_CONF����������� ������������������
key����������� ������������������ :����������� ������������������ code����������� ������������������
SN_SVC����������� ������������������
key����������� ������������������ :����������� ������������������ code����������� ������������������
Global����������� ������������������ Table����������� ������������������
12����������� ������������������
□ nSQL����������� ������������������ data����������� ������������������ types����������� ������������������
□ nSQL����������� ������������������
§ nSQL����������� ������������������ query����������� ������������������ should����������� ������������������ be����������� ������������������ delivered����������� ������������������ with����������� ������������������ a����������� ������������������ key����������� ������������������ space����������� ������������������ name����������� ������������������ and����������� ������������������ a����������� ������������������ container����������� ������������������ key����������� ������������������ as����������� ������������������ an����������� ������������������ ar
gument����������� ������������������
• Container����������� ������������������ key����������� ������������������ is����������� ������������������ not����������� ������������������ used����������� ������������������ in����������� ������������������ global����������� ������������������ table����������� ������������������ operation����������� ������������������
nStore����������� ������������������ nSQL����������� ������������������ Spec����������� ������������������
integer����������� ������������������ 64-bit����������� ������������������ 2’s����������� ������������������ complement����������� ������������������ arithmetic����������� ������������������ integer����������� ������������������
double����������� ������������������ 64-bit����������� ������������������ real����������� ������������������
boolean����������� ������������������ True,����������� ������������������ false����������� ������������������
string����������� ������������������ UTF-8����������� ������������������ string����������� ������������������
timestamp����������� ������������������ millisecond����������� ������������������ since����������� ������������������ 1970.1.1����������� ������������������
id����������� ������������������ 128����������� ������������������ bit����������� ������������������ integer����������� ������������������ (UUID����������� ������������������ format)����������� ������������������
nsql = (dml | ddl) [“;”] ;
ddl = create | alter | drop ;
dml = insert | delete | update | select ;
13����������� ������������������
nStore����������� ������������������ The����������� ������������������ Configuration����������� ������������������ and����������� ������������������ Operation����������� ������������������ of����������� ������������������ Program����������� ������������������
Request����������� ������������������ (REST)����������� ������������������
Client����������� ������������������
Replication����������� ������������������
Migration����������� ������������������ (Data����������� ������������������ Rebalancing)����������� ������������������
HTTP����������� ������������������
HTTP����������� ������������������
HTTP����������� ������������������
HTTP����������� ������������������ HTTP����������� ������������������
Coordinator����������� ������������������
Replica����������� ������������������ 1����������� ������������������
Replica����������� ������������������ 2����������� ������������������ Replica����������� ������������������ 3����������� ������������������
14����������� ������������������
nStore����������� ������������������ How����������� ������������������ to����������� ������������������ meet����������� ������������������ global����������� ������������������ consistency����������� ������������������
§ Eventually����������� ������������������ Consistent����������� ������������������ § Commutative����������� ������������������ –����������� ������������������ The����������� ������������������ order����������� ������������������ of����������� ������������������ operati
ons����������� ������������������ does����������� ������������������ not����������� ������������������ affect����������� ������������������ the����������� ������������������ final����������� ������������������ result����������� ������������������ § Idempotent����������� ������������������ –����������� ������������������ the����������� ������������������ same����������� ������������������ result����������� ������������������ with����������� ������������������ e
xecution����������� ������������������ multiple����������� ������������������ times����������� ������������������ § Good����������� ������������������ at����������� ������������������ recovery����������� ������������������
• Ex)����������� ������������������ Gizzard����������� ������������������ (Tweeter)����������� ������������������ § A����������� ������������������ =����������� ������������������ A����������� ������������������ +����������� ������������������ 1����������� ������������������ NOT����������� ������������������ allow����������� ������������������ § How����������� ������������������ to����������� ������������������ make����������� ������������������ it����������� ������������������ based����������� ������������������ on����������� ������������������ RDB?����������� ������������������ § How����������� ������������������ to����������� ������������������ order?����������� ������������������ Timestamp?����������� ������������������
§ Execute����������� ������������������ N����������� ������������������ replicas����������� ������������������ with����������� ������������������ same����������� ������������������ order����������� ������������������
§ Globally����������� ������������������ conflict����������� ������������������ equivalent����������� ������������������ § Ex)����������� ������������������ Master-slave����������� ������������������
§ How?����������� ������������������ • Timestamp����������� ������������������
• Version����������� ������������������
• Global����������� ������������������ lock����������� ������������������
• Global����������� ������������������ queue����������� ������������������
§ Much����������� ������������������ less����������� ������������������ restriction����������� ������������������
15����������� ������������������
nStore����������� ������������������ Consistency����������� ������������������ Model����������� ������������������
16����������� ������������������
nStore����������� ������������������ Benchmark����������� ������������������
17����������� ������������������ ����������� ������������������
Test����������� ������������������ beds����������� ������������������ :����������� ������������������ Nehalem����������� ������������������ 6����������� ������������������ Core����������� ������������������ x����������� ������������������ 2����������� ������������������ CPU����������� ������������������ ,����������� ������������������ 16GB����������� ������������������ Memory,����������� ������������������ 320GB����������� ������������������ x����������� ������������������ 6����������� ������������������ HDD����������� ������������������ RAID0����������� ������������������
Tool����������� ������������������ :����������� ������������������ YCSB(Yahoo����������� ������������������ Cluster����������� ������������������ Serving����������� ������������������ Benchmark)����������� ������������������
Workloads����������� ������������������
����������� ������������������ Insert����������� ������������������ :����������� ������������������ 50M����������� ������������������ records����������� ������������������
����������� ������������������ Read����������� ������������������ :����������� ������������������ Zipian����������� ������������������ distribution����������� ������������������
����������� ������������������ Read/Update����������� ������������������ :����������� ������������������ 50/50����������� ������������������ ����������� ������������������
����������� ������������������ Read/Insert����������� ������������������ :����������� ������������������ 50/50����������� ������������������
Targets����������� ������������������
����������� ������������������ HBASE����������� ������������������
����������� ������������������ Cassandra����������� ������������������
����������� ������������������ MongoDB����������� ������������������
����������� ������������������ nStore����������� ������������������ ����������� ������������������
����������� ������������������
Client����������� ������������������ ����������� ������������������ (128����������� ������������������ threads)����������� ������������������
nStore����������� ������������������
nStore����������� ������������������ Benchmark����������� ������������������ :����������� ������������������ Insert����������� ������������������
18����������� ������������������ ����������� ������������������
0
5000
10000
15000
20000
25000
Insert
nStore����������� ������������������
nStore����������� ������������������ Benchmark����������� ������������������ :����������� ������������������ Read����������� ������������������
19����������� ������������������ ����������� ������������������
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
Read
nStore����������� ������������������
nStore����������� ������������������ Benchmark����������� ������������������ :����������� ������������������ Read/Update����������� ������������������
20����������� ������������������ ����������� ������������������
0
1000
2000
3000
4000
5000
6000
Read/Update
nStore����������� ������������������
nStore����������� ������������������ Benchmark����������� ������������������ :����������� ������������������ Read/Insert����������� ������������������
21����������� ������������������ ����������� ������������������
0
1000
2000
3000
4000
5000
6000
Read/Insert
nStore����������� ������������������
Deploy����������� ������������������ on����������� ������������������ various����������� ������������������ services����������� ������������������
Simplify����������� ������������������ more,����������� ������������������ Gains����������� ������������������ performance����������� ������������������ more����������� ������������������
Lighter����������� ������������������ infra����������� ������������������ storage����������� ������������������
����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ light����������� ������������������
Various����������� ������������������ infra����������� ������������������ storages����������� ������������������ and����������� ������������������ customized����������� ������������������ query����������� ������������������ spec����������� ������������������
nStore����������� ������������������ Future����������� ������������������ Works����������� ������������������
22����������� ������������������
Q����������� ������������������ &����������� ������������������ A����������� ������������������