UC Berkeley新發(fā)布的KV數(shù)據(jù)庫(kù)Anna簡(jiǎn)評(píng)

要點(diǎn):

  • 充分發(fā)揮多核的威力
  • Actor模型傅是,不共享內(nèi)存,lock-free
  • 每一個(gè)Actor固定在一個(gè)core的一個(gè)線程上
  • Key按一致性哈希分配到不同Server的不同Actor中
  • Hot Key采用多主(multi master)復(fù)制陵究,由多個(gè)Actor同時(shí)并行處理辉词,副本(replica)數(shù)量需要根據(jù)情況進(jìn)行選擇
  • Actor之間(包括本地和網(wǎng)絡(luò)中)通過(guò)定期廣播進(jìn)行同步禽绪,且只同步本地更新的最終狀態(tài)(如果一次廣播期間發(fā)生多次改動(dòng))
  • Lattice Composition算法進(jìn)行并行修改的合并医瘫,Actor接收到廣播消息進(jìn)行本地合并
  • 保證最終一致性
  • 跟Redis相比侣肄,單線程的性能變化不大,優(yōu)勢(shì)主要是伸縮性和Hot Key的多副本并發(fā)

需要更多細(xì)節(jié)可以閱讀文末鏈接中的論文醇份,下面是論文內(nèi)容的一些摘錄稼锅。

Anna is a new key-value store system called Anna: a partitioned, multi-mastered system that achieves high performance and elasticity via wait-free execution and coordination-free consistency

Our design rests on a simple architecture of coordination-free actors that perform state update via merge of lattice-based composite data structures.

Goal

providing excellent performance on a single multicore
machine, while scaling up elastically to geo-distributed
cloud deployment.

Requirements

  • partition (shard) the key space, not only across nodes at cloud scale but also across cores for high performance
  • workload scaling, employ multi-master replication to concurrently serve puts and gets against a single key from multiple threads
  • wait-free execution, meaning that each thread is always doing useful work (serving requests), and never waiting for other threads for reasons of consistency or semantics
  • coordination-free consistency models

Design

Coordination-free Actors

besting state-of-the-art lock-free shared memory implementations while scaling smoothly and making repartitioning for elasticity extremely responsive.

uses lattice composition to maintain the consistency of replicated state. Lattices are resilient to message re-ordering and duplication, allowing Anna to employ asynchronous multi-master replication without need for any waiting

Anna combines asynchronous multi-master replication with lattice-based state management to remain scalable across both low and high conflict workloads while still guaranteeing consistency

Multi Master Replication

In multi-master replication, a key is replicated on multiple actors, each of which can read and update its own local copy.

In a coordination-free approach, on the other hand, each actor can process a request locally without introducing any inter-actor communication on the critical path. Updates are periodically communicated to other actors when a timer is triggered or when the actor experiences a reduction in request load.

Unlike synchronous multi-master and single-master replication, a coordination-free multi-master scheme could lead to inconsistencies between replicas, because replicas may observe and process messages in different orders.

Rader: Key通過(guò)一致性哈希分不到不同的Server和Actors

Multi Cast Periodically

Anna perform updates against their local state in parallel without synchronizing, and periodically exchange state via multicast.

Anna employs simple eventual consistency, and threads are set to multicast every 100 milliseconds.

On single machine, Actors update their local states, then write the updates to a shared buffer and multicast the address of updates in buffer to other actors.

On different machines, updates needs to be serialized (e.g. through protobuf) and then broadcast through tcp.

Rader:Anna是最終一致性的,意味著會(huì)有一個(gè)時(shí)間窗口各個(gè)Actor本地的狀態(tài)是不同步的

Results

Good performance than shared-memory models

Anna indeed achieves wait-free execution: the vast majority of CPU time (90%) is spent processing requests without many cache misses, while overheads of lattice merge and multicast are small. In short, Anna’s Coordination-free actor model addresses the heart of the scalability limitations of multi-core KVS systems.

TBB and Masstree spend 92% - 95% of the CPU time on atomic instructions under high contention, and only 4% - 7% of the CPU time is devoted to request handling. As a result, the TBB hash map and Masstree perform 50× slower than Anna (rep= 1) and 700× slower than Anna (full replication).

Rader:更新沖突較多的情況下僚纷,共享內(nèi)存模型花費(fèi)了絕大多數(shù)的CPU在原子操作上矩距,不管是有鎖還是無(wú)鎖的實(shí)現(xiàn)方式維護(hù)“緩存一致性”都是瓶頸。 Redis因?yàn)槭菃尉€程的怖竭,沒(méi)有這方面的問(wèn)題锥债。

Be care of replications

for systems that support multi-master replication, having a high replication factor under low contention workloads can hurt performance. Instead, we want to dynamically monitor the data’s contention level and
selectively replicate the highly contented keys across threads

Rader:沖突較少的情況下,謹(jǐn)慎選擇副本數(shù)量侵状,過(guò)多的副本會(huì)傷害性能

Compare with Redis Cluster

Anna can significantly outperform Redis Cluster by replicating hot keys under high contention, and can
match the performance of Redis Cluster under low contention.

Rader:低沖突的情況下跟Redis性能差不多赞弥,但是高沖突的時(shí)候可以通過(guò)Hot Key副本提高性能

Refs

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末毅整,一起剝皮案震驚了整個(gè)濱河市趣兄,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌悼嫉,老刑警劉巖艇潭,帶你破解...
    沈念sama閱讀 222,729評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡蹋凝,警方通過(guò)查閱死者的電腦和手機(jī)鲁纠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,226評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)鳍寂,“玉大人改含,你說(shuō)我怎么就攤上這事∑矗” “怎么了捍壤?”我有些...
    開(kāi)封第一講書人閱讀 169,461評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)鞍爱。 經(jīng)常有香客問(wèn)我鹃觉,道長(zhǎng),這世上最難降的妖魔是什么睹逃? 我笑而不...
    開(kāi)封第一講書人閱讀 60,135評(píng)論 1 300
  • 正文 為了忘掉前任盗扇,我火速辦了婚禮,結(jié)果婚禮上沉填,老公的妹妹穿的比我還像新娘疗隶。我一直安慰自己,他們只是感情好翼闹,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,130評(píng)論 6 398
  • 文/花漫 我一把揭開(kāi)白布抽减。 她就那樣靜靜地躺著,像睡著了一般橄碾。 火紅的嫁衣襯著肌膚如雪卵沉。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 52,736評(píng)論 1 312
  • 那天法牲,我揣著相機(jī)與錄音史汗,去河邊找鬼。 笑死拒垃,一個(gè)胖子當(dāng)著我的面吹牛停撞,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播悼瓮,決...
    沈念sama閱讀 41,179評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼戈毒,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了横堡?” 一聲冷哼從身側(cè)響起埋市,我...
    開(kāi)封第一講書人閱讀 40,124評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎命贴,沒(méi)想到半個(gè)月后道宅,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體食听,經(jīng)...
    沈念sama閱讀 46,657評(píng)論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,723評(píng)論 3 342
  • 正文 我和宋清朗相戀三年污茵,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了樱报。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,872評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡泞当,死狀恐怖迹蛤,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情襟士,我是刑警寧澤笤受,帶...
    沈念sama閱讀 36,533評(píng)論 5 351
  • 正文 年R本政府宣布,位于F島的核電站敌蜂,受9級(jí)特大地震影響箩兽,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜章喉,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,213評(píng)論 3 336
  • 文/蒙蒙 一汗贫、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧秸脱,春花似錦落包、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 32,700評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至巷查,卻和暖如春有序,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背岛请。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,819評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工旭寿, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人崇败。 一個(gè)月前我還...
    沈念sama閱讀 49,304評(píng)論 3 379
  • 正文 我出身青樓盅称,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親后室。 傳聞我的和親對(duì)象是個(gè)殘疾皇子缩膝,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,876評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,350評(píng)論 0 10
  • “從前的日色變的慢,車馬郵件都很慢岸霹,一生只夠愛(ài)一個(gè)人…… 如今的一切都很快疾层,我看到一個(gè)姑娘,聽(tīng)著音樂(lè)在微風(fēng)里散步松申,...
    清歡三月閱讀 235評(píng)論 0 0
  • 具體的應(yīng)該是空間“花藤”或者是“QQ花園”應(yīng)用云芦。 QQ空間添加花藤應(yīng)用: 一:進(jìn)入空間“個(gè)人中心”,點(diǎn)擊應(yīng)用列表上...
    dgdfgf123閱讀 1,061評(píng)論 0 0
  • 慢慢地,我們都會(huì)變老皇筛,從起點(diǎn)走向終點(diǎn)琉历,自然而必然。成長(zhǎng)的途中水醋,匆匆而又忙忙旗笔,跌跌而又撞撞,奔波而又小心拄踪,勞累而又費(fèi)...
    我愛(ài)吃任何魚閱讀 835評(píng)論 1 9