# 第å
«ç« ï¼åå¸å¼ç³»ç»ç麻ç¦
![](img/ch8.png)
> éé
ç¸é
>
> ç½ç»å»¶è¿
>
> åä¹ä¸ºå¾
>
> æ é£ææ°
>
> ââ Kyle Kingsbury, Carly Rae Jepsen ãç½ç»ååºçå±å®³ãï¼2013 å¹´ï¼[^è¯è1]
---------
[TOC]
æè¿å ç« ä¸åå¤åºç°ç主é¢æ¯ï¼ç³»ç»å¦ä½å¤çé误çäºæ
ãä¾å¦ï¼æä»¬è®¨è®ºäº **å¯æ¬æ
éåæ¢**ï¼â[å¤çèç¹ä¸æ](ch5.md#å¤çèç¹å®æº)âï¼ï¼**å¤å¶å»¶è¿**ï¼â[å¤å¶å»¶è¿é®é¢](ch5.md#å¤å¶å»¶è¿é®é¢)âï¼åäºå¡æ§å¶ï¼â[å¼±é离级å«](ch7.md#å¼±é离级å«)âï¼ãå½æ们äºè§£å¯è½å¨å®é
ç³»ç»ä¸åºç°çåç§è¾¹ç¼æ
åµæ¶ï¼æ们ä¼æ´å¥½å°å¤çå®ä»¬ã
ä½æ¯ï¼å°½ç®¡æ们已ç»è°äºå¾å¤é误ï¼ä½ä¹åå ç« ä»ç¶è¿äºä¹è§ãç°å®æ´å é»æãæ们ç°å¨å°æ²è§ä¸»ä¹æ大åï¼å设任ä½å¯è½åºéçä¸è¥¿ **é½ä¼** åºé [^i]ãï¼ç»éªä¸°å¯çç³»ç»è¿ç»´ä¼åè¯ä½ ï¼è¿æ¯ä¸ä¸ªåççå设ãå¦æä½ é®å¾å¥½ï¼ä»ä»¬å¯è½ä¼ä¸è¾¹æ²»çå¿çå伤ä¸è¾¹åè¯ä½ ä¸äºå¯æçæ
äºï¼
[^i]: é¤äºä¸ä¸ªä¾å¤ï¼æ们å°åå®æ
éæ¯éæå åºå¼çï¼è¯·åé
â[æå åºæ
é](#æå åºæ
é)âï¼ã
使ç¨åå¸å¼ç³»ç»ä¸å¨ä¸å°è®¡ç®æºä¸ç¼å软件æçæ ¹æ¬çåºå«ï¼ä¸»è¦çåºå«å¨äºï¼æ许å¤æ°é¢ååºæ¿çæ¹æ³å¯ä»¥ä½¿äºæ
åºéã1,2ããå¨è¿ä¸ç« ä¸ï¼æ们å°äºè§£å®è·µä¸åºç°çé®é¢ï¼ç解æ们è½å¤ä¾èµï¼åä¸å¯ä»¥ä¾èµçä¸è¥¿ã
æåï¼ä½ä¸ºå·¥ç¨å¸ï¼æ们çä»»å¡æ¯æ建è½å¤å®æå·¥ä½çç³»ç»ï¼å³æ»¡è¶³ç¨æ·ææçä¿è¯ï¼ï¼å°½ç®¡ä¸åé½åºéäºãå¨ [第ä¹ç« ](ch9.md) ä¸ï¼æ们å°ççä¸äºå¯ä»¥å¨åå¸å¼ç³»ç»ä¸æä¾è¿ç§ä¿è¯çç®æ³çä¾åãä½é¦å
ï¼å¨æ¬ç« ä¸ï¼æ们å¿
é¡»äºè§£æ们é¢ä¸´çææã
æ¬ç« 对åå¸å¼ç³»ç»ä¸å¯è½åºç°çé®é¢è¿è¡å½»åºçæ²è§å沮丧çæ»ç»ãæ们å°ç 究ç½ç»çé®é¢ï¼â[ä¸å¯é çç½ç»](#ä¸å¯é çç½ç»)âï¼; æ¶éåæ¶åºé®é¢ï¼â[ä¸å¯é çæ¶é](#ä¸å¯é çæ¶é)âï¼; æ们å°è®¨è®ºä»ä»¬å¯ä»¥é¿å
çç¨åº¦ãææè¿äºé®é¢çåæé½æ¯å°æçï¼æ以æ们å°æ¢ç´¢å¦ä½æèä¸ä¸ªåå¸å¼ç³»ç»çç¶æï¼ä»¥åå¦ä½æ¨çåççäºæ
ï¼â[ç¥è¯ãçç¸ä¸è°è¨](#ç¥è¯ãçç¸ä¸è°è¨)âï¼ã
## æ
éä¸é¨å失æ
å½ä½ å¨ä¸å°è®¡ç®æºä¸ç¼åä¸ä¸ªç¨åºæ¶ï¼å®é常ä¼ä»¥ä¸ç§ç¸å½å¯é¢æµçæ¹å¼è¿è¡ï¼æ 论æ¯å·¥ä½è¿æ¯ä¸å·¥ä½ãå
满é误ç软件å¯è½ä¼è®©äººè§å¾çµèææ¶åä¹ä¼æ âç³ç³çä¸å¤©âï¼è¿ç§é®é¢é常æ¯éæ°å¯å¨å°±æ¢å¤äºï¼ï¼ä½è¿ä¸»è¦æ¯è½¯ä»¶åå¾ä¸å¥½çç»æã
å个计ç®æºä¸ç软件没ææ ¹æ¬æ§çä¸å¯é åå ï¼å½ç¡¬ä»¶æ£å¸¸å·¥ä½æ¶ï¼ç¸åçæä½æ»æ¯äº§çç¸åçç»æï¼è¿æ¯ç¡®å®æ§çï¼ãå¦æåå¨ç¡¬ä»¶é®é¢ï¼ä¾å¦ï¼å
åæåæè¿æ¥å¨æ¾å¨ï¼ï¼å
¶åæé常æ¯æ´ä¸ªç³»ç»æ
éï¼ä¾å¦ï¼å
æ ¸ææ
ï¼âèå±æ»æºâï¼å¯å¨å¤±è´¥ï¼ãè£
æè¯å¥½è½¯ä»¶ç个人计ç®æºé常è¦ä¹åè½å®å¥½ï¼è¦ä¹å®å
¨å¤±æï¼èä¸æ¯ä»äºä¸¤è
ä¹é´ã
è¿æ¯è®¡ç®æºè®¾è®¡ä¸çä¸ä¸ªææçéæ©ï¼å¦æåçå
é¨é误ï¼æ们å®æ¿çµèå®å
¨å´©æºï¼èä¸æ¯è¿åé误çç»æï¼å 为é误çç»æå¾é¾å¤çãå 为计ç®æºéèäºæ¨¡ç³ä¸æ¸
çç©çå®ç°ï¼å¹¶åç°åºä¸ä¸ªçæ³åçç³»ç»æ¨¡åï¼å¹¶ä»¥æ°å¦ä¸æ ·çå®ç¾çæ¹å¼è¿ä½ãCPU æ令æ»æ¯ååæ ·çäºæ
ï¼å¦æä½ å°ä¸äºæ°æ®åå
¥å
åæç£çï¼é£ä¹è¿äºæ°æ®å°ä¿æä¸åï¼å¹¶ä¸ä¸ä¼è¢«éæºç ´åãä»ç¬¬ä¸å°æ°å计ç®æºå¼å§ï¼*å§ç»æ£ç¡®å°è®¡ç®* è¿ä¸ªè®¾è®¡ç®æ 贯穿å§ç»ã3ãã
å½ä½ ç¼åè¿è¡å¨å¤å°è®¡ç®æºä¸ç软件æ¶ï¼æ
åµææ¬è´¨ä¸çåºå«ãå¨åå¸å¼ç³»ç»ä¸ï¼æ们ä¸åå¤äºçæ³åçç³»ç»æ¨¡åä¸ï¼æ们å«æ éæ©ï¼åªè½é¢å¯¹ç°å®ä¸ççæ··ä¹±ç°å®ãèå¨ç°å®ä¸çä¸ï¼åç§åæ ·çäºæ
é½å¯è½ä¼åºç°é®é¢ã4ãï¼å¦ä¸é¢ç轶äºæè¿°ï¼
> å¨ææéçä»ä¸ç»åä¸ï¼æå·²ç»åå¾å¤ä¸è¥¿æè¿äº¤éï¼å个 **æ°æ®ä¸å¿ï¼DCï¼** ä¸é¿æåå¨çç½ç»ååºï¼é
çµåå
PDU æ
éï¼äº¤æ¢æºæ
éï¼æ´ä¸ªæºæ¶çæå¤éå¯ï¼æ´ä¸ªæ°æ®ä¸å¿ä¸»å¹²ç½ç»æ
éï¼æ´ä¸ªæ°æ®ä¸å¿ççµæºæ
éï¼ä»¥åä¸ä¸ªä½è¡ç³çå¸æºæä»çç¦ç¹ç®å¡æå¨æ°æ®ä¸å¿ç HVACï¼å çï¼éé£å空è°ï¼ç³»ç»ä¸ãèä¸æçè³ä¸æ¯ä¸ä¸ªè¿ç»´ã
>
> ââ æ¯è¾¾é»å°
å¨åå¸å¼ç³»ç»ä¸ï¼å°½ç®¡ç³»ç»çå
¶ä»é¨åå·¥ä½æ£å¸¸ï¼ä½ç³»ç»çæäºé¨åå¯è½ä¼ä»¥æç§ä¸å¯é¢ç¥çæ¹å¼è¢«ç ´åãè¿è¢«ç§°ä¸º **é¨å失æï¼partial failureï¼**ãé¾ç¹å¨äºé¨å失ææ¯ **ä¸ç¡®å®æ§çï¼nondeterministicï¼**ï¼å¦æä½ è¯å¾åä»»ä½æ¶åå¤ä¸ªèç¹åç½ç»çäºæ
ï¼å®ææ¶å¯è½ä¼å·¥ä½ï¼ææ¶ä¼åºç°ä¸å¯é¢ç¥ç失败ãæ£å¦æ们å°è¦çå°çï¼ä½ çè³ä¸ç¥éæ¯å¦æåäºï¼å 为æ¶æ¯éè¿ç½ç»ä¼ æçæ¶é´ä¹æ¯ä¸ç¡®å®çï¼
è¿ç§ä¸ç¡®å®æ§åé¨å失æçå¯è½æ§ï¼ä½¿å¾åå¸å¼ç³»ç»é¾ä»¥å·¥ä½ã5ãã
### äºè®¡ç®ä¸è¶
级计ç®æº
å
³äºå¦ä½æ建大å计ç®ç³»ç»æä¸ç³»åçå²å¦ï¼
* ä¸ä¸ªæ端æ¯é«æ§è½è®¡ç®ï¼HPCï¼é¢åãå
·ææ°å个 CPU çè¶
级计ç®æºé常ç¨äºè®¡ç®å¯éåç§å¦è®¡ç®ä»»å¡ï¼å¦å¤©æ°é¢æ¥æååå¨åå¦ï¼æ¨¡æåååååçè¿å¨ï¼ã
* å¦ä¸ä¸ªæç«¯æ¯ **äºè®¡ç®ï¼cloud computingï¼**ï¼äºè®¡ç®å¹¶ä¸æ¯ä¸ä¸ªè¯å¥½å®ä¹çæ¦å¿µã6ãï¼ä½é常ä¸å¤ç§æ·æ°æ®ä¸å¿ï¼è¿æ¥ IP ç½ç»ï¼é常æ¯ä»¥å¤ªç½ï¼çåç¨è®¡ç®æºï¼å¼¹æ§ / æéèµæºåé
以å计é计费çç¸å
³èã
* ä¼ ç»ä¼ä¸æ°æ®ä¸å¿ä½äºè¿ä¸¤ä¸ªæ端ä¹é´ã
ä¸åçå²å¦ä¼å¯¼è´ä¸åçæ
éå¤çæ¹å¼ãå¨è¶
级计ç®æºä¸ï¼ä½ä¸é常ä¼ä¸æ¶å°å°è®¡ç®çç¶æåçå°æä¹
åå¨ä¸ãå¦æä¸ä¸ªèç¹åºç°æ
éï¼é常ç解å³æ¹æ¡æ¯ç®åå°åæ¢æ´ä¸ªé群çå·¥ä½è´è½½ãæ
éèç¹ä¿®å¤åï¼è®¡ç®ä»ä¸ä¸ä¸ªæ£æ¥ç¹éæ°å¼å§ã7,8ããå æ¤ï¼è¶
级计ç®æºæ´åæ¯ä¸ä¸ªåèç¹è®¡ç®æºèä¸æ¯åå¸å¼ç³»ç»ï¼éè¿è®©é¨å失败å级为å®å
¨å¤±è´¥æ¥å¤çé¨å失败 ââ å¦æç³»ç»çä»»ä½é¨ååçæ
éï¼åªæ¯è®©ææçä¸è¥¿é½å´©æºï¼å°±ååå°æºå¨ä¸çå
æ ¸ææ
ä¸æ ·ï¼ã
å¨æ¬ä¹¦ä¸ï¼æ们å°éç¹æ¾å¨å®ç°äºèç½æå¡çç³»ç»ä¸ï¼è¿äºç³»ç»é常ä¸è¶
级计ç®æºçèµ·æ¥æå¾å¤§ä¸åï¼
* 许å¤ä¸äºèç½æå
³çåºç¨ç¨åºé½æ¯ **å¨çº¿ï¼onlineï¼** çï¼å 为å®ä»¬éè¦è½å¤éæ¶ä»¥ä½å»¶è¿æå¡ç¨æ·ã使æå¡ä¸å¯ç¨ï¼ä¾å¦ï¼åæ¢é群以è¿è¡ä¿®å¤ï¼æ¯ä¸å¯æ¥åçãç¸æ¯ä¹ä¸ï¼å天æ°æ¨¡æè¿æ ·ç离线ï¼æ¹å¤çï¼å·¥ä½å¯ä»¥åæ¢å¹¶éæ°å¯å¨ï¼å½±åç¸å½å°ã
* è¶
级计ç®æºé常ç±ä¸ç¨ç¡¬ä»¶æ建èæï¼æ¯ä¸ªèç¹ç¸å½å¯é ï¼èç¹éè¿å
±äº«å
åå **è¿ç¨ç´æ¥å
å访é®ï¼RDMAï¼** è¿è¡éä¿¡ãå¦ä¸æ¹é¢ï¼äºæå¡ä¸çèç¹æ¯ç±åç¨æºå¨æ建èæçï¼ç±äºè§æ¨¡ç»æµï¼å¯ä»¥ä»¥è¾ä½çææ¬æä¾ç¸åçæ§è½ï¼èä¸å
·æè¾é«çæ
éçã
* 大åæ°æ®ä¸å¿ç½ç»é常åºäº IP å以太ç½ï¼ä»¥ CLOS æææåï¼ä»¥æä¾æ´é«ç对åï¼bisectionï¼å¸¦å®½ã9ããè¶
级计ç®æºé常使ç¨ä¸é¨çç½ç»ææç»æï¼ä¾å¦å¤ç»´ç½æ ¼å Torus ç½ç» ã10ãï¼è¿ä¸ºå
·æå·²ç¥é信模å¼ç HPC å·¥ä½è´è½½æä¾äºæ´å¥½çæ§è½ã
* ç³»ç»è¶å¤§ï¼å
¶ç»ä»¶ä¹ä¸å°±è¶æå¯è½åæãéçæ¶é´çæ¨ç§»ï¼åæçä¸è¥¿å¾å°ä¿®å¤ï¼æ°çä¸è¥¿ååæï¼ä½æ¯å¨ä¸ä¸ªææåä¸ä¸ä¸ªèç¹çç³»ç»ä¸ï¼æçç±è®¤ä¸ºæ»æ¯æä¸äºä¸è¥¿æ¯åæçã7ããå½é误å¤çççç¥åªç±ç®åæ¾å¼ç»ææ¶ï¼ä¸ä¸ªå¤§çç³»ç»æç»ä¼è±è´¹å¤§éæ¶é´ä»é误ä¸æ¢å¤ï¼èä¸æ¯åæç¨çå·¥ä½ã8ãã
* å¦æç³»ç»å¯ä»¥å®¹å¿åçæ
éçèç¹ï¼å¹¶ç»§ç»ä¿ææ´ä½å·¥ä½ç¶æï¼é£ä¹è¿å¯¹äºè¿è¥åç»´æ¤é常æç¨ï¼ä¾å¦ï¼å¯ä»¥æ§è¡æ»å¨å级ï¼è¯·åé
[第åç« ](ch4.md)ï¼ï¼ä¸æ¬¡éæ°å¯å¨ä¸ä¸ªèç¹ï¼åæ¶ç»§ç»ç»ç¨æ·æä¾ä¸ä¸æçæå¡ãå¨äºç¯å¢ä¸ï¼å¦æä¸å°èææºè¿è¡ä¸ä½³ï¼å¯ä»¥ææ»å®å¹¶è¯·æ±ä¸å°æ°çèææºï¼å¸ææ°çèææºé度æ´å¿«ï¼ã
* å¨å°çä½ç½®åæ£çé¨ç½²ä¸ï¼ä¿ææ°æ®å¨å°çä½ç½®ä¸æ¥è¿ç¨æ·ä»¥åå°è®¿é®å»¶è¿ï¼ï¼éä¿¡å¾å¯è½éè¿äºèç½è¿è¡ï¼ä¸æ¬å°ç½ç»ç¸æ¯ï¼éä¿¡é度ç¼æ
¢ä¸ä¸å¯é ãè¶
级计ç®æºé常å设å®ä»¬çææèç¹é½é è¿å¨ä¸èµ·ã
å¦æè¦ä½¿åå¸å¼ç³»ç»å·¥ä½ï¼å°±å¿
é¡»æ¥åé¨åæ
éçå¯è½æ§ï¼å¹¶å¨è½¯ä»¶ä¸å»ºç«å®¹éæºå¶ãæ¢å¥è¯è¯´ï¼æ们éè¦ä»ä¸å¯é çç»ä»¶æ建ä¸ä¸ªå¯é çç³»ç»ï¼æ£å¦ â[å¯é æ§](ch1.md#å¯é æ§)â ä¸æ讨论çé£æ ·ï¼æ²¡æå®ç¾çå¯é æ§ï¼æ以æ们éè¦ç解æ们å¯ä»¥å®é
æ¿è¯ºçæéï¼ã
å³ä½¿å¨åªæå°æ°èç¹çå°åç³»ç»ä¸ï¼èèé¨åæ
éä¹æ¯å¾éè¦çãå¨ä¸ä¸ªå°ç³»ç»ä¸ï¼å¾å¯è½å¤§é¨åç»ä»¶å¨å¤§é¨åæ¶é´é½æ£å¸¸å·¥ä½ãç¶èï¼è¿æ©ä¼æä¸é¨åç³»ç»åºç°æ
éï¼è½¯ä»¶å¿
须以æç§æ¹å¼å¤çãæ
éå¤çå¿
é¡»æ¯è½¯ä»¶è®¾è®¡çä¸é¨åï¼å¹¶ä¸ä½ä¸ºè½¯ä»¶çè¿ç»´ï¼ä½ éè¦ç¥éå¨åçæ
éçæ
åµä¸ï¼è½¯ä»¶å¯è½ä¼è¡¨ç°åºææ ·çè¡ä¸ºã
ç®åå°å设缺é·å¾ç½è§å¹¶å¸æå§ç»ä¿ææ好çç¶åµæ¯ä¸ææºçãèèä¸ç³»åå¯è½çé误ï¼çè³æ¯ä¸å¤ªå¯è½çé误ï¼ï¼å¹¶å¨æµè¯ç¯å¢ä¸äººä¸ºå°å建è¿äºæ
åµæ¥æ¥çä¼åçä»ä¹æ¯é常éè¦çãå¨åå¸å¼ç³»ç»ä¸ï¼æçï¼æ²è§ååæ§çæ¯å¼å¾çã
> #### ä»ä¸å¯é çç»ä»¶æ建å¯é çç³»ç»
>
> ä½ å¯è½æ³ç¥éè¿æ¯å¦ææä¹ ââ ç´è§å°çæ¥ï¼ç³»ç»åªè½åå
¶æä¸å¯é çç»ä»¶ï¼æèå¼±çç¯èï¼ä¸æ ·å¯é ãäºå®å¹¶éå¦æ¤ï¼äºå®ä¸ï¼ä»ä¸å¤ªå¯é çæ½å¨åºç¡æ建æ´å¯é çç³»ç»æ¯è®¡ç®æºé¢åçä¸ä¸ªå¤èææ³ã11ããä¾å¦ï¼
>
> * çº éç å
许æ°åæ°æ®å¨éä¿¡ä¿¡éä¸åç¡®ä¼ è¾ï¼å¶å°ä¼åºç°ä¸äºé误ï¼ä¾å¦ç±äºæ 线ç½ç»ä¸çæ 线çµå¹²æ°ã12ãã
> * **äºèç½åè®®ï¼Internet Protocol, IPï¼** ä¸å¯é ï¼å¯è½ä¸¢å¼ã延è¿ãéå¤æéææ°æ®å
ãä¼ è¾æ§å¶åè®®ï¼Transmission Control Protocol, TCPï¼å¨äºèç½åè®®ï¼IPï¼ä¹ä¸æä¾äºæ´å¯é çä¼ è¾å±ï¼å®ç¡®ä¿ä¸¢å¤±çæ°æ®å
被éæ°ä¼ è¾ï¼æ¶é¤éå¤ï¼å¹¶ä¸æ°æ®å
被éæ°ç»è£
æå®ä»¬è¢«åéç顺åºã
>
> è½ç¶è¿ä¸ªç³»ç»å¯ä»¥æ¯å®çåºå±é¨åæ´å¯é ï¼ä½å®çå¯é æ§æ»æ¯æéçãä¾å¦ï¼çº éç å¯ä»¥å¤çå°éçåæ¯ç¹é误ï¼ä½æ¯å¦æä½ çä¿¡å·è¢«å¹²æ°æ淹没ï¼é£ä¹éè¿ä¿¡éå¯ä»¥å¾å°å¤å°æ°æ®ï¼æ¯ææ ¹æ¬æ§çéå¶çã13ããTCP å¯ä»¥éèæ°æ®å
ç丢失ï¼éå¤åéæ°æåºï¼ä½æ¯å®ä¸è½ç¥å¥å°æ¶é¤ç½ç»ä¸ç延è¿ã
>
> è½ç¶æ´å¯é çé«çº§ç³»ç»å¹¶ä¸å®ç¾ï¼ä½å®ä»ç¶æç¨ï¼å 为å®å¤çäºä¸äºæ£æçä½çº§é误ï¼æ以å
¶ä½çé误é常æ´å®¹ææ¨çåå¤çãæ们å°å¨ â[æ°æ®åºç端å°ç«¯åå](ch12.md#æ°æ®åºç端å°ç«¯åå)â ä¸è¿ä¸æ¥æ¢è®¨è¿ä¸ªé®é¢ã
## ä¸å¯é çç½ç»
æ£å¦å¨ [第äºé¨å](part-ii.md) çä»ç»ä¸æ讨论çé£æ ·ï¼æ们å¨æ¬ä¹¦ä¸å
³æ³¨çåå¸å¼ç³»ç»æ¯æ å
±äº«çç³»ç»ï¼å³éè¿ç½ç»è¿æ¥çä¸å æºå¨ãç½ç»æ¯è¿äºæºå¨å¯ä»¥éä¿¡çå¯ä¸éå¾ ââ æ们å设æ¯å°æºå¨é½æèªå·±çå
ååç£çï¼ä¸å°æºå¨ä¸è½è®¿é®å¦ä¸å°æºå¨çå
åæç£çï¼é¤äºéè¿ç½ç»åæå¡å¨ååºè¯·æ±ï¼ã
**æ å
±äº«** 并ä¸æ¯æ建系ç»çå¯ä¸æ¹å¼ï¼ä½å®å·²ç»æ为æ建äºèç½æå¡ç主è¦æ¹å¼ï¼å
¶åå å¦ä¸ï¼ç¸å¯¹ä¾¿å®ï¼å 为å®ä¸éè¦ç¹æ®ç硬件ï¼å¯ä»¥å©ç¨åååçäºè®¡ç®æå¡ï¼éè¿è·¨å¤ä¸ªå°çåå¸çæ°æ®ä¸å¿è¿è¡åä½å¯ä»¥å®ç°é«å¯é æ§ã
äºèç½åæ°æ®ä¸å¿ï¼é常æ¯ä»¥å¤ªç½ï¼ä¸ç大å¤æ°å
é¨ç½ç»é½æ¯ **å¼æ¥åç»ç½ç»ï¼asynchronous packet networksï¼**ãå¨è¿ç§ç½ç»ä¸ï¼ä¸ä¸ªèç¹å¯ä»¥åå¦ä¸ä¸ªèç¹åéä¸ä¸ªæ¶æ¯ï¼ä¸ä¸ªæ°æ®å
ï¼ï¼ä½æ¯ç½ç»ä¸è½ä¿è¯å®ä»ä¹æ¶åå°è¾¾ï¼æè
æ¯å¦å°è¾¾ãå¦æä½ åé请æ±å¹¶æå¾
ååºï¼åå¾å¤äºæ
å¯è½ä¼åºéï¼å
¶ä¸ä¸äºå¦ [å¾ 8-1](img/fig8-1.png) æ示ï¼ï¼
1. 请æ±å¯è½å·²ç»ä¸¢å¤±ï¼å¯è½æ人ææäºç½çº¿ï¼ã
2. 请æ±å¯è½æ£å¨æéï¼ç¨åå°äº¤ä»ï¼ä¹è®¸ç½ç»ææ¥æ¶æ¹è¿è½½ï¼ã
3. è¿ç¨èç¹å¯è½å·²ç»å¤±æï¼å¯è½æ¯å´©æºæå
³æºï¼ã
4. è¿ç¨èç¹å¯è½ææ¶åæ¢äºååºï¼å¯è½ä¼éå°é¿æ¶é´çåå¾åæ¶æåï¼è¯·åé
â[è¿ç¨æå](#è¿ç¨æå)âï¼ï¼ä½ç¨åä¼å次ååºã
5. è¿ç¨èç¹å¯è½å·²ç»å¤çäºè¯·æ±ï¼ä½æ¯ç½ç»ä¸çååºå·²ç»ä¸¢å¤±ï¼å¯è½æ¯ç½ç»äº¤æ¢æºé
ç½®é误ï¼ã
6. è¿ç¨èç¹å¯è½å·²ç»å¤çäºè¯·æ±ï¼ä½æ¯ååºå·²ç»è¢«å»¶è¿ï¼å¹¶ä¸ç¨åå°è¢«ä¼ éï¼å¯è½æ¯ç½ç»æè
ä½ èªå·±çæºå¨è¿è½½ï¼ã
![](img/fig8-1.png)
**å¾ 8-1 å¦æåé请æ±å¹¶æ²¡æå¾å°ååºï¼åæ æ³åºåï¼aï¼è¯·æ±æ¯å¦ä¸¢å¤±ï¼ï¼bï¼è¿ç¨èç¹æ¯å¦å
³éï¼æï¼cï¼ååºæ¯å¦ä¸¢å¤±ã**
åéè
çè³ä¸è½å辨æ°æ®å
æ¯å¦è¢«åéï¼å¯ä¸çéæ©æ¯è®©æ¥æ¶è
åéååºæ¶æ¯ï¼è¿å¯è½ä¼ä¸¢å¤±æ延è¿ãè¿äºé®é¢å¨å¼æ¥ç½ç»ä¸é¾ä»¥åºåï¼ä½ ææ¥æçå¯ä¸ä¿¡æ¯æ¯ï¼ä½ å°æªæ¶å°ååºãå¦æä½ åå¦ä¸ä¸ªèç¹åé请æ±å¹¶ä¸æ²¡ææ¶å°ååºï¼åä¸å¯è½å¤ææ¯ä»ä¹åå ã
å¤çè¿ä¸ªé®é¢çé常æ¹æ³æ¯ **è¶
æ¶ï¼Timeoutï¼**ï¼å¨ä¸æ®µæ¶é´ä¹åæ¾å¼çå¾
ï¼å¹¶ä¸è®¤ä¸ºååºä¸ä¼å°è¾¾ãä½æ¯ï¼å½åçè¶
æ¶æ¶ï¼ä½ ä»ç¶ä¸ç¥éè¿ç¨èç¹æ¯å¦æ¶å°äºè¯·æ±ï¼å¦æ请æ±ä»ç¶å¨æ个å°æ¹æéï¼é£ä¹å³ä½¿åéè
å·²ç»æ¾å¼äºè¯¥è¯·æ±ï¼ä»ç¶å¯è½ä¼å°å
¶åéç»æ¥æ¶è
ï¼ã
### çå®ä¸ççç½ç»æ
é
æ们å åå¹´æ¥ä¸ç´å¨å»ºè®¾è®¡ç®æºç½ç» ââ æ人å¯è½å¸æç°å¨æ们已ç»æ¾åºäºä½¿ç½ç»åå¾å¯é çæ¹æ³ãä½æ¯ç°å¨ä¼¼ä¹è¿æ²¡ææåã
æä¸äºç³»ç»çç 究å大éç轶äºè¯æ®è¡¨æï¼å³ä½¿å¨åä¸å®¶å
¬å¸è¿è¥çæ°æ®ä¸å¿é£æ ·çåæ§ç¯å¢ä¸ï¼ç½ç»é®é¢ä¹å¯è½åºä¹ææå°æ®éãå¨ä¸å®¶ä¸åæ°æ®ä¸å¿è¿è¡çä¸é¡¹ç 究åç°ï¼æ¯ä¸ªæ大约æ 12 个ç½ç»æ
éï¼å
¶ä¸ä¸åæå¼ä¸å°æºå¨ï¼ä¸åæå¼æ´ä¸ªæºæ¶ã15ããå¦ä¸é¡¹ç 究æµéäºæ¶é¡¶å¼äº¤æ¢æºï¼æ±è交æ¢æºåè´è½½å¹³è¡¡å¨çç»ä»¶çæ
éçã16ããå®åç°æ·»å åä½ç½ç»è®¾å¤ä¸ä¼åä½ æå¸æçé£æ ·åå°æ
éï¼å 为å®ä¸è½é²è人为é误ï¼ä¾å¦ï¼é误é
ç½®ç交æ¢æºï¼ï¼è¿æ¯é æä¸æç主è¦åå ã
è¯¸å¦ EC2 ä¹ç±»çå
¬æäºæå¡å é¢ç¹çææç½ç»æ
éèèåæèã14ãï¼ç®¡çè¯å¥½çç§ææ°æ®ä¸å¿ç½ç»å¯è½æ¯æ´ç¨³å®çç¯å¢ã尽管å¦æ¤ï¼æ²¡æ人ä¸åç½ç»é®é¢çå°æ°ï¼ä¾å¦ï¼äº¤æ¢æºè½¯ä»¶å级è¿ç¨ä¸çä¸ä¸ªé®é¢å¯è½ä¼å¼åç½ç»ææéæï¼å¨æ¤æé´ç½ç»æ°æ®å
å¯è½ä¼å»¶è¿è¶
è¿ä¸åéã17ãã鲨鱼å¯è½å¬ä½æµ·åºçµç¼å¹¶æåå®ä»¬ ã18ããå
¶ä»ä»¤äººæ讶çæ
éå
æ¬ç½ç»æ¥å£ææ¶ä¼ä¸¢å¼ææå
¥ç«æ°æ®å
ï¼ä½æ¯æååéåºç«æ°æ®å
ã19ãï¼ä»
ä»
å 为ç½ç»é¾æ¥å¨ä¸ä¸ªæ¹åä¸å·¥ä½ï¼å¹¶ä¸è½ä¿è¯å®ä¹å¨ç¸åçæ¹åå·¥ä½ã
> #### ç½ç»ååº
>
> å½ç½ç»çä¸é¨åç±äºç½ç»æ
éè被åææ¶ï¼ææ¶ç§°ä¸º **ç½ç»ååºï¼network partitionï¼** æ **ç½ç»æè£ï¼netsplitï¼**ãå¨æ¬ä¹¦ä¸ï¼æ们é常ä¼åæ使ç¨æ´ä¸è¬çæ¯è¯ **ç½ç»æ
éï¼network faultï¼**ï¼ä»¥é¿å
ä¸ [第å
ç« ](ch6.md) 讨论çåå¨ç³»ç»çååºï¼åçï¼ç¸æ··æ·ã
å³ä½¿ç½ç»æ
éå¨ä½ çç¯å¢ä¸é常ç½è§ï¼æ
éå¯è½åççäºå®ï¼æå³çä½ ç软件éè¦è½å¤å¤çå®ä»¬ãæ 论ä½æ¶éè¿ç½ç»è¿è¡éä¿¡ï¼é½å¯è½ä¼å¤±è´¥ï¼è¿æ¯æ æ³é¿å
çã
å¦æç½ç»æ
éçé误å¤ç没æå®ä¹ä¸æµè¯ï¼æ¦æå°è®²ï¼åç§é误å¯è½é½ä¼åçï¼ä¾å¦ï¼å³ä½¿ç½ç»æ¢å¤ã20ãï¼é群å¯è½ä¼åç **æ»é**ï¼æ°¸ä¹
æ æ³ä¸ºè¯·æ±æä¾æå¡ï¼çè³å¯è½ä¼å é¤ææçæ°æ®ã21ããå¦æ软件被置äºææä¹å¤çæ
åµä¸ï¼å®å¯è½ä¼ååºåºä¹ææçäºæ
ã
å¤çç½ç»æ
é并ä¸æå³ç容å¿å®ä»¬ï¼å¦æä½ çç½ç»é常æ¯ç¸å½å¯é çï¼ä¸ä¸ªææçæ¹æ³å¯è½æ¯å½ä½ çç½ç»éå°é®é¢æ¶ï¼ç®åå°åç¨æ·æ¾ç¤ºä¸æ¡é误信æ¯ãä½æ¯ï¼ä½ ç¡®å®éè¦ç¥éä½ ç软件å¦ä½åºå¯¹ç½ç»é®é¢ï¼å¹¶ç¡®ä¿ç³»ç»è½å¤ä»ä¸æ¢å¤ãææè¯å°è§¦åç½ç»é®é¢å¹¶æµè¯ç³»ç»ååºï¼è¿æ¯ Chaos Monkey èåçæ³æ³ï¼è¯·åé
â[å¯é æ§](ch1.md#å¯é æ§)âï¼ã
### æ£æµæ
é
许å¤ç³»ç»éè¦èªå¨æ£æµæ
éèç¹ãä¾å¦ï¼
* è´è½½å¹³è¡¡å¨éè¦åæ¢åå·²æ»äº¡çèç¹è½¬å请æ±ï¼ä»è½®è¯¢å表移åºï¼å³ out of rotationï¼ã
* å¨å主å¤å¶åè½çåå¸å¼æ°æ®åºä¸ï¼å¦æ主åºå¤±æï¼åéè¦å°ä»åºä¹ä¸å级为æ°ä¸»åºï¼è¯·åé
â[å¤çèç¹å®æº](ch5.md#å¤çèç¹å®æº)âï¼ã
ä¸å¹¸çæ¯ï¼ç½ç»çä¸ç¡®å®æ§ä½¿å¾å¾é¾å¤æä¸ä¸ªèç¹æ¯å¦å·¥ä½ãå¨æäºç¹å®çæ
åµä¸ï¼ä½ å¯è½ä¼æ¶å°ä¸äºåé¦ä¿¡æ¯ï¼æç¡®åè¯ä½ æäºäºæ
没ææåï¼
* å¦æä½ å¯ä»¥è¿æ¥å°è¿è¡èç¹çæºå¨ï¼ä½æ²¡æè¿ç¨æ£å¨ä¾¦å¬ç®æ 端å£ï¼ä¾å¦ï¼å 为è¿ç¨å´©æºï¼ï¼æä½ç³»ç»å°éè¿åé FIN æ RST æ¥å
³é并éç¨ TCP è¿æ¥ãä½æ¯ï¼å¦æèç¹å¨å¤ç请æ±æ¶åçå´©æºï¼åæ æ³ç¥éè¿ç¨èç¹å®é
å¤çäºå¤å°æ°æ®ã22ãã
* å¦æèç¹è¿ç¨å´©æºï¼æ被管çåææ»ï¼ï¼ä½èç¹çæä½ç³»ç»ä»å¨è¿è¡ï¼åèæ¬å¯ä»¥éç¥å
¶ä»èç¹æå
³è¯¥å´©æºçä¿¡æ¯ï¼ä»¥ä¾¿å¦ä¸ä¸ªèç¹å¯ä»¥å¿«éæ¥ç®¡ï¼èæ éçå¾
è¶
æ¶å°æãä¾å¦ï¼HBase å°±æ¯è¿ä¹åçã23ãã
* å¦æä½ ææ访é®æ°æ®ä¸å¿ç½ç»äº¤æ¢æºç管ççé¢ï¼åå¯ä»¥éè¿å®ä»¬æ£æµç¡¬ä»¶çº§å«çé¾è·¯æ
éï¼ä¾å¦ï¼è¿ç¨æºå¨æ¯å¦å
³éçµæºï¼ãå¦æä½ éè¿äºèç½è¿æ¥ï¼æè
å¦æä½ å¤äºå
±äº«æ°æ®ä¸å¿èæ æ³è®¿é®äº¤æ¢æºï¼æè
ç±äºç½ç»é®é¢èæ æ³è®¿é®ç®¡ççé¢ï¼åæé¤æ¤é项ã
* å¦æè·¯ç±å¨ç¡®è®¤ä½ å°è¯è¿æ¥ç IP å°åä¸å¯ç¨ï¼åå¯è½ä¼ä½¿ç¨ ICMP ç®æ ä¸å¯è¾¾æ°æ®å
åå¤ä½ ãä½æ¯ï¼è·¯ç±å¨ä¸å
·å¤ç¥å¥çæ
éæ£æµè½å ââ å®åå°ä¸ç½ç»å
¶ä»åä¸è
ç¸åçéå¶ã
å
³äºè¿ç¨èç¹å
³éçå¿«éåé¦å¾æç¨ï¼ä½æ¯ä½ ä¸è½ææå®ãå³ä½¿ TCP 确认已ç»ä¼ éäºä¸ä¸ªæ°æ®å
ï¼åºç¨ç¨åºå¨å¤çä¹åå¯è½å·²ç»å´©æºãå¦æä½ æ³ç¡®ä¿ä¸ä¸ªè¯·æ±æ¯æåçï¼ä½ éè¦åºç¨ç¨åºæ¬èº«çæ£ç¡®ååºã24ãã
ç¸åï¼å¦æåºäºä»ä¹é®é¢ï¼ä½ å¯è½ä¼å¨å æ çæ个å±æ¬¡ä¸å¾å°ä¸ä¸ªé误ååºï¼ä½æ»çæ¥è¯´ï¼ä½ å¿
é¡»åè®¾ä½ å¯è½æ ¹æ¬å°±å¾ä¸å°ä»»ä½ååºãä½ å¯ä»¥éè¯å 次ï¼TCP éè¯æ¯éæçï¼ä½æ¯ä½ ä¹å¯ä»¥å¨åºç¨ç¨åºçº§å«éè¯ï¼ï¼çå¾
è¶
æ¶è¿æï¼å¹¶ä¸å¦æå¨è¶
æ¶æ¶é´å
没ææ¶å°ååºï¼åæç»å£°æèç¹å·²ç»æ»äº¡ã
### è¶
æ¶ä¸æ ç©·ç延è¿
å¦æè¶
æ¶æ¯æ£æµæ
éçå¯ä¸å¯é æ¹æ³ï¼é£ä¹è¶
æ¶åºè¯¥çå¾
å¤ä¹
ï¼ä¸å¹¸çæ¯æ²¡æç®åççæ¡ã
é¿æ¶é´çè¶
æ¶æå³çé¿æ¶é´çå¾
ï¼ç´å°ä¸ä¸ªèç¹è¢«å®£åæ»äº¡ï¼å¨è¿æ®µæ¶é´å
ï¼ç¨æ·å¯è½ä¸å¾ä¸çå¾
ï¼æè
çå°é误信æ¯ï¼ãççè¶
æ¶å¯ä»¥æ´å¿«å°æ£æµå°æ
éï¼ä½ææ´é«å°é£é©è¯¯å°ä¸ä¸ªèç¹å®£å¸ä¸ºå¤±æï¼è该èç¹å®é
ä¸åªæ¯ææ¶å°åæ
¢äºï¼ä¾å¦ç±äºèç¹æç½ç»ä¸çè´è½½å³°å¼ï¼ã
è¿æ©å°å£°æä¸ä¸ªèç¹å·²ç»æ»äºæ¯æé®é¢çï¼å¦æè¿ä¸ªèç¹å®é
ä¸æ¯æ´»ççï¼å¹¶ä¸æ£å¨æ§è¡ä¸äºå¨ä½ï¼ä¾å¦ï¼åéä¸å°çµåé®ä»¶ï¼ï¼èå¦ä¸ä¸ªèç¹æ¥ç®¡ï¼é£ä¹è¿ä¸ªå¨ä½å¯è½ä¼æç»æ§è¡ä¸¤æ¬¡ãæ们å°å¨ â[ç¥è¯ãçç¸ä¸è°è¨](#ç¥è¯ãçç¸ä¸è°è¨)â 以å [第ä¹ç« ](ch9.md) å [第åä¸ç« ](ch11.md) ä¸æ´è¯¦ç»å°è®¨è®ºè¿ä¸ªé®é¢ã
å½ä¸ä¸ªèç¹è¢«å®£åæ»äº¡æ¶ï¼å®çèè´£éè¦è½¬ç§»å°å
¶ä»èç¹ï¼è¿ä¼ç»å
¶ä»èç¹åç½ç»å¸¦æ¥é¢å¤çè´æ
ãå¦æç³»ç»å·²ç»å¤äºé«è´è·ç¶æï¼åè¿æ©å®£åèç¹æ»äº¡ä¼ä½¿é®é¢æ´ä¸¥éãç¹å«æ¯å¦æèç¹å®é
ä¸æ²¡ææ»äº¡ï¼åªæ¯ç±äºè¿è½½å¯¼è´å
¶ååºç¼æ
¢ï¼è¿æ¶å°å
¶è´è½½è½¬ç§»å°å
¶ä»èç¹å¯è½ä¼å¯¼è´ **级è失æ**ï¼å³ cascading failureï¼è¡¨ç¤ºå¨æ端æ
åµä¸ï¼ææèç¹é½å®£å对æ¹æ»äº¡ï¼ææèç¹é½å°åæ¢å·¥ä½ï¼ã
设æ³ä¸ä¸ªèæçç³»ç»ï¼å
¶ç½ç»å¯ä»¥ä¿è¯æ°æ®å
çæå¤§å»¶è¿ ââ æ¯ä¸ªæ°æ®å
è¦ä¹å¨ä¸æ®µæ¶é´å
ä¼ éï¼è¦ä¹ä¸¢å¤±ï¼ä½æ¯ä¼ éæ°¸è¿ä¸ä¼æ¯ $d$ æ´é¿ãæ¤å¤ï¼åè®¾ä½ å¯ä»¥ä¿è¯ä¸ä¸ªéæ
éèç¹æ»æ¯å¨ä¸æ®µæ¶é´ $r$ å
å¤çä¸ä¸ªè¯·æ±ãå¨è¿ç§æ
åµä¸ï¼ä½ å¯ä»¥ä¿è¯æ¯ä¸ªæåç请æ±å¨ $2d + r$ æ¶é´å
é½è½æ¶å°ååºï¼å¦æä½ å¨æ¤æ¶é´å
没ææ¶å°ååºï¼åç¥éç½ç»æè¿ç¨èç¹ä¸å·¥ä½ãå¦æè¿æ¯æç«çï¼$2d + r$ ä¼æ¯ä¸ä¸ªåççè¶
æ¶è®¾ç½®ã
ä¸å¹¸çæ¯ï¼æ们æ使ç¨ç大å¤æ°ç³»ç»é½æ²¡æè¿äºä¿è¯ï¼å¼æ¥ç½ç»å
·ææ éç延è¿ï¼å³å°½å¯è½å¿«å°ä¼ éæ°æ®å
ï¼ä½æ°æ®å
å°è¾¾å¯è½éè¦çæ¶é´æ²¡æä¸éï¼ï¼å¹¶ä¸å¤§å¤æ°æå¡å¨å®ç°å¹¶ä¸è½ä¿è¯å®ä»¬å¯ä»¥å¨ä¸å®çæ大æ¶é´å
å¤ç请æ±ï¼è¯·åé
â[ååºæ¶é´ä¿è¯](#ååºæ¶é´ä¿è¯)âï¼ã对äºæ
éæ£æµï¼å³ä½¿ç³»ç»å¤§é¨åæ¶é´å¿«éè¿è¡ä¹æ¯ä¸å¤çï¼å¦æä½ çè¶
æ¶æ¶é´å¾çï¼å¾è¿æ¶é´åªéè¦ä¸ä¸ªç¬æ¶å°å³°å°±å¯ä»¥ä½¿ç³»ç»å¤±è¡¡ã
#### ç½ç»æ¥å¡åæé
å¨é©¾é©¶æ±½è½¦æ¶ï¼ç±äºäº¤éæ¥å µï¼é路交éç½ç»çéè¡æ¶é´å¾å¾ä¸å°½ç¸åãåæ ·ï¼è®¡ç®æºç½ç»ä¸æ°æ®å
延è¿çå¯åæ§é常æ¯ç±äºæéã25ãï¼
* å¦æå¤ä¸ªä¸åçèç¹åæ¶å°è¯å°æ°æ®å
åéå°åä¸ç®çå°ï¼åç½ç»äº¤æ¢æºå¿
é¡»å°å®ä»¬æé并å°å®ä»¬é个éå
¥ç®æ ç½ç»é¾è·¯ï¼å¦ [å¾ 8-2](img/fig8-2.png) æ示ï¼ãå¨ç¹å¿çç½ç»é¾è·¯ä¸ï¼æ°æ®å
å¯è½éè¦çå¾
ä¸æ®µæ¶é´æè½è·å¾ä¸ä¸ªæ槽ï¼è¿ç§°ä¸ºç½ç»æ¥å¡ï¼ãå¦æä¼ å
¥çæ°æ®å¤ªå¤ï¼äº¤æ¢æºéå填满ï¼æ°æ®å
å°è¢«ä¸¢å¼ï¼å æ¤éè¦éæ°åéæ°æ®å
- å³ä½¿ç½ç»è¿è¡è¯å¥½ã
* å½æ°æ®å
å°è¾¾ç®æ æºå¨æ¶ï¼å¦æææ CPU å
æ ¸å½åé½å¤äºç¹å¿ç¶æï¼åæ¥èªç½ç»çä¼ å
¥è¯·æ±å°è¢«æä½ç³»ç»æéï¼ç´å°åºç¨ç¨åºåå¤å¥½å¤çå®ä¸ºæ¢ãæ ¹æ®æºå¨ä¸çè´è½½ï¼è¿å¯è½éè¦ä¸æ®µä»»æçæ¶é´ã
* å¨èæåç¯å¢ä¸ï¼æ£å¨è¿è¡çæä½ç³»ç»ç»å¸¸æåå å毫ç§ï¼å 为å¦ä¸ä¸ªèææºæ£å¨ä½¿ç¨ CPU å
æ ¸ãå¨è¿æ®µæ¶é´å
ï¼èææºä¸è½ä»ç½ç»ä¸æ¶èä»»ä½æ°æ®ï¼æä»¥ä¼ å
¥çæ°æ®è¢«èææºçè§å¨ ã26ãæéï¼ç¼å²ï¼ï¼è¿ä¸æ¥å¢å äºç½ç»å»¶è¿çå¯åæ§ã
* TCP æ§è¡ **æµéæ§å¶**ï¼flow controlï¼ä¹ç§°ä¸º **æ¥å¡é¿å
**ï¼å³ congestion avoidanceï¼æ **èå**ï¼å³ backpressureï¼ï¼å
¶ä¸èç¹ä¼éå¶èªå·±çåééç以é¿å
ç½ç»é¾è·¯ææ¥æ¶èç¹è¿è½½ã27ããè¿æå³ççè³å¨æ°æ®è¿å
¥ç½ç»ä¹åï¼å¨åéè
å¤å°±éè¦è¿è¡é¢å¤çæéã
![](img/fig8-2.png)
**å¾ 8-2 å¦ææå¤å°æºå¨å°ç½ç»æµéåéå°åä¸ç®çå°ï¼åå
¶äº¤æ¢æºéåå¯è½ä¼è¢«å¡«æ»¡ãå¨è¿éï¼ç«¯å£ 1,2 å 4 é½è¯å¾åéæ°æ®å
å°ç«¯å£ 3**
èä¸ï¼å¦æ TCP å¨æ个è¶
æ¶æ¶é´å
没æ被确认ï¼è¿æ¯æ ¹æ®è§å¯çå¾è¿æ¶é´è®¡ç®çï¼ï¼å认为æ°æ®å
丢失ï¼ä¸¢å¤±çæ°æ®å
å°èªå¨éæ°åéã尽管åºç¨ç¨åºæ²¡æçå°æ°æ®å
丢失åéæ°ä¼ è¾ï¼ä½å®çå°äºå»¶è¿ï¼çå¾
è¶
æ¶å°æï¼ç¶åçå¾
éæ°ä¼ è¾çæ°æ®å
å¾å°ç¡®è®¤ï¼ã
> #### TCPä¸UDP
>
> ä¸äºå¯¹å»¶è¿ææçåºç¨ç¨åºï¼æ¯å¦è§é¢ä¼è®®å IP è¯é³ï¼VoIPï¼ï¼ä½¿ç¨äº UDP èä¸æ¯ TCPãè¿æ¯å¨å¯é æ§åå延è¿ååä¹é´çæè¡·ï¼ç±äº UDP ä¸æ§è¡æµéæ§å¶å¹¶ä¸ä¸éä¼ ä¸¢å¤±çåç»ï¼æ以é¿å
äºç½ç»å»¶è¿ååçä¸äºåå ï¼å°½ç®¡å®ä»ç¶æååæ¢éååè°åº¦å»¶è¿çå½±åï¼ã
>
> å¨å»¶è¿æ°æ®æ¯«æ ä»·å¼çæ
åµä¸ï¼UDP æ¯ä¸ä¸ªä¸éçéæ©ãä¾å¦ï¼å¨ VoIP çµè¯å¼å«ä¸ï¼å¯è½æ²¡æ足å¤çæ¶é´éæ°åé丢失çæ°æ®å
ï¼å¹¶å¨æ¬å£°å¨ä¸ææ¾æ°æ®ãå¨è¿ç§æ
åµä¸ï¼éåæ°æ®å
没ææä¹ ââ åºç¨ç¨åºå¿
须使ç¨éé³å¡«å
丢失æ°æ®å
çæ¶éï¼å¯¼è´å£°é³çæä¸æï¼ï¼ç¶åå¨æ°æ®æµä¸ç»§ç»ãéè¯åçå¨äººç±»å±ï¼âä½ è½å说ä¸éåï¼å£°é³ååæäºä¸ä¼å¿ãâï¼ã
ææè¿äºå ç´ é½ä¼é æç½ç»å»¶è¿çååãå½ç³»ç»æ¥è¿å
¶æ大容éæ¶ï¼æé延è¿çååèå´ç¹å«å¤§ï¼æ¥æ足å¤å¤ç¨å®¹éçç³»ç»å¯ä»¥è½»æ¾æ空éåï¼èå¨é«å©ç¨ççç³»ç»ä¸ï¼å¾å¿«å°±è½ç§¯ç´¯å¾é¿çéåã
å¨å
Œ
±äºåå¤ç§æ·æ°æ®ä¸å¿ä¸ï¼èµæºè¢«è®¸å¤å®¢æ·å
±äº«ï¼ç½ç»é¾æ¥å交æ¢æºï¼çè³æ¯ä¸ªæºå¨çç½å¡å CPUï¼å¨èææºä¸è¿è¡æ¶ï¼ãæ¹å¤çå·¥ä½è´è½½ï¼å¦ MapReduceï¼è¯·åé
[第åç« ](ch10.md)ï¼è½å¤å¾å®¹æ使ç½ç»é¾æ¥é¥±åãç±äºæ æ³æ§å¶æäºè§£å
¶ä»å®¢æ·å¯¹å
±äº«èµæºç使ç¨æ
åµï¼å¦æéè¿çæ个人ï¼åæçé»å±
ï¼æ£å¨ä½¿ç¨å¤§éèµæºï¼åç½ç»å»¶è¿å¯è½ä¼åçå§çååã28,29ãã
å¨è¿ç§ç¯å¢ä¸ï¼ä½ åªè½éè¿å®éªæ¹å¼éæ©è¶
æ¶ï¼å¨ä¸æ®µè¾é¿çæ¶æå
ãå¨å¤å°æºå¨ä¸æµéç½ç»å¾è¿æ¶é´çåå¸ï¼ä»¥ç¡®å®å»¶è¿çé¢æååãç¶åï¼èèå°åºç¨ç¨åºçç¹æ§ï¼å¯ä»¥ç¡®å® **æ
éæ£æµå»¶è¿** ä¸ **è¿æ©è¶
æ¶é£é©** ä¹é´çéå½æè¡·ã
æ´å¥½çä¸ç§åæ³æ¯ï¼ç³»ç»ä¸æ¯ä½¿ç¨é
ç½®ç常éè¶
æ¶æ¶é´ï¼èæ¯è¿ç»æµéååºæ¶é´åå
¶ååï¼æå¨ï¼ï¼å¹¶æ ¹æ®è§å¯å°çååºæ¶é´åå¸èªå¨è°æ´è¶
æ¶æ¶é´ãè¿å¯ä»¥éè¿ Phi Accrual æ
éæ£æµå¨ã30ãæ¥å®æï¼è¯¥æ£æµå¨å¨ä¾å¦ Akka å Cassandra ã31ãä¸ä½¿ç¨ãTCP çè¶
æ¶éä¼ æºå¶ä¹æ¯ä»¥ç±»ä¼¼çæ¹å¼å·¥ä½ã27ãã
### åæ¥ç½ç»ä¸å¼æ¥ç½ç»
å¦ææ们å¯ä»¥ä¾é ç½ç»æ¥ä¼ éä¸äº **æ大延è¿åºå®** çæ°æ®å
ï¼èä¸æ¯ä¸¢å¼æ°æ®å
ï¼é£ä¹åå¸å¼ç³»ç»å°±ä¼ç®åå¾å¤ã为ä»ä¹æ们ä¸è½å¨ç¡¬ä»¶å±é¢ä¸è§£å³è¿ä¸ªé®é¢ï¼ä½¿ç½ç»å¯é ï¼ä½¿è½¯ä»¶ä¸å¿
æ
å¿å¢ï¼
为äºåçè¿ä¸ªé®é¢ï¼å°æ°æ®ä¸å¿ç½ç»ä¸é常å¯é çä¼ ç»åºå®çµè¯ç½ç»ï¼éèçªï¼é VoIPï¼è¿è¡æ¯è¾æ¯å¾æ趣çï¼å»¶è¿é³é¢å¸§åæè¯æ¯é常ç½è§çãä¸ä¸ªçµè¯éè¦ä¸ä¸ªå¾ä½ç端å°ç«¯å»¶è¿ï¼ä»¥å足å¤ç带宽æ¥ä¼ è¾ä½ 声é³çé³é¢éæ ·æ°æ®ãå¨è®¡ç®æºç½ç»ä¸æ类似çå¯é æ§åå¯é¢æµæ§ä¸æ¯å¾å¥½åï¼
å½ä½ éè¿çµè¯ç½ç»æ¨æçµè¯æ¶ï¼å®ä¼å»ºç«ä¸ä¸ªçµè·¯ï¼å¨ä¸¤ä¸ªå¼å«è
ä¹é´çæ´ä¸ªè·¯çº¿ä¸ä¸ºå¼å«åé
ä¸ä¸ªåºå®çï¼æä¿è¯ç带宽éãè¿ä¸ªçµè·¯ä¼ä¿æè³éè¯ç»æã32ããä¾å¦ï¼ISDN ç½ç»ä»¥æ¯ç§ 4000 帧çåºå®éçè¿è¡ãå¼å«å»ºç«æ¶ï¼æ¯ä¸ªå¸§å
ï¼æ¯ä¸ªæ¹åï¼åé
16 ä½ç©ºé´ãå æ¤ï¼å¨éè¯æé´ï¼æ¯ä¸æ¹é½ä¿è¯è½å¤æ¯ 250 å¾®ç§åéä¸ä¸ªç²¾ç¡®ç 16 ä½é³é¢æ°æ®ã33,34ãã
è¿ç§ç½ç»æ¯åæ¥çï¼å³ä½¿æ°æ®ç»è¿å¤ä¸ªè·¯ç±å¨ï¼ä¹ä¸ä¼åå°æéçå½±åï¼å 为å¼å«ç 16 ä½ç©ºé´å·²ç»å¨ç½ç»çä¸ä¸è·³ä¸ä¿çäºä¸æ¥ãèä¸ç±äºæ²¡ææéï¼ç½ç»çæ大端å°ç«¯å»¶è¿æ¯åºå®çãæ们称ä¹ä¸º **æé延è¿ï¼bounded delayï¼**ã
#### æ们ä¸è½ç®åå°ä½¿ç½ç»å»¶è¿å¯é¢æµåï¼
请注æï¼çµè¯ç½ç»ä¸ççµè·¯ä¸ TCP è¿æ¥æå¾å¤§ä¸åï¼çµè·¯æ¯åºå®æ°éçé¢ç带宽ï¼å¨çµè·¯å»ºç«æ¶æ²¡æå
¶ä»äººå¯ä»¥ä½¿ç¨ï¼è TCP è¿æ¥çæ°æ®å
**æºä¼æ§å°** 使ç¨ä»»ä½å¯ç¨çç½ç»å¸¦å®½ãä½ å¯ä»¥ç» TCP ä¸ä¸ªå¯å大å°çæ°æ®åï¼ä¾å¦ï¼ä¸ä¸ªçµåé®ä»¶æä¸ä¸ªç½é¡µï¼ï¼å®ä¼å°½å¯è½å¨æççæ¶é´å
ä¼ è¾å®ãTCP è¿æ¥ç©ºé²æ¶ï¼ä¸ä½¿ç¨ä»»ä½å¸¦å®½ [^ii]ã
[^ii]: é¤äºå¶å°ç keepalive æ°æ®å
ï¼å¦æ TCP keepalive 被å¯ç¨ã
å¦ææ°æ®ä¸å¿ç½ç»åäºèç½æ¯çµè·¯äº¤æ¢ç½ç»ï¼é£ä¹å¨å»ºç«çµè·¯æ¶å°±å¯ä»¥å»ºç«ä¸ä¸ªåä¿è¯çæ大å¾è¿æ¶é´ãä½æ¯ï¼å®ä»¬å¹¶ä¸è½è¿æ ·ï¼ä»¥å¤ªç½å IP æ¯ **åç»äº¤æ¢åè®®**ï¼ä¸å¾ä¸å¿åæéçæ磨åå æ¤å¯¼è´çç½ç»æ é延è¿ï¼è¿äºå议没æçµè·¯çæ¦å¿µã
为ä»ä¹æ°æ®ä¸å¿ç½ç»åäºèç½ä½¿ç¨åç»äº¤æ¢ï¼çæ¡æ¯ï¼å®ä»¬é对 **çªåæµéï¼bursty trafficï¼** è¿è¡äºä¼åãä¸ä¸ªçµè·¯éç¨äºé³é¢æè§é¢éè¯ï¼å¨éè¯æé´éè¦æ¯ç§ä¼ éç¸å½æ°éçæ¯ç¹ãå¦ä¸æ¹é¢ï¼è¯·æ±ç½é¡µï¼åéçµåé®ä»¶æä¼ è¾æ件没æä»»ä½ç¹å®ç带宽è¦æ± ââ æ们åªæ¯å¸æå®å°½å¿«å®æã
å¦ææ³éè¿çµè·¯ä¼ è¾æ件ï¼ä½ å¾é¢æµä¸ä¸ªå¸¦å®½åé
ãå¦æä½ çç太ä½ï¼ä¼ è¾é度ä¼ä¸å¿
è¦ç太æ
¢ï¼å¯¼è´ç½ç»å®¹éé²ç½®ãå¦æä½ çç太é«ï¼çµè·¯å°±æ æ³å»ºç«ï¼å 为å¦ææ æ³ä¿è¯å
¶å¸¦å®½åé
ï¼ç½ç»ä¸è½å»ºç«çµè·¯ï¼ãå æ¤ï¼å°çµè·¯ç¨äºçªåæ°æ®ä¼ è¾ä¼æµªè´¹ç½ç»å®¹éï¼å¹¶ä¸ä½¿ä¼ è¾ä¸å¿
è¦å°ç¼æ
¢ãç¸æ¯ä¹ä¸ï¼TCP å¨æè°æ´æ°æ®ä¼ è¾éç以éåºå¯ç¨çç½ç»å®¹éã
å·²ç»æä¸äºå°è¯å»å»ºç«åæ¶æ¯æçµè·¯äº¤æ¢ååç»äº¤æ¢çæ··åç½ç»ï¼æ¯å¦ ATM [^iii]ãInfiniBand æä¸äºç¸ä¼¼ä¹å¤ã35ãï¼å®å¨é¾è·¯å±å®ç°äºç«¯å°ç«¯çæµéæ§å¶ï¼ä»èåå°äºå¨ç½ç»ä¸æéçéè¦ï¼å°½ç®¡å®ä»ç¶å¯è½å é¾è·¯æ¥å¡èåå°å»¶è¿ã36ããéè¿ä»ç»ä½¿ç¨ **æå¡è´¨é**ï¼quality of serviceï¼å³ QoSï¼æ°æ®å
çä¼å
级åè°åº¦ï¼å **åå
¥æ§å¶**ï¼admission controlï¼ééåéå¨ï¼ï¼å¯ä»¥å¨åç»ç½ç»ä¸æ¨¡æçµè·¯äº¤æ¢ï¼ææä¾ç»è®¡ä¸ç **æé延è¿**ã25,32ãã
[^iii]: **å¼æ¥ä¼ è¾æ¨¡å¼ï¼Asynchronous Transfer Mode, ATMï¼** å¨ 20 ä¸çºª 80 年代æ¯ä»¥å¤ªç½çç«äºå¯¹æã32ãï¼ä½å¨çµè¯ç½æ ¸å¿äº¤æ¢æºä¹å¤å¹¶æ²¡æå¾å°å¤ªå¤çéç¨ãå®ä¸èªå¨æåæºï¼ä¹ç§°ä¸ºèªå¨å款æºï¼æ å
³ï¼å°½ç®¡å
±ç¨ä¸ä¸ªç¼©åè¯ãæ许ï¼å¨ä¸äºå¹³è¡çä¸çéï¼äºèç½æ¯åºäºå ATM è¿æ ·çä¸è¥¿ï¼å æ¤å®ä»¬çäºèç½è§é¢éè¯å¯è½æ¯æ们çæ´å¯é ï¼å 为å®ä»¬ä¸ä¼éåå
ç丢失å延è¿ã
ä½æ¯ï¼ç®åå¨å¤ç§æ·æ°æ®ä¸å¿åå
Œ
±äºæéè¿äºèç½ [^iv] è¿è¡éä¿¡æ¶ï¼æ¤ç±»æå¡è´¨éå°æªå¯ç¨ãå½åé¨ç½²çææ¯ä¸å
许æ们对ç½ç»ç延è¿æå¯é æ§ä½åºä»»ä½ä¿è¯ï¼æ们å¿
é¡»å设ç½ç»æ¥å¡ï¼æéåæ éç延è¿æ»æ¯ä¼åçãå æ¤ï¼è¶
æ¶æ¶é´æ²¡æ âæ£ç¡®â çå¼ ââ å®éè¦éè¿å®éªæ¥ç¡®å®ã
[^iv]: äºèç½æå¡æä¾åä¹é´ç对çåè®®åéè¿ **BGP ç½å
³åè®®ï¼BGPï¼** 建ç«çè·¯ç±ï¼ä¸ IP åè®®ç¸æ¯ï¼æ´æ¥è¿äºçµè·¯äº¤æ¢ãå¨è¿ä¸ªçº§å«ä¸ï¼å¯ä»¥è´ä¹°ä¸ç¨å¸¦å®½ãä½æ¯ï¼äºèç½è·¯ç±å¨ç½ç»çº§å«è¿è¡ï¼èä¸æ¯ä¸»æºä¹é´çåç¬è¿æ¥ï¼èä¸è¿è¡æ¶é´è¦é¿å¾å¤ã
> ### 延è¿åèµæºå©ç¨
>
> æ´ä¸è¬å°è¯´ï¼å¯ä»¥å° **延è¿åå** è§ä¸º **å¨æèµæºååº** çç»æã
>
> å设两å°çµè¯äº¤æ¢æºä¹é´æä¸æ¡çº¿è·¯ï¼å¯ä»¥åæ¶è¿è¡ 10,000 个å¼å«ãéè¿æ¤çº¿è·¯åæ¢çæ¯ä¸ªçµè·¯é½å ç¨å
¶ä¸ä¸ä¸ªå¼å«æ槽ãå æ¤ï¼ä½ å¯ä»¥å°çº¿è·¯è§ä¸ºå¯ç±å¤è¾¾ 10,000 个并åç¨æ·å
±äº«çèµæºãèµæºä»¥éææ¹å¼åé
ï¼å³ä½¿ä½ ç°å¨æ¯çº¿è·¯ä¸å¯ä¸çå¼å«ï¼å¹¶ä¸ææå
¶ä» 9,999 个æ槽é½æªä½¿ç¨ï¼ä½ ççµè·¯ä»å°åé
ä¸çº¿è·¯å
åå©ç¨æ¶ç¸åçåºå®æ°éç带宽ã
>
> ç¸æ¯ä¹ä¸ï¼äºèç½å¨æå享ç½ç»å¸¦å®½ãåéè
äºç¸æ¨æ¤åäºå¤ºï¼ä»¥è®©ä»ä»¬çæ°æ®å
å°½å¯è½å¿«å°éè¿ç½ç»ï¼å¹¶ä¸ç½ç»äº¤æ¢æºå³å®ä»ä¸ä¸ªæ¶å»å°å¦ä¸ä¸ªæ¶å»åéåªä¸ªåç»ï¼å³ï¼å¸¦å®½åé
ï¼ãè¿ç§æ¹æ³ææéç缺ç¹ï¼ä½å
¶ä¼ç¹æ¯å®æ大é度å°å©ç¨äºçº¿è·¯ã线路åºå®ææ¬ï¼æ以å¦æä½ æ´å¥½å°å©ç¨å®ï¼ä½ éè¿çº¿è·¯åéçæ¯ä¸ªåèé½ä¼æ´ä¾¿å®ã
>
> CPU ä¹ä¼åºç°ç±»ä¼¼çæ
åµï¼å¦æä½ å¨å¤ä¸ªçº¿ç¨é´å¨æå
±äº«æ¯ä¸ª CPU å
æ ¸ï¼åä¸ä¸ªçº¿ç¨ææ¶å¿
é¡»å¨æä½ç³»ç»çè¿è¡éåéçå¾
ï¼èå¦ä¸ä¸ªçº¿ç¨æ£å¨è¿è¡ï¼è¿æ ·æ¯ä¸ªçº¿ç¨é½æå¯è½è¢«æåä¸ä¸ªä¸å®çæ¶é´é¿åº¦ãä½æ¯ï¼ä¸ä¸ºæ¯ä¸ªçº¿ç¨åé
éææ°éç CPU å¨æç¸æ¯ï¼è¿ä¼æ´å¥½å°å©ç¨ç¡¬ä»¶ï¼è¯·åé
â[ååºæ¶é´ä¿è¯](#ååºæ¶é´ä¿è¯)âï¼ãæ´å¥½ç硬件å©ç¨çä¹æ¯ä½¿ç¨èææºçéè¦å¨æºã
>
> å¦æèµæºæ¯éæååºçï¼ä¾å¦ï¼ä¸ç¨ç¡¬ä»¶åä¸ç¨å¸¦å®½åé
ï¼ï¼åå¨æäºç¯å¢ä¸å¯ä»¥å®ç° **延è¿ä¿è¯**ãä½æ¯ï¼è¿æ¯ä»¥éä½å©ç¨ç为代价ç ââ æ¢å¥è¯è¯´ï¼å®æ¯æ´æè´µçãå¦ä¸æ¹é¢ï¼å¨æèµæºåé
çå¤ç§æ·æä¾äºæ´å¥½çå©ç¨çï¼æ以å®æ´ä¾¿å®ï¼ä½å®å
·æå¯å延è¿ç缺ç¹ã
>
> ç½ç»ä¸çå¯å延è¿ä¸æ¯ä¸ç§èªç¶è§å¾ï¼èåªæ¯ææ¬ / æ¶çæè¡¡çç»æã
## ä¸å¯é çæ¶é
æ¶éåæ¶é´å¾éè¦ãåºç¨ç¨åºä»¥åç§æ¹å¼ä¾èµäºæ¶éæ¥åç以ä¸é®é¢ï¼
1. è¿ä¸ªè¯·æ±æ¯å¦è¶
æ¶äºï¼
2. è¿é¡¹æå¡ç第 99 ç¾åä½ååºæ¶é´æ¯å¤å°ï¼
3. å¨è¿å»äºåéå
ï¼è¯¥æå¡å¹³åæ¯ç§å¤çå¤å°ä¸ªæ¥è¯¢ï¼
4. ç¨æ·å¨æ们çç½ç«ä¸è±äºå¤é¿æ¶é´ï¼
5. è¿ç¯æç« å¨ä½æ¶åå¸ï¼
6. å¨ä»ä¹æ¶é´åéæéé®ä»¶ï¼
7. è¿ä¸ªç¼åæ¡ç®ä½æ¶å°æï¼
8. æ¥å¿æ件ä¸æ¤é误æ¶æ¯çæ¶é´æ³æ¯ä»ä¹ï¼
[ä¾ 1-4](ch1.md) æµéäº **æç»æ¶é´**ï¼durationsï¼ä¾å¦ï¼è¯·æ±åéä¸ååºæ¥æ¶ä¹é´çæ¶é´é´éï¼ï¼è [ä¾ 5-8](ch5.md) æè¿°äº **æ¶é´ç¹**ï¼point in timeï¼å¨ç¹å®æ¥æååç¹å®æ¶é´åççäºä»¶ï¼ã
å¨åå¸å¼ç³»ç»ä¸ï¼æ¶é´æ¯ä¸ä»¶æ£æçäºæ
ï¼å 为éä¿¡ä¸æ¯å³æ¶çï¼æ¶æ¯éè¿ç½ç»ä»ä¸å°æºå¨ä¼ éå°å¦ä¸å°æºå¨éè¦æ¶é´ãæ¶å°æ¶æ¯çæ¶é´æ»æ¯æäºåéçæ¶é´ï¼ä½æ¯ç±äºç½ç»ä¸çå¯å延è¿ï¼æ们ä¸ç¥éæäºå¤å°æ¶é´ãè¿ä¸ªäºå®å¯¼è´ææ¶å¾é¾ç¡®å®å¨æ¶åå¤å°æºå¨æ¶åçäºæ
ç顺åºã
èä¸ï¼ç½ç»ä¸çæ¯å°æºå¨é½æèªå·±çæ¶éï¼è¿æ¯ä¸ä¸ªå®é
ç硬件设å¤ï¼é常æ¯ç³è±æ¶ä½æ¯è¡å¨ãè¿äºè®¾å¤ä¸æ¯å®å
¨åç¡®çï¼æ以æ¯å°æºå¨é½æèªå·±çæ¶é´æ¦å¿µï¼å¯è½æ¯å
¶ä»æºå¨ç¨å¿«ææ´æ
¢ãå¯ä»¥å¨ä¸å®ç¨åº¦ä¸åæ¥æ¶éï¼æ常ç¨çæºå¶æ¯ **ç½ç»æ¶é´åè®®ï¼NTPï¼**ï¼å®å
è®¸æ ¹æ®ä¸ç»æå¡å¨æ¥åçæ¶é´æ¥è°æ´è®¡ç®æºæ¶éã37ããæå¡å¨åä»æ´ç²¾ç¡®çæ¶é´æºï¼å¦ GPS æ¥æ¶æºï¼è·åæ¶é´ã
### åè°éä¸æ¥åæ¶é
ç°ä»£è®¡ç®æºè³å°æ两ç§ä¸åçæ¶éï¼æ¥åæ¶éï¼time-of-day clockï¼ååè°éï¼monotonic clockï¼ã尽管å®ä»¬é½è¡¡éæ¶é´ï¼ä½åºåè¿ä¸¤è
å¾éè¦ï¼å 为å®ä»¬æä¸åçç®çã
#### æ¥åæ¶é
æ¥åæ¶éæ¯ä½ ç´è§å°äºè§£æ¶éçä¾æ®ï¼å®æ ¹æ®æ个æ¥åï¼ä¹ç§°ä¸º **æéæ¶é´**ï¼å³ wall-clock timeï¼è¿åå½åæ¥æåæ¶é´ãä¾å¦ï¼Linux ä¸ç `clock_gettime(CLOCK_REALTIME)`[^v] å Java ä¸ç `System.currentTimeMillis()` è¿åèª epochï¼UTC æ¶é´ 1970 å¹´ 1 æ 1 æ¥åå¤ï¼ä»¥æ¥çç§æ°ï¼æ毫ç§ï¼ï¼æ ¹æ®å
¬åï¼Gregorianï¼æ¥åï¼ä¸å
æ¬é°ç§ãæäºç³»ç»ä½¿ç¨å
¶ä»æ¥æä½ä¸ºåèç¹ã
[^v]: è½ç¶è¯¥æ¶é被称为å®æ¶æ¶éï¼ä½å®ä¸å®æ¶æä½ç³»ç»æ å
³ï¼å¦ â[ååºæ¶é´ä¿è¯](#ååºæ¶é´ä¿è¯)â ä¸æè¿°ã
æ¥åæ¶ééå¸¸ä¸ NTP åæ¥ï¼è¿æå³çæ¥èªä¸å°æºå¨çæ¶é´æ³ï¼çæ³æ
åµä¸ï¼ä¸å¦ä¸å°æºå¨ä¸çæ¶é´æ³ç¸åãä½æ¯å¦ä¸èæè¿°ï¼æ¥åæ¶éä¹å
·æåç§åæ ·çå¥ç¹ä¹å¤ãç¹å«æ¯ï¼å¦ææ¬å°æ¶éå¨ NTP æå¡å¨ä¹å太è¿ï¼åå®å¯è½ä¼è¢«å¼ºå¶éç½®ï¼çä¸å»å¥½åè·³åäºå
åçæ¶é´ç¹ãè¿äºè·³è·ä»¥åä»ä»¬ç»å¸¸å¿½ç¥é°ç§çäºå®ï¼ä½¿æ¥åæ¶éä¸è½ç¨äºæµéç»è¿æ¶é´ï¼elapsed timeï¼ã38ãã
åå²ä¸çæ¥åæ¶éè¿å
·æç¸å½ç²ç¥çå辨çï¼ä¾å¦ï¼å¨è¾æ©ç Windows ç³»ç»ä¸ä»¥ 10 毫ç§ä¸ºåä½åè¿ã39ããå¨æè¿çç³»ç»ä¸è¿å·²ç»ä¸æ¯ä¸ä¸ªé®é¢äºã
#### åè°é
åè°ééç¨äºæµéæç»æ¶é´ï¼æ¶é´é´éï¼ï¼ä¾å¦è¶
æ¶ææå¡çååºæ¶é´ï¼Linux ä¸ç `clock_gettime(CLOCK_MONOTONIC)`ï¼å Java ä¸ç `System.nanoTime()` é½æ¯åè°æ¶éãè¿ä¸ªååæ¥æºäºä»ä»¬ä¿è¯æ»æ¯å¾åèµ°çäºå®ï¼èæ¥åæ¶éå¯ä»¥å¾åè·³ï¼ã
ä½ å¯ä»¥å¨æ个æ¶é´ç¹æ£æ¥åè°éçå¼ï¼åä¸äºäºæ
ï¼ä¸ç¨åå次æ£æ¥å®ãè¿ä¸¤ä¸ªå¼ä¹é´çå·®å¼åè¯ä½ 两次æ£æ¥ä¹é´ç»è¿äºå¤é¿æ¶é´ãä½åè°éçç»å¯¹å¼æ¯æ¯«æ æä¹çï¼å®å¯è½æ¯è®¡ç®æºå¯å¨ä»¥æ¥ç纳ç§æ°ï¼æ类似çä»»æå¼ãç¹å«æ¯æ¯è¾æ¥èªä¸¤å°ä¸å计ç®æºçåè°éçå¼æ¯æ²¡ææä¹çï¼å 为å®ä»¬å¹¶ä¸æ¯ä¸åäºã
å¨å
·æå¤ä¸ª CPU æ槽çæå¡å¨ä¸ï¼æ¯ä¸ª CPU å¯è½æä¸ä¸ªåç¬ç计æ¶å¨ï¼ä½ä¸ä¸å®ä¸å
¶ä» CPU åæ¥ãæä½ç³»ç»ä¼è¡¥å¿ææçå·®å¼ï¼å¹¶å°è¯ååºç¨çº¿ç¨è¡¨ç°åºåè°éçæ ·åï¼å³ä½¿è¿äºçº¿ç¨è¢«è°åº¦å°ä¸åç CPU ä¸ãå½ç¶ï¼ææºçåæ³æ¯ä¸è¦å¤ªæè¿ç§åè°æ§ä¿è¯å½åäºã40ãã
å¦æ NTP åè®®æ£æµå°è®¡ç®æºçæ¬å°ç³è±éæ¯ NTP æå¡å¨è¦æ´å¿«ææ´æ
¢ï¼åå¯ä»¥è°æ´åè°éååèµ°çé¢çï¼è¿ç§°ä¸º **å移ï¼skewingï¼** æ¶éï¼ãé»è®¤æ
åµä¸ï¼NTP å
许æ¶ééçå¢å æåæ
¢æé«è³ 0.05%ï¼ä½ NTP ä¸è½ä½¿åè°æ¶éååæåå跳转ãåè°æ¶éçå辨çé常ç¸å½å¥½ï¼å¨å¤§å¤æ°ç³»ç»ä¸ï¼å®ä»¬è½å¨å å¾®ç§ææ´ççæ¶é´å
æµéæ¶é´é´éã
å¨åå¸å¼ç³»ç»ä¸ï¼ä½¿ç¨åè°éæµé **ç»è¿æ¶é´**ï¼elapsed timeï¼æ¯å¦è¶
æ¶ï¼é常å¾å¥½ï¼å 为å®ä¸åå®ä¸åèç¹çæ¶éä¹é´åå¨ä»»ä½åæ¥ï¼å¹¶ä¸å¯¹æµéç轻微ä¸åç¡®æ§ä¸ææã
### æ¶éåæ¥ä¸åç¡®æ§
åè°éä¸éè¦åæ¥ï¼ä½æ¯æ¥åæ¶ééè¦æ ¹æ® NTP æå¡å¨æå
¶ä»å¤é¨æ¶é´æºæ¥è®¾ç½®æè½æç¨ãä¸å¹¸çæ¯ï¼æ们è·åæ¶éçæ¹æ³å¹¶ä¸åä½ æå¸æçé£æ ·å¯é æåç¡® ââ 硬件æ¶éå NTP å¯è½ä¼åå¹»è«æµã举å 个ä¾åï¼
* 计ç®æºä¸çç³è±éä¸å¤ç²¾ç¡®ï¼å®ä¼ **æ¼ç§»**ï¼driftsï¼å³è¿è¡é度快äºææ
¢äºé¢æï¼ãæ¶éæ¼ç§»åå³äºæºå¨ç温度ãGoogle å设å
¶æå¡å¨æ¶éæ¼ç§»ä¸º 200 ppmï¼ç¾ä¸åä¹ä¸ï¼ã41ãï¼ç¸å½äºæ¯ 30 ç§ä¸æå¡å¨éæ°åæ¥ä¸æ¬¡çæ¶éæ¼ç§»ä¸º 6 毫ç§ï¼æè
æ¯å¤©éæ°åæ¥çæ¶éæ¼ç§»ä¸º 17 ç§ãå³ä½¿ä¸åå·¥ä½æ£å¸¸ï¼æ¤æ¼ç§»ä¹ä¼éå¶å¯ä»¥è¾¾å°çæä½³å确度ã
* å¦æ计ç®æºçæ¶éä¸ NTP æå¡å¨çæ¶éå·®å«å¤ªå¤§ï¼å¯è½ä¼æç»åæ¥ï¼æè
æ¬å°æ¶éå°è¢«å¼ºå¶éç½®ã37ããä»»ä½è§å¯éç½®ååæ¶é´çåºç¨ç¨åºé½å¯è½ä¼çå°æ¶é´åéæçªç¶è·³è·ã
* å¦ææ个èç¹è¢« NTP æå¡å¨çé²ç«å¢æå¤é»å¡ï¼æå¯è½ä¼æç»ä¸æ®µæ¶é´é½æ²¡æ人ä¼æ³¨æå°ãæè¯æ®è¡¨æï¼è¿å¨å®è·µä¸ç¡®å®åçè¿ã
* NTP åæ¥åªè½åç½ç»å»¶è¿ä¸æ ·å¥½ï¼æ以å½ä½ å¨æ¥æå¯åæ°æ®å
延è¿çæ¥å¡ç½ç»ä¸æ¶ï¼NTP åæ¥çåç¡®æ§ä¼åå°éå¶ãä¸ä¸ªå®éªè¡¨æï¼å½éè¿äºèç½åæ¥æ¶ï¼35 毫ç§çæå°è¯¯å·®æ¯å¯ä»¥å®ç°çï¼å°½ç®¡å¶å°çç½ç»å»¶è¿å³°å¼ä¼å¯¼è´å¤§çº¦ä¸ç§ç误差ãæ ¹æ®é
ç½®ï¼è¾å¤§çç½ç»å»¶è¿ä¼å¯¼è´ NTP 客æ·ç«¯å®å
¨æ¾å¼ã
* ä¸äº NTP æå¡å¨æ¯é误çæè
é
ç½®é误çï¼æ¥åçæ¶é´å¯è½ç¸å·®å 个å°æ¶ã43,44ããè¿å¥½ NTP 客æ·ç«¯é常å¥å£®ï¼å 为ä»ä»¬ä¼æ¥è¯¢å¤ä¸ªæå¡å¨å¹¶å¿½ç¥å¼å¸¸å¼ãæ 论å¦ä½ï¼ä¾èµäºäºèç½ä¸çéç人æåè¯ä½ çæ¶é´æ¥ä¿è¯ä½ çç³»ç»çæ£ç¡®æ§ï¼è¿è¿æºè®©äººæ
忧çã
* é°ç§å¯¼è´ä¸åéå¯è½æ 59 ç§æ 61 ç§ï¼è¿ä¼æç ´ä¸äºå¨è®¾è®¡ä¹æ¶æªèèé°ç§çç³»ç»çæ¶åºå设ã45ããé°ç§å·²ç»ä½¿è®¸å¤å¤§åç³»ç»å´©æºçäºå®ã38,46ã说æäºï¼å
³äºæ¶éçé误å设æ¯å¤ä¹å®¹æå·å·æºå
¥ç³»ç»ä¸ãå¤çé°ç§çæä½³æ¹æ³å¯è½æ¯è®© NTP æå¡å¨ âæè°âï¼å¹¶å¨ä¸å¤©ä¸éæ¸æ§è¡é°ç§è°æ´ï¼è¿è¢«ç§°ä¸º **æå°¾**ï¼å³ smearingï¼ã47,48ãï¼è½ç¶å®é
ç NTP æå¡å¨è¡¨ç°åå¼ã49ãã
* å¨èææºä¸ï¼ç¡¬ä»¶æ¶é被èæåï¼è¿å¯¹äºéè¦ç²¾ç¡®è®¡æ¶çåºç¨ç¨åºæåºäºé¢å¤çææã50ããå½ä¸ä¸ª CPU æ ¸å¿å¨èææºä¹é´å
±äº«æ¶ï¼æ¯ä¸ªèææºé½ä¼æåå å毫ç§ï¼ä¸æ¤åæ¶å¦ä¸ä¸ªèææºæ£å¨è¿è¡ãä»åºç¨ç¨åºçè§åº¦æ¥çï¼è¿ç§å顿表ç°ä¸ºæ¶éçªç¶ååè·³è·ã26ãã
* å¦æä½ å¨æ²¡æå®æ´æ§å¶æç设å¤ï¼ä¾å¦ï¼ç§»å¨è®¾å¤æåµå
¥å¼è®¾å¤ï¼ä¸è¿è¡è½¯ä»¶ï¼åå¯è½å®å
¨ä¸è½ä¿¡ä»»è¯¥è®¾å¤ç硬件æ¶éãä¸äºç¨æ·æ
æå°å
¶ç¡¬ä»¶æ¶é设置为ä¸æ£ç¡®çæ¥æåæ¶é´ï¼ä¾å¦ï¼ä¸ºäºè§é¿æ¸¸æä¸çæ¶é´éå¶ï¼æ¶éå¯è½ä¼è¢«è®¾ç½®å°å¾è¿çè¿å»æå°æ¥ã
å¦æä½ è¶³å¤å¨ä¹è¿ä»¶äºå¹¶æå
¥å¤§éèµæºï¼å°±å¯ä»¥è¾¾å°é常好çæ¶é精度ãä¾å¦ï¼é对éèæºæç欧洲æ³è§èæ¡ MiFID II è¦æ±ææé«é¢ç交æåºéå¨ UTC æ¶é´ 100 å¾®ç§å
åæ¥æ¶éï¼ä»¥ä¾¿è°è¯ âéªå´©â çå¸åºå¼å¸¸ç°è±¡ï¼å¹¶å¸®å©æ£æµå¸åºæ纵ã51ãã
éè¿ GPS æ¥æ¶æºï¼ç²¾ç¡®æ¶é´åè®®ï¼PTPï¼ã52ã以åä»ç»çé¨ç½²åçæµå¯ä»¥å®ç°è¿ç§ç²¾ç¡®åº¦ãç¶èï¼è¿éè¦å¾å¤åªååä¸ä¸ç¥è¯ï¼èä¸æå¾å¤ä¸è¥¿é½ä¼å¯¼è´æ¶éåæ¥é误ãå¦æä½ ç NTP å®æ¤è¿ç¨é
ç½®é误ï¼æè
é²ç«å¢é»æ¢äº NTP éä¿¡ï¼ç±æ¼ç§»å¼èµ·çæ¶é误差å¯è½å¾å¿«å°±ä¼å大ã
### ä¾èµåæ¥æ¶é
æ¶éçé®é¢å¨äºï¼è½ç¶å®ä»¬çèµ·æ¥ç®åæç¨ï¼ä½å´å
·æ令人æ讶ç缺é·ï¼ä¸å¤©å¯è½ä¸ä¼æ精确ç 86,400 ç§ï¼**æ¥åæ¶é** å¯è½ä¼ååè·³è·ï¼èä¸ä¸ªèç¹ä¸çæ¶é´å¯è½ä¸å¦ä¸ä¸ªèç¹ä¸çæ¶é´å®å
¨ä¸åã
æ¬ç« æ©äºæ¶åï¼æ们讨论äºç½ç»ä¸¢å
åä»»æ延è¿å
çé®é¢ã尽管ç½ç»å¨å¤§å¤æ°æ
åµä¸è¡¨ç°è¯å¥½ï¼ä½è½¯ä»¶ç设计å¿
é¡»åå®ç½ç»å¶å°ä¼åºç°æ
éï¼è软件å¿
é¡»æ£å¸¸å¤çè¿äºæ
éãæ¶éä¹æ¯å¦æ¤ï¼å°½ç®¡å¤§å¤æ°æ¶é´é½å·¥ä½å¾å¾å¥½ï¼ä½éè¦åå¤å¥å£®ç软件æ¥å¤çä¸æ£ç¡®çæ¶éã
æä¸é¨åé®é¢æ¯ï¼ä¸æ£ç¡®çæ¶éå¾å®¹æ被è§èä¸è§ãå¦æä¸å°æºå¨ç CPU åºç°æ
éæè
ç½ç»é
ç½®é误ï¼å¾å¯è½æ ¹æ¬æ æ³å·¥ä½ï¼æ以å¾å¿«å°±ä¼è¢«æ³¨æåä¿®å¤ãå¦ä¸æ¹é¢ï¼å¦æå®çç³è±æ¶éæ缺é·ï¼æè
å®ç NTP 客æ·ç«¯é
ç½®é误ï¼å¤§é¨åäºæ
ä¼¼ä¹ä»ç¶å¯ä»¥æ£å¸¸å·¥ä½ï¼å³ä½¿å®çæ¶ééæ¸å离ç°å®ãå¦ææ个软件ä¾èµäºç²¾ç¡®åæ¥çæ¶éï¼é£ä¹ç»ææ´å¯è½æ¯ææ 声æ¯çï¼ä»
æå¾®éçæ°æ®ä¸¢å¤±ï¼èä¸æ¯ä¸æ¬¡æ天å¨å°çå´©æºã53,54ãã
å æ¤ï¼å¦æä½ ä½¿ç¨éè¦åæ¥æ¶éç软件ï¼å¿
é¡»ä»ç»çæ§æææºå¨ä¹é´çæ¶éå移ãæ¶éå离å
¶ä»æ¶é太è¿çèç¹åºå½è¢«å®£åæ»äº¡ï¼å¹¶ä»é群ä¸ç§»é¤ãè¿æ ·ççæ§å¯ä»¥ç¡®ä¿ä½ å¨æ失åçä¹å注æå°ç ´æçæ¶éã
#### æåºäºä»¶çæ¶é´æ³
让æ们èèä¸ä¸ªç¹å«çæ
åµï¼ä¸ä»¶å¾æ诱æä½ä¹å¾å±é©çäºæ
ï¼ä¾èµæ¶éï¼å¨å¤ä¸ªèç¹ä¸å¯¹äºä»¶è¿è¡æåºãä¾å¦ï¼å¦æ两个客æ·ç«¯åå
¥åå¸å¼æ°æ®åºï¼è°å
å°è¾¾ï¼ åªä¸ä¸ªæ´è¿ï¼
[å¾ 8-3](img/fig8-3.png) æ¾ç¤ºäºå¨å
·æå¤ä¸»å¤å¶çæ°æ®åºä¸å¯¹æ¶éçå±é©ä½¿ç¨ï¼è¯¥ä¾åç±»ä¼¼äº [å¾ 5-9](img/fig5-9.png)ï¼ã客æ·ç«¯ A å¨èç¹ 1 ä¸åå
¥ `x = 1`ï¼åå
¥è¢«å¤å¶å°èç¹ 3ï¼å®¢æ·ç«¯ B å¨èç¹ 3 ä¸å¢å xï¼æ们ç°å¨æ `x = 2`ï¼ï¼æåè¿ä¸¤ä¸ªåå
¥é½è¢«å¤å¶å°èç¹ 2ã
![](img/fig8-3.png)
**å¾ 8-3 客æ·ç«¯ B çåå
¥æ¯å®¢æ·ç«¯ A çåå
¥è¦æï¼ä½æ¯ B çåå
¥å
·æè¾æ©çæ¶é´æ³ã**
å¨ [å¾ 8-3](img/fig8-3.png) ä¸ï¼å½ä¸ä¸ªåå
¥è¢«å¤å¶å°å
¶ä»èç¹æ¶ï¼å®ä¼æ ¹æ®åçåå
¥çèç¹ä¸çæ¥åæ¶éæ è®°ä¸ä¸ªæ¶é´æ³ãå¨è¿ä¸ªä¾åä¸ï¼æ¶éåæ¥æ¯é常好çï¼èç¹ 1 åèç¹ 3 ä¹é´çåå·®å°äº 3msï¼è¿å¯è½æ¯ä½ å¨å®è·µä¸è½é¢æçæ´å¥½ã
尽管å¦æ¤ï¼[å¾ 8-3](img/fig8-3.png) ä¸çæ¶é´æ³å´æ æ³æ£ç¡®æåäºä»¶ï¼åå
¥ `x = 1` çæ¶é´æ³ä¸º 42.004 ç§ï¼ä½åå
¥ `x = 2` çæ¶é´æ³ä¸º 42.003 ç§ï¼å³ä½¿ `x = 2` å¨ç¨ååºç°ãå½èç¹ 2 æ¥æ¶å°è¿ä¸¤ä¸ªäºä»¶æ¶ï¼ä¼é误å°æ¨æåº `x = 1` æ¯æè¿çå¼ï¼è丢å¼åå
¥ `x = 2`ãææä¸è¡¨ç°ä¸ºï¼å®¢æ·ç«¯ B çå¢éæä½ä¼ä¸¢å¤±ã
è¿ç§å²çªè§£å³çç¥è¢«ç§°ä¸º **æååå
¥èå©ï¼LWWï¼**ï¼å®å¨å¤ä¸»å¤å¶åæ 主æ°æ®åºï¼å¦ Cassandra ã53ãå Riak ã54ãï¼ä¸è¢«å¹¿æ³ä½¿ç¨ï¼è¯·åé
â[æååå
¥èå©ï¼ä¸¢å¼å¹¶ååå
¥ï¼](ch5.md#æååå
¥èå©ï¼ä¸¢å¼å¹¶ååå
¥ï¼)â ä¸èï¼ãæäºå®ç°ä¼å¨å®¢æ·ç«¯èä¸æ¯æå¡å¨ä¸çææ¶é´æ³ï¼ä½è¿å¹¶ä¸è½æ¹å LWW çåºæ¬é®é¢ï¼
* æ°æ®åºåå
¥å¯è½ä¼ç¥ç§å°æ¶å¤±ï¼å
·ææ»åæ¶éçèç¹æ æ³è¦çä¹åå
·æå¿«éæ¶éçèç¹åå
¥çå¼ï¼ç´å°èç¹ä¹é´çæ¶éåå·®æ¶éã54,55ããæ¤æ¹æ¡å¯è½å¯¼è´ä¸å®æ°éçæ°æ®è¢«ææ丢å¼ï¼èæªååºç¨æ¥åä»»ä½é误ã
* LWW æ æ³åºå **é«é¢é¡ºåºåå
¥**ï¼å¨ [å¾ 8-3](img/fig8-3.png) ä¸ï¼å®¢æ·ç«¯ B çå¢éæä½ **ä¸å®** åçå¨å®¢æ·ç«¯ A çåå
¥ä¹åï¼å **çæ£å¹¶ååå
¥**ï¼åå
¥è
æè¯ä¸å°å
¶ä»åå
¥è
ï¼ãéè¦é¢å¤çå æå
³ç³»è·è¸ªæºå¶ï¼ä¾å¦çæ¬åéï¼ï¼ä»¥é²æ¢è¿èå æå
³ç³»ï¼è¯·åé
â[æ£æµå¹¶ååå
¥](ch5.md#æ£æµå¹¶ååå
¥)âï¼ã
* 两个èç¹å¾å¯è½ç¬ç«å°çæå
·æç¸åæ¶é´æ³çåå
¥ï¼ç¹å«æ¯å¨æ¶éä»
å
·æ毫ç§å辨ççæ
åµä¸ã为äºè§£å³è¿æ ·çå²çªï¼è¿éè¦ä¸ä¸ªé¢å¤ç **å³èå¼**ï¼tiebreakerï¼å¯ä»¥ç®åå°æ¯ä¸ä¸ªå¤§éæºæ°ï¼ï¼ä½è¿ç§æ¹æ³ä¹å¯è½ä¼å¯¼è´è¿èå æå
³ç³»ã53ãã
å æ¤ï¼å°½ç®¡éè¿ä¿ç âæè¿â çå¼å¹¶æ¾å¼å
¶ä»å¼æ¥è§£å³å²çªæ¯å¾è¯±æ人çï¼ä½æ¯è¦æ³¨æï¼âæè¿â çå®ä¹åå³äºæ¬å°ç **æ¥åæ¶é**ï¼è¿å¾å¯è½æ¯ä¸æ£ç¡®çãå³ä½¿ç¨ä¸¥æ ¼åæ¥ç NTP æ¶éï¼ä¸ä¸ªæ°æ®å
ä¹å¯è½å¨æ¶é´æ³ 100 毫ç§ï¼æ ¹æ®åéè
çæ¶éï¼æ¶åéï¼å¹¶å¨æ¶é´æ³ 99 毫ç§ï¼æ ¹æ®æ¥æ¶è
çæ¶éï¼å¤å°è¾¾ ââ çèµ·æ¥å¥½åæ°æ®å
å¨åéä¹åå·²ç»å°è¾¾ï¼è¿æ¯ä¸å¯è½çã
NTP åæ¥æ¯å¦è½è¶³å¤åç¡®ï¼ä»¥è³äºè¿ç§ä¸æ£ç¡®çæåºä¸ä¼åçï¼ä¹è®¸ä¸è½ï¼å 为 NTP çåæ¥ç²¾åº¦æ¬èº«ï¼é¤äºç³è±éæ¼ç§»è¿ç±»è¯¯å·®æºä¹å¤ï¼è¿åå°ç½ç»å¾è¿æ¶é´çéå¶ã为äºè¿è¡æ£ç¡®çæåºï¼ä½ éè¦ä¸ä¸ªæ¯æµé对象ï¼å³ç½ç»å»¶è¿ï¼è¦ç²¾ç¡®å¾å¤çæ¶éã
æè°ç **é»è¾æ¶éï¼logic clockï¼**ã56,57ãæ¯åºäºéå¢è®¡æ°å¨èä¸æ¯æ¯è¡ç³è±æ¶ä½ï¼å¯¹äºæåºäºä»¶æ¥è¯´æ¯æ´å®å
¨çéæ©ï¼è¯·åé
â[æ£æµå¹¶ååå
¥](ch5.md#æ£æµå¹¶ååå
¥)âï¼ãé»è¾æ¶éä¸æµéä¸å¤©ä¸çæ¶é´æç»è¿çç§æ°ï¼èä»
æµéäºä»¶çç¸å¯¹é¡ºåºï¼æ 论ä¸ä¸ªäºä»¶åçå¨å¦ä¸ä¸ªäºä»¶ä¹åè¿æ¯ä¹åï¼ãç¸åï¼ç¨æ¥æµéå®é
ç»è¿æ¶é´ç **æ¥åæ¶é** å **åè°é** ä¹è¢«ç§°ä¸º **ç©çæ¶éï¼physical clockï¼**ãæ们å°å¨ â[顺åºä¿è¯](ch9.md#顺åºä¿è¯)â ä¸æ¥ç顺åºé®é¢ã
#### æ¶é读æ°åå¨ç½®ä¿¡åºé´
ä½ å¯è½è½å¤ä»¥å¾®ç§æçè³çº³ç§ç精度读åæºå¨çæ¶éãä½å³ä½¿å¯ä»¥å¾å°å¦æ¤ç»è´çæµéç»æï¼è¿å¹¶ä¸æå³çè¿ä¸ªå¼å¯¹äºè¿æ ·ç精度å®é
ä¸æ¯åç¡®çãå®é
ä¸ï¼å¤§æ¦çæ¯ä¸åç¡®ç ââ å¦åæè¿°ï¼å³ä½¿ä½ æ¯åéä¸æ¬å°ç½ç»ä¸ç NTP æå¡å¨è¿è¡åæ¥ï¼å 毫ç§çæ¶é´æ¼ç§»ä¹å¾å®¹æå¨ä¸ç²¾ç¡®çç³è±æ¶éä¸åçã使ç¨å
Œ
±äºèç½ä¸ç NTP æå¡å¨ï¼æ好çå确度å¯è½è¾¾å°å å毫ç§ï¼èä¸å½ç½ç»æ¥å¡æ¶ï¼è¯¯å·®å¯è½ä¼è¶
è¿ 100 毫ç§ã57ãã
å æ¤ï¼å°æ¶é读æ°è§ä¸ºä¸ä¸ªæ¶é´ç¹æ¯æ²¡ææä¹ç ââ å®æ´åæ¯ä¸æ®µæ¶é´èå´ï¼ä¾å¦ï¼ä¸ä¸ªç³»ç»å¯è½ä»¥ 95% ç置信度认为å½åæ¶é´å¤äºæ¬åéå
ç第 10.3 ç§å 10.5 ç§ä¹é´ï¼å®å¯è½æ²¡æ³æ¯è¿æ´ç²¾ç¡®äºã58ããå¦ææ们åªç¥é ±100 毫ç§çæ¶é´ï¼é£ä¹æ¶é´æ³ä¸çå¾®ç§æ°åé¨ååºæ¬ä¸æ¯æ²¡ææä¹çã
ä¸ç¡®å®æ§çéå¯ä»¥æ ¹æ®ä½ çæ¶é´æºæ¥è®¡ç®ãå¦æä½ ç GPS æ¥æ¶å¨æååï¼é¯ï¼æ¶éç´æ¥è¿æ¥å°ä½ ç计ç®æºä¸ï¼é¢æçé误èå´ç±å¶é ååç¥ãå¦æä»æå¡å¨è·å¾æ¶é´ï¼åä¸ç¡®å®æ§åå³äºèªä¸æ¬¡ä¸æå¡å¨åæ¥ä»¥æ¥çç³è±éæ¼ç§»çææå¼ï¼å ä¸ NTP æå¡å¨çä¸ç¡®å®æ§ï¼åå ä¸å°æå¡å¨çç½ç»å¾è¿æ¶é´ï¼åªæ¯è·åç²ç¥è¿ä¼¼å¼ï¼å¹¶å设æå¡å¨æ¯å¯ä¿¡çï¼ã
ä¸å¹¸çæ¯ï¼å¤§å¤æ°ç³»ç»ä¸å
¬å¼è¿ç§ä¸ç¡®å®æ§ï¼ä¾å¦ï¼å½è°ç¨ `clock_gettime()` æ¶ï¼è¿åå¼ä¸ä¼åè¯ä½ æ¶é´æ³çé¢æé误ï¼æä»¥ä½ ä¸ç¥éå
¶ç½®ä¿¡åºé´æ¯ 5 毫ç§è¿æ¯ 5 å¹´ã
ä¸ä¸ªæ趣çä¾å¤æ¯ Spanner ä¸ç Google TrueTime API ã41ãï¼å®æç¡®å°æ¥åäºæ¬å°æ¶éç置信åºé´ãå½ä½ 询é®å½åæ¶é´æ¶ï¼ä½ ä¼å¾å°ä¸¤ä¸ªå¼ï¼[ææ©ï¼ææ]ï¼è¿æ¯ææ©å¯è½çæ¶é´æ³åææå¯è½çæ¶é´æ³ãå¨ä¸ç¡®å®æ§ä¼°è®¡çåºç¡ä¸ï¼æ¶éç¥éå½åçå®é
æ¶é´è½å¨è¯¥åºé´å
ãåºé´ç宽度åå³äºèªä»æ¬å°ç³è±éæåä¸æ´ç²¾ç¡®çæ¶éæºåæ¥ä»¥æ¥å·²ç»è¿äºå¤é¿æ¶é´ã
#### å
¨å±å¿«ç
§çåæ¥æ¶é
å¨ â[å¿«ç
§é离åå¯éå¤è¯»](ch7.md#å¿«ç
§é离åå¯éå¤è¯»)â ä¸ï¼æ们讨论äºå¿«ç
§é离ï¼è¿æ¯æ°æ®åºä¸é常æç¨çåè½ï¼éè¦æ¯æå°åå¿«é读åäºå¡å大åé¿æ¶é´è¿è¡çåªè¯»äºå¡ï¼ç¨äºå¤ä»½æåæï¼ãå®å
许åªè¯»äºå¡çå°ç¹å®æ¶é´ç¹çå¤äºä¸è´ç¶æçæ°æ®åºï¼ä¸ä¸ä¼éå®åå¹²æ°è¯»åäºå¡ã
å¿«ç
§é离æ常è§çå®ç°éè¦åè°éå¢çäºå¡ IDãå¦æåå
¥æ¯å¿«ç
§æï¼å³ï¼åå
¥å
·ææ¯å¿«ç
§æ´å¤§çäºå¡ IDï¼ï¼å该åå
¥å¯¹äºå¿«ç
§äºå¡æ¯ä¸å¯è§çãå¨åèç¹æ°æ®åºä¸ï¼ä¸ä¸ªç®åç计æ°å¨å°±è¶³ä»¥çæäºå¡ IDã
ä½æ¯å½æ°æ®åºåå¸å¨è®¸å¤æºå¨ä¸ï¼ä¹è®¸å¯è½å¨å¤ä¸ªæ°æ®ä¸å¿ä¸æ¶ï¼ç±äºéè¦åè°ï¼ï¼è·¨ææååºï¼å
¨å±åè°éå¢çäºå¡ ID ä¼å¾é¾çæãäºå¡ ID å¿
é¡»åæ å æå
³ç³»ï¼å¦æäºå¡ B 读åç±äºå¡ A åå
¥çå¼ï¼å B å¿
é¡»å
·ææ¯ A æ´å¤§çäºå¡ IDï¼å¦åå¿«ç
§å°±æ æ³ä¿æä¸è´ãå¨æ大éçå°è§æ¨¡ãé«é¢ççäºå¡æ
æ¯ä¸ï¼å¨åå¸å¼ç³»ç»ä¸å建äºå¡ ID æ为ä¸ä¸ªé¾ä»¥å¤ççç¶é¢ [^vi]ã
[^vi]: åå¨åå¸å¼åºåå·çæå¨ï¼ä¾å¦ Twitter çéªè±ï¼Snowflakeï¼ï¼å
¶ä»¥å¯ä¼¸ç¼©çæ¹å¼ï¼ä¾å¦ï¼éè¿å° ID 空é´çååé
ç»ä¸åèç¹ï¼è¿ä¼¼åè°å°å¢å å¯ä¸ IDãä½æ¯ï¼å®ä»¬é常æ æ³ä¿è¯ä¸å æå
³ç³»ä¸è´çæåºï¼å 为åé
ç ID åçæ¶é´èå´æ¯æ°æ®åºè¯»åååå
¥çæ¶é´èå´è¦é¿ãå¦è¯·åé
â[顺åºä¿è¯](ch9.md#顺åºä¿è¯)âã
æ们å¯ä»¥ä½¿ç¨åæ¥æ¶éçæ¶é´æ³ä½ä¸ºäºå¡ ID åï¼å¦ææ们è½å¤è·å¾è¶³å¤å¥½çåæ¥æ§ï¼é£ä¹è¿ç§æ¹æ³å°å
·æå¾åéçå±æ§ï¼æ´æçäºå¡ä¼ææ´å¤§çæ¶é´æ³ãå½ç¶ï¼é®é¢å¨äºæ¶é精度çä¸ç¡®å®æ§ã
Spanner 以è¿ç§æ¹å¼å®ç°è·¨æ°æ®ä¸å¿çå¿«ç
§é离ã59ï¼60ããå®ä½¿ç¨ TrueTime API æ¥åçæ¶é置信åºé´ï¼å¹¶åºäºä»¥ä¸è§å¯ç»æï¼å¦æä½ æ两个置信åºé´ï¼æ¯ä¸ªç½®ä¿¡åºé´å
å«ææ©åææå¯è½çæ¶é´æ³ï¼$A = [A_{earliest}, A_{latest}]$ï¼$B=[B_{earliest}, B_{latest}]$ï¼ï¼è¿ä¸¤ä¸ªåºé´ä¸éå ï¼å³ï¼$A_{earliest} #### å®æ¶æ¯ççåï¼
>
> å¨åµå
¥å¼ç³»ç»ä¸ï¼å®æ¶æ¯æç³»ç»ç»è¿ç²¾å¿è®¾è®¡åæµè¯ï¼ä»¥æ»¡è¶³æææ
åµä¸çç¹å®æ¶é´ä¿è¯ãè¿ä¸ªå«ä¹ä¸ Web ä¸å¯¹å®æ¶æ¯è¯ç模ç³ä½¿ç¨ç¸åï¼åè
æè¿°äºæå¡å¨å°æ°æ®æ¨éå°å®¢æ·ç«¯ä»¥å没æä¸¥æ ¼çååºæ¶é´éå¶çæµå¤çï¼è§ [第åä¸ç« ](ch11.md)ï¼ã
ä¾å¦ï¼å¦æè½¦è½½ä¼ æå¨æ£æµå°å½åæ£å¨ç»å碰æï¼ä½ è¯å®ä¸å¸æå®å
¨æ°åéæ¾ç³»ç»å 为 GC æåè延è¿å¼¹åºã
å¨ç³»ç»ä¸æä¾ **å®æ¶ä¿è¯** éè¦å级软件æ çæ¯æï¼ä¸ä¸ªå®æ¶æä½ç³»ç»ï¼RTOSï¼ï¼å
许å¨æå®çæ¶é´é´éå
ä¿è¯ CPU æ¶é´çåé
ãåºå½æ°å¿
é¡»ç³ææåæ
åµä¸çæ§è¡æ¶é´ï¼å¨æå
ååé
å¯è½åå°éå¶æå®å
¨ä¸å
许ï¼å®æ¶åå¾æ¶éå¨åå¨ï¼ä½æ¯åºç¨ç¨åºä»ç¶å¿
须确ä¿å®ä¸ä¼ç» GC 太å¤çè´æ
ï¼ï¼å¿
é¡»è¿è¡å¤§éçæµè¯åæµéï¼ä»¥ç¡®ä¿è¾¾å°ä¿è¯ã
ææè¿äºé½éè¦å¤§éé¢å¤çå·¥ä½ï¼ä¸¥ééå¶äºå¯ä»¥ä½¿ç¨çç¼ç¨è¯è¨ãåºåå·¥å
·çèå´ï¼å 为大å¤æ°è¯è¨åå·¥å
·ä¸æä¾å®æ¶ä¿è¯ï¼ãç±äºè¿äºåå ï¼å¼åå®æ¶ç³»ç»é常æè´µï¼å¹¶ä¸å®ä»¬é常ç¨äºå®å
¨å
³é®çåµå
¥å¼è®¾å¤ãèä¸ï¼â**å®æ¶**â ä¸ â**é«æ§è½**â ä¸ä¸æ · ââ äºå®ä¸ï¼å®æ¶ç³»ç»å¯è½å
·æè¾ä½çååéï¼å 为ä»ä»¬å¿
须让åæ¶ååºçä¼å
级é«äºä¸åï¼å¦è¯·åé
â[延è¿åèµæºå©ç¨](#延è¿åèµæºå©ç¨)âï¼ã
对äºå¤§å¤æ°æå¡å¨ç«¯æ°æ®å¤çç³»ç»æ¥è¯´ï¼å®æ¶ä¿è¯æ¯ä¸ç»æµæä¸åéçãå æ¤ï¼è¿äºç³»ç»å¿
é¡»æ¿åå¨éå®æ¶ç¯å¢ä¸è¿è¡çæååæ¶éä¸ç¨³å®æ§ã
#### éå¶åå¾æ¶éçå½±å
è¿ç¨æåçè´é¢å½±åå¯ä»¥å¨ä¸è¯è¯¸æè´µçå®æ¶è°åº¦ä¿è¯çæ
åµä¸å¾å°ç¼è§£ãè¯è¨è¿è¡æ¶å¨è®¡ååå¾åæ¶æ¶å
·æä¸å®ççµæ´»æ§ï¼å 为å®ä»¬å¯ä»¥è·è¸ªå¯¹è±¡åé
çé度åéçæ¶é´çæ¨ç§»å©ä½ç空é²å
åã
ä¸ä¸ªæ°å
´çæ³æ³æ¯å° GC æåè§ä¸ºä¸ä¸ªèç¹ççæ计åä¸æï¼å¹¶å¨è¿ä¸ªèç¹æ¶éå
¶åå¾çåæ¶ï¼è®©å
¶ä»èç¹å¤çæ¥èªå®¢æ·ç«¯ç请æ±ãå¦æè¿è¡æ¶å¯ä»¥è¦ååºç¨ç¨åºä¸ä¸ªèç¹å¾å¿«éè¦ GC æåï¼é£ä¹åºç¨ç¨åºå¯ä»¥åæ¢å该èç¹åéæ°ç请æ±ï¼çå¾
å®å®æå¤çæªå®æç请æ±ï¼ç¶åå¨æ²¡æ请æ±æ£å¨è¿è¡æ¶æ§è¡ GCãè¿ä¸ªæå·§å客æ·ç«¯éèäº GC æåï¼å¹¶éä½äºååºæ¶é´çé«ç¾åæ¯ã70,71ããä¸äºå¯¹å»¶è¿ææçéè交æç³»ç»ã72ã使ç¨è¿ç§æ¹æ³ã
è¿ä¸ªæ³æ³çä¸ä¸ªåç§æ¯åªç¨åå¾æ¶éå¨æ¥å¤ççå½å¯¹è±¡ï¼è¿äºå¯¹è±¡å¯ä»¥å¿«éæ¶éï¼ï¼å¹¶å®æå¨ç§¯ç´¯å¤§éé¿å¯¿å¯¹è±¡ï¼å æ¤éè¦å®æ´ GCï¼ä¹åéæ°å¯å¨è¿ç¨ã65,73ããä¸æ¬¡å¯ä»¥éæ°å¯å¨ä¸ä¸ªèç¹ï¼å¨è®¡åéæ°å¯å¨ä¹åï¼æµéå¯ä»¥ä»è¯¥èç¹ç§»å¼ï¼å°±å [第åç« ](ch4.md) éæè¿°çæ»å¨å级ä¸æ ·ã
è¿äºæªæ½ä¸è½å®å
¨é»æ¢åå¾åæ¶æåï¼ä½å¯ä»¥ææå°åå°å®ä»¬å¯¹åºç¨çå½±åã
## ç¥è¯ãçç¸ä¸è°è¨
æ¬ç« å°ç®å为æ¢ï¼æ们已ç»æ¢ç´¢äºåå¸å¼ç³»ç»ä¸è¿è¡å¨åå°è®¡ç®æºä¸çç¨åºçä¸åä¹å¤ï¼æ²¡æå
±äº«å
åï¼åªæéè¿å¯å延è¿çä¸å¯é ç½ç»ä¼ éçæ¶æ¯ï¼ç³»ç»å¯è½éåé¨å失æï¼ä¸å¯é çæ¶éåå¤çæåã
å¦æä½ ä¸ä¹ æ¯äºåå¸å¼ç³»ç»ï¼é£ä¹è¿äºé®é¢çåæå°±ä¼è®©äººè¿·æä¸è§£ãç½ç»ä¸çä¸ä¸ªèç¹æ æ³ç¡®åå°ç¥éä»»ä½äºæ
ââ å®åªè½æ ¹æ®å®éè¿ç½ç»æ¥æ¶å°ï¼æ没ææ¥æ¶å°ï¼çæ¶æ¯è¿è¡çæµãèç¹åªè½éè¿äº¤æ¢æ¶æ¯æ¥æ¾åºå¦ä¸ä¸ªèç¹æå¤çç¶æï¼åå¨äºåªäºæ°æ®ï¼æ¯å¦æ£ç¡®è¿è¡ççï¼ãå¦æè¿ç¨èç¹æ²¡æååºï¼åæ æ³ç¥éå®å¤äºä»ä¹ç¶æï¼å 为ç½ç»ä¸çé®é¢ä¸è½å¯é å°ä¸èç¹ä¸çé®é¢åºåå¼æ¥ã
è¿äºç³»ç»ç讨论ä¸å²å¦æå
³ï¼å¨ç³»ç»ä¸ä»ä¹æ¯çä»ä¹æ¯åï¼å¦ææç¥åæµéçæºå¶é½æ¯ä¸å¯é çï¼é£ä¹å
³äºè¿äºç¥è¯æ们åè½å¤ä¹ç¡®å®å¢ï¼è½¯ä»¶ç³»ç»åºè¯¥éµå¾ªæ们对ç©çä¸çæææçæ³åï¼å¦å æå
³ç³»åï¼
幸è¿çæ¯ï¼æ们ä¸éè¦å»ææ¸
æ¥çå½çæä¹ãå¨åå¸å¼ç³»ç»ä¸ï¼æ们å¯ä»¥éè¿°å
³äºè¡ä¸ºï¼ç³»ç»æ¨¡åï¼çå设ï¼å¹¶ä»¥æ»¡è¶³è¿äºå设çæ¹å¼è®¾è®¡å®é
ç³»ç»ãç®æ³å¯ä»¥è¢«è¯æå¨æ个系ç»æ¨¡åä¸æ£ç¡®è¿è¡ãè¿æå³çå³ä½¿åºå±ç³»ç»æ¨¡åæä¾äºå¾å°çä¿è¯ï¼ä¹å¯ä»¥å®ç°å¯é çè¡ä¸ºã
ä½æ¯ï¼å°½ç®¡å¯ä»¥ä½¿è½¯ä»¶å¨ä¸å¯é çç³»ç»æ¨¡åä¸è¡¨ç°è¯å¥½ï¼ä½è¿å¹¶ä¸æ¯å¯ä»¥ç´æªäºå½å®ç°çãå¨æ¬ç« çå
¶ä½é¨åä¸ï¼æ们å°è¿ä¸æ¥æ¢è®¨åå¸å¼ç³»ç»ä¸çç¥è¯åçç¸çæ¦å¿µï¼è¿å°æå©äºæ们æèæ们å¯ä»¥ååºçåç§å设以åæ们å¯è½å¸ææä¾çä¿è¯ãå¨ [第ä¹ç« ](ch9.md) ä¸ï¼æ们å°çç¼äºåå¸å¼ç³»ç»çä¸äºä¾åï¼è¿äºç®æ³å¨ç¹å®çå设æ¡ä»¶ä¸æä¾äºç¹å®çä¿è¯ã
### çç¸ç±å¤æ°æå®ä¹
设æ³ä¸ä¸ªå
·æä¸å¯¹ç§°æ
éçç½ç»ï¼ä¸ä¸ªèç¹è½å¤æ¥æ¶åéç»å®çæææ¶æ¯ï¼ä½æ¯æ¥èªè¯¥èç¹çä»»ä½ä¼ åºæ¶æ¯è¢«ä¸¢å¼æ延è¿ã19ããå³ä½¿è¯¥èç¹è¿è¡è¯å¥½ï¼å¹¶ä¸æ£å¨æ¥æ¶æ¥èªå
¶ä»èç¹ç请æ±ï¼å
¶ä»èç¹ä¹æ æ³å¬å°å
¶ååºãç»è¿ä¸æ®µæ¶é´åï¼å
¶ä»èç¹å®£å¸å®å·²ç»æ»äº¡ï¼å 为ä»ä»¬æ²¡æå¬å°èç¹çæ¶æ¯ãè¿ç§æ
åµå°±å梦éä¸æ ·ï¼**åæå¼ï¼semi-disconnectedï¼** çèç¹è¢«æåå¢å°ï¼æ²æå°å«é âæ没æ»ï¼â ââ ä½æ¯ç±äºæ²¡æ人è½å¬å°å®çå°å«ï¼è¬ç¤¼éä¼ç»§ç»ä»¥åå¿çå³å¿ç»§ç»è¡è¿ã
å¨ä¸ä¸ªç¨å¾®ä¸é£ä¹æ¢¦éçåºæ¯ä¸ï¼åæå¼çèç¹å¯è½ä¼æ³¨æå°å®åéçæ¶æ¯æ²¡æ被å
¶ä»èç¹ç¡®è®¤ï¼å æ¤æè¯å°ç½ç»ä¸å¿
å®åå¨æ
éã尽管å¦æ¤ï¼èç¹è¢«å
¶ä»èç¹é误å°å®£å为æ»äº¡ï¼èåè¿æ¥çèç¹å¯¹æ¤æ è½ä¸ºåã
第ä¸ç§æ
åµï¼æ³è±¡ä¸ä¸ªæ£å¨ç»åé¿æ¶é´ **åå¾æ¶éæåï¼stop-the-world GC Pauseï¼** çèç¹ï¼èç¹çææ线ç¨è¢« GC æ¢å 并æåä¸åéï¼å æ¤æ²¡æ请æ±è¢«å¤çï¼ä¹æ²¡æååºè¢«åéãå
¶ä»èç¹çå¾
ï¼éè¯ï¼ä¸èç¦ï¼å¹¶æç»å®£å¸èç¹æ»äº¡ï¼å¹¶å°å
¶ä¸¢å°çµè½¦ä¸ãæåï¼GC å®æï¼èç¹ç线ç¨ç»§ç»ï¼å¥½åä»ä¹ä¹æ²¡æåçãå
¶ä»èç¹æå°æ讶ï¼å 为æè°çæ»äº¡èç¹çªç¶ä»æ£ºæä¸æ¬èµ·å¤´æ¥ï¼èº«ä½å¥åº·ï¼å¼å§åæè§è
é«å
´å°è天ãGC åçèç¹æåçè³æ²¡ææè¯å°å·²ç»ç»è¿äºæ´æ´ä¸åéï¼èä¸èªå·±å·²è¢«å®£åæ»äº¡ãä»å®èªå·±çè§åº¦æ¥çï¼ä»æåä¸æ¬¡ä¸å
¶ä»èç¹äº¤è°ä»¥æ¥ï¼å ä¹æ²¡æç»è¿ä»»ä½æ¶é´ã
è¿äºæ
äºçå¯ææ¯ï¼èç¹ä¸ä¸å®è½ç¸ä¿¡èªå·±å¯¹äºæ
åµçå¤æãåå¸å¼ç³»ç»ä¸è½å®å
¨ä¾èµå个èç¹ï¼å 为èç¹å¯è½éæ¶å¤±æï¼å¯è½ä¼ä½¿ç³»ç»å¡æ»ï¼æ æ³æ¢å¤ãç¸åï¼è®¸å¤åå¸å¼ç®æ³é½ä¾èµäºæ³å®äººæ°ï¼å³å¨èç¹ä¹é´è¿è¡æ票ï¼è¯·åé
â[读åçæ³å®äººæ°](ch5.md#读åçæ³å®äººæ°)âï¼ï¼å³çéè¦æ¥èªå¤ä¸ªèç¹çæå°æ票æ°ï¼ä»¥åå°å¯¹äºæ个ç¹å®èç¹çä¾èµã
è¿ä¹å
æ¬å
³äºå®£åèç¹æ»äº¡çå³å®ãå¦ææ³å®æ°éçèç¹å®£åå¦ä¸ä¸ªèç¹å·²ç»æ»äº¡ï¼é£ä¹å³ä½¿è¯¥èç¹ä»æè§èªå·±æ´»çï¼å®ä¹å¿
须被认为æ¯æ»çã个ä½èç¹å¿
é¡»éµå®æ³å®å³å®å¹¶ä¸å°ã
æ常è§çæ³å®äººæ°æ¯è¶
è¿ä¸åçç»å¯¹å¤æ°ï¼å°½ç®¡å
¶ä»ç±»åçæ³å®äººæ°ä¹æ¯å¯è½çï¼ãå¤æ°æ³å®äººæ°å
许系ç»ç»§ç»å·¥ä½ï¼å¦æå个èç¹åçæ
éï¼ä¸ä¸ªèç¹å¯ä»¥å®¹å¿åèç¹æ
éï¼äºä¸ªèç¹å¯ä»¥å®¹å¿åèç¹æ
éï¼ãç³»ç»ä»ç¶æ¯å®å
¨çï¼å 为å¨è¿ä¸ªå¶åº¦ä¸åªè½æä¸ä¸ªå¤æ° ââ ä¸è½åæ¶åå¨ä¸¤ä¸ªç¸äºå²çªçå¤æ°å³å®ãå½æä»¬å¨ [第ä¹ç« ](ch9.md) ä¸è®¨è®º **å
±è¯ç®æ³ï¼consensus algorithmsï¼** æ¶ï¼æ们å°æ´è¯¦ç»å°è®¨è®ºæ³å®äººæ°çåºç¨ã
#### é¢å¯¼è
åé
é常æ
åµä¸ï¼ä¸äºä¸è¥¿å¨ä¸ä¸ªç³»ç»ä¸åªè½æä¸ä¸ªãä¾å¦ï¼
* æ°æ®åºååºçé¢å¯¼è
åªè½æä¸ä¸ªèç¹ï¼ä»¥é¿å
**èè£**ï¼å³ split brainï¼è¯·åé
â[å¤çèç¹å®æº](ch5.md#å¤çèç¹å®æº)âï¼ã
* ç¹å®èµæºçéæ对象åªå
许ä¸ä¸ªäºå¡ / 客æ·ç«¯ææï¼ä»¥é²åæ¶åå
¥åæåã
* ä¸ä¸ªç¹å®çç¨æ·ååªè½è¢«ä¸ä¸ªç¨æ·æ注åï¼å 为ç¨æ·åå¿
é¡»å¯ä¸æ è¯ä¸ä¸ªç¨æ·ã
å¨åå¸å¼ç³»ç»ä¸å®ç°è¿ä¸ç¹éè¦æ³¨æï¼å³ä½¿ä¸ä¸ªèç¹è®¤ä¸ºå®æ¯ â**天éè
ï¼the choosen oneï¼**âï¼ååºçè´è´£äººï¼éçææè
ï¼æåè·åç¨æ·åçç¨æ·ç请æ±å¤çç¨åºï¼ï¼ä½è¿å¹¶ä¸ä¸å®æå³çææ³å®äººæ°çèç¹åæï¼ä¸ä¸ªèç¹å¯è½ä»¥åæ¯é¢å¯¼è
ï¼ä½æ¯å¦æå
¶ä»èç¹å¨æ¤æé´å®£å¸å®æ»äº¡ï¼ä¾å¦ï¼ç±äºç½ç»ä¸ææ GC æåï¼ï¼åå®å¯è½å·²è¢«é级ï¼ä¸å¦ä¸ä¸ªé¢å¯¼è
å¯è½å·²ç»å½éã
å¦æä¸ä¸ªèç¹ç»§ç»è¡¨ç°ä¸º **天éè
**ï¼å³ä½¿å¤§å¤æ°èç¹å·²ç»å£°æå®å·²ç»æ»äºï¼åå¨èèä¸å¨çç³»ç»ä¸å¯è½ä¼å¯¼è´é®é¢ãè¿æ ·çèç¹è½ä»¥èªå·±èµäºçæè½åå
¶ä»èç¹åéæ¶æ¯ï¼å¦æå
¶ä»èç¹ç¸ä¿¡ï¼æ´ä¸ªç³»ç»å¯è½ä¼åä¸äºä¸æ£ç¡®çäºæ
ã
ä¾å¦ï¼[å¾ 8-4](img/fig8-4.png) æ¾ç¤ºäºç±äºä¸æ£ç¡®çéå®ç°å¯¼è´çæ°æ®æåé误ãï¼è¿ä¸ªé误ä¸ä»
ä»
æ¯ç论ä¸çï¼HBase æ¾ç»æè¿ä¸ªé®é¢ã74,75ãï¼åè®¾ä½ è¦ç¡®ä¿ä¸ä¸ªåå¨æå¡ä¸çæ件ä¸æ¬¡åªè½è¢«ä¸ä¸ªå®¢æ·è®¿é®ï¼å 为å¦æå¤ä¸ªå®¢æ·è¯å¾å¯¹æ¤åå
¥ï¼è¯¥æ件å°è¢«æåãä½ å°è¯éè¿å¨è®¿é®æ件ä¹åè¦æ±å®¢æ·ç«¯ä»éå®æå¡è·åç§çº¦æ¥å®ç°æ¤ç®çã
![](img/fig8-4.png)
**å¾ 8-4 åå¸å¼éçå®ç°ä¸æ£ç¡®ï¼å®¢æ·ç«¯ 1 认为å®ä»ç¶å
·æææçç§çº¦ï¼å³ä½¿å®å·²ç»è¿æï¼ä»èç ´åäºåå¨ä¸çæ件**
è¿ä¸ªé®é¢å°±æ¯æ们å
åå¨ â[è¿ç¨æå](#è¿ç¨æå)â ä¸è®¨è®ºè¿çä¸ä¸ªä¾åï¼å¦æææç§çº¦ç客æ·ç«¯æå太ä¹
ï¼å®çç§çº¦å°å°æãå¦ä¸ä¸ªå®¢æ·ç«¯å¯ä»¥è·å¾åä¸æ件çç§çº¦ï¼å¹¶å¼å§åå
¥æ件ãå½æåç客æ·ç«¯åæ¥æ¶ï¼å®è®¤ä¸ºï¼ä¸æ£ç¡®ï¼å®ä»ç¶æä¸ä¸ªææçç§çº¦ï¼å¹¶ç»§ç»åå
¥æ件ãç»æï¼å®¢æ·çåå
¥å°äº§çå²çªå¹¶æåæ件ã
#### é²æ¤ä»¤ç
å½ä½¿ç¨éæç§çº¦æ¥ä¿æ¤å¯¹æäºèµæºï¼å¦ [å¾ 8-4](img/fig8-4.png) ä¸çæ件åå¨ï¼ç访é®æ¶ï¼éè¦ç¡®ä¿ä¸ä¸ªè¢«è¯¯è®¤ä¸ºèªå·±æ¯ â天éè
â çèç¹ä¸è½æ°ä¹±ç³»ç»çå
¶å®é¨åãå®ç°è¿ä¸ç®æ çä¸ä¸ªç¸å½ç®åçææ¯å°±æ¯ **é²æ¤ï¼fencingï¼**ï¼å¦ [å¾ 8-5](img/fig8-5.png) æ示
![](img/fig8-5.png)
**å¾ 8-5 åªå
许以å¢å é²æ¤ä»¤çç顺åºè¿è¡åæä½ï¼ä»èä¿è¯åå¨å®å
¨**
æ们å设æ¯æ¬¡éå®æå¡å¨æäºéæç§çº¦æ¶ï¼å®è¿ä¼è¿åä¸ä¸ª **é²æ¤ä»¤çï¼fencing tokenï¼**ï¼è¿ä¸ªæ°åå¨æ¯æ¬¡æäºéå®æ¶é½ä¼å¢å ï¼ä¾å¦ï¼ç±éå®æå¡å¢å ï¼ãç¶åï¼æ们å¯ä»¥è¦æ±å®¢æ·ç«¯æ¯æ¬¡ååå¨æå¡åéåå
¥è¯·æ±æ¶ï¼é½å¿
é¡»å
å«å½åçé²æ¤ä»¤çã
å¨ [å¾ 8-5](img/fig8-5.png) ä¸ï¼å®¢æ·ç«¯ 1 以 33 ç令çè·å¾ç§çº¦ï¼ä½éåè¿å
¥ä¸ä¸ªé¿æ¶é´çå顿并ä¸ç§çº¦å°æã客æ·ç«¯ 2 以 34 ç令çï¼è¯¥æ°åæ»æ¯å¢å ï¼è·åç§çº¦ï¼ç¶åå°å
¶åå
¥è¯·æ±åéå°åå¨æå¡ï¼å
æ¬ 34 ç令çãç¨åï¼å®¢æ·ç«¯ 1 æ¢å¤çæºå¹¶å°å
¶åå
¥åå¨æå¡ï¼å
æ¬å
¶ä»¤çå¼ 33ãä½æ¯ï¼åå¨æå¡å¨ä¼è®°ä½å®å·²ç»å¤çäºä¸ä¸ªå
·ææ´é«ä»¤çç¼å·ï¼34ï¼çåå
¥ï¼å æ¤å®ä¼æç»å¸¦æ令ç 33 ç请æ±ã
å¦æå° ZooKeeper ç¨ä½éå®æå¡ï¼åå¯å°äºå¡æ è¯ `zxid` æèç¹çæ¬ `cversion` ç¨ä½é²æ¤ä»¤çãç±äºå®ä»¬ä¿è¯åè°éå¢ï¼å æ¤å®ä»¬å
·ææéçå±æ§ã74ãã
请注æï¼è¿ç§æºå¶è¦æ±èµæºæ¬èº«å¨æ£æ¥ä»¤çæ¹é¢åæ¥ç§¯æä½ç¨ï¼éè¿æç»ä½¿ç¨æ§ç令çï¼èä¸æ¯å·²ç»è¢«å¤çç令çæ¥è¿è¡åæä½ ââ ä»
ä»
ä¾é 客æ·ç«¯æ£æ¥èªå·±çéç¶ææ¯ä¸å¤çã对äºä¸æç¡®æ¯æé²æ¤ä»¤ççèµæºï¼å¯è½ä»ç¶å¯ä»¥è§£å³æ¤éå¶ï¼ä¾å¦ï¼å¨æ件åå¨æå¡çæ
åµä¸ï¼å¯ä»¥å°é²æ¤ä»¤çå
å«å¨æ件åä¸ï¼ãä½æ¯ï¼ä¸ºäºé¿å
å¨éçä¿æ¤ä¹å¤å¤ç请æ±ï¼éè¦è¿è¡æç§æ£æ¥ã
å¨æå¡å¨ç«¯æ£æ¥ä¸ä¸ªä»¤çå¯è½çèµ·æ¥åæ¯ä¸ä¸ªç¼ºç¹ï¼ä½è¿å¯ä»¥è¯´æ¯ä¸ä»¶å¥½äºï¼ä¸ä¸ªæå¡åå®å®ç客æ·æ»æ¯å®è§ç©å¹¶ä¸ææºï¼å 为使ç¨å®¢æ·ç«¯ç人ä¸è¿è¡æå¡ç人ä¼å
级é常ä¸ä¸æ ·ã76ããå æ¤ï¼ä»»ä½æå¡ä¿æ¤èªå·±å
åæå¤å®¢æ·ç滥ç¨æ¯ä¸ä¸ªå¥½ä¸»æã
### æå åºæ
é
é²æ¤ä»¤çå¯ä»¥æ£æµåé»æ¢æ æä¸åçé误çèç¹ï¼ä¾å¦ï¼å 为å®å°æªåç°å
¶ç§çº¦å·²è¿æï¼ãä½æ¯ï¼å¦æèç¹ææç ´åç³»ç»çä¿è¯ï¼åå¯ä»¥éè¿ä½¿ç¨åé²æ¤ä»¤çåéæ¶æ¯æ¥è½»æ¾å®ææ¤æä½ã
å¨æ¬ä¹¦ä¸ï¼æ们å设èç¹æ¯ä¸å¯é ä½è¯å®çï¼å®ä»¬å¯è½å¾æ
¢æè
ä»ä¸ååºï¼ç±äºæ
éï¼ï¼å¹¶ä¸å®ä»¬çç¶æå¯è½å·²ç»è¿æ¶ï¼ç±äº GC æåæç½ç»å»¶è¿ï¼ï¼ä½æ¯æ们å设å¦æèç¹å®ååºäºååºï¼å®æ£å¨è¯´åº âçç¸âï¼å°½å
¶æç¥ï¼å®æ£å¨æç
§åè®®çè§åæ®æ¼å
¶è§è²ã
å¦æåå¨èç¹å¯è½ âæè°âï¼åéä»»æé误ææåçååºï¼çé£é©ï¼ååå¸å¼ç³»ç»çé®é¢åå¾æ´å°é¾äº ââ ä¾å¦ï¼å¦æèç¹å¯è½å£°ç§°å
¶å®é
ä¸æ²¡ææ¶å°ç¹å®çæ¶æ¯ãè¿ç§è¡ä¸ºè¢«ç§°ä¸º **æå åºæ
éï¼Byzantine faultï¼**ï¼**å¨ä¸ä¿¡ä»»çç¯å¢ä¸è¾¾æå
±è¯çé®é¢è¢«ç§°ä¸ºæå åºå°åé®é¢**ã77ãã
> ### æå åºå°åé®é¢
>
> æå åºå°åé®é¢æ¯å¯¹æè° â两å°åé®é¢â çæ³åã78ãï¼å®æ³è±¡ä¸¤ä¸ªå°åéè¦å°±ææ计åè¾¾æä¸è´çæ
åµãç±äºä»ä»¬å¨ä¸¤ä¸ªä¸åçå°ç¹å»ºç«äºè¥å°ï¼ä»ä»¬åªè½éè¿ä¿¡ä½¿è¿è¡æ²éï¼ä¿¡ä½¿ææ¶ä¼è¢«å»¶è¿æ丢失ï¼å°±åç½ç»ä¸çä¿¡æ¯å
ä¸æ ·ï¼ãæ们å°å¨ [第ä¹ç« ](ch9.md) 讨论è¿ä¸ªå
±è¯é®é¢ã
>
> å¨è¿ä¸ªé®é¢çæå åºçæ¬éï¼æ n ä½å°åéè¦åæï¼ä»ä»¬çåªåå 为æä¸äºåå¾å¨ä»ä»¬ä¸é´èåå°é»ç¢ã大å¤æ°çå°åé½æ¯å¿ è¯çï¼å èååºäºçå®çä¿¡æ¯ï¼ä½æ¯åå¾å¯è½ä¼è¯å¾éè¿åéèåæä¸çå®çä¿¡æ¯æ¥æ¬ºéªåæ··æ·ä»äººï¼å¨è¯å¾ä¿ææªè¢«åç°çåæ¶ï¼ãäºå
并ä¸ç¥éåå¾æ¯è°ã
>
> æå åºæ¯åæ¥æ为å士å¦ä¸å ¡çå¤å¸è
åå¸ï¼ç°å¨å¨åè³å
¶çä¼æ¯å¦å¸å°ã没æä»»ä½åå²è¯æ®è¡¨ææå åºå°åæ¯å
¶ä»å°æ¹æ´å®¹æåºç°è¯¡è®¡åé´è°ãç¸åï¼è¿ä¸ªååæ¥æºäºæå åºå¼çè¿åº¦å¤æï¼å®åï¼è¿åçæä¹ï¼æ©å¨è®¡ç®æºä¹å就已ç»å¨æ¿æ²»ä¸è¢«ä½¿ç¨äºã79ããLamport æ³è¦éä¸ä¸ªä¸ä¼åç¯ä»»ä½è¯»è
çå½å®¶ï¼ä»è¢«åç¥å°å
¶ç§°ä¸ºé¿å°å·´å°¼äºå°åé®é¢å¹¶ä¸æ¯ä¸ä¸ªå¥½ä¸»æã80ãã
å½ä¸ä¸ªç³»ç»å¨é¨åèç¹åçæ
éãä¸éµå®åè®®ãçè³æ¶ææ»å»ãæ°ä¹±ç½ç»æ¶ä»ç¶è½ç»§ç»æ£ç¡®å·¥ä½ï¼ç§°ä¹ä¸º **æå åºå®¹éï¼Byzantine fault-tolerantï¼** çï¼è¿ç§æ
忧å¨æäºç¹å®æ
åµä¸æ¯ææä¹çï¼
* å¨èªç©ºèªå¤©ç¯å¢ä¸ï¼è®¡ç®æºå
åæ CPU å¯åå¨ä¸çæ°æ®å¯è½è¢«è¾å°ç ´åï¼å¯¼è´å
¶ä»¥ä»»æä¸å¯é¢ç¥çæ¹å¼ååºå
¶ä»èç¹ãç±äºç³»ç»æ
éé常æè´µï¼ä¾å¦ï¼é£æºææ¯åç¸æ»è¹ä¸ææ人åï¼æç«ç®ä¸å½é
空é´ç«ç¸æï¼ï¼é£è¡æ§å¶ç³»ç»å¿
须容å¿æå åºæ
éã81,82ãã
* å¨å¤ä¸ªåä¸ç»ç»çç³»ç»ä¸ï¼ä¸äºåä¸è
å¯è½ä¼è¯å¾æ¬ºéªæè¯éªä»äººãå¨è¿ç§æ
åµä¸ï¼èç¹ä»
ä»
ä¿¡ä»»å¦ä¸ä¸ªèç¹çæ¶æ¯æ¯ä¸å®å
¨çï¼å 为å®ä»¬å¯è½æ¯åºäºæ¶æçç®çè被åéçãä¾å¦ï¼åæ¯ç¹å¸åå
¶ä»åºåé¾ä¸æ ·ç对çç½ç»å¯ä»¥è¢«è®¤ä¸ºæ¯è®©äºä¸ä¿¡ä»»çåæ¹åæ交ææ¯å¦åççä¸ç§æ¹å¼ï¼èä¸ä¾èµäºä¸å¿æºæï¼central authorityï¼ã83ãã
ç¶èï¼å¨æ¬ä¹¦è®¨è®ºçé£äºç³»ç»ä¸ï¼æ们é常å¯ä»¥å®å
¨å°å设没ææå åºå¼çé误ãå¨ä½ çæ°æ®ä¸å¿éï¼ææçèç¹é½æ¯ç±ä½ çç»ç»æ§å¶çï¼æ以ä»ä»¬å¯ä»¥ä¿¡ä»»ï¼ï¼è¾å°æ°´å¹³è¶³å¤ä½ï¼å
åæåä¸æ¯ä¸ä¸ªå¤§é®é¢ãå¶ä½æå åºå®¹éç³»ç»çåè®®ç¸å½å¤æã84ãï¼è容éåµå
¥å¼ç³»ç»ä¾èµäºç¡¬ä»¶å±é¢çæ¯æã81ããå¨å¤§å¤æ°æå¡å¨ç«¯æ°æ®ç³»ç»ä¸ï¼é¨ç½²æå åºå®¹é解å³æ¹æ¡çææ¬ä½¿å
¶åå¾ä¸åå®é
ã
Web åºç¨ç¨åºç¡®å®éè¦é¢æåç»ç«¯ç¨æ·æ§å¶ç客æ·ç«¯ï¼å¦ Web æµè§å¨ï¼çä»»æåæ¶æè¡ä¸ºãè¿å°±æ¯ä¸ºä»ä¹è¾å
¥éªè¯ï¼æ°æ®æ¸
æ´åè¾åºè½¬ä¹å¦æ¤éè¦ï¼ä¾å¦ï¼é²æ¢ SQL 注å
¥åè·¨ç«ç¹èæ¬ãç¶èï¼æ们é常ä¸å¨è¿é使ç¨æå åºå®¹éåè®®ï¼èåªæ¯è®©æå¡å¨ææå³å®æ¯å¦å
许客æ·ç«¯è¡ä¸ºãä½å¨æ²¡æè¿ç§ä¸å¿æºæç对çç½ç»ä¸ï¼æå åºå®¹éæ´ä¸ºéè¦ã
软件ä¸çä¸ä¸ªé误ï¼bugï¼å¯è½è¢«è®¤ä¸ºæ¯æå åºå¼çé误ï¼ä½æ¯å¦æä½ å°ç¸åç软件é¨ç½²å°ææèç¹ä¸ï¼é£ä¹æå åºå¼ç容éç®æ³å¸®ä¸å°ä½ ã大å¤æ°æå åºå¼å®¹éç®æ³è¦æ±è¶
è¿ä¸åä¹äºçèç¹è½å¤æ£å¸¸å·¥ä½ï¼å³ï¼å¦ææå个èç¹ï¼æå¤åªè½æä¸ä¸ªæ
éï¼ãè¦ä½¿ç¨è¿ç§æ¹æ³å¯¹ä» bugï¼ä½ å¿
é¡»æå个ç¬ç«çç¸å软件çå®ç°ï¼å¹¶å¸æä¸ä¸ª bug åªåºç°å¨å个å®ç°ä¹ä¸ä¸ã
åæ ·ï¼å¦æä¸ä¸ªåè®®å¯ä»¥ä¿æ¤æ们å
åæ¼æ´ï¼å®å
¨æ¸éåæ¶ææ»å»ï¼é£ä¹è¿å°æ¯æå¸å¼åçãä¸å¹¸çæ¯ï¼è¿ä¹æ¯ä¸ç°å®çï¼å¨å¤§å¤æ°ç³»ç»ä¸ï¼å¦ææ»å»è
å¯ä»¥æ¸éä¸ä¸ªèç¹ï¼é£ä»ä»¬å¯è½ä¼æ¸éææè¿äºèç¹ï¼å 为å®ä»¬å¯è½é½è¿è¡çç¸åç软件ãå æ¤ï¼ä¼ ç»æºå¶ï¼è®¤è¯ï¼è®¿é®æ§å¶ï¼å å¯ï¼é²ç«å¢çï¼ä»ç¶æ¯æµå¾¡æ»å»è
ç主è¦ä¿æ¤æªæ½ã
#### å¼±è°è¨å½¢å¼
尽管æ们å设èç¹é常æ¯è¯å®çï¼ä½å¼å¾å软件ä¸æ·»å é²æ¢ âæè°â 弱形å¼çæºå¶ ââ ä¾å¦ï¼ç±ç¡¬ä»¶é®é¢å¯¼è´çæ ææ¶æ¯ï¼è½¯ä»¶é误åé误é
ç½®ãè¿ç§ä¿æ¤æºå¶å¹¶ä¸æ¯å®å
¨çæå åºå®¹éï¼å 为å®ä»¬ä¸è½æµæ¡å³å¿åå®ç对æï¼ä½å®ä»¬ä»ç¶æ¯ç®åèå®ç¨çæ¥éª¤ï¼ä»¥æé«å¯é æ§ãä¾å¦ï¼
* ç±äºç¡¬ä»¶é®é¢ææä½ç³»ç»ã驱å¨ç¨åºãè·¯ç±å¨çä¸çé误ï¼ç½ç»æ°æ®å
ææ¶ä¼åå°æåãé常ï¼æåçæ°æ®å
ä¼è¢«å
å»ºäº TCP å UDP ä¸çæ ¡éªåæä¿è·ï¼ä½ææ¶å®ä»¬ä¹ä¼éè±æ£æµã85,86,87ã ãè¦å¯¹ä»è¿ç§ç ´åé常使ç¨ç®åçæ¹æ³å°±å¯ä»¥åå°ï¼ä¾å¦åºç¨ç¨åºçº§åè®®ä¸çæ ¡éªåã
* å¯å
¬å¼è®¿é®çåºç¨ç¨åºå¿
é¡»ä»ç»æ¸
çæ¥èªç¨æ·çä»»ä½è¾å
¥ï¼ä¾å¦æ£æ¥å¼æ¯å¦å¨åççèå´å
ï¼å¹¶éå¶å符串ç大å°ä»¥é²æ¢éè¿å¤§å
ååé
çæç»æå¡ãé²ç«å¢åé¢çå
é¨æå¡å¯¹äºè¾å
¥ä¹è®¸å¯ä»¥åªéåä¸äºä¸é£ä¹ä¸¥æ ¼çæ£æ¥ï¼ä½æ¯éåä¸äºåºæ¬çåçæ§æ£æ¥ï¼ä¾å¦ï¼å¨å议解æä¸ï¼ä»ç¶æ¯ä¸ä¸ªå¥½ä¸»æã
* NTP 客æ·ç«¯å¯ä»¥é
ç½®å¤ä¸ªæå¡å¨å°åãåæ¥æ¶ï¼å®¢æ·ç«¯èç³»ææçæå¡å¨ï¼ä¼°è®¡å®ä»¬ç误差ï¼å¹¶æ£æ¥å¤§å¤æ°æå¡å¨æ¯å¦å¯¹æ个æ¶é´èå´è¾¾æä¸è´ãåªè¦å¤§å¤æ°çæå¡å¨æ²¡é®é¢ï¼ä¸ä¸ªé
ç½®é误ç NTP æå¡å¨æ¥åçæ¶é´ä¼è¢«å½æç¹å¼å¼ä»åæ¥ä¸æé¤ã37ãã使ç¨å¤ä¸ªæå¡å¨ä½¿ NTP æ´å¥å£®ï¼æ¯èµ·åªç¨å个æå¡å¨æ¥ï¼ã
### ç³»ç»æ¨¡åä¸ç°å®
å·²ç»æå¾å¤ç®æ³è¢«è®¾è®¡ä»¥è§£å³åå¸å¼ç³»ç»é®é¢ ââ ä¾å¦ï¼æ们å°å¨ [第ä¹ç« ](ch9.md) 讨论å
±è¯é®é¢ç解å³æ¹æ¡ã为äºæç¨ï¼è¿äºç®æ³éè¦å®¹å¿æ们å¨æ¬ç« ä¸è®¨è®ºçåå¸å¼ç³»ç»çåç§æ
éã
ç®æ³çç¼åæ¹å¼ä¸åºè¯¥è¿åä¾èµäºè¿è¡ç硬件å软件é
ç½®çç»èãè¿å°±è¦æ±æ们以æç§æ¹å¼å°æ们ææå¨ç³»ç»ä¸åççé误形å¼åãæ们éè¿å®ä¹ä¸ä¸ªç³»ç»æ¨¡åæ¥åå°è¿ä¸ç¹ï¼è¿ä¸ªæ¨¡åæ¯ä¸ä¸ªæ½è±¡ï¼æè¿°ä¸ä¸ªç®æ³å¯ä»¥å设çäºæ
ã
å
³äºæ¶åºå设ï¼ä¸ç§ç³»ç»æ¨¡åæ¯å¸¸ç¨çï¼
* åæ¥æ¨¡å
**åæ¥æ¨¡åï¼synchronous modelï¼** å设ç½ç»å»¶è¿ãè¿ç¨æåååæ¶é误差é½æ¯åéçãè¿å¹¶ä¸æå³çå®å
¨åæ¥çæ¶éæé¶ç½ç»å»¶è¿ï¼è¿åªæå³çä½ ç¥éç½ç»å»¶è¿ãæååæ¶éæ¼ç§»å°æ°¸è¿ä¸ä¼è¶
è¿æ个åºå®çä¸éã88ããåæ¥æ¨¡å并ä¸æ¯å¤§å¤æ°å®é
ç³»ç»çç°å®æ¨¡åï¼å 为ï¼å¦æ¬ç« æ讨论çï¼æ é延è¿åæåç¡®å®ä¼åçã
* é¨ååæ¥æ¨¡å
**é¨ååæ¥ï¼partial synchronousï¼** æå³çä¸ä¸ªç³»ç»å¨å¤§å¤æ°æ
åµä¸åä¸ä¸ªåæ¥ç³»ç»ä¸æ ·è¿è¡ï¼ä½ææ¶åä¼è¶
åºç½ç»å»¶è¿ï¼è¿ç¨æååæ¶éæ¼ç§»ççéã88ããè¿æ¯å¾å¤ç³»ç»çç°å®æ¨¡åï¼å¤§å¤æ°æ
åµä¸ï¼ç½ç»åè¿ç¨è¡¨ç°è¯å¥½ï¼å¦åæ们永è¿æ æ³å®æä»»ä½äºæ
ï¼ä½æ¯æ们å¿
é¡»æ¿è®¤ï¼å¨ä»»ä½æ¶å»é½åå¨æ¶åºå设å¶ç¶è¢«ç ´åçäºå®ãåçè¿ç§æ
åµæ¶ï¼ç½ç»å»¶è¿ãæååæ¶éé误å¯è½ä¼åå¾ç¸å½å¤§ã
* å¼æ¥æ¨¡å
å¨è¿ä¸ªæ¨¡åä¸ï¼ä¸ä¸ªç®æ³ä¸å
许对æ¶åºåä»»ä½å设 ââ äºå®ä¸å®çè³æ²¡ææ¶éï¼æ以å®ä¸è½ä½¿ç¨è¶
æ¶ï¼ãä¸äºç®æ³è¢«è®¾è®¡ä¸ºå¯ç¨äºå¼æ¥æ¨¡åï¼ä½é常åéã
è¿ä¸æ¥æ¥è¯´ï¼é¤äºæ¶åºé®é¢ï¼æ们è¿è¦èè **èç¹å¤±æ**ãä¸ç§æ常è§çèç¹ç³»ç»æ¨¡åæ¯ï¼
* å´©æº - åæ¢æ
é
å¨ **å´©æºåæ¢ï¼crash-stopï¼** 模åä¸ï¼ç®æ³å¯è½ä¼å设ä¸ä¸ªèç¹åªè½ä»¥ä¸ç§æ¹å¼å¤±æï¼å³éè¿å´©æºãè¿æå³çèç¹å¯è½å¨ä»»ææ¶å»çªç¶åæ¢ååºï¼æ¤å该èç¹æ°¸è¿æ¶å¤± ââ å®æ°¸è¿ä¸ä¼åæ¥ã
* å´©æº - æ¢å¤æ
é
æ们å设èç¹å¯è½ä¼å¨ä»»ä½æ¶åå´©æºï¼ä½ä¹è®¸ä¼å¨æªç¥çæ¶é´ä¹åå次å¼å§ååºãå¨ **å´©æº - æ¢å¤ï¼crash-recoveryï¼** 模åä¸ï¼å设èç¹å
·æ稳å®çåå¨ï¼å³ï¼éæ失æ§ç£çåå¨ï¼ä¸ä¼å¨å´©æºä¸ä¿çï¼èå
åä¸çç¶æä¼ä¸¢å¤±ã
* æå åºï¼ä»»æï¼æ
é
èç¹å¯ä»¥åï¼ç»å¯¹æä¹ä¸çï¼ä»»ä½äºæ
ï¼å
æ¬è¯å¾æå¼å欺éªå
¶ä»èç¹ï¼å¦ä¸ä¸èæè¿°ã
对äºçå®ç³»ç»ç建模ï¼å
·æ **å´©æº - æ¢å¤æ
éï¼crash-recoveryï¼** ç **é¨ååæ¥æ¨¡åï¼partial synchronousï¼** é常æ¯ææç¨ç模åãåå¸å¼ç®æ³å¦ä½åºå¯¹è¿ç§æ¨¡åï¼
#### ç®æ³çæ£ç¡®æ§
为äºå®ä¹ç®æ³æ¯æ£ç¡®çï¼æ们å¯ä»¥æè¿°å®çå±æ§ãä¾å¦ï¼æåºç®æ³çè¾åºå
·æå¦ä¸ç¹æ§ï¼å¯¹äºè¾åºå表ä¸çä»»ä½ä¸¤ä¸ªä¸åçå
ç´ ï¼å·¦è¾¹çå
ç´ æ¯å³è¾¹çå
ç´ å°ãè¿åªæ¯å®ä¹å¯¹å表è¿è¡æåºå«ä¹çä¸ç§å½¢å¼æ¹å¼ã
åæ ·ï¼æ们å¯ä»¥åä¸æ们æ³è¦çåå¸å¼ç®æ³çå±æ§æ¥å®ä¹å®çæ£ç¡®å«ä¹ãä¾å¦ï¼å¦ææ们æ£å¨ä¸ºä¸ä¸ªéçæé²æ¤ä»¤çï¼è¯·åé
â[é²æ¤ä»¤ç](#é²æ¤ä»¤ç)âï¼ï¼æ们å¯è½è¦æ±ç®æ³å
·æ以ä¸å±æ§ï¼
* å¯ä¸æ§ï¼uniquenessï¼
没æ两个é²æ¤ä»¤ç请æ±è¿åç¸åçå¼ã
* åè°åºåï¼monotonic sequenceï¼
å¦æè¯·æ± $x$ è¿åäºä»¤ç $t_x$ï¼å¹¶ä¸è¯·æ± $y$ è¿åäºä»¤ç $t_y$ï¼å¹¶ä¸ $x$ å¨ $y$ å¼å§ä¹åå·²ç»å®æï¼é£ä¹ $t_x < t_y$ã
* å¯ç¨æ§ï¼availabilityï¼
请æ±é²æ¤ä»¤ç并ä¸ä¸ä¼å´©æºçèç¹ï¼æç»ä¼æ¶å°ååºã
å¦æä¸ä¸ªç³»ç»æ¨¡åä¸çç®æ³æ»æ¯æ»¡è¶³å®å¨æææ们å设å¯è½åççæ
åµä¸çæ§è´¨ï¼é£ä¹è¿ä¸ªç®æ³æ¯æ£ç¡®çãä½è¿å¦ä½ææä¹ï¼å¦æææçèç¹å´©æºï¼æè
ææçç½ç»å»¶è¿çªç¶åå¾æ éé¿ï¼é£ä¹æ²¡æä»»ä½ç®æ³è½å¤å®æä»»ä½äºæ
ã
#### å®å
¨æ§åæ´»æ§
为äºæ¾æ¸
è¿ç§æ
åµï¼æå¿
è¦åºå两ç§ä¸åçå±æ§ï¼**å®å
¨ï¼safetyï¼å±æ§** å **æ´»æ§ï¼livenessï¼å±æ§**ãå¨ååç»åºçä¾åä¸ï¼**å¯ä¸æ§** å **åè°åºå** æ¯å®å
¨å±æ§ï¼è **å¯ç¨æ§** æ¯æ´»æ§å±æ§ã
è¿ä¸¤ç§æ§è´¨æä»ä¹åºå«ï¼ä¸ä¸ªè¯éç³å°±æ¯ï¼æ´»æ§å±æ§é常å¨å®ä¹ä¸é常å
æ¬ â**æç»**â ä¸è¯ï¼æ¯çï¼ä½ çå¯¹äº ââ æç»ä¸è´æ§æ¯ä¸ä¸ªæ´»æ§å±æ§ã89ãï¼ã
å®å
¨é常被éæ£å¼å°å®ä¹ä¸ºï¼**没æåäºåç**ï¼èæ´»æ§é常就类似ï¼**æç»å¥½äºåç**ãä½æ¯ï¼æ好ä¸è¦è¿å¤å°é
读é£äºéæ£å¼çå®ä¹ï¼å 为好ä¸åçå«ä¹æ¯ä¸»è§çãå®å
¨åæ´»æ§çå®é
å®ä¹æ¯ç²¾ç¡®çåæ°å¦çã90ãï¼
* å¦æå®å
¨å±æ§è¢«è¿åï¼æ们å¯ä»¥æåä¸ä¸ªç¹å®çå®å
¨å±æ§è¢«ç ´åçæ¶é´ç¹ï¼ä¾å¦ï¼å¦æè¿åäºå¯ä¸æ§å±æ§ï¼æ们å¯ä»¥ç¡®å®éå¤çé²æ¤ä»¤ç被è¿åçç¹å®æä½ï¼ãè¿åå®å
¨å±æ§åï¼è¿è§è¡ä¸ºä¸è½è¢«æ¤é ââ æ失已ç»åçã
* æ´»æ§å±æ§åè¿æ¥ï¼å¨æ个æ¶é´ç¹ï¼ä¾å¦ï¼ä¸ä¸ªèç¹å¯è½åéäºä¸ä¸ªè¯·æ±ï¼ä½è¿æ²¡ææ¶å°ååºï¼ï¼å®å¯è½ä¸æç«ï¼ä½æ»æ¯å¸æå¨æªæ¥è½æç«ï¼å³éè¿æ¥åçå¤ï¼ã
åºåå®å
¨å±æ§åæ´»æ§å±æ§çä¸ä¸ªä¼ç¹æ¯å¯ä»¥å¸®å©æ们å¤çå°é¾çç³»ç»æ¨¡åã对äºåå¸å¼ç®æ³ï¼å¨ç³»ç»æ¨¡åçææå¯è½æ
åµä¸ï¼è¦æ± **å§ç»** ä¿æå®å
¨å±æ§æ¯å¸¸è§çã88ããä¹å°±æ¯è¯´ï¼å³ä½¿ææèç¹å´©æºï¼æè
æ´ä¸ªç½ç»åºç°æ
éï¼ç®æ³ä»ç¶å¿
须确ä¿å®ä¸ä¼è¿åé误çç»æï¼å³ä¿è¯å®å
¨å±æ§å¾å°æ»¡è¶³ï¼ã
ä½æ¯ï¼å¯¹äºæ´»æ§å±æ§ï¼æ们å¯ä»¥æåºä¸äºæ³¨æäºé¡¹ï¼ä¾å¦ï¼åªæå¨å¤§å¤æ°èç¹æ²¡æå´©æºçæ
åµä¸ï¼åªæå½ç½ç»æç»ä»ä¸æä¸æ¢å¤æ¶ï¼æ们æå¯ä»¥è¯´è¯·æ±éè¦æ¥æ¶ååºãé¨ååæ¥æ¨¡åçå®ä¹è¦æ±ç³»ç»æç»è¿åå°åæ¥ç¶æ ââ å³ä»»ä½ç½ç»ä¸æçæ¶é´æ®µåªä¼æç»ä¸æ®µæéçæ¶é´ï¼ç¶åè¿è¡ä¿®å¤ã
#### å°ç³»ç»æ¨¡åæ å°å°ç°å®ä¸ç
å®å
¨å±æ§åæ´»æ§å±æ§ä»¥åç³»ç»æ¨¡å对äºæ¨çåå¸å¼ç®æ³çæ£ç¡®æ§é常æç¨ãç¶èï¼å¨å®è·µä¸å®æ½ç®æ³æ¶ï¼ç°å®çæ··ä¹±äºå®åä¸æ¬¡å°è®©ä½ å¬çå齿ï¼å¾ææ¾ç³»ç»æ¨¡åæ¯å¯¹ç°å®çç®åæ½è±¡ã
ä¾å¦ï¼å¨å´©æº - æ¢å¤ï¼crash-recoveryï¼æ¨¡åä¸çç®æ³é常å设稳å®åå¨å¨ä¸çæ°æ®å¨å´©æºåå¯ä»¥å¹¸åãä½æ¯ï¼å¦æç£çä¸çæ°æ®è¢«ç ´åï¼æè
ç±äºç¡¬ä»¶é误æé误é
置导è´æ°æ®è¢«æ¸
é¤ï¼ä¼åçä»ä¹æ
åµã91ãï¼å¦ææå¡å¨åå¨åºä»¶é误并ä¸å¨éæ°å¯å¨æ¶æ æ³è¯å«å
¶ç¡¬ç驱å¨å¨ï¼å³ä½¿é©±å¨å¨å·²æ£ç¡®è¿æ¥å°æå¡å¨ï¼é£åä¼åçä»ä¹æ
åµã92ãï¼
æ³å®äººæ°ç®æ³ï¼è¯·åé
â[读åçæ³å®äººæ°](ch5.md#读åçæ³å®äººæ°)âï¼ä¾èµèç¹æ¥è®°ä½å®å£°ç§°åå¨çæ°æ®ãå¦æä¸ä¸ªèç¹å¯è½æ£æå¥å¿çï¼å¿è®°äºä»¥ååå¨çæ°æ®ï¼è¿ä¼æç ´æ³å®æ¡ä»¶ï¼ä»èç ´åç®æ³çæ£ç¡®æ§ãä¹è®¸éè¦ä¸ä¸ªæ°çç³»ç»æ¨¡åï¼å¨è¿ä¸ªæ¨¡åä¸ï¼æ们å设稳å®çåå¨å¤§å¤è½å¨å´©æºå幸åï¼ä½ææ¶ä¹å¯è½ä¼ä¸¢å¤±ãä½æ¯é£ä¸ªæ¨¡åå°±åå¾æ´é¾ä»¥æ¨çäºã
ç®æ³çç论æè¿°å¯ä»¥ç®å宣称ä¸äºäºæ¯ä¸ä¼åçç ââ å¨éæå åºå¼ç³»ç»ä¸ï¼æ们确å®éè¦å¯¹å¯è½åçåä¸å¯è½åççæ
éååºå设ãç¶èï¼çå®ä¸ççå®ç°ï¼ä»ç¶ä¼å
æ¬å¤ç âå设ä¸ä¸å¯è½â æ
åµç代ç ï¼å³ä½¿ä»£ç å¯è½å°±æ¯ `printf("Sucks to be you")` å `exit(666)`ï¼å®é
ä¸ä¹å°±æ¯çç»è¿ç»´æ¥æ¦å±è¡ã93ããï¼è¿å¯ä»¥è¯´æ¯è®¡ç®æºç§å¦å软件工ç¨é´çä¸ä¸ªå·®å¼ï¼ã
è¿å¹¶ä¸æ¯è¯´ç论ä¸æ½è±¡çç³»ç»æ¨¡åæ¯æ¯«æ ä»·å¼çï¼æ°æ°ç¸åãå®ä»¬å¯¹äºå°å®é
ç³»ç»çå¤ææ§æåæä¸ä¸ªä¸ªæ们å¯ä»¥æ¨ççå¯å¤ççé误类åæ¯é常æ帮å©çï¼ä»¥ä¾¿æ们è½å¤ç解è¿ä¸ªé®é¢ï¼å¹¶è¯å¾ç³»ç»å°è§£å³è¿ä¸ªé®é¢ãæ们å¯ä»¥è¯æç®æ³æ¯æ£ç¡®çï¼éè¿è¡¨æå®ä»¬çå±æ§å¨æ个系ç»æ¨¡åä¸æ»æ¯æç«çã
è¯æç®æ³æ£ç¡®å¹¶ä¸æå³çå®å¨çå®ç³»ç»ä¸çå®ç°å¿
ç¶æ»æ¯æ£ç¡®çãä½è¿è¿åºäºå¾å¥½ç第ä¸æ¥ï¼å 为ç论åæå¯ä»¥åç°ç®æ³ä¸çé®é¢ï¼è¿ç§é®é¢å¯è½ä¼å¨ç°å®ç³»ç»ä¸é¿ææ½ä¼ï¼ç´å°ä½ çå设ï¼ä¾å¦ï¼æ¶åºï¼å 为ä¸å¯»å¸¸çæ
åµè¢«æç ´ãç论åæä¸ç»éªæµè¯åæ ·éè¦ã
## æ¬ç« å°ç»
å¨æ¬ç« ä¸ï¼æ们讨论äºåå¸å¼ç³»ç»ä¸å¯è½åççåç§é®é¢ï¼å
æ¬ï¼
* å½ä½ å°è¯éè¿ç½ç»åéæ°æ®å
æ¶ï¼æ°æ®å
å¯è½ä¼ä¸¢å¤±æä»»æ延è¿ãåæ ·ï¼çå¤å¯è½ä¼ä¸¢å¤±æ延è¿ï¼æ以å¦æä½ æ²¡æå¾å°çå¤ï¼ä½ ä¸ç¥éæ¶æ¯æ¯å¦åéæåäºã
* èç¹çæ¶éå¯è½ä¼ä¸å
¶ä»èç¹æ¾èä¸åæ¥ï¼å°½ç®¡ä½ å°½æ大åªå设置 NTPï¼ï¼å®å¯è½ä¼çªç¶è·³è½¬æè·³åï¼ä¾é å®æ¯å¾å±é©çï¼å ä¸ºä½ å¾å¯è½æ²¡æ好çæ¹æ³æ¥æµéä½ çæ¶éçé误é´éã
* ä¸ä¸ªè¿ç¨å¯è½ä¼å¨å
¶æ§è¡çä»»ä½æ¶åæåä¸æ®µç¸å½é¿çæ¶é´ï¼å¯è½æ¯å 为åæ¢ææå¤ççåå¾æ¶éå¨ï¼ï¼è¢«å
¶ä»èç¹å®£åæ»äº¡ï¼ç¶åå次å¤æ´»ï¼å´æ²¡ææè¯å°å®è¢«æåäºã
è¿ç±» **é¨å失æï¼partial failureï¼** å¯è½åççäºå®æ¯åå¸å¼ç³»ç»çå³å®æ§ç¹å¾ãæ¯å½è½¯ä»¶è¯å¾åä»»ä½æ¶åå
¶ä»èç¹çäºæ
æ¶ï¼å¶å°å°±æå¯è½ä¼å¤±è´¥ï¼æè
éæºåæ
¢ï¼æè
æ ¹æ¬æ²¡æååºï¼æç»è¶
æ¶ï¼ãå¨åå¸å¼ç³»ç»ä¸ï¼æ们è¯å¾å¨è½¯ä»¶ä¸å»ºç« **é¨å失æ** ç容éæºå¶ï¼è¿æ ·æ´ä¸ªç³»ç»å¨å³ä½¿æäºç»æé¨åè¢«ç ´åçæ
åµä¸ï¼ä¹å¯ä»¥ç»§ç»è¿è¡ã
为äºå®¹å¿é误ï¼ç¬¬ä¸æ¥æ¯ **æ£æµ** å®ä»¬ï¼ä½å³ä½¿è¿æ ·ä¹å¾é¾ã大å¤æ°ç³»ç»æ²¡ææ£æµèç¹æ¯å¦åçæ
éçåç¡®æºå¶ï¼æ以大å¤æ°åå¸å¼ç®æ³ä¾é **è¶
æ¶** æ¥ç¡®å®è¿ç¨èç¹æ¯å¦ä»ç¶å¯ç¨ãä½æ¯ï¼è¶
æ¶æ æ³åºåç½ç»å¤±æåèç¹å¤±æï¼å¹¶ä¸å¯åçç½ç»å»¶è¿ææ¶ä¼å¯¼è´èç¹è¢«é误å°æçåçæ
éãæ¤å¤ï¼ææ¶ä¸ä¸ªèç¹å¯è½å¤äºé级ç¶æï¼ä¾å¦ï¼ç±äºé©±å¨ç¨åºé误ï¼åå
ç½å¡å¯è½çªç¶ä¸éå° 1 Kb/s çååéã94ããè¿æ ·ä¸ä¸ª âè·è¡â èä¸æ¯æ»æçèç¹å¯è½æ¯ä¸ä¸ªå¹²åç失æèç¹æ´é¾å¤çã
ä¸æ¦æ£æµå°æ
éï¼ä½¿ç³»ç»å®¹å¿å®ä¹å¹¶ä¸å®¹æï¼æ²¡æå
¨å±åéï¼æ²¡æå
±äº«å
åï¼æ²¡æå
±åçç¥è¯ï¼ææºå¨ä¹é´ä»»ä½å
¶ä»ç§ç±»çå
±äº«ç¶æãèç¹çè³ä¸è½å°±ç°å¨æ¯ä»ä¹æ¶é´è¾¾æä¸è´ï¼å°±ä¸ç¨è¯´æ´æ·±å¥¥çäºãä¿¡æ¯ä»ä¸ä¸ªèç¹æµåå¦ä¸ä¸ªèç¹çå¯ä¸æ¹æ³æ¯éè¿ä¸å¯é çç½ç»åéä¿¡æ¯ãé大å³çä¸è½ç±ä¸ä¸ªèç¹å®å
¨å°å®æï¼å æ¤æ们éè¦ä¸ä¸ªè½ä»å
¶ä»èç¹è·å¾å¸®å©çåè®®ï¼å¹¶äºåè¾¾å°æ³å®äººæ°ä»¥è¾¾æä¸è´ã
å¦æä½ ä¹ æ¯äºå¨çæ³åçæ°å¦å®ç¾çåæºç¯å¢ï¼åä¸ä¸ªæä½æ»è½ç¡®å®å°è¿åç¸åçç»æï¼ä¸ç¼å软件ï¼é£ä¹è½¬ååå¸å¼ç³»ç»çåä¹±çç©çç°å®å¯è½ä¼æäºä»¤äººéæãç¸åï¼å¦æè½å¤å¨åå°è®¡ç®æºä¸è§£å³ä¸ä¸ªé®é¢ï¼é£ä¹åå¸å¼ç³»ç»å·¥ç¨å¸é常ä¼è®¤ä¸ºè¿ä¸ªé®é¢æ¯å¹³å¡çã5ãï¼ç°å¨å个计ç®æºç¡®å®å¯ä»¥åå¾å¤äºæ
ã95ããå¦æä½ å¯ä»¥é¿å
æå¼æ½å¤æççåï¼æä¸è¥¿æ¾å¨ä¸å°æºå¨ä¸ï¼é£ä¹é常æ¯å¼å¾çã
ä½æ¯ï¼æ£å¦å¨ [第äºé¨å](part-ii.md) çä»ç»ä¸æ讨论çé£æ ·ï¼å¯ä¼¸ç¼©æ§å¹¶ä¸æ¯ä½¿ç¨åå¸å¼ç³»ç»çå¯ä¸åå ã容éåä½å»¶è¿ï¼éè¿å°æ°æ®æ¾ç½®å¨è·ç¦»ç¨æ·è¾è¿çå°æ¹ï¼æ¯åçéè¦çç®æ ï¼èè¿äºä¸è½ç¨å个èç¹å®ç°ã
å¨æ¬ç« ä¸ï¼æ们ä¹è½¬æ¢äºå 次è¯é¢ï¼æ¢è®¨äºç½ç»ãæ¶éåè¿ç¨çä¸å¯é æ§æ¯å¦æ¯ä¸å¯é¿å
çèªç¶è§å¾ãæ们çå°è¿å¹¶ä¸æ¯ï¼æå¯è½ç»ç½ç»æä¾ç¡¬å®æ¶çååºä¿è¯åæéç延è¿ï¼ä½æ¯è¿æ ·åé常æè´µï¼ä¸å¯¼è´ç¡¬ä»¶èµæºçå©ç¨çéä½ã大å¤æ°éå®å
¨å
³é®ç³»ç»ä¼éæ© **便å®èä¸å¯é **ï¼èä¸æ¯ **æè´µåå¯é **ã
æ们è¿è°å°äºè¶
级计ç®æºï¼å®ä»¬éç¨å¯é çç»ä»¶ï¼å æ¤å½ç»ä»¶åçæ
éæ¶å¿
é¡»å®å
¨åæ¢å¹¶éæ°å¯å¨ãç¸æ¯ä¹ä¸ï¼åå¸å¼ç³»ç»å¯ä»¥æ°¸ä¹
è¿è¡èä¸ä¼å¨æå¡å±é¢ä¸æï¼å 为ææçé误åç»´æ¤é½å¯ä»¥å¨èç¹çº§å«è¿è¡å¤ç ââ è³å°å¨ç论ä¸æ¯å¦æ¤ãï¼å®é
ä¸ï¼å¦æä¸ä¸ªé误çé
ç½®åæ´è¢«åºç¨å°ææçèç¹ï¼ä»ç¶ä¼ä½¿åå¸å¼ç³»ç»ç«çªï¼ã
æ¬ç« ä¸ç´å¨è®²åå¨çé®é¢ï¼ç»æ们å±ç°äºä¸å¹
黯淡çåæ¯ãå¨ [ä¸ä¸ç« ](ch9.md) ä¸ï¼æ们å°ç»§ç»è®¨è®ºè§£å³æ¹æ¡ï¼å¹¶è®¨è®ºä¸äºæ¨å¨è§£å³åå¸å¼ç³»ç»ä¸ææé®é¢çç®æ³ã
## åèæç®
1. Mark Cavage: Just No Getting Around It: Youâre Building a Distributed System](http://queue.acm.org/detail.cfm?id=2482856),â *ACM Queue*, volume 11, number 4, pages 80-89, April 2013. [doi:10.1145/2466486.2482856](http://dx.doi.org/10.1145/2466486.2482856)
1. Jay Kreps: â[Getting Real About Distributed System Reliability](http://blog.empathybox.com/post/19574936361/getting-real-about-distributed-system-reliability),â *blog.empathybox.com*, March 19, 2012.
1. Sydney Padua: *The Thrilling Adventures of Lovelace and Babbage: The (Mostly) True Story of the First Computer*. Particular Books, April ISBN: 978-0-141-98151-2
1. Coda Hale: â[You Canât Sacrifice Partition Tolerance](http://codahale.com/you-cant-sacrifice-partition-tolerance/),â *codahale.com*, October 7, 2010.
1. Jeff Hodges: â[Notes on Distributed Systems for Young Bloods](http://www.somethingsimilar.com/2013/01/14/notes-on-distributed-systems-for-young-bloods/),â *somethingsimilar.com*, January 14, 2013.
1. Antonio Regalado: â[Who Coined 'Cloud Computing’?](http://www.technologyreview.com/news/425970/who-coined-cloud-computing/),â *technologyreview.com*, October 31, 2011.
1. Luiz André Barroso, Jimmy Clidaras, and Urs Hölzle: â[The Datacenter as a Computer: An Introduction to the Design of Warehouse-Scale Machines, Second Edition](http://www.morganclaypool.com/doi/abs/10.2200/S00516ED2V01Y201306CAC024),â *Synthesis Lectures on Computer Architecture*, volume 8, number 3, Morgan & Claypool Publishers, July 2013.[doi:10.2200/S00516ED2V01Y201306CAC024](http://dx.doi.org/10.2200/S00516ED2V01Y201306CAC024), ISBN: 978-1-627-05010-4
1. David Fiala, Frank Mueller, Christian Engelmann, et al.: â[Detection and Correction of Silent Data Corruption for Large-Scale High-Performance Computing](http://moss.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/sc12.pdf),â at *International Conference for High Performance Computing, Networking, Storage and Analysis* (SC12), November 2012.
1. Arjun Singh, Joon Ong, Amit Agarwal, et al.: â[Jupiter Rising: A Decade of Clos Topologies and Centralized Control in Googleâs Datacenter Network](http://conferences.sigcomm.org/sigcomm/2015/pdf/papers/p183.pdf),â at *Annual Conference of the ACM Special Interest Group on Data Communication* (SIGCOMM), August 2015. [doi:10.1145/2785956.2787508](http://dx.doi.org/10.1145/2785956.2787508)
1. Glenn K. Lockwood: â[Hadoop's Uncomfortable Fit in HPC](http://glennklockwood.blogspot.co.uk/2014/05/hadoops-uncomfortable-fit-in-hpc.html),â *glennklockwood.blogspot.co.uk*, May 16, 2014.
1. John von Neumann: â[Probabilistic Logics and the Synthesis of Reliable Organisms from Unreliable Components](https://ece.uwaterloo.ca/~ssundara/courses/prob_logics.pdf),â in *Automata Studies (AM-34)*, edited by Claude E. Shannon and John McCarthy, Princeton University Press, 1956. ISBN: 978-0-691-07916-5
1. Richard W. Hamming: *The Art of Doing Science and Engineering*. Taylor & Francis, 1997. ISBN: 978-9-056-99500-3
1. Claude E. Shannon: â[A Mathematical Theory of Communication](http://cs.brynmawr.edu/Courses/cs380/fall2012/shannon1948.pdf),â *The Bell System Technical Journal*, volume 27, number 3, pages 379â423 and 623â656, July 1948.
1. Peter Bailis and Kyle Kingsbury: â[The Network Is Reliable](https://queue.acm.org/detail.cfm?id=2655736),â *ACM Queue*, volume 12, number 7, pages 48-55, July 2014. [doi:10.1145/2639988.2639988](http://dx.doi.org/10.1145/2639988.2639988)
1. Joshua B. Leners, Trinabh Gupta, Marcos K. Aguilera, and Michael Walfish: â[Taming Uncertainty in Distributed Systems with Help from the Network](http://www.cs.nyu.edu/~mwalfish/papers/albatross-eurosys15.pdf),â at *10th European Conference on Computer Systems* (EuroSys), April 2015. [doi:10.1145/2741948.2741976](http://dx.doi.org/10.1145/2741948.2741976)
1. Phillipa Gill, Navendu Jain, and Nachiappan Nagappan: â[Understanding Network Failures in Data Centers: Measurement, Analysis, and Implications](http://conferences.sigcomm.org/sigcomm/2011/papers/sigcomm/p350.pdf),â at *ACM SIGCOMM Conference*, August 2011. [doi:10.1145/2018436.2018477](http://dx.doi.org/10.1145/2018436.2018477)
1. Mark Imbriaco: â[Downtime Last Saturday](https://github.com/blog/1364-downtime-last-saturday),â *github.com*, December 26, 2012.
1. Will Oremus: â[The Global Internet Is Being Attacked by Sharks, Google Confirms](http://www.slate.com/blogs/future_tense/2014/08/15/shark_attacks_threaten_google_s_undersea_internet_cables_video.html),â *slate.com*, August 15, 2014.
1. Marc A. Donges: â[Re: bnx2 cards Intermittantly Going Offline](http://www.spinics.net/lists/netdev/msg210485.html),â Message to Linux *netdev* mailing list, *spinics.net*, September 13, 2012.
1. Kyle Kingsbury: â[Call Me Maybe: Elasticsearch](https://aphyr.com/posts/317-call-me-maybe-elasticsearch),â *aphyr.com*, June 15, 2014.
1. Salvatore Sanfilippo: â[A Few Arguments About Redis Sentinel Properties and Fail Scenarios](http://antirez.com/news/80),â *antirez.com*, October 21, 2014.
1. Bert Hubert: â[The Ultimate SO_LINGER Page, or: Why Is My TCP Not Reliable](http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable),â *blog.netherlabs.nl*, January 18, 2009.
1. Nicolas Liochon: â[CAP: If All You Have Is a Timeout, Everything Looks Like a Partition](http://blog.thislongrun.com/2015/05/CAP-theorem-partition-timeout-zookeeper.html),â *blog.thislongrun.com*, May 25, 2015.
1. Jerome H. Saltzer, David P. Reed, and David D. Clark: â[End-To-End Arguments in System Design](http://www.ece.drexel.edu/courses/ECE-C631-501/SalRee1984.pdf),â *ACM Transactions on Computer Systems*, volume 2, number 4, pages 277â288, November 1984. [doi:10.1145/357401.357402](http://dx.doi.org/10.1145/357401.357402)
1. Matthew P. Grosvenor, Malte Schwarzkopf, Ionel Gog, et al.: â[Queues Donât Matter When You Can JUMP Them!](https://www.usenix.org/system/files/conference/nsdi15/nsdi15-paper-grosvenor_update.pdf),â at *12th USENIX Symposium on Networked Systems Design and Implementation* (NSDI), May 2015.
1. Guohui Wang and T. S. Eugene Ng: â[The Impact of Virtualization on Network Performance of Amazon EC2 Data Center](http://www.cs.rice.edu/~eugeneng/papers/INFOCOM10-ec2.pdf),â at *29th IEEE International Conference on Computer Communications* (INFOCOM), March 2010. [doi:10.1109/INFCOM.2010.5461931](http://dx.doi.org/10.1109/INFCOM.2010.5461931)
1. Van Jacobson: â[Congestion Avoidance and Control](http://www.cs.usask.ca/ftp/pub/discus/seminars2002-2003/p314-jacobson.pdf),â at *ACM Symposium on Communications Architectures and Protocols* (SIGCOMM), August 1988. [doi:10.1145/52324.52356](http://dx.doi.org/10.1145/52324.52356)
1. Brandon Philips: â[etcd: Distributed Locking and Service Discovery](https://www.youtube.com/watch?v=HJIjTTHWYnE),â at *Strange Loop*, September 2014.
1. Steve Newman: â[A Systematic Look at EC2 I/O](http://blog.scalyr.com/2012/10/a-systematic-look-at-ec2-io/),â *blog.scalyr.com*, October 16, 2012.
1. Naohiro Hayashibara, Xavier Défago, Rami Yared, and Takuya Katayama: â[The Ï Accrual Failure Detector](http://hdl.handle.net/10119/4784),â Japan Advanced Institute of Science and Technology, School of Information Science, Technical Report IS-RR-2004-010, May 2004.
1. Jeffrey Wang: â[Phi Accrual Failure Detector](http://ternarysearch.blogspot.co.uk/2013/08/phi-accrual-failure-detector.html),â *ternarysearch.blogspot.co.uk*, August 11, 2013.
1. Srinivasan Keshav: *An Engineering Approach to Computer Networking: ATM Networks, the Internet, and the Telephone Network*. Addison-Wesley Professional, May 1997. ISBN: 978-0-201-63442-6
1. Cisco, â[Integrated Services Digital Network](http://docwiki.cisco.com/wiki/Integrated_Services_Digital_Network),â *docwiki.cisco.com*.
1. Othmar Kyas: *ATM Networks*. International Thomson Publishing, 1995. ISBN: 978-1-850-32128-6
1. â[InfiniBand FAQ](http://www.mellanox.com/related-docs/whitepapers/InfiniBandFAQ_FQ_100.pdf),â Mellanox Technologies, December 22, 2014.
1. Jose Renato Santos, Yoshio Turner, and G. (John) Janakiraman: â[End-to-End Congestion Control for InfiniBand](http://www.hpl.hp.com/techreports/2002/HPL-2002-359.pdf),â at *22nd Annual Joint Conference of the IEEE Computer and Communications Societies* (INFOCOM), April 2003. Also published by HP Laboratories Palo Alto, Tech Report HPL-2002-359. [doi:10.1109/INFCOM.2003.1208949](http://dx.doi.org/10.1109/INFCOM.2003.1208949)
1. Ulrich Windl, David Dalton, Marc Martinec, and Dale R. Worley: â[The NTP FAQ and HOWTO](http://www.ntp.org/ntpfaq/NTP-a-faq.htm),â *ntp.org*, November 2006.
1. John Graham-Cumming: â[How and why the leap second affected Cloudflare DNS](https://blog.cloudflare.com/how-and-why-the-leap-second-affected-cloudflare-dns/),â *blog.cloudflare.com*, January 1, 2017.
1. David Holmes: â[Inside the Hotspot VM: Clocks, Timers and Scheduling Events â Part I â Windows](https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks),â *blogs.oracle.com*, October 2, 2006.
1. Steve Loughran: â[Time on Multi-Core, Multi-Socket Servers](http://steveloughran.blogspot.co.uk/2015/09/time-on-multi-core-multi-socket-servers.html),â *steveloughran.blogspot.co.uk*, September 17, 2015.
1. James C. Corbett, Jeffrey Dean, Michael Epstein, et al.: â[Spanner: Googleâs Globally-Distributed Database](http://research.google.com/archive/spanner.html),â at *10th USENIX Symposium on Operating System Design and Implementation* (OSDI), October 2012.
1. M. Caporaloni and R. Ambrosini: â[How Closely Can a Personal Computer Clock Track the UTC Timescale Via the Internet?](https://iopscience.iop.org/0143-0807/23/4/103/),â *European Journal of Physics*, volume 23, number 4, pages L17âL21, June 2012. [doi:10.1088/0143-0807/23/4/103](http://dx.doi.org/10.1088/0143-0807/23/4/103)
1. Nelson Minar: â[A Survey of the NTP Network](http://alumni.media.mit.edu/~nelson/research/ntp-survey99/),â *alumni.media.mit.edu*, December 1999.
1. Viliam Holub: â[Synchronizing Clocks in a Cassandra Cluster Pt. 1 â The Problem](https://blog.logentries.com/2014/03/synchronizing-clocks-in-a-cassandra-cluster-pt-1-the-problem/),â *blog.logentries.com*, March 14, 2014.
1. Poul-Henning Kamp: â[The One-Second War (What Time Will You Die?)](http://queue.acm.org/detail.cfm?id=1967009),â *ACM Queue*, volume 9, number 4, pages 44â48, April 2011. [doi:10.1145/1966989.1967009](http://dx.doi.org/10.1145/1966989.1967009)
1. Nelson Minar: â[Leap Second Crashes Half the Internet](http://www.somebits.com/weblog/tech/bad/leap-second-2012.html),â *somebits.com*, July 3, 2012.
1. Christopher Pascoe: â[Time, Technology and Leaping Seconds](http://googleblog.blogspot.co.uk/2011/09/time-technology-and-leaping-seconds.html),â *googleblog.blogspot.co.uk*, September 15, 2011.
1. Mingxue Zhao and Jeff Barr: â[Look Before You Leap â The Coming Leap Second and AWS](https://aws.amazon.com/blogs/aws/look-before-you-leap-the-coming-leap-second-and-aws/),â *aws.amazon.com*, May 18, 2015.
1. Darryl Veitch and Kanthaiah Vijayalayan: â[Network Timing and the 2015 Leap Second](http://crin.eng.uts.edu.au/~darryl/Publications/LeapSecond_camera.pdf),â at *17th International Conference on Passive and Active Measurement* (PAM), April 2016. [doi:10.1007/978-3-319-30505-9_29](http://dx.doi.org/10.1007/978-3-319-30505-9_29)
1. â[Timekeeping in VMware Virtual Machines](http://www.vmware.com/resources/techresources/238),â Information Guide, VMware, Inc., December 2011.
1. â[MiFID II / MiFIR: Regulatory Technical and Implementing Standards â Annex I (Draft)](https://www.esma.europa.eu/sites/default/files/library/2015/11/2015-esma-1464_annex_i_-_draft_rts_and_its_on_mifid_ii_and_mifir.pdf),â European Securities and Markets Authority, Report ESMA/2015/1464, September 2015.
1. Luke Bigum: â[Solving MiFID II Clock Synchronisation With Minimum Spend (Part 1)](https://www.lmax.com/blog/staff-blogs/2015/11/27/solving-mifid-ii-clock-synchronisation-minimum-spend-part-1/),â *lmax.com*, November 27, 2015.
1. Kyle Kingsbury: â[Call Me Maybe: Cassandra](https://aphyr.com/posts/294-call-me-maybe-cassandra/),â *aphyr.com*, September 24, 2013.
1. John Daily: â[Clocks Are Bad, or, Welcome to the Wonderful World of Distributed Systems](http://basho.com/clocks-are-bad-or-welcome-to-distributed-systems/),â *basho.com*, November 12, 2013.
1. Kyle Kingsbury: â[The Trouble with Timestamps](https://aphyr.com/posts/299-the-trouble-with-timestamps),â *aphyr.com*, October 12, 2013.
1. Leslie Lamport: â[Time, Clocks, and the Ordering of Events in a Distributed System](http://research.microsoft.com/en-US/um/people/Lamport/pubs/time-clocks.pdf),â *Communications of the ACM*, volume 21, number 7, pages 558â565, July 1978. [doi:10.1145/359545.359563](http://dx.doi.org/10.1145/359545.359563)
1. Sandeep Kulkarni, Murat Demirbas, Deepak Madeppa, et al.: â[Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases](http://www.cse.buffalo.edu/tech-reports/2014-04.pdf),â State University of New York at Buffalo, Computer Science and Engineering Technical Report 2014-04, May 2014.
1. Justin Sheehy: â[There Is No Now: Problems With Simultaneity in Distributed Systems](https://queue.acm.org/detail.cfm?id=2745385),â *ACM Queue*, volume 13, number 3, pages 36â41, March 2015. [doi:10.1145/2733108](http://dx.doi.org/10.1145/2733108)
1. Murat Demirbas: â[Spanner: Google's Globally-Distributed Database](http://muratbuffalo.blogspot.co.uk/2013/07/spanner-googles-globally-distributed_4.html),â *muratbuffalo.blogspot.co.uk*, July 4, 2013.
1. Dahlia Malkhi and Jean-Philippe Martin: â[Spanner's Concurrency Control](http://www.cs.cornell.edu/~ie53/publications/DC-col51-Sep13.pdf),â *ACM SIGACT News*, volume 44, number 3, pages 73â77, September 2013. [doi:10.1145/2527748.2527767](http://dx.doi.org/10.1145/2527748.2527767)
1. Manuel Bravo, Nuno Diegues, Jingna Zeng, et al.: â[On the Use of Clocks to Enforce Consistency in the Cloud](http://sites.computer.org/debull/A15mar/p18.pdf),â *IEEE Data Engineering Bulletin*, volume 38, number 1, pages 18â31, March 2015.
1. Spencer Kimball: â[Living Without Atomic Clocks](http://www.cockroachlabs.com/blog/living-without-atomic-clocks/),â *cockroachlabs.com*, February 17, 2016.
1. Cary G. Gray and David R. Cheriton:â[Leases: An Efficient Fault-Tolerant Mechanism for Distributed File Cache Consistency](http://web.stanford.edu/class/cs240/readings/89-leases.pdf),â at *12th ACM Symposium on Operating Systems Principles* (SOSP), December 1989. [doi:10.1145/74850.74870](http://dx.doi.org/10.1145/74850.74870)
1. Todd Lipcon: â[Avoiding Full GCs in Apache HBase with MemStore-Local Allocation Buffers: Part 1](http://blog.cloudera.com/blog/2011/02/avoiding-full-gcs-in-hbase-with-memstore-local-allocation-buffers-part-1/),â *blog.cloudera.com*, February 24, 2011.
1. Martin Thompson: â[Java Garbage Collection Distilled](http://mechanical-sympathy.blogspot.co.uk/2013/07/java-garbage-collection-distilled.html),â *mechanical-sympathy.blogspot.co.uk*, July 16, 2013.
1. Alexey Ragozin: â[How to Tame Java GC Pauses? Surviving 16GiB Heap and Greater](http://java.dzone.com/articles/how-tame-java-gc-pauses),â *java.dzone.com*, June 28, 2011.
1. Christopher Clark, Keir Fraser, Steven Hand, et al.: â[Live Migration of Virtual Machines](http://www.cl.cam.ac.uk/research/srg/netos/papers/2005-nsdi-migration.pdf),â at *2nd USENIX Symposium on Symposium on Networked Systems Design & Implementation* (NSDI), May 2005.
1. Mike Shaver: â[fsyncers and Curveballs](http://shaver.off.net/diary/2008/05/25/fsyncers-and-curveballs/),â *shaver.off.net*, May 25, 2008.
1. Zhenyun Zhuang and Cuong Tran: â[Eliminating Large JVM GC Pauses Caused by Background IO Traffic](https://engineering.linkedin.com/blog/2016/02/eliminating-large-jvm-gc-pauses-caused-by-background-io-traffic),â *engineering.linkedin.com*, February 10, 2016.
1. David Terei and Amit Levy: â[Blade: A Data Center Garbage Collector](http://arxiv.org/pdf/1504.02578.pdf),â arXiv:1504.02578, April 13, 2015.
1. Martin Maas, Tim Harris, Krste AsanoviÄ, and John Kubiatowicz: â[Trash Day: Coordinating Garbage Collection in Distributed Systems](https://timharris.uk/papers/2015-hotos.pdf),â at *15th USENIX Workshop on Hot Topics in Operating Systems* (HotOS), May 2015.
1. â[Predictable Low Latency](http://cdn2.hubspot.net/hubfs/1624455/Website_2016/content/White%20papers/Cinnober%20on%20GC%20pause%20free%20Java%20applications.pdf),â Cinnober Financial Technology AB, *cinnober.com*, November 24, 2013.
1. Martin Fowler: â[The LMAX Architecture](http://martinfowler.com/articles/lmax.html),â *martinfowler.com*, July 12, 2011.
1. Flavio P. Junqueira and Benjamin Reed: *ZooKeeper: Distributed Process Coordination*. O'Reilly Media, 2013. ISBN: 978-1-449-36130-3
1. Enis Söztutar: â[HBase and HDFS: Understanding Filesystem Usage in HBase](http://www.slideshare.net/enissoz/hbase-and-hdfs-understanding-filesystem-usage),â at *HBaseCon*, June 2013.
1. Caitie McCaffrey: â[Clients Are Jerks: AKA How Halo 4 DoSed the Services at Launch & How We Survived](http://caitiem.com/2015/06/23/clients-are-jerks-aka-how-halo-4-dosed-the-services-at-launch-how-we-survived/),â *caitiem.com*, June 23, 2015.
1. Leslie Lamport, Robert Shostak, and Marshall Pease: â[The Byzantine Generals Problem](http://research.microsoft.com/en-us/um/people/lamport/pubs/byz.pdf),â *ACM Transactions on Programming Languages and Systems* (TOPLAS), volume 4, number 3, pages 382â401, July 1982. [doi:10.1145/357172.357176](http://dx.doi.org/10.1145/357172.357176)
1. Jim N. Gray: â[Notes on Data Base Operating Systems](http://research.microsoft.com/en-us/um/people/gray/papers/DBOS.pdf),â in *Operating Systems: An Advanced Course*, Lecture Notes in Computer Science, volume 60, edited by R. Bayer, R. M. Graham, and G. Seegmüller, pages 393â481, Springer-Verlag, 1978. ISBN: 978-3-540-08755-7
1. Brian Palmer: â[How Complicated Was the Byzantine Empire?](http://www.slate.com/articles/news_and_politics/explainer/2011/10/the_byzantine_tax_code_how_complicated_was_byzantium_anyway_.html),â *slate.com*, October 20, 2011.
1. Leslie Lamport: â[My Writings](http://research.microsoft.com/en-us/um/people/lamport/pubs/pubs.html),â *research.microsoft.com*, December 16, 2014. This page can be found by searching the web for the 23-character string obtained by removing the hyphens from the string `allla-mport-spubso-ntheweb`.
1. John Rushby: â[Bus Architectures for Safety-Critical Embedded Systems](http://www.csl.sri.com/papers/emsoft01/emsoft01.pdf),â at *1st International Workshop on Embedded Software* (EMSOFT), October 2001.
1. Jake Edge: â[ELC: SpaceX Lessons Learned](http://lwn.net/Articles/540368/),â *lwn.net*, March 6, 2013.
1. Andrew Miller and Joseph J. LaViola, Jr.: â[Anonymous Byzantine Consensus from Moderately-Hard Puzzles: A Model for Bitcoin](http://nakamotoinstitute.org/static/docs/anonymous-byzantine-consensus.pdf),â University of Central Florida, Technical Report CS-TR-14-01, April 2014.
1. James Mickens: â[The Saddest Moment](https://www.usenix.org/system/files/login-logout_1305_mickens.pdf),â *USENIX ;login: logout*, May 2013.
1. Evan Gilman: â[The Discovery of Apache ZooKeeperâs Poison Packet](http://www.pagerduty.com/blog/the-discovery-of-apache-zookeepers-poison-packet/),â *pagerduty.com*, May 7, 2015.
1. Jonathan Stone and Craig Partridge: â[When the CRC and TCP Checksum Disagree](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.27.7611&rep=rep1&type=pdf),â at *ACM Conference on Applications, Technologies, Architectures, and Protocols for Computer Communication* (SIGCOMM), August 2000. [doi:10.1145/347059.347561](http://dx.doi.org/10.1145/347059.347561)
1. Evan Jones: â[How Both TCP and Ethernet Checksums Fail](http://www.evanjones.ca/tcp-and-ethernet-checksums-fail.html),â *evanjones.ca*, October 5, 2015.
1. Cynthia Dwork, Nancy Lynch, and Larry Stockmeyer: â[Consensus in the Presence of Partial Synchrony](http://www.net.t-labs.tu-berlin.de/~petr/ADC-07/papers/DLS88.pdf),â *Journal of the ACM*, volume 35, number 2, pages 288â323, April 1988. [doi:10.1145/42282.42283](http://dx.doi.org/10.1145/42282.42283)
1. Peter Bailis and Ali Ghodsi: â[Eventual Consistency Today: Limitations, Extensions, and Beyond](http://queue.acm.org/detail.cfm?id=2462076),â *ACM Queue*, volume 11, number 3, pages 55-63, March 2013. [doi:10.1145/2460276.2462076](http://dx.doi.org/10.1145/2460276.2462076)
1. Bowen Alpern and Fred B. Schneider: â[Defining Liveness](https://www.cs.cornell.edu/fbs/publications/DefLiveness.pdf),â *Information Processing Letters*, volume 21, number 4, pages 181â185, October 1985. [doi:10.1016/0020-0190(85)90056-0](http://dx.doi.org/10.1016/0020-0190(85)90056-0)
1. Flavio P. Junqueira: â[Dude, Whereâs My Metadata?](http://fpj.me/2015/05/28/dude-wheres-my-metadata/),â *fpj.me*, May 28, 2015.
1. Scott Sanders: â[January 28th Incident Report](https://github.com/blog/2106-january-28th-incident-report),â *github.com*, February 3, 2016.
1. Jay Kreps: â[A Few Notes on Kafka and Jepsen](http://blog.empathybox.com/post/62279088548/a-few-notes-on-kafka-and-jepsen),â *blog.empathybox.com*, September 25, 2013.
1. Thanh Do, Mingzhe Hao, Tanakorn Leesatapornwongsa, et al.: â[Limplock: Understanding the Impact of Limpware on Scale-out Cloud Systems](http://ucare.cs.uchicago.edu/pdf/socc13-limplock.pdf),â at *4th ACM Symposium on Cloud Computing* (SoCC), October 2013. [doi:10.1145/2523616.2523627](http://dx.doi.org/10.1145/2523616.2523627)
1. Frank McSherry, Michael Isard, and Derek G. Murray: â[Scalability! But at What COST?](http://www.frankmcsherry.org/assets/COST.pdf),â at *15th USENIX Workshop on Hot Topics in Operating Systems* (HotOS), May 2015.
[^è¯è1]: åè¯ä¸ºï¼Hey I just met you. The networkâs laggy. But hereâs my data. So store it maybe.Hey, åºæ¹ç¼èªãCall Me Maybeãæè¯ï¼I just met you, And this is crazy, But here's my number, So call me, maybe?
------
| ä¸ä¸ç« | ç®å½ | ä¸ä¸ç« |
| ---------------------- | ------------------------------- | ------------------------------ |
| [第ä¸ç« ï¼äºå¡](ch7.md) | [设计æ°æ®å¯éååºç¨](README.md) | [第ä¹ç« ï¼ä¸è´æ§ä¸å
±è¯](ch9.md) |