# 第å ç« ï¼ååº ![](img/ch6.png) > æä»¬å¿ é¡»è·³åºçµèæ令åºåççª è¼ãåè¿°å®ä¹ãæè¿°å æ°æ®ã梳çå ³ç³»ï¼èä¸æ¯ç¼åè¿ç¨ã > > ââ Grace Murray Hopperï¼æªæ¥ç计ç®æºåå ¶ç®¡çï¼1962ï¼ > ------------- [TOC] å¨ [第äºç« ](ch5.md) ä¸ï¼æ们讨论äºå¤å¶ ââ å³æ°æ®å¨ä¸åèç¹ä¸çå¯æ¬ï¼å¯¹äºé常大çæ°æ®éï¼æé常é«çååéï¼ä» ä» è¿è¡å¤å¶æ¯ä¸å¤çï¼æ们éè¦å°æ°æ®è¿è¡ **ååºï¼partitionsï¼**ï¼ä¹ç§°ä¸º **åçï¼shardingï¼**[^i]ã [^i]: æ£å¦æ¬ç« æ讨论çï¼ååºæ¯ä¸ç§ææå°å¤§åæ°æ®åºå解æå°åæ°æ®åºçæ¹å¼ãå®ä¸ **ç½ç»ååºï¼network partitions, netsplitsï¼** æ å ³ï¼è¿æ¯èç¹ä¹é´ç½ç»æ éçä¸ç§ãæ们å°å¨ [ç¬¬å «ç« ](ch8.md) 讨论è¿äºé误ã > #### æ¯è¯æ¾æ¸ > > ä¸æä¸ç **ååºï¼partitionï¼**ï¼å¨ MongoDBï¼Elasticsearch å Solr Cloud ä¸è¢«ç§°ä¸º **åçï¼shardï¼**ï¼å¨ HBase ä¸ç§°ä¹ä¸º **åºåï¼Regionï¼**ï¼Bigtable ä¸åæ¯ **表åï¼tabletï¼**ï¼Cassandra å Riak ä¸æ¯ **èèç¹ï¼vnodeï¼**ï¼Couchbase ä¸å«å **è桶ï¼vBucketï¼**ãä½æ¯ **ååºï¼partitioningï¼** æ¯æ约å®ä¿æçå«æ³ã > é常æ åµä¸ï¼æ¯æ¡æ°æ®ï¼æ¯æ¡è®°å½ï¼æ¯è¡ææ¯ä¸ªææ¡£ï¼å±äºä¸ä» å±äºä¸ä¸ªååºãæå¾å¤æ¹æ³å¯ä»¥å®ç°è¿ä¸ç¹ï¼æ¬ç« å°è¿è¡æ·±å ¥è®¨è®ºãå®é ä¸ï¼æ¯ä¸ªååºé½æ¯èªå·±çå°åæ°æ®åºï¼å°½ç®¡æ°æ®åºå¯è½æ¯æåæ¶è¿è¡å¤ä¸ªååºçæä½ã ååºä¸»è¦æ¯ä¸ºäº **å¯ä¼¸ç¼©æ§**ãä¸åçååºå¯ä»¥æ¾å¨ä¸å ±äº«é群ä¸çä¸åèç¹ä¸ï¼è¯·åé [第äºé¨å](part-ii.md) å ³äº [æ å ±äº«æ¶æ](part-ii.md#æ å ±äº«æ¶æ) çå®ä¹ï¼ãå æ¤ï¼å¤§æ°æ®éå¯ä»¥åå¸å¨å¤ä¸ªç£çä¸ï¼å¹¶ä¸æ¥è¯¢è´è½½å¯ä»¥åå¸å¨å¤ä¸ªå¤çå¨ä¸ã 对äºå¨å个ååºä¸è¿è¡çæ¥è¯¢ï¼æ¯ä¸ªèç¹å¯ä»¥ç¬ç«æ§è¡å¯¹èªå·±çæ¥è¯¢ï¼å æ¤å¯ä»¥éè¿æ·»å æ´å¤çèç¹æ¥æ©å¤§æ¥è¯¢ååéã大åï¼å¤æçæ¥è¯¢å¯è½ä¼è·¨è¶å¤ä¸ªèç¹å¹¶è¡å¤çï¼å°½ç®¡è¿ä¹å¸¦æ¥äºæ°çå°é¾ã ååºæ°æ®åºå¨ 20 ä¸çºª 80 å¹´ä»£ç± Teradata å NonStop SQLã1ãç产åçå æ¨åºï¼æè¿å 为 NoSQL æ°æ®åºååºäº Hadoop çæ°æ®ä»åºéæ°è¢«å ³æ³¨ãæäºç³»ç»æ¯ä¸ºäºå¡æ§å·¥ä½è®¾è®¡çï¼æäºç³»ç»åç¨äºåæï¼è¯·åé â[äºå¡å¤çè¿æ¯åæ](ch3.md#äºå¡å¤çè¿æ¯åæï¼)âï¼ï¼è¿ç§å·®å¼ä¼å½±åç³»ç»çè¿ä½æ¹å¼ï¼ä½æ¯ååºçåºæ¬åçåéç¨äºè¿ä¸¤ç§å·¥ä½æ¹å¼ã å¨æ¬ç« ä¸ï¼æ们å°é¦å ä»ç»åå²å¤§åæ°æ®éçä¸åæ¹æ³ï¼å¹¶è§å¯ç´¢å¼å¦ä½ä¸ååºé åãç¶åæ们å°è®¨è®º [ååºå平衡ï¼rebalancingï¼](#ååºå平衡)ï¼å¦ææ³è¦æ·»å æå é¤é群ä¸çèç¹ï¼åå¿ é¡»è¿è¡å平衡ãæåï¼æ们å°æ¦è¿°æ°æ®åºå¦ä½å°è¯·æ±è·¯ç±å°æ£ç¡®çååºå¹¶æ§è¡æ¥è¯¢ã ## ååºä¸å¤å¶ ååºé常ä¸å¤å¶ç»å使ç¨ï¼ä½¿å¾æ¯ä¸ªååºçå¯æ¬åå¨å¨å¤ä¸ªèç¹ä¸ãè¿æå³çï¼å³ä½¿æ¯æ¡è®°å½å±äºä¸ä¸ªååºï¼å®ä»ç¶å¯ä»¥åå¨å¨å¤ä¸ªä¸åçèç¹ä¸ä»¥è·å¾å®¹éè½åã ä¸ä¸ªèç¹å¯è½åå¨å¤ä¸ªååºãå¦æ使ç¨ä¸»ä»å¤å¶æ¨¡åï¼åååºåå¤å¶çç»åå¦ [å¾ 6-1](img/fig6-1.png) æ示ãæ¯ä¸ªååºé¢å¯¼è ï¼ä¸»åºï¼è¢«åé ç»ä¸ä¸ªèç¹ï¼è¿½éè ï¼ä»åºï¼è¢«åé ç»å ¶ä»èç¹ãæ¯ä¸ªèç¹å¯è½æ¯æäºååºç主åºï¼åæ¶æ¯å ¶ä»ååºçä»åºã æä»¬å¨ [第äºç« ](ch5.md) 讨论çå ³äºæ°æ®åºå¤å¶çææå 容åæ ·éç¨äºååºçå¤å¶ã大å¤æ°æ åµä¸ï¼ååºæ¹æ¡çéæ©ä¸å¤å¶æ¹æ¡çéæ©æ¯ç¬ç«çï¼ä¸ºç®åèµ·è§ï¼æ¬ç« ä¸å°å¿½ç¥å¤å¶ã ![](img/fig6-1.png) **å¾ 6-1 ç»å使ç¨å¤å¶åååºï¼æ¯ä¸ªèç¹å å½æäºååºç主åºï¼å ¶ä»ååºå å½ä»åºã** ## é®å¼æ°æ®çååº åè®¾ä½ æ大éæ°æ®å¹¶ä¸æ³è¦ååºï¼å¦ä½å³å®å¨åªäºèç¹ä¸åå¨åªäºè®°å½å¢ï¼ ååºç®æ æ¯å°æ°æ®åæ¥è¯¢è´è½½åååå¸å¨å个èç¹ä¸ãå¦ææ¯ä¸ªèç¹å ¬å¹³å享æ°æ®åè´è½½ï¼é£ä¹çè®ºä¸ 10 个èç¹åºè¯¥è½å¤å¤ç 10 åçæ°æ®éå 10 åçå个èç¹ç读åååéï¼ææ¶å¿½ç¥å¤å¶ï¼ã å¦æååºæ¯ä¸å ¬å¹³çï¼ä¸äºååºæ¯å ¶ä»ååºææ´å¤çæ°æ®ææ¥è¯¢ï¼æ们称ä¹ä¸º **åæï¼skewï¼**ãæ°æ®åæçåå¨ä½¿ååºæçä¸éå¾å¤ãå¨æ端çæ åµä¸ï¼ææçè´è½½å¯è½åå¨ä¸ä¸ªååºä¸ï¼å ¶ä½ 9 个èç¹ç©ºé²çï¼ç¶é¢è½å¨è¿ä¸ä¸ªç¹å¿çèç¹ä¸ãä¸å衡导è´çé«è´è½½çååºè¢«ç§°ä¸º **çç¹ï¼hot spotï¼**ã é¿å çç¹æç®åçæ¹æ³æ¯å°è®°å½éæºåé ç»èç¹ãè¿å°å¨ææèç¹ä¸å¹³ååé æ°æ®ï¼ä½æ¯å®æä¸ä¸ªå¾å¤§ç缺ç¹ï¼å½ä½ è¯å¾è¯»åä¸ä¸ªç¹å®çå¼æ¶ï¼ä½ æ æ³ç¥éå®å¨åªä¸ªèç¹ä¸ï¼æä»¥ä½ å¿ é¡»å¹¶è¡å°æ¥è¯¢ææçèç¹ã æ们å¯ä»¥åå¾æ´å¥½ãç°å¨åè®¾ä½ æä¸ä¸ªç®åçé®å¼æ°æ®æ¨¡åï¼å ¶ä¸ä½ æ»æ¯éè¿å ¶ä¸»é®è®¿é®è®°å½ãä¾å¦ï¼å¨ä¸æ¬èå¼ç纸质ç¾ç§å ¨ä¹¦ä¸ï¼ä½ å¯ä»¥éè¿æ é¢æ¥æ¥æ¾ä¸ä¸ªæ¡ç®ï¼ç±äºæææ¡ç®æåæ¯é¡ºåºæåºï¼å æ¤ä½ å¯ä»¥å¿«éæ¾å°ä½ è¦æ¥æ¾çæ¡ç®ã ### æ ¹æ®é®çèå´ååº ä¸ç§ååºçæ¹æ³æ¯ä¸ºæ¯ä¸ªååºæå®ä¸åè¿ç»çé®èå´ï¼ä»æå°å¼å°æ大å¼ï¼ï¼å¦çº¸è´¨ç¾ç§å ¨ä¹¦çå·ï¼[å¾ 6-2](img/fig6-2.png)ï¼ãå¦æç¥éèå´ä¹é´çè¾¹çï¼åå¯ä»¥è½»æ¾ç¡®å®åªä¸ªååºå å«æ个å¼ãå¦æä½ è¿ç¥éååºæå¨çèç¹ï¼é£ä¹å¯ä»¥ç´æ¥åç¸åºçèç¹ååºè¯·æ±ï¼å¯¹äºç¾ç§å ¨ä¹¦èè¨ï¼å°±åä»ä¹¦æ¶ä¸éåæ£ç¡®ç书ç±ï¼ã ![](img/fig6-2.png) **å¾ 6-2 å°å·çç¾ç§å ¨ä¹¦æç §å ³é®åèå´è¿è¡ååº** é®çèå´ä¸ä¸å®åååå¸ï¼å 为æ°æ®ä¹å¾å¯è½ä¸åååå¸ãä¾å¦å¨ [å¾ 6-2](img/fig6-2.png) ä¸ï¼ç¬¬ 1 å·å å«ä»¥ A å B å¼å¤´çåè¯ï¼ä½ç¬¬ 12 å·åå å«ä»¥ TãUãVãXãY å Z å¼å¤´çåè¯ãåªæ¯ç®åçè§å®æ¯ä¸ªå·å å«ä¸¤ä¸ªåæ¯ä¼å¯¼è´ä¸äºå·æ¯å ¶ä»å·å¤§ã为äºåååé æ°æ®ï¼ååºè¾¹çéè¦ä¾æ®æ°æ®è°æ´ã ååºè¾¹çå¯ä»¥ç±ç®¡çåæå¨éæ©ï¼ä¹å¯ä»¥ç±æ°æ®åºèªå¨éæ©ï¼æ们ä¼å¨ â[ååºå平衡](#ååºå平衡)â ä¸æ´è¯¦ç»å°è®¨è®ºååºè¾¹ççéæ©ï¼ãBigtable 使ç¨äºè¿ç§ååºçç¥ï¼ä»¥åå ¶å¼æºçä»·ç© HBase ã2, 3ããRethinkDB å 2.4 çæ¬ä¹åç MongoDB ã4ãã å¨æ¯ä¸ªååºä¸ï¼æ们å¯ä»¥æç §ä¸å®ç顺åºä¿åé®ï¼è¯·åé â[SSTables å LSM æ ](ch3.md#SSTablesåLSMæ )âï¼ã好å¤æ¯è¿è¡èå´æ«æé常ç®åï¼ä½ å¯ä»¥å°é®ä½ä¸ºèåç´¢å¼æ¥å¤çï¼ä»¥ä¾¿å¨ä¸æ¬¡æ¥è¯¢ä¸è·åå¤ä¸ªç¸å ³è®°å½ï¼è¯·åé â[å¤åç´¢å¼](ch3.md#å¤åç´¢å¼)âï¼ãä¾å¦ï¼å设æ们æä¸ä¸ªç¨åºæ¥åå¨ä¼ æå¨ç½ç»çæ°æ®ï¼å ¶ä¸ä¸»é®æ¯æµéçæ¶é´æ³ï¼å¹´ææ¥æ¶åç§ï¼ãèå´æ«æå¨è¿ç§æ åµä¸é常æç¨ï¼å 为æ们å¯ä»¥è½»æ¾è·åæ个æ份çæææ°æ®ã ç¶èï¼Key Range ååºç缺ç¹æ¯æäºç¹å®ç访é®æ¨¡å¼ä¼å¯¼è´çç¹ãå¦æ主é®æ¯æ¶é´æ³ï¼åååºå¯¹åºäºæ¶é´èå´ï¼ä¾å¦ï¼ç»æ¯å¤©åé ä¸ä¸ªååºãä¸å¹¸çæ¯ï¼ç±äºæ们å¨æµéåçæ¶å°æ°æ®ä»ä¼ æå¨åå ¥æ°æ®åºï¼å æ¤ææåå ¥æä½é½ä¼è½¬å°åä¸ä¸ªååºï¼å³ä»å¤©çååºï¼ï¼è¿æ ·ååºå¯è½ä¼å åå ¥èè¿è½½ï¼èå ¶ä»ååºåå¤äºç©ºé²ç¶æã5ãã 为äºé¿å ä¼ æå¨æ°æ®åºä¸çè¿ä¸ªé®é¢ï¼éè¦ä½¿ç¨é¤äºæ¶é´æ³ä»¥å¤çå ¶ä»ä¸è¥¿ä½ä¸ºä¸»é®ç第ä¸ä¸ªé¨åãä¾å¦ï¼å¯ä»¥å¨æ¯ä¸ªæ¶é´æ³åæ·»å ä¼ æå¨å称ï¼è¿æ ·ä¼é¦å æä¼ æå¨å称ï¼ç¶åææ¶é´è¿è¡ååºãå设æå¤ä¸ªä¼ æå¨åæ¶è¿è¡ï¼åå ¥è´è½½å°æç»åååå¸å¨ä¸åååºä¸ãç°å¨ï¼å½æ³è¦å¨ä¸ä¸ªæ¶é´èå´å è·åå¤ä¸ªä¼ æå¨çå¼æ¶ï¼ä½ éè¦ä¸ºæ¯ä¸ªä¼ æå¨å称æ§è¡ä¸ä¸ªåç¬çèå´æ¥è¯¢ã ### æ ¹æ®é®çæ£åååº ç±äºåæåçç¹çé£é©ï¼è®¸å¤åå¸å¼æ°æ®åå¨ä½¿ç¨æ£åå½æ°æ¥ç¡®å®ç»å®é®çååºã ä¸ä¸ªå¥½çæ£åå½æ°å¯ä»¥å°åæçæ°æ®åååå¸ãåè®¾ä½ æä¸ä¸ª 32 ä½æ£åå½æ°ï¼æ 论ä½æ¶ç»å®ä¸ä¸ªæ°çå符串è¾å ¥ï¼å®å°è¿åä¸ä¸ª 0 å° $2^{32}$ -1 ä¹é´ç âéæºâ æ°ãå³ä½¿è¾å ¥çå符串é常ç¸ä¼¼ï¼å®ä»¬çæ£åä¹ä¼åååå¸å¨è¿ä¸ªæ°åèå´å ã åºäºååºçç®çï¼æ£åå½æ°ä¸éè¦å¤ä¹å¼ºå£®çå å¯ç®æ³ï¼ä¾å¦ï¼Cassandra å MongoDB ä½¿ç¨ MD5ï¼Voldemort ä½¿ç¨ Fowler-Noll-Vo å½æ°ã许å¤ç¼ç¨è¯è¨é½æå ç½®çç®ååå¸å½æ°ï¼å®ä»¬ç¨äºæ£å表ï¼ï¼ä½æ¯å®ä»¬å¯è½ä¸éåååºï¼ä¾å¦ï¼å¨ Java ç `Object.hashCode()` å Ruby ç `Object#hash`ï¼åä¸ä¸ªé®å¯è½å¨ä¸åçè¿ç¨ä¸æä¸åçåå¸å¼ã6ãã ä¸æ¦ä½ æä¸ä¸ªåéçé®æ£åå½æ°ï¼ä½ å¯ä»¥ä¸ºæ¯ä¸ªååºåé ä¸ä¸ªæ£åèå´ï¼èä¸æ¯é®çèå´ï¼ï¼æ¯ä¸ªéè¿åå¸æ£åè½å¨ååºèå´å çé®å°è¢«åå¨å¨è¯¥ååºä¸ãå¦ [å¾ 6-3](img/fig6-3.png) æ示ã ![](img/fig6-3.png) **å¾ 6-3 æåå¸é®ååº** è¿ç§ææ¯æ é¿å¨ååºä¹é´å ¬å¹³å°åé é®ãååºè¾¹çå¯ä»¥æ¯ååé´éçï¼ä¹å¯ä»¥æ¯ä¼ªéæºéæ©çï¼å¨è¿ç§æ åµä¸ï¼è¯¥ææ¯ææ¶ä¹è¢«ç§°ä¸º **ä¸è´æ§åå¸**ï¼å³ consistent hashingï¼ã > #### ä¸è´æ§åå¸ > > ä¸è´æ§åå¸ç± Karger ç人å®ä¹ãã7ã ç¨äºè·¨äºèç½çº§å«çç¼åç³»ç»ï¼ä¾å¦ CDN ä¸ï¼æ¯ä¸ç§è½åååé è´è½½çæ¹æ³ãå®ä½¿ç¨éæºéæ©ç **ååºè¾¹çï¼partition boundariesï¼** æ¥é¿å ä¸å¤®æ§å¶æåå¸å¼å ±è¯çéè¦ã请注æï¼è¿éçä¸è´æ§ä¸å¤å¶ä¸è´æ§ï¼è¯·åé [第äºç« ](ch5.md)ï¼æ ACID ä¸è´æ§ï¼è¯·åé [第ä¸ç« ](ch7.md)ï¼æ å ³ï¼èåªæ¯æè¿°äºä¸ç§å平衡ï¼rebalancingï¼çç¹å®æ¹æ³ã > > æ£å¦æ们å°å¨ â[ååºå平衡](#ååºå平衡)â ä¸æçå°çï¼è¿ç§ç¹æ®çæ¹æ³å¯¹äºæ°æ®åºå®é ä¸å¹¶ä¸æ¯å¾å¥½ï¼æ以å¨å®é ä¸å¾å°ä½¿ç¨ï¼æäºæ°æ®åºçææ¡£ä»ç¶ä¼ä½¿ç¨ä¸è´æ§åå¸ç说æ³ï¼ä½æ¯å®å¾å¾æ¯ä¸åç¡®çï¼ãå 为æå¯è½äº§çæ··æ·ï¼æ以æ好é¿å 使ç¨ä¸è´æ§åå¸è¿ä¸ªæ¯è¯ï¼èåªæ¯æå®ç§°ä¸º **æ£åååºï¼hash partitioningï¼**ã ä¸å¹¸çæ¯ï¼éè¿ä½¿ç¨é®æ£åè¿è¡ååºï¼æ们失å»äºé®èå´ååºçä¸ä¸ªå¾å¥½çå±æ§ï¼é«ææ§è¡èå´æ¥è¯¢çè½åãæ¾ç»ç¸é»çé®ç°å¨åæ£å¨ææååºä¸ï¼æ以å®ä»¬ä¹é´ç顺åºå°±ä¸¢å¤±äºãå¨ MongoDB ä¸ï¼å¦æä½ ä½¿ç¨äºåºäºæ£åçååºæ¨¡å¼ï¼åä»»ä½èå´æ¥è¯¢é½å¿ é¡»åéå°ææååºã4ããRiakã9ããCouchbase ã10ãæ Voldemort ä¸æ¯æ主é®ä¸çèå´æ¥è¯¢ã Cassandra éåäºæè¡·ççç¥ã11, 12, 13ããCassandra ä¸ç表å¯ä»¥ä½¿ç¨ç±å¤ä¸ªåç»æçå¤å主é®æ¥å£°æãé®ä¸åªæ第ä¸åä¼ä½ä¸ºæ£åçä¾æ®ï¼èå ¶ä»åå被ç¨ä½ Casssandra ç SSTables ä¸æåºæ°æ®çè¿æ¥ç´¢å¼ã尽管æ¥è¯¢æ æ³å¨å¤å主é®ç第ä¸åä¸æèå´æ«è¡¨ï¼ä½å¦æ第ä¸åå·²ç»æå®äºåºå®å¼ï¼åå¯ä»¥å¯¹è¯¥é®çå ¶ä»åæ§è¡ææçèå´æ«æã ç»åç´¢å¼æ¹æ³ä¸ºä¸å¯¹å¤å ³ç³»æä¾äºä¸ä¸ªä¼é çæ°æ®æ¨¡åãä¾å¦ï¼å¨ç¤¾äº¤åªä½ç½ç«ä¸ï¼ä¸ä¸ªç¨æ·å¯è½ä¼åå¸å¾å¤æ´æ°ãå¦ææ´æ°ç主é®è¢«éæ©ä¸º `(user_id, update_timestamp)`ï¼é£ä¹ä½ å¯ä»¥ææå°æ£ç´¢ç¹å®ç¨æ·å¨æ个æ¶é´é´éå ææ¶é´æ³æåºçæææ´æ°ãä¸åçç¨æ·å¯ä»¥åå¨å¨ä¸åçååºä¸ï¼å¯¹äºæ¯ä¸ªç¨æ·ï¼æ´æ°ææ¶é´æ³é¡ºåºåå¨å¨å个ååºä¸ã ### è´è½½åæä¸çç¹æ¶é¤ å¦åæè¿°ï¼åå¸ååºå¯ä»¥å¸®å©åå°çç¹ãä½æ¯ï¼å®ä¸è½å®å ¨é¿å å®ä»¬ï¼å¨æ端æ åµä¸ï¼ææç读åæä½é½æ¯é对åä¸ä¸ªé®çï¼ææç请æ±é½ä¼è¢«è·¯ç±å°åä¸ä¸ªååºã è¿ç§åºæ¯ä¹è®¸å¹¶ä¸å¸¸è§ï¼ä½å¹¶éé»ææªé»ï¼ä¾å¦ï¼å¨ç¤¾äº¤åªä½ç½ç«ä¸ï¼ä¸ä¸ªæ¥ææ°ç¾ä¸è¿½éè çå人ç¨æ·å¨åæäºæ¶å¯è½ä¼å¼åä¸åºé£æ´ã14ããè¿ä¸ªäºä»¶å¯è½å¯¼è´åä¸ä¸ªé®ç大éåå ¥ï¼é®å¯è½æ¯å人çç¨æ· IDï¼æè 人们æ£å¨è¯è®ºçå¨ä½ç IDï¼ãåå¸çç¥ä¸èµ·ä½ç¨ï¼å 为两个ç¸å ID çåå¸å¼ä»ç¶æ¯ç¸åçã å¦ä»ï¼å¤§å¤æ°æ°æ®ç³»ç»æ æ³èªå¨è¡¥å¿è¿ç§é«åº¦åæçè´è½½ï¼å æ¤åºç¨ç¨åºæ责任åå°åæãä¾å¦ï¼å¦æä¸ä¸ªä¸»é®è¢«è®¤ä¸ºæ¯é常ç«ççï¼ä¸ä¸ªç®åçæ¹æ³æ¯å¨ä¸»é®çå¼å§æç»å°¾æ·»å ä¸ä¸ªéæºæ°ãåªè¦ä¸ä¸ªä¸¤ä½æ°çåè¿å¶éæºæ°å°±å¯ä»¥å°ä¸»é®åæ£ä¸º 100 ç§ä¸åç主é®ï¼ä»èåå¨å¨ä¸åçååºä¸ã ç¶èï¼å°ä¸»é®è¿è¡åå²ä¹åï¼ä»»ä½è¯»åé½å¿ é¡»è¦åé¢å¤çå·¥ä½ï¼å 为ä»ä»¬å¿ é¡»ä»ææ 100 个主é®åå¸ä¸è¯»åæ°æ®å¹¶å°å ¶å并ãæ¤ææ¯è¿éè¦é¢å¤çè®°å½ï¼åªéè¦å¯¹å°éçç¹éå éæºæ°ï¼å¯¹äºåå ¥ååéä½çç»å¤§å¤æ°ä¸»é®æ¥è¯´æ¯ä¸å¿ è¦çå¼éãå æ¤ï¼ä½ è¿éè¦ä¸äºæ¹æ³æ¥è·è¸ªåªäºé®éè¦è¢«åå²ã ä¹è®¸å¨å°æ¥ï¼æ°æ®ç³»ç»å°è½å¤èªå¨æ£æµåè¡¥å¿åæçå·¥ä½è´è½½ï¼ä½ç°å¨ï¼ä½ éè¦èªå·±æ¥æè¡¡ã ## ååºä¸æ¬¡çº§ç´¢å¼ å°ç®å为æ¢ï¼æ们讨论çååºæ¹æ¡ä¾èµäºé®å¼æ°æ®æ¨¡åãå¦æåªéè¿ä¸»é®è®¿é®è®°å½ï¼æ们å¯ä»¥ä»è¯¥é®ç¡®å®ååºï¼å¹¶ä½¿ç¨å®æ¥å°è¯»å请æ±è·¯ç±å°è´è´£è¯¥é®çååºã å¦ææ¶å次级索å¼ï¼æ åµä¼åå¾æ´å å¤æï¼åè â[å ¶ä»ç´¢å¼ç»æ](ch3.md#å ¶ä»ç´¢å¼ç»æ)âï¼ã次级索å¼é常并ä¸è½å¯ä¸å°æ è¯è®°å½ï¼èæ¯ä¸ç§æ索记å½ä¸åºç°ç¹å®å¼çæ¹å¼ï¼æ¥æ¾ç¨æ· 123 çæææä½ãæ¥æ¾å å«è¯è¯ `hogwash` çæææç« ãæ¥æ¾ææé¢è²ä¸ºçº¢è²ç车è¾ççã 次级索å¼æ¯å ³ç³»åæ°æ®åºçåºç¡ï¼å¹¶ä¸å¨ææ¡£æ°æ®åºä¸ä¹å¾æ®éã许å¤é®å¼åå¨ï¼å¦ HBase å Volde-mortï¼ä¸ºäºåå°å®ç°çå¤æ度èæ¾å¼äºæ¬¡çº§ç´¢å¼ï¼ä½æ¯ä¸äºï¼å¦ Riakï¼å·²ç»å¼å§æ·»å å®ä»¬ï¼å 为å®ä»¬å¯¹äºæ°æ®æ¨¡åå®å¨æ¯å¤ªæç¨äºã并ä¸æ¬¡çº§ç´¢å¼ä¹æ¯ Solr å Elasticsearch çæç´¢æå¡å¨çåºç³ã 次级索å¼çé®é¢æ¯å®ä»¬ä¸è½æ´é½å°æ å°å°ååºãæ两ç§ç¨æ¬¡çº§ç´¢å¼å¯¹æ°æ®åºè¿è¡ååºçæ¹æ³ï¼**åºäºææ¡£çååºï¼document-basedï¼** å **åºäºå ³é®è¯ï¼term-basedï¼çååº**ã ### åºäºææ¡£ç次级索å¼è¿è¡ååº åè®¾ä½ æ£å¨ç»è¥ä¸ä¸ªéå®äºæ车çç½ç«ï¼å¦ [å¾ 6-4](img/fig6-4.png) æ示ï¼ãæ¯ä¸ªå表é½æä¸ä¸ªå¯ä¸ç IDââ 称ä¹ä¸ºææ¡£ IDââ 并ä¸ç¨ææ¡£ ID 对æ°æ®åºè¿è¡ååºï¼ä¾å¦ï¼ååº 0 ä¸ç ID 0 å° 499ï¼ååº 1 ä¸ç ID 500 å° 999 çï¼ã ä½ æ³è®©ç¨æ·æ索汽车ï¼å 许ä»ä»¬éè¿é¢è²åååè¿æ»¤ï¼æ以éè¦ä¸ä¸ªå¨é¢è²åååä¸ç次级索å¼ï¼ææ¡£æ°æ®åºä¸è¿äºæ¯ **å段ï¼fieldï¼**ï¼å ³ç³»æ°æ®åºä¸è¿äºæ¯ **åï¼columnï¼** ï¼ãå¦æä½ å£°æäºç´¢å¼ï¼åæ°æ®åºå¯ä»¥èªå¨æ§è¡ç´¢å¼ [^ii]ãä¾å¦ï¼æ 论ä½æ¶å°çº¢è²æ±½è½¦æ·»å å°æ°æ®åºï¼æ°æ®åºååºé½ä¼èªå¨å°å ¶æ·»å å°ç´¢å¼æ¡ç® `color:red` çææ¡£ ID å表ä¸ã [^ii]: å¦ææ°æ®åºä» æ¯æé®å¼æ¨¡åï¼åä½ å¯è½ä¼å°è¯å¨åºç¨ç¨åºä»£ç ä¸å建ä»å¼å°ææ¡£ ID çæ å°æ¥å®ç°æ¬¡çº§ç´¢å¼ãå¦æ沿çè¿æ¡è·¯çº¿èµ°ä¸å»ï¼è¯·ä¸åå°å¿ï¼ç¡®ä¿ä½ çç´¢å¼ä¸åºå±æ°æ®ä¿æä¸è´ãç«äºæ¡ä»¶åé´ææ§åå ¥å¤±è´¥ï¼å ¶ä¸ä¸äºæ´æ¹å·²ä¿åï¼ä½å ¶ä»æ´æ¹æªä¿åï¼å¾å®¹æ导è´æ°æ®ä¸åæ¥ - 请åé â[å¤å¯¹è±¡äºå¡çéæ±](ch7.md#å¤å¯¹è±¡äºå¡çéæ±)âã ![](img/fig6-4.png) **å¾ 6-4 åºäºææ¡£ç次级索å¼è¿è¡ååº** å¨è¿ç§ç´¢å¼æ¹æ³ä¸ï¼æ¯ä¸ªååºæ¯å®å ¨ç¬ç«çï¼æ¯ä¸ªååºç»´æ¤èªå·±ç次级索å¼ï¼ä» è¦ç该ååºä¸çææ¡£ãå®ä¸å ³å¿åå¨å¨å ¶ä»ååºçæ°æ®ãæ 论ä½æ¶ä½ éè¦åå ¥æ°æ®åºï¼æ·»å ï¼å é¤ææ´æ°ææ¡£ï¼ï¼åªéå¤çå å«ä½ æ£å¨ç¼åçææ¡£ ID çååºå³å¯ãåºäºè¿ä¸ªåå ï¼**ææ¡£ååºç´¢å¼** ä¹è¢«ç§°ä¸º **æ¬å°ç´¢å¼**ï¼èä¸æ¯å°å¨ä¸ä¸èä¸æè¿°ç **å ¨å±ç´¢å¼**ï¼ã ä½æ¯ï¼ä»ææ¡£ååºç´¢å¼ä¸è¯»åéè¦æ³¨æï¼é¤éä½ å¯¹ææ¡£ ID åäºç¹å«çå¤çï¼å¦å没æçç±å°ææå ·æç¹å®é¢è²æç¹å®åçç汽车æ¾å¨åä¸ä¸ªååºä¸ãå¨ [å¾ 6-4](img/fig6-4.png) ä¸ï¼çº¢è²æ±½è½¦åºç°å¨ååº 0 åååº 1 ä¸ãå æ¤ï¼å¦æè¦æ索红è²æ±½è½¦ï¼åéè¦å°æ¥è¯¢åéå°ææååºï¼å¹¶å并ææè¿åçç»æã è¿ç§æ¥è¯¢ååºæ°æ®åºçæ¹æ³ææ¶è¢«ç§°ä¸º **åæ£ / èéï¼scatter/gatherï¼**ï¼å¹¶ä¸å¯è½ä¼ä½¿æ¬¡çº§ç´¢å¼ä¸ç读åæ¥è¯¢ç¸å½æè´µãå³ä½¿å¹¶è¡æ¥è¯¢ååºï¼åæ£ / èéä¹å®¹æ导è´å°¾é¨å»¶è¿æ¾å¤§ï¼è¯·åé â[å®è·µä¸çç¾åä½ç¹](ch1.md#å®è·µä¸çç¾åä½ç¹)âï¼ãç¶èï¼å®è¢«å¹¿æ³ä½¿ç¨ï¼MongoDBï¼Riak ã15ãï¼Cassandra ã16ãï¼Elasticsearch ã17ãï¼SolrCloud ã18ãå VoltDB ã19ãé½ä½¿ç¨ææ¡£ååºæ¬¡çº§ç´¢å¼ã大å¤æ°æ°æ®åºä¾åºåå»ºè®®ä½ æ建ä¸ä¸ªè½ä»å个ååºæä¾æ¬¡çº§ç´¢å¼æ¥è¯¢çååºæ¹æ¡ï¼ä½è¿å¹¶ä¸æ»æ¯å¯è¡ï¼å°¤å ¶æ¯å½å¨å个æ¥è¯¢ä¸ä½¿ç¨å¤ä¸ªæ¬¡çº§ç´¢å¼æ¶ï¼ä¾å¦åæ¶éè¦æé¢è²åå¶é åæ¥è¯¢ï¼ã ### åºäºå ³é®è¯(Term)ç次级索å¼è¿è¡ååº æ们å¯ä»¥æ建ä¸ä¸ªè¦çææååºæ°æ®ç **å ¨å±ç´¢å¼**ï¼èä¸æ¯ç»æ¯ä¸ªååºå建èªå·±ç次级索å¼ï¼æ¬å°ç´¢å¼ï¼ãä½æ¯ï¼æ们ä¸è½åªæè¿ä¸ªç´¢å¼åå¨å¨ä¸ä¸ªèç¹ä¸ï¼å 为å®å¯è½ä¼æ为ç¶é¢ï¼è¿èäºååºçç®çãå ¨å±ç´¢å¼ä¹å¿ é¡»è¿è¡ååºï¼ä½å¯ä»¥éç¨ä¸ä¸»é®ä¸åçååºæ¹å¼ã [å¾ 6-5](img/fig6-5.png) æè¿°äºè¿å¯è½æ¯ä»ä¹æ ·åï¼æ¥èªææååºç红è²æ±½è½¦å¨çº¢è²ç´¢å¼ä¸ï¼å¹¶ä¸ç´¢å¼æ¯ååºçï¼é¦åæ¯ä» `a` å° `r` çé¢è²å¨ååº 0 ä¸ï¼`s` å° `z` çå¨ååº 1ã汽车å¶é åçç´¢å¼ä¹ä¸ä¹ç±»ä¼¼ï¼ååºè¾¹çå¨ `f` å `h` ä¹é´ï¼ã ![](img/fig6-5.png) **å¾ 6-5 åºäºå ³é®è¯å¯¹æ¬¡çº§ç´¢å¼è¿è¡ååº** æ们å°è¿ç§ç´¢å¼ç§°ä¸º **å ³é®è¯ååºï¼term-partitionedï¼**ï¼å 为æ们寻æ¾çå ³é®è¯å³å®äºç´¢å¼çååºæ¹å¼ãä¾å¦ï¼ä¸ä¸ªå ³é®è¯å¯è½æ¯ï¼`color:red`ã**å ³é®è¯ï¼Termï¼** è¿ä¸ªå称æ¥æºäºå ¨ææ索索å¼ï¼ä¸ç§ç¹æ®ç次级索å¼ï¼ï¼æææ¡£ä¸åºç°çææåè¯ã åä¹åä¸æ ·ï¼æ们å¯ä»¥éè¿ **å ³é®è¯** æ¬èº«æè å®çæ£åè¿è¡ç´¢å¼ååºãæ ¹æ®å ³é®è¯æ¬èº«æ¥ååºå¯¹äºèå´æ«æé常æç¨ï¼ä¾å¦å¯¹äºæ°å¼ç±»çå±æ§ï¼å汽车çæ¥ä»·ï¼ï¼èå¯¹å ³é®è¯çåå¸ååºæä¾äºè´è½½åè¡¡çè½åã å ³é®è¯ååºçå ¨å±ç´¢å¼ä¼äºææ¡£ååºç´¢å¼çå°æ¹ç¹æ¯å®å¯ä»¥ä½¿è¯»åæ´ææçï¼ä¸éè¦ **åæ£ / æ¶é** ææååºï¼å®¢æ·ç«¯åªéè¦åå å«å ³é®è¯çååºååºè¯·æ±ãå ¨å±ç´¢å¼ç缺ç¹å¨äºåå ¥é度è¾æ ¢ä¸è¾ä¸ºå¤æï¼å 为åå ¥å个ææ¡£ç°å¨å¯è½ä¼å½±åç´¢å¼çå¤ä¸ªååºï¼ææ¡£ä¸çæ¯ä¸ªå ³é®è¯å¯è½ä½äºä¸åçååºæè ä¸åçèç¹ä¸ï¼ ã çæ³æ åµä¸ï¼ç´¢å¼æ»æ¯ææ°çï¼åå ¥æ°æ®åºçæ¯ä¸ªææ¡£é½ä¼ç«å³åæ å¨ç´¢å¼ä¸ãä½æ¯ï¼å¨å ³é®è¯ååºç´¢å¼ä¸ï¼è¿éè¦è·¨ååºçåå¸å¼äºå¡ï¼å¹¶ä¸æ¯æææ°æ®åºé½æ¯æï¼è¯·åé [第ä¸ç« ](ch7.md) å [第ä¹ç« ](ch9.md)ï¼ã å¨å®è·µä¸ï¼å¯¹å ¨å±æ¬¡çº§ç´¢å¼çæ´æ°éå¸¸æ¯ **å¼æ¥** çï¼ä¹å°±æ¯è¯´ï¼å¦æå¨åå ¥ä¹åä¸ä¹ 读åç´¢å¼ï¼åææåçæ´æ¹å¯è½å°æªåæ å¨ç´¢å¼ä¸ï¼ãä¾å¦ï¼Amazon DynamoDB 声称å¨æ£å¸¸æ åµä¸ï¼å ¶å ¨å±æ¬¡çº§ç´¢å¼ä¼å¨ä¸å°ä¸ç§çæ¶é´å æ´æ°ï¼ä½å¨åºç¡æ¶æåºç°æ éçæ åµä¸å¯è½ä¼æ延è¿ã20ãã å ¨å±å ³é®è¯ååºç´¢å¼çå ¶ä»ç¨éå æ¬ Riak çæç´¢åè½ã21ãå Oracle æ°æ®ä»åºï¼å®å è®¸ä½ å¨æ¬å°åå ¨å±ç´¢å¼ä¹é´è¿è¡éæ©ã22ããæ们å°å¨ [第åäºç« ](ch12.md) ä¸ç»§ç»å ³é®è¯ååºæ¬¡çº§ç´¢å¼å®ç°çè¯é¢ã ## ååºå平衡 éçæ¶é´çæ¨ç§»ï¼æ°æ®åºä¼æåç§ååï¼ * æ¥è¯¢ååéå¢å ï¼æä»¥ä½ æ³è¦æ·»å æ´å¤ç CPU æ¥å¤çè´è½½ã * æ°æ®é大å°å¢å ï¼æä»¥ä½ æ³æ·»å æ´å¤çç£çå RAM æ¥åå¨å®ã * æºå¨åºç°æ éï¼å ¶ä»æºå¨éè¦æ¥ç®¡æ éæºå¨ç责任ã ææè¿äºæ´æ¹é½éè¦æ°æ®å请æ±ä»ä¸ä¸ªèç¹ç§»å¨å°å¦ä¸ä¸ªèç¹ãå°è´è½½ä»é群ä¸çä¸ä¸ªèç¹åå¦ä¸ä¸ªèç¹ç§»å¨çè¿ç¨ç§°ä¸º **å平衡ï¼rebalancingï¼**ã æ 论使ç¨åªç§ååºæ¹æ¡ï¼å平衡é常é½è¦æ»¡è¶³ä¸äºæä½è¦æ±ï¼ * å平衡ä¹åï¼è´è½½ï¼æ°æ®åå¨ï¼è¯»åååå ¥è¯·æ±ï¼åºè¯¥å¨é群ä¸çèç¹ä¹é´å ¬å¹³å°å ±äº«ã * å平衡åçæ¶ï¼æ°æ®åºåºè¯¥ç»§ç»æ¥å读åååå ¥ã * èç¹ä¹é´åªç§»å¨å¿ é¡»çæ°æ®ï¼ä»¥ä¾¿å¿«éå平衡ï¼å¹¶åå°ç½ç»åç£ç I/O è´è½½ã ### å平衡çç¥ æå ç§ä¸åçååºåé æ¹æ³ã23ãï¼è®©æ们ä¾æ¬¡ç®è¦è®¨è®ºä¸ä¸ã #### åé¢ææï¼hash mod N æ们å¨åé¢è¯´è¿ï¼[å¾ 6-3](img/fig6-3.png)ï¼ï¼æ好å°å¯è½çæ£ååæä¸åçèå´ï¼å¹¶å°æ¯ä¸ªèå´åé ç»ä¸ä¸ªååºï¼ä¾å¦ï¼å¦æ $0 ⤠hash(key)< b_0$ï¼åå°é®åé ç»ååº 0ï¼å¦æ $b_0 ⤠hash(key) < b_1$ï¼ååé ç»ååº 1ï¼ ä¹è®¸ä½ æ³ç¥é为ä»ä¹æ们ä¸ä½¿ç¨ ***å模ï¼modï¼***ï¼è®¸å¤ç¼ç¨è¯è¨ä¸ç % è¿ç®ç¬¦ï¼ãä¾å¦ï¼`hash(key) mod 10` ä¼è¿åä¸ä¸ªä»äº 0 å 9 ä¹é´çæ°åï¼å¦ææ们å°æ£åå为åè¿å¶æ°ï¼æ£å模 10 å°æ¯æåä¸ä¸ªæ°åï¼ãå¦ææ们æ 10 个èç¹ï¼ç¼å·ä¸º 0 å° 9ï¼è¿ä¼¼ä¹æ¯å°æ¯ä¸ªé®åé ç»ä¸ä¸ªèç¹çç®åæ¹æ³ã 模 Nï¼$mod N$ï¼æ¹æ³çé®é¢æ¯ï¼å¦æèç¹æ°é N åçååï¼å¤§å¤æ°é®å°éè¦ä»ä¸ä¸ªèç¹ç§»å¨å°å¦ä¸ä¸ªèç¹ãä¾å¦ï¼å设 $hash(key)=123456$ãå¦ææåæ 10 个èç¹ï¼é£ä¹è¿ä¸ªé®ä¸å¼å§æ¾å¨èç¹ 6 ä¸ï¼å 为 $123456\ mod\ 10 = 6$ï¼ãå½ä½ å¢é¿å° 11 个èç¹æ¶ï¼é®éè¦ç§»å¨å°èç¹ 3ï¼$123456\ mod\ 11 = 3$ï¼ï¼å½ä½ å¢é¿å° 12 个èç¹æ¶ï¼éè¦ç§»å¨å°èç¹ 0ï¼$123456\ mod\ 12 = 0$ï¼ãè¿ç§é¢ç¹ç举å¨ä½¿å¾å平衡çææ¬è¿é«ã æ们éè¦ä¸ç§åªç§»å¨å¿ éæ°æ®çæ¹æ³ã #### åºå®æ°éçååº å¹¸è¿çæ¯ï¼æä¸ä¸ªç¸å½ç®åç解å³æ¹æ¡ï¼å建æ¯èç¹æ´å¤çååºï¼å¹¶ä¸ºæ¯ä¸ªèç¹åé å¤ä¸ªååºãä¾å¦ï¼è¿è¡å¨ 10 个èç¹çé群ä¸çæ°æ®åºå¯è½ä¼ä»ä¸å¼å§å°±è¢«æå为 1,000 个ååºï¼å æ¤å¤§çº¦æ 100 个ååºè¢«åé ç»æ¯ä¸ªèç¹ã ç°å¨ï¼å¦æä¸ä¸ªèç¹è¢«æ·»å å°é群ä¸ï¼æ°èç¹å¯ä»¥ä»å½åæ¯ä¸ªèç¹ä¸ **çªå** ä¸äºååºï¼ç´å°ååºåæ¬¡å ¬å¹³åé ãè¿ä¸ªè¿ç¨å¦ [å¾ 6-6](img/fig6-6.png) æ示ãå¦æä»é群ä¸å é¤ä¸ä¸ªèç¹ï¼åä¼åçç¸åçæ åµã åªæååºå¨èç¹ä¹é´ç移å¨ãååºçæ°éä¸ä¼æ¹åï¼é®ææå®çååºä¹ä¸ä¼æ¹åãå¯ä¸æ¹åçæ¯ååºæå¨çèç¹ãè¿ç§åæ´å¹¶ä¸æ¯å³æ¶ç â å¨ç½ç»ä¸ä¼ è¾å¤§éçæ°æ®éè¦ä¸äºæ¶é´ â æ以å¨ä¼ è¾è¿ç¨ä¸ï¼åæååºä»ç¶ä¼æ¥å读åæä½ã ![](img/fig6-6.png) **å¾ 6-6 å°æ°èç¹æ·»å å°æ¯ä¸ªèç¹å ·æå¤ä¸ªååºçæ°æ®åºé群ã** ååä¸ï¼ä½ çè³å¯ä»¥è§£å³é群ä¸ç硬件ä¸å¹é é®é¢ï¼éè¿ä¸ºæ´å¼ºå¤§çèç¹åé æ´å¤çååºï¼å¯ä»¥å¼ºå¶è¿äºèç¹æ¿è½½æ´å¤çè´è½½ãå¨ Riak ã15ããElasticsearch ã24ããCouchbase ã10ãå Voldemort ã25ãä¸ä½¿ç¨äºè¿ç§å平衡çæ¹æ³ã å¨è¿ç§é ç½®ä¸ï¼ååºçæ°éé常å¨æ°æ®åºç¬¬ä¸æ¬¡å»ºç«æ¶ç¡®å®ï¼ä¹åä¸ä¼æ¹åãè½ç¶ååä¸å¯ä»¥åå²åå并ååºï¼è¯·åé ä¸ä¸èï¼ï¼ä½åºå®æ°éçååºå¨æä½ä¸æ´ç®åï¼å æ¤è®¸å¤åºå®ååºæ°æ®åºéæ©ä¸å®æ½ååºåå²ãå æ¤ï¼ä¸å¼å§é ç½®çååºæ°å°±æ¯ä½ å¯ä»¥æ¥æçæ大èç¹æ°éï¼æä»¥ä½ éè¦éæ©è¶³å¤å¤çååºä»¥éåºæªæ¥çå¢é¿ãä½æ¯ï¼æ¯ä¸ªååºä¹æ管çå¼éï¼æ以éæ©å¤ªå¤§çæ°åä¼éå¾å ¶åã å¦ææ°æ®éçæ»å¤§å°é¾ä»¥é¢ä¼°ï¼ä¾å¦ï¼å¯è½å®å¼å§å¾å°ï¼ä½éçæ¶é´çæ¨ç§»ä¼åå¾æ´å¤§ï¼ï¼éæ©æ£ç¡®çååºæ°æ¯å°é¾çãç±äºæ¯ä¸ªååºå å«äºæ»æ°æ®éåºå®æ¯ççæ°æ®ï¼å æ¤æ¯ä¸ªååºç大å°ä¸é群ä¸çæ°æ®æ»éææ¯ä¾å¢é¿ãå¦æååºé常大ï¼å平衡åä»èç¹æ éæ¢å¤åå¾æè´µãä½æ¯ï¼å¦æååºå¤ªå°ï¼åä¼äº§ç太å¤çå¼éãå½ååºå¤§å° âæ°å°å¥½å¤â çæ¶åæè½è·å¾å¾å¥½çæ§è½ï¼å¦æååºæ°éåºå®ï¼ä½æ°æ®éåå¨å¾å¤§ï¼åé¾ä»¥è¾¾å°æä½³æ§è½ã #### å¨æååº å¯¹äºä½¿ç¨é®èå´ååºçæ°æ®åºï¼è¯·åé â[æ ¹æ®é®çèå´ååº](#æ ¹æ®é®çèå´ååº)âï¼ï¼å ·æåºå®è¾¹ççåºå®æ°éçååºå°é常ä¸ä¾¿ï¼å¦æè¾¹ç设置é误ï¼å¯è½ä¼å¯¼è´æææ°æ®é½å¨ä¸ä¸ªååºä¸ï¼èå ¶ä»ååºå为空ãæå¨éæ°é ç½®ååºè¾¹çå°é常ç¹çã åºäºè¿ä¸ªåå ï¼æé®çèå´è¿è¡ååºçæ°æ®åºï¼å¦ HBase å RethinkDBï¼ä¼å¨æå建ååºãå½ååºå¢é¿å°è¶ è¿é ç½®ç大å°æ¶ï¼å¨ HBase ä¸ï¼é»è®¤å¼æ¯ 10GBï¼ï¼ä¼è¢«åæ两个ååºï¼æ¯ä¸ªååºçº¦å ä¸åçæ°æ®ã26ããä¸ä¹ç¸åï¼å¦æ大éæ°æ®è¢«å é¤å¹¶ä¸ååºç¼©å°å°æ个éå¼ä»¥ä¸ï¼åå¯ä»¥å°å ¶ä¸ç¸é»ååºå并ãæ¤è¿ç¨ä¸ B æ 顶å±åççè¿ç¨ç±»ä¼¼ï¼è¯·åé â[B æ ](ch3.md#Bæ )âï¼ã æ¯ä¸ªååºåé ç»ä¸ä¸ªèç¹ï¼æ¯ä¸ªèç¹å¯ä»¥å¤çå¤ä¸ªååºï¼å°±ååºå®æ°éçååºä¸æ ·ã大åååºæååï¼å¯ä»¥å°å ¶ä¸çä¸å转移å°å¦ä¸ä¸ªèç¹ï¼ä»¥å¹³è¡¡è´è½½ãå¨ HBase ä¸ï¼ååºæ件çä¼ è¾éè¿ HDFSï¼åºå±ä½¿ç¨çåå¸å¼æ件系ç»ï¼æ¥å®ç°ã3ãã å¨æååºçä¸ä¸ªä¼ç¹æ¯ååºæ°ééåºæ»æ°æ®éãå¦æåªæå°éçæ°æ®ï¼å°éçååºå°±è¶³å¤äºï¼æ以å¼éå¾å°ï¼å¦ææ大éçæ°æ®ï¼æ¯ä¸ªååºç大å°è¢«éå¶å¨ä¸ä¸ªå¯é ç½®çæ大å¼ã23ãã éè¦æ³¨æçæ¯ï¼ä¸ä¸ªç©ºçæ°æ®åºä»ä¸ä¸ªååºå¼å§ï¼å 为没æå ³äºå¨åªéç»å¶ååºè¾¹ççå éªä¿¡æ¯ãæ°æ®éå¼å§æ¶å¾å°ï¼ç´å°è¾¾å°ç¬¬ä¸ä¸ªååºçåå²ç¹ï¼ææåå ¥æä½é½å¿ é¡»ç±å个èç¹å¤çï¼èå ¶ä»èç¹åå¤äºç©ºé²ç¶æã为äºè§£å³è¿ä¸ªé®é¢ï¼HBase å MongoDB å 许å¨ä¸ä¸ªç©ºçæ°æ®åºä¸é ç½®ä¸ç»åå§ååºï¼è¿è¢«ç§°ä¸º **é¢åå²**ï¼å³ pre-splittingï¼ãå¨é®èå´ååºçæ åµä¸ï¼é¢åå²éè¦æåç¥éé®æ¯å¦ä½è¿è¡åé çã4,26ãã å¨æååºä¸ä» éç¨äºæ°æ®çèå´ååºï¼èä¸ä¹éç¨äºæ£åååºãä»çæ¬ 2.4 å¼å§ï¼MongoDB åæ¶æ¯æèå´åæ£åååºï¼å¹¶ä¸é½æ¯æå¨æåå²ååºã #### æèç¹æ¯ä¾ååº éè¿å¨æååºï¼ååºçæ°éä¸æ°æ®éç大å°ææ£æ¯ï¼å 为æååå并è¿ç¨å°æ¯ä¸ªååºç大å°ä¿æå¨åºå®çæå°å¼åæ大å¼ä¹é´ãå¦ä¸æ¹é¢ï¼å¯¹äºåºå®æ°éçååºï¼æ¯ä¸ªååºç大å°ä¸æ°æ®éç大å°ææ£æ¯ãå¨è¿ä¸¤ç§æ åµä¸ï¼ååºçæ°éé½ä¸èç¹çæ°éæ å ³ã Cassandra å Ketama 使ç¨ç第ä¸ç§æ¹æ³æ¯ä½¿ååºæ°ä¸èç¹æ°ææ£æ¯ ââ æ¢å¥è¯è¯´ï¼æ¯ä¸ªèç¹å ·æåºå®æ°éçååºã23,27,28ããå¨è¿ç§æ åµä¸ï¼æ¯ä¸ªååºç大å°ä¸æ°æ®é大å°ææ¯ä¾å°å¢é¿ï¼èèç¹æ°éä¿æä¸åï¼ä½æ¯å½å¢å èç¹æ°æ¶ï¼ååºå°å次åå°ãç±äºè¾å¤§çæ°æ®éé常éè¦è¾å¤§æ°éçèç¹è¿è¡åå¨ï¼å æ¤è¿ç§æ¹æ³ä¹ä½¿æ¯ä¸ªååºç大å°è¾ä¸ºç¨³å®ã å½ä¸ä¸ªæ°èç¹å å ¥é群æ¶ï¼å®éæºéæ©åºå®æ°éçç°æååºè¿è¡æåï¼ç¶åå æè¿äºæåååºä¸æ¯ä¸ªååºçä¸åï¼åæ¶å°æ¯ä¸ªååºçå¦ä¸åçå¨åå°ãéæºåå¯è½ä¼äº§çä¸å ¬å¹³çåå²ï¼ä½æ¯å¹³åå¨æ´å¤§æ°éçååºä¸æ¶ï¼å¨ Cassandra ä¸ï¼é»è®¤æ åµä¸ï¼æ¯ä¸ªèç¹æ 256 个ååºï¼ï¼æ°èç¹æç»ä»ç°æèç¹è·å¾å ¬å¹³çè´è½½ä»½é¢ãCassandra 3.0 å¼å ¥äºå¦ä¸ç§å平衡çç®æ³æ¥é¿å ä¸å ¬å¹³çåå²ã29ãã éæºéæ©ååºè¾¹çè¦æ±ä½¿ç¨åºäºæ£åçååºï¼å¯ä»¥ä»æ£åå½æ°äº§ççæ°åèå´ä¸æéè¾¹çï¼ãå®é ä¸ï¼è¿ç§æ¹æ³æ符åä¸è´æ§åå¸çåå§å®ä¹ã7ãï¼è¯·åé â[ä¸è´æ§åå¸](#ä¸è´æ§åå¸)âï¼ãææ°çåå¸å½æ°å¯ä»¥å¨è¾ä½å æ°æ®å¼éçæ åµä¸è¾¾å°ç±»ä¼¼çææã8ãã ### è¿ç»´ï¼æå¨è¿æ¯èªå¨å平衡 å ³äºå平衡æä¸ä¸ªéè¦é®é¢ï¼èªå¨è¿æ¯æå¨è¿è¡ï¼ å¨å ¨èªå¨å平衡ï¼ç³»ç»èªå¨å³å®ä½æ¶å°ååºä»ä¸ä¸ªèç¹ç§»å¨å°å¦ä¸ä¸ªèç¹ï¼æ 须人工干é¢ï¼åå®å ¨æå¨ï¼ååºææ´¾ç»èç¹ç±ç®¡çåæç¡®é ç½®ï¼ä» å¨ç®¡çåæç¡®éæ°é ç½®æ¶æä¼æ´æ¹ï¼ä¹é´æä¸ä¸ªæè¡¡ãä¾å¦ï¼CouchbaseãRiak å Voldemort ä¼èªå¨çæ建议çååºåé ï¼ä½éè¦ç®¡çåæ交æè½çæã å ¨èªå¨å平衡å¯ä»¥å¾æ¹ä¾¿ï¼å 为æ£å¸¸ç»´æ¤çæä½å·¥ä½è¾å°ãç¶èï¼å®å¯è½æ¯ä¸å¯é¢æµçãå平衡æ¯ä¸ä¸ªæè´µçæä½ï¼å 为å®éè¦éæ°è·¯ç±è¯·æ±å¹¶å°å¤§éæ°æ®ä»ä¸ä¸ªèç¹ç§»å¨å°å¦ä¸ä¸ªèç¹ãå¦æ没æå好ï¼è¿ä¸ªè¿ç¨å¯è½ä¼ä½¿ç½ç»æèç¹è´è½½è¿éï¼éä½å ¶ä»è¯·æ±çæ§è½ã è¿ç§èªå¨åä¸èªå¨æ éæ£æµç¸ç»åå¯è½ååå±é©ãä¾å¦ï¼å设ä¸ä¸ªèç¹è¿è½½ï¼å¹¶ä¸å¯¹è¯·æ±çååºææ¶å¾æ ¢ãå ¶ä»èç¹å¾åºç»è®ºï¼è¿è½½çèç¹å·²ç»æ»äº¡ï¼å¹¶èªå¨éæ°å¹³è¡¡é群ï¼ä½¿è´è½½ç¦»å¼å®ãè¿ä¼å¯¹å·²ç»è¶ è´è·çèç¹ï¼å ¶ä»èç¹åç½ç»é æé¢å¤çè´è½½ï¼ä»è使æ åµåå¾æ´ç³ï¼å¹¶å¯è½å¯¼è´çº§è失败ã åºäºè¿ä¸ªåå ï¼å平衡çè¿ç¨ä¸æ人åä¸æ¯ä¸ä»¶å¥½äºãè¿æ¯å ¨èªå¨çè¿ç¨æ ¢ï¼ä½å¯ä»¥å¸®å©é²æ¢è¿ç»´æå¤ã ## 请æ±è·¯ç± ç°å¨æ们已ç»å°æ°æ®éåå²å°å¤ä¸ªæºå¨ä¸è¿è¡çå¤ä¸ªèç¹ä¸ãä½æ¯ä»ç¶åå¨ä¸ä¸ªæ¬èæªå³çé®é¢ï¼å½å®¢æ·æ³è¦ååºè¯·æ±æ¶ï¼å¦ä½ç¥éè¦è¿æ¥åªä¸ªèç¹ï¼éçååºçéæ°å¹³è¡¡ï¼ååºå¯¹èç¹çåé ä¹åçååã为äºåçè¿ä¸ªé®é¢ï¼éè¦æ人ç¥æè¿äºååï¼å¦æææ³è¯»æåé® âfooâï¼éè¦è¿æ¥åªä¸ª IP å°åå端å£å·ï¼ è¿ä¸ªé®é¢å¯ä»¥æ¦æ¬ä¸º **æå¡åç°ï¼service discoveryï¼** ï¼å®ä¸ä» éäºæ°æ®åºãä»»ä½å¯éè¿ç½ç»è®¿é®ç软件é½æè¿ä¸ªé®é¢ï¼ç¹å«æ¯å¦æå®çç®æ æ¯é«å¯ç¨æ§ï¼å¨å¤å°æºå¨ä¸è¿è¡åä½é ç½®ï¼ã许å¤å ¬å¸å·²ç»ç¼åäºèªå·±çå é¨æå¡åç°å·¥å ·ï¼å ¶ä¸è®¸å¤å·²ç»ä½ä¸ºå¼æºåå¸ã30ãã æ¦æ¬æ¥è¯´ï¼è¿ä¸ªé®é¢æå ç§ä¸åçæ¹æ¡ï¼å¦å¾ 6-7 æ示ï¼: 1. å 许客æ·è系任ä½èç¹ï¼ä¾å¦ï¼éè¿ **循ç¯çç¥çè´è½½åè¡¡**ï¼å³ Round-Robin Load Balancerï¼ãå¦æ该èç¹æ°å·§æ¥æ请æ±çååºï¼åå®å¯ä»¥ç´æ¥å¤ç该请æ±ï¼å¦åï¼å®å°è¯·æ±è½¬åå°éå½çèç¹ï¼æ¥æ¶åå¤å¹¶ä¼ éç»å®¢æ·ç«¯ã 2. é¦å å°æææ¥èªå®¢æ·ç«¯ç请æ±åéå°è·¯ç±å±ï¼å®å³å®äºåºè¯¥å¤ç请æ±çèç¹ï¼å¹¶ç¸åºå°è½¬åãæ¤è·¯ç±å±æ¬èº«ä¸å¤çä»»ä½è¯·æ±ï¼å®ä» è´è´£ååºçè´è½½åè¡¡ã 3. è¦æ±å®¢æ·ç«¯ç¥éååºåèç¹çåé ãå¨è¿ç§æ åµä¸ï¼å®¢æ·ç«¯å¯ä»¥ç´æ¥è¿æ¥å°éå½çèç¹ï¼èä¸éè¦ä»»ä½ä¸ä»ã 以ä¸æææ åµä¸çå ³é®é®é¢æ¯ï¼ä½åºè·¯ç±å³ççç»ä»¶ï¼å¯è½æ¯èç¹ä¹ä¸ï¼è¿æ¯è·¯ç±å±æ客æ·ç«¯ï¼å¦ä½äºè§£ååº - èç¹ä¹é´çåé å ³ç³»ååï¼ ![](img/fig6-7.png) **å¾ 6-7 å°è¯·æ±è·¯ç±å°æ£ç¡®èç¹çä¸ç§ä¸åæ¹å¼ã** è¿æ¯ä¸ä¸ªå ·ææææ§çé®é¢ï¼å 为éè¦çæ¯ææåä¸è é½è¾¾æå ±è¯ - å¦å请æ±å°è¢«åéå°é误çèç¹ï¼å¾ä¸å°æ£ç¡®çå¤çãå¨åå¸å¼ç³»ç»ä¸æè¾¾æå ±è¯çåè®®ï¼ä½å¾é¾æ£ç¡®å°å®ç°ï¼è§ [第ä¹ç« ](ch9.md)ï¼ã 许å¤åå¸å¼æ°æ®ç³»ç»é½ä¾èµäºä¸ä¸ªç¬ç«çåè°æå¡ï¼æ¯å¦ ZooKeeper æ¥è·è¸ªé群å æ°æ®ï¼å¦ [å¾ 6-8](img/fig6-8.png) æ示ãæ¯ä¸ªèç¹å¨ ZooKeeper ä¸æ³¨åèªå·±ï¼ZooKeeper ç»´æ¤ååºå°èç¹çå¯é æ å°ãå ¶ä»åä¸è ï¼å¦è·¯ç±å±æååºæç¥å®¢æ·ç«¯ï¼å¯ä»¥å¨ ZooKeeper ä¸è®¢é æ¤ä¿¡æ¯ãåªè¦ååºåé åçäºæ¹åï¼æè é群ä¸æ·»å æå é¤äºä¸ä¸ªèç¹ï¼ZooKeeper å°±ä¼éç¥è·¯ç±å±ä½¿è·¯ç±ä¿¡æ¯ä¿æææ°ç¶æã ![](img/fig6-8.png) **å¾ 6-8 ä½¿ç¨ ZooKeeper è·è¸ªååºåé ç»èç¹ã** ä¾å¦ï¼LinkedInçEspresso使ç¨Helix ã31ãè¿è¡é群管çï¼ä¾é ZooKeeperï¼ï¼å®ç°äºå¦[å¾6-8](img/fig6-8.png)æ示çè·¯ç±å±ãHBaseãSolrCloudåKafkaä¹ä½¿ç¨ZooKeeperæ¥è·è¸ªååºåé ãMongoDBå ·æ类似çä½ç³»ç»æï¼ä½å®ä¾èµäºèªå·±ç**é ç½®æå¡å¨ï¼config serverï¼** å®ç°åmongoså®æ¤è¿ç¨ä½ä¸ºè·¯ç±å±ã Cassandra å Riak éåä¸åçæ¹æ³ï¼ä»ä»¬å¨èç¹ä¹é´ä½¿ç¨ **æµè¨åè®®ï¼gossip protocolï¼** æ¥ä¼ æé群ç¶æçååã请æ±å¯ä»¥åéå°ä»»æèç¹ï¼è¯¥èç¹ä¼è½¬åå°å å«æ请æ±çååºçéå½èç¹ï¼[å¾ 6-7](img/fig6-7.png) ä¸çæ¹æ³ 1ï¼ãè¿ä¸ªæ¨¡åå¨æ°æ®åºèç¹ä¸å¢å äºæ´å¤çå¤ææ§ï¼ä½æ¯é¿å äºå¯¹å ZooKeeper è¿æ ·çå¤é¨åè°æå¡çä¾èµã Couchbase ä¸ä¼èªå¨è¿è¡å平衡ï¼è¿ç®åäºè®¾è®¡ãé常æ åµä¸ï¼å®é ç½®äºä¸ä¸ªå为 moxi çè·¯ç±å±ï¼å®ä¼ä»é群èç¹äºè§£è·¯ç±ååã32ãã å½ä½¿ç¨è·¯ç±å±æåéæºèç¹åé请æ±æ¶ï¼å®¢æ·ç«¯ä»ç¶éè¦æ¾å°è¦è¿æ¥ç IP å°åãè¿äºå°å并ä¸åååºçèç¹åå¸ååçé£ä¹å¿«ï¼æä»¥ä½¿ç¨ DNS é常就足å¤äºã ### æ§è¡å¹¶è¡æ¥è¯¢ å°ç®å为æ¢ï¼æ们åªå ³æ³¨è¯»åæåå ¥å个é®çé常ç®åçæ¥è¯¢ï¼å ä¸åºäºææ¡£ååºç次级索å¼åºæ¯ä¸çåæ£ / èéæ¥è¯¢ï¼ãè¿ä¹æ¯å¤§å¤æ° NoSQL åå¸å¼æ°æ®åå¨ææ¯æç访é®å±çº§ã ç¶èï¼é常ç¨äºåæç **大è§æ¨¡å¹¶è¡å¤çï¼MPP, Massively parallel processingï¼** å ³ç³»åæ°æ®åºäº§åå¨å ¶æ¯æçæ¥è¯¢ç±»åæ¹é¢è¦å¤æå¾å¤ãä¸ä¸ªå ¸åçæ°æ®ä»åºæ¥è¯¢å å«å¤ä¸ªè¿æ¥ï¼è¿æ»¤ï¼åç»åèåæä½ãMPP æ¥è¯¢ä¼åå¨å°è¿ä¸ªå¤æçæ¥è¯¢å解æ许å¤æ§è¡é¶æ®µåååºï¼å ¶ä¸è®¸å¤å¯ä»¥å¨æ°æ®åºé群çä¸åèç¹ä¸å¹¶è¡æ§è¡ãæ¶åæ«æ大è§æ¨¡æ°æ®éçæ¥è¯¢ç¹å«åçäºè¿ç§å¹¶è¡æ§è¡ã æ°æ®ä»åºæ¥è¯¢çå¿«é并è¡æ§è¡æ¯ä¸ä¸ªä¸é¨çè¯é¢ï¼ç±äºåææå¾éè¦çåä¸æä¹ï¼å¯ä»¥å¸¦æ¥å¾å¤å©çãæ们å°å¨ [第åç« ](ch10.md) 讨论并è¡æ¥è¯¢æ§è¡çä¸äºæå·§ãæå ³å¹¶è¡æ°æ®åºä¸ä½¿ç¨çææ¯çæ´è¯¦ç»çæ¦è¿°ï¼è¯·åé åèæç®ã1,33ãã ## æ¬ç« å°ç» å¨æ¬ç« ä¸ï¼æ们æ¢è®¨äºå°å¤§æ°æ®éååææ´å°çåéçä¸åæ¹æ³ãæ°æ®éé常大çæ¶åï¼å¨åå°æºå¨ä¸åå¨åå¤çä¸åå¯è¡ï¼èååºåååå¿ è¦ãååºçç®æ æ¯å¨å¤å°æºå¨ä¸åååå¸æ°æ®åæ¥è¯¢è´è½½ï¼é¿å åºç°çç¹ï¼è´è½½ä¸ææ¯ä¾çèç¹ï¼ãè¿éè¦éæ©éåäºä½ çæ°æ®çååºæ¹æ¡ï¼å¹¶å¨å°èç¹æ·»å å°é群æä»é群å é¤æ¶éæ°å¹³è¡¡ååºã æ们讨论äºä¸¤ç§ä¸»è¦çååºæ¹æ³ï¼ * é®èå´ååº å ¶ä¸é®æ¯æåºçï¼å¹¶ä¸ååºæ¥æä»æ个æå°å¼å°æ个æ大å¼çææé®ãæåºçä¼å¿å¨äºå¯ä»¥è¿è¡ææçèå´æ¥è¯¢ï¼ä½æ¯å¦æåºç¨ç¨åºç»å¸¸è®¿é®ç¸é»çé®ï¼ååå¨çç¹çé£é©ã å¨è¿ç§æ¹æ³ä¸ï¼å½ååºåå¾å¤ªå¤§æ¶ï¼é常å°ååºåæ两个åååºæ¥å¨æå°éæ°å¹³è¡¡ååºã * æ£åååº æ£åå½æ°åºç¨äºæ¯ä¸ªé®ï¼ååºæ¥æä¸å®èå´çæ£åãè¿ç§æ¹æ³ç ´åäºé®çæåºï¼ä½¿å¾èå´æ¥è¯¢æçä½ä¸ï¼ä½å¯ä»¥æ´ååå°åé è´è½½ã éè¿æ£åè¿è¡ååºæ¶ï¼é常å æåå建åºå®æ°éçååºï¼ä¸ºæ¯ä¸ªèç¹åé å¤ä¸ªååºï¼å¹¶å¨æ·»å æå é¤èç¹æ¶å°æ´ä¸ªååºä»ä¸ä¸ªèç¹ç§»å¨å°å¦ä¸ä¸ªèç¹ãä¹å¯ä»¥ä½¿ç¨å¨æååºã 两ç§æ¹æ³æé 使ç¨ä¹æ¯å¯è¡çï¼ä¾å¦ä½¿ç¨å¤å主é®ï¼ä½¿ç¨é®çä¸é¨åæ¥æ è¯ååºï¼è使ç¨å¦ä¸é¨åä½ä¸ºæåºé¡ºåºã æ们è¿è®¨è®ºäºååºå次级索å¼ä¹é´çç¸äºä½ç¨ã次级索å¼ä¹éè¦ååºï¼æ两ç§æ¹æ³ï¼ * åºäºææ¡£ååºï¼æ¬å°ç´¢å¼ï¼ï¼å ¶ä¸æ¬¡çº§ç´¢å¼åå¨å¨ä¸ä¸»é®åå¼ç¸åçååºä¸ãè¿æå³çåªæä¸ä¸ªååºéè¦å¨åå ¥æ¶æ´æ°ï¼ä½æ¯è¯»å次级索å¼éè¦å¨ææååºä¹é´è¿è¡åæ£ / æ¶éã * åºäºå ³é®è¯ååºï¼å ¨å±ç´¢å¼ï¼ï¼å ¶ä¸æ¬¡çº§ç´¢å¼åå¨ä¸åçååºä¸ã次级索å¼ä¸çæ¡ç®å¯ä»¥å æ¬æ¥èªä¸»é®çææååºçè®°å½ãå½ææ¡£åå ¥æ¶ï¼éè¦æ´æ°å¤ä¸ªååºä¸ç次级索å¼ï¼ä½æ¯å¯ä»¥ä»å个ååºä¸è¿è¡è¯»åã æåï¼æ们讨论äºå°æ¥è¯¢è·¯ç±å°éå½çååºçææ¯ï¼ä»ç®åçååºè´è½½å¹³è¡¡å°å¤æç并è¡æ¥è¯¢æ§è¡å¼æã æç §è®¾è®¡ï¼å¤æ°æ åµä¸æ¯ä¸ªååºæ¯ç¬ç«è¿è¡ç â è¿å°±æ¯ååºæ°æ®åºå¯ä»¥ä¼¸ç¼©å°å¤å°æºå¨çåå ãä½æ¯ï¼éè¦åå ¥å¤ä¸ªååºçæä½ç»æå¯è½é¾ä»¥é¢æï¼ä¾å¦ï¼å¦æåå ¥ä¸ä¸ªååºæåï¼ä½å¦ä¸ä¸ªååºå¤±è´¥ï¼ä¼åçä»ä¹æ åµï¼æ们å°å¨ä¸é¢çç« èä¸è®¨è®ºè¿ä¸ªé®é¢ã ## åèæç® 1. David J. DeWitt and Jim N. Gray: â[Parallel Database Systems: The Future of High Performance Database Systems](),â *Communications of the ACM*, volume 35, number 6, pages 85â98, June 1992. [doi:10.1145/129888.129894](http://dx.doi.org/10.1145/129888.129894) 1. Lars George: â[HBase vs. BigTable Comparison](http://www.larsgeorge.com/2009/11/hbase-vs-bigtable-comparison.html),â *larsgeorge.com*, November 2009. 1. â[The Apache HBase Reference Guide](https://hbase.apache.org/book/book.html),â Apache Software Foundation, *hbase.apache.org*, 2014. 1. MongoDB, Inc.: â[New Hash-Based Sharding Feature in MongoDB 2.4](http://blog.mongodb.org/post/47633823714/new-hash-based-sharding-feature-in-mongodb-24),â *blog.mongodb.org*, April 10, 2013. 1. Ikai Lan: â[App Engine Datastore Tip: Monotonically Increasing Values Are Bad](http://ikaisays.com/2011/01/25/app-engine-datastore-tip-monotonically-increasing-values-are-bad/),â *ikaisays.com*, January 25, 2011. 1. Martin Kleppmann: â[Java's hashCode Is Not Safe for Distributed Systems](http://martin.kleppmann.com/2012/06/18/java-hashcode-unsafe-for-distributed-systems.html),â *martin.kleppmann.com*, June 18, 2012. 1. David Karger, Eric Lehman, Tom Leighton, et al.: â[Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web](http://www.akamai.com/dl/technical_publications/ConsistenHashingandRandomTreesDistributedCachingprotocolsforrelievingHotSpotsontheworldwideweb.pdf),â at *29th Annual ACM Symposium on Theory of Computing* (STOC), pages 654â663, 1997. [doi:10.1145/258533.258660](http://dx.doi.org/10.1145/258533.258660) 1. John Lamping and Eric Veach: â[A Fast, Minimal Memory, Consistent Hash Algorithm](http://arxiv.org/pdf/1406.2294v1.pdf),â *arxiv.org*, June 2014. 1. Eric Redmond: â[A Little Riak Book](http://littleriakbook.com/),â Version 1.4.0, Basho Technologies, September 2013. 1. â[Couchbase 2.5 Administrator Guide](http://docs.couchbase.com/couchbase-manual-2.5/cb-admin/),â Couchbase, Inc., 2014. 1. Avinash Lakshman and Prashant Malik: â[Cassandra â A Decentralized Structured Storage System](http://www.cs.cornell.edu/Projects/ladis2009/papers/Lakshman-ladis2009.PDF),â at *3rd ACM SIGOPS International Workshop on Large Scale Distributed Systems and Middleware* (LADIS), October 2009. 1. Jonathan Ellis: â[Facebookâs Cassandra Paper, Annotated and Compared to Apache Cassandra 2.0](http://www.datastax.com/documentation/articles/cassandra/cassandrathenandnow.html),â *datastax.com*, September 12, 2013. 1. â[Introduction to Cassandra Query Language](http://www.datastax.com/documentation/cql/3.1/cql/cql_intro_c.html),â DataStax, Inc., 2014. 1. Samuel Axon: â[3% of Twitter's Servers Dedicated to Justin Bieber](http://mashable.com/2010/09/07/justin-bieber-twitter/),â *mashable.com*, September 7, 2010. 1. â[Riak 1.4.8 Docs](http://docs.basho.com/riak/1.4.8/),â Basho Technologies, Inc., 2014. 1. Richard Low: â[The Sweet Spot for Cassandra Secondary Indexing](http://www.wentnet.com/blog/?p=77),â *wentnet.com*, October 21, 2013. 1. Zachary Tong: â[Customizing Your Document Routing](http://www.elasticsearch.org/blog/customizing-your-document-routing/),â *elasticsearch.org*, June 3, 2013. 1. â[Apache Solr Reference Guide](https://cwiki.apache.org/confluence/display/solr/Apache+Solr+Reference+Guide),â Apache Software Foundation, 2014. 1. Andrew Pavlo: â[H-Store Frequently Asked Questions](http://hstore.cs.brown.edu/documentation/faq/),â *hstore.cs.brown.edu*, October 2013. 1. â[Amazon DynamoDB Developer Guide](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/),â Amazon Web Services, Inc., 2014. 1. Rusty Klophaus: â[Difference Between 2I and Search](http://lists.basho.com/pipermail/riak-users_lists.basho.com/2011-October/006220.html),â email to *riak-users* mailing list, *lists.basho.com*, October 25, 2011. 1. Donald K. Burleson: â[Object Partitioning in Oracle](http://www.dba-oracle.com/art_partit.htm),â*dba-oracle.com*, November 8, 2000. 1. Eric Evans: â[Rethinking Topology in Cassandra](http://www.slideshare.net/jericevans/virtual-nodes-rethinking-topology-in-cassandra),â at *ApacheCon Europe*, November 2012. 1. RafaÅ KuÄ: â[Reroute API Explained](http://elasticsearchserverbook.com/reroute-api-explained/),â *elasticsearchserverbook.com*, September 30, 2013. 1. â[Project Voldemort Documentation](http://www.project-voldemort.com/voldemort/),â *project-voldemort.com*. 1. Enis Soztutar: â[Apache HBase Region Splitting and Merging](http://hortonworks.com/blog/apache-hbase-region-splitting-and-merging/),â *hortonworks.com*, February 1, 2013. 1. Brandon Williams: â[Virtual Nodes in Cassandra 1.2](http://www.datastax.com/dev/blog/virtual-nodes-in-cassandra-1-2),â *datastax.com*, December 4, 2012. 1. Richard Jones: â[libketama: Consistent Hashing Library for Memcached Clients](https://www.metabrew.com/article/libketama-consistent-hashing-algo-memcached-clients),â *metabrew.com*, April 10, 2007. 1. Branimir Lambov: â[New Token Allocation Algorithm in Cassandra 3.0](http://www.datastax.com/dev/blog/token-allocation-algorithm),â *datastax.com*, January 28, 2016. 1. Jason Wilder: â[Open-Source Service Discovery](http://jasonwilder.com/blog/2014/02/04/service-discovery-in-the-cloud/),â *jasonwilder.com*, February 2014. 1. Kishore Gopalakrishna, Shi Lu, Zhen Zhang, et al.: â[Untangling Cluster Management with Helix](http://www.socc2012.org/helix_onecol.pdf?attredirects=0),â at *ACM Symposium on Cloud Computing* (SoCC), October 2012. [doi:10.1145/2391229.2391248](http://dx.doi.org/10.1145/2391229.2391248) 1. â[Moxi 1.8 Manual](http://docs.couchbase.com/moxi-manual-1.8/),â Couchbase, Inc., 2014. 1. Shivnath Babu and Herodotos Herodotou: â[Massively Parallel Databases and MapReduce Systems](http://research.microsoft.com/pubs/206464/db-mr-survey-final.pdf),â *Foundations and Trends in Databases*, volume 5, number 1, pages 1â104, November 2013.[doi:10.1561/1900000036](http://dx.doi.org/10.1561/1900000036) ------ | ä¸ä¸ç« | ç®å½ | ä¸ä¸ç« | | :--------------------: | :-----------------------------: | :--------------------: | | [第äºç« ï¼å¤å¶](ch5.md) | [设计æ°æ®å¯éååºç¨](README.md) | [第ä¸ç« ï¼äºå¡](ch7.md) |