# 第åäºç« ï¼æ°æ®ç³»ç»çæªæ¥ ![](img/ch12.png) > å¦æè¹é¿çç»æç®æ æ¯ä¿æ¤è¹åªï¼ä»åºè¯¥æ°¸è¿å¾ å¨æ¸¯å£ã > > ââ å£æ马æ¯ã»é¿å¥é£ãç¥å¦å¤§å ¨ãï¼1265-1274ï¼ --------------- [TOC] å°ç®å为æ¢ï¼æ¬ä¹¦ä¸»è¦æè¿°çæ¯ **ç°ç¶**ãå¨è¿æåä¸ç« ä¸ï¼æ们å°æ¾ç¼ **æªæ¥**ï¼è®¨è®ºåºè¯¥æ¯æä¹æ ·çï¼æå°æåºä¸äºæ³æ³ä¸æ¹æ³ï¼æç¸ä¿¡å®ä»¬è½ä»æ ¹æ¬ä¸æ¹è¿æ们设计ä¸æ建åºç¨çæ¹å¼ã 对æªæ¥ççæ³ä¸æ¨æµå½ç¶å ·æå¾å¤§ç主è§æ§ãæ以å¨æ°åæ¬ç« æ¶ï¼å½æåæ个人çè§ç¹æ¶ä¼ä½¿ç¨ç¬¬ä¸äººç§°ãä½ å®å ¨å¯ä»¥ä¸åæè¿äºè§ç¹å¹¶æåºèªå·±ççæ³ï¼ä½æå¸ææ¬ç« ä¸çæ¦å¿µï¼è³å°è½æ为å¯æææç讨论åºåç¹ï¼å¹¶æ¾æ¸ ä¸äºç»å¸¸è¢«æ··æ·çæ¦å¿µã [第ä¸ç« ](ch1.md) æ¦è¿°äºæ¬ä¹¦çç®æ ï¼æ¢ç´¢å¦ä½å建 **å¯é **ã**å¯ä¼¸ç¼©** å **å¯ç»´æ¤** çåºç¨ä¸ç³»ç»ãè¿ä¸ä¸»é¢è´¯ç©¿äºææçç« èï¼ä¾å¦ï¼æ们讨论äºè®¸å¤æå©äºæé«å¯é æ§ç容éç®æ³ï¼æå©äºæé«å¯ä¼¸ç¼©æ§çååºï¼ä»¥åæå©äºæé«å¯ç»´æ¤æ§çæ¼åä¸æ½è±¡æºå¶ãå¨æ¬ç« ä¸ï¼æ们å°æææè¿äºæ³æ³ç»åå¨ä¸èµ·ï¼å¹¶å¨å®ä»¬çåºç¡ä¸å±ææªæ¥ãæ们çç®æ æ¯ï¼åç°å¦ä½è®¾è®¡åºæ¯ç°æåºç¨æ´å¥½çåºç¨ ââ å¥å£®ãæ£ç¡®ãå¯æ¼åãä¸æç»å¯¹äººç±»æçã ## æ°æ®éæ æ¬ä¹¦ä¸åå¤åºç°ç主é¢æ¯ï¼å¯¹äºä»»ä½ç»å®çé®é¢é½ä¼æ好å ç§è§£å³æ¹æ¡ï¼ææè¿äºè§£å³æ¹æ¡é½æä¸åçä¼ç¼ºç¹ä¸å©å¼æè¡¡ãä¾å¦å¨ [第ä¸ç« ](ch3.md) 讨论åå¨å¼ææ¶ï¼æ们çå°äºæ¥å¿ç»æåå¨ãB æ 以ååå¼åå¨ãå¨ [第äºç« ](ch5.md) 讨论å¤å¶æ¶ï¼æ们çå°äºåé¢å¯¼è ãå¤é¢å¯¼è åæ é¢å¯¼è çæ¹æ³ã å¦æä½ æä¸ä¸ªç±»ä¼¼äº âææ³åå¨ä¸äºæ°æ®å¹¶ç¨ååæ¥è¯¢â çé®é¢ï¼é£ä¹å¹¶æ²¡æä¸ç§æ£ç¡®ç解å³æ¹æ¡ãä½å¯¹äºä¸åçå ·ä½ç¯å¢ï¼æ»ä¼æä¸åçåéæ¹æ³ã软件å®ç°éå¸¸å¿ é¡»éæ©ä¸ç§ç¹å®çæ¹æ³ã使åæ¡ä»£ç è·¯å¾è½åå°ç¨³å®å¥å£®ä¸è¡¨ç°è¯å¥½å·²ç»æ¯ä¸ä»¶é常å°é¾çäºæ äº ââ å°è¯å¨å个软件ä¸å®æææäºæ ï¼å ä¹å¯ä»¥ä¿è¯ï¼å®ç°ææä¼å¾å·®ã å æ¤è½¯ä»¶å·¥å ·çæä½³éæ©ä¹åå³äºæ åµãæ¯ä¸ç§è½¯ä»¶ï¼çè³æè°ç âéç¨â æ°æ®åºï¼é½æ¯é对ç¹å®ç使ç¨æ¨¡å¼è®¾è®¡çã é¢å¯¹è®©äººç¼è±ç¼ä¹±ç诸å¤æ¿ä»£åï¼ç¬¬ä¸ä¸ªææå°±æ¯å¼æ¸ 软件ä¸å ¶éç¨ç¯å¢çæ å°å ³ç³»ãä¾åºåä¸æ¿åè¯ä½ ä»ä»¬è½¯ä»¶ä¸éç¨çå·¥ä½è´è½½ï¼è¿æ¯å¯ä»¥ç解çãä½æ¯å¸æå åçç« èè½ç»ä½ æä¾ä¸äºé®é¢ï¼è®©ä½ 读åºåéè¡é´çè¨å¤ä¹æï¼å¹¶æ´å¥½å°ç解è¿äºæè¡¡ã ä½æ¯ï¼å³ä½¿ä½ å·²ç»å®å ¨ç解åç§å·¥å ·ä¸å ¶éç¨ç¯å¢é´çå ³ç³»ï¼è¿æä¸ä¸ªææï¼å¨å¤æçåºç¨ä¸ï¼æ°æ®çç¨æ³é常è±æ ·ç¾åºãä¸å¤ªå¯è½åå¨éç¨äº **ææ** ä¸åæ°æ®åºç¨åºæ¯ç软件ï¼å æ¤ä½ ä¸å¯é¿å å°éè¦æ¼åå 个ä¸åç软件æ¥ä»¥æä¾åºç¨æéçåè½ã ### ç»å使ç¨è¡çæ°æ®çå·¥å · ä¾å¦ï¼ä¸ºäºå¤çä»»æå ³é®è¯çæç´¢æ¥è¯¢ï¼å° OLTP æ°æ®åºä¸å ¨ææ索索å¼éæå¨ä¸èµ·æ¯å¾å¸¸è§ççéæ±ã尽管ä¸äºæ°æ®åºï¼ä¾å¦ PostgreSQLï¼å å«äºå ¨æç´¢å¼åè½ï¼å¯¹äºç®åçåºç¨å®å ¨å¤äºã1ãï¼ä½æ´å¤æçæç´¢è½åå°±éè¦ä¸ä¸çä¿¡æ¯æ£ç´¢å·¥å ·äºãç¸åçæ¯ï¼æ索索å¼é常ä¸éåä½ä¸ºæä¹ çè®°å½ç³»ç»ï¼å æ¤è®¸å¤åºç¨éè¦ç»åè¿ä¸¤ç§ä¸åçå·¥å ·ä»¥æ»¡è¶³ææéæ±ã æä»¬å¨ â[ä¿æç³»ç»åæ¥](ch11.md#ä¿æç³»ç»åæ¥)â ä¸æ¥è§¦è¿éææ°æ®ç³»ç»çé®é¢ãéçæ°æ®ä¸å表示形å¼çå¢å ï¼éæé®é¢åå¾è¶æ¥è¶å°é¾ãé¤äºæ°æ®åºåæ索索å¼ä¹å¤ï¼ä¹è®¸ä½ éè¦å¨åæç³»ç»ï¼æ°æ®ä»åºï¼ææ¹å¤çåæµå¤çç³»ç»ï¼ä¸ç»´æ¤æ°æ®å¯æ¬ï¼ç»´æ¤ä»åå§æ°æ®ä¸è¡ççç¼åï¼æåè§èåçæ°æ®çæ¬ï¼å°æ°æ®çå ¥æºå¨å¦ä¹ ãåç±»ãæåææ¨èç³»ç»ä¸ï¼æè åºäºæ°æ®åæ´åééç¥ã 令人æ讶çæ¯ï¼æç»å¸¸çå°è½¯ä»¶å·¥ç¨å¸ååºè¿æ ·çéè¿°ï¼âæ ¹æ®æçç»éªï¼99% ç人åªéè¦ Xâ æè â...... ä¸éè¦ Xâï¼å¯¹äºåç§åæ ·ç Xï¼ãæ认为è¿ç§éè¿°æ´åæ¯åè¨äººèªå·±çç»éªï¼èä¸æ¯ææ¯å®é ä¸çå®ç¨æ§ãå¯è½å¯¹æ°æ®æ§è¡çæä½ï¼å ¶èå´æå ¶å®½å¹¿ãæ人认为鸡èè毫æ æä¹çåè½å¯è½æ¯å«äººçæ ¸å¿éæ±ãå½ä½ æé«è§è§ï¼å¹¶èèè·¨è¶æ´ä¸ªç»ç»èå´çæ°æ®æµæ¶ï¼æ°æ®éæçéæ±å¾å¾å°±ä¼åå¾ææ¾èµ·æ¥ã #### ç解æ°æ®æµ å½éè¦å¨å¤ä¸ªåå¨ç³»ç»ä¸ç»´æ¤ç¸åæ°æ®çå¯æ¬ä»¥æ»¡è¶³ä¸åç访é®æ¨¡å¼æ¶ï¼ä½ è¦å¯¹è¾å ¥åè¾åºäºå¦ææï¼åªäºæ°æ®å åå ¥ï¼åªäºæ°æ®è¡¨ç¤ºè¡çèªåªäºæ¥æºï¼å¦ä½ä»¥æ£ç¡®çæ ¼å¼ï¼å°æææ°æ®å¯¼å ¥æ£ç¡®çå°æ¹ï¼ ä¾å¦ï¼ä½ å¯è½ä¼é¦å å°æ°æ®åå ¥ **è®°å½ç³»ç»** æ°æ®åºï¼æè·å¯¹è¯¥æ°æ®åºæåçåæ´ï¼è¯·åé â[åæ´æ°æ®æè·](ch11.md#åæ´æ°æ®æè·)âï¼ï¼ç¶åå°åæ´ä»¥ç¸åç顺åºåºç¨äºæ索索å¼ãå¦æåæ´æ°æ®æè·ï¼CDCï¼æ¯æ´æ°ç´¢å¼çå¯ä¸æ¹å¼ï¼åå¯ä»¥ç¡®å®è¯¥ç´¢å¼å®å ¨æ´¾çèªè®°å½ç³»ç»ï¼å æ¤ä¸å ¶ä¿æä¸è´ï¼é¤è½¯ä»¶é误å¤ï¼ãåå ¥æ°æ®åºæ¯å该系ç»æä¾æ°è¾å ¥çå¯ä¸æ¹å¼ã å 许åºç¨ç¨åºç´æ¥åå ¥æ索索å¼åæ°æ®åºå¼å ¥äºå¦ [å¾ 11-4](img/fig11-4.png) æ示çé®é¢ï¼å ¶ä¸ä¸¤ä¸ªå®¢æ·ç«¯åæ¶åéå²çªçåå ¥ï¼ä¸ä¸¤ä¸ªåå¨ç³»ç»æä¸å顺åºå¤çå®ä»¬ãå¨è¿ç§æ åµä¸ï¼æ¢ä¸æ¯æ°æ®åºè¯´äºç®ï¼ä¹ä¸æ¯æ索索å¼è¯´äºç®ï¼æ以å®ä»¬ååºäºç¸åçå³å®ï¼è¿å ¥å½¼æ¤é´æä¹ æ§çä¸ä¸è´ç¶æã å¦æä½ å¯ä»¥éè¿å个系ç»æ¥æä¾ææç¨æ·è¾å ¥ï¼ä»èå³å®ææåå ¥çæåºï¼åéè¿æç¸å顺åºå¤çåå ¥ï¼å¯ä»¥æ´å®¹æå°è¡çåºå ¶ä»æ°æ®è¡¨ç¤ºã è¿æ¯ç¶ææºå¤å¶æ¹æ³çä¸ä¸ªåºç¨ï¼æä»¬å¨ â[å ¨åºå¹¿æ](ch9.md#å ¨åºå¹¿æ)â ä¸çå°ãæ è®ºä½ ä½¿ç¨åæ´æ°æ®æè·è¿æ¯äºä»¶æº¯æºæ¥å¿ï¼é½ä¸å¦ç®åçåºäºå ¨åºçå³çååæ´éè¦ã åºäºäºä»¶æ¥å¿æ¥æ´æ°è¡çæ°æ®çç³»ç»ï¼é常å¯ä»¥åå° **ç¡®å®æ§** ä¸ **å¹çæ§**ï¼è¯·åé â[å¹çæ§](ch11.md#å¹çæ§)âï¼ï¼ä½¿å¾ä»æ éä¸æ¢å¤ç¸å½å®¹æã #### è¡çæ°æ®ä¸åå¸å¼äºå¡ ä¿æä¸åæ°æ®ç³»ç»å½¼æ¤ä¸è´çç»å ¸æ¹æ³æ¶ååå¸å¼äºå¡ï¼å¦ â[ååæ交ä¸ä¸¤é¶æ®µæ交](ch9.md#ååæ交ä¸ä¸¤é¶æ®µæ交)â ä¸æè¿°ãä¸åå¸å¼äºå¡ç¸æ¯ï¼ä½¿ç¨è¡çæ°æ®ç³»ç»çæ¹æ³å¦ä½ï¼ å¨æ½è±¡å±é¢ï¼å®ä»¬éè¿ä¸åçæ¹å¼è¾¾å°ç±»ä¼¼çç®æ ãåå¸å¼äºå¡éè¿ **é** è¿è¡äºæ¥æ¥å³å®åå ¥ç顺åºï¼è¯·åé â[两é¶æ®µéå®](ch7.md#两é¶æ®µéå®)âï¼ï¼è CDC åäºä»¶æº¯æºä½¿ç¨æ¥å¿è¿è¡æåºãåå¸å¼äºå¡ä½¿ç¨ååæ交æ¥ç¡®ä¿åæ´åªçæä¸æ¬¡ï¼èåºäºæ¥å¿çç³»ç»é常åºäº **ç¡®å®æ§éè¯** å **å¹çæ§**ã æ大çä¸åä¹å¤å¨äºäºå¡ç³»ç»é常æä¾ [线æ§ä¸è´æ§](ch9.md#线æ§ä¸è´æ§)ï¼è¿å å«çæç¨çä¿è¯ï¼ä¾å¦ [读己ä¹å](ch5.md#读己ä¹å)ãå¦ä¸æ¹é¢ï¼è¡çæ°æ®ç³»ç»é常æ¯å¼æ¥æ´æ°çï¼å æ¤å®ä»¬é»è®¤ä¸ä¼æä¾ç¸åçæ¶åºä¿è¯ã å¨æ¿æ为åå¸å¼äºå¡ä»åºä»£ä»·çæéåºæ¯ä¸ï¼å®ä»¬å·²è¢«æååºç¨ãä½æ¯ï¼æ认为 XA ç容éè½ååæ§è½å¾å·®å²ï¼è¯·åé â[å®è·µä¸çåå¸å¼äºå¡](ch9.md#å®è·µä¸çåå¸å¼äºå¡)âï¼ï¼è¿ä¸¥ééå¶äºå®çå®ç¨æ§ãæç¸ä¿¡ä¸ºåå¸å¼äºå¡è®¾è®¡ä¸ç§æ´å¥½çåè®®æ¯å¯è¡çãä½ä½¿è¿æ ·ä¸ç§å议被ç°æå·¥å ·å¹¿æ³æ¥åæ¯å¾æææçï¼ä¸ä¸æ¯ç«ç«¿è§å½±çäºã å¨æ²¡æ广æ³æ¯æçè¯å¥½åå¸å¼äºå¡åè®®çæ åµä¸ï¼æ认为åºäºæ¥å¿çè¡çæ°æ®æ¯éæä¸åæ°æ®ç³»ç»çææåéçæ¹æ³ãç¶èï¼è¯¸å¦è¯»å·±ä¹åçä¿è¯æ¯æç¨çï¼æ认为åè¯ææ人 âæç»ä¸è´æ§æ¯ä¸å¯é¿å ç ââ å¿ä¸å¿å¹¶å¦ä¼åå®æ交éâ æ¯æ²¡æä»ä¹å»ºè®¾æ§çï¼è³å°å¨ç¼ºä¹ **å¦ä½** åºå¯¹çè¯å¥½æ导æ¶ï¼ã å¨ â[å°äºæ åæ£ç¡®](#å°äºæ åæ£ç¡®)â ä¸ï¼æ们å°è®¨è®ºä¸äºå¨å¼æ¥è¡çç³»ç»ä¹ä¸å®ç°æ´å¼ºä¿éçæ¹æ³ï¼å¹¶è¿ååå¸å¼äºå¡ååºäºæ¥å¿çå¼æ¥ç³»ç»ä¹é´çä¸é´å°å¸¦ã #### å ¨åºçéå¶ å¯¹äºè¶³å¤å°çç³»ç»ï¼æ建ä¸ä¸ªå®å ¨æåºçäºä»¶æ¥å¿æ¯å®å ¨å¯è¡çï¼æ£å¦å主å¤å¶æ°æ®åºçæµè¡æè¯æçé£æ ·ï¼å®æ£å¥½å»ºç«äºè¿æ ·ä¸ç§æ¥å¿ï¼ãä½æ¯ï¼éçç³»ç»åæ´å¤§æ´å¤æçå·¥ä½è´è½½ä¼¸ç¼©ï¼éå¶å¼å§åºç°ï¼ * å¨å¤§å¤æ°æ åµä¸ï¼æ建å®å ¨æåºçæ¥å¿ï¼éè¦ææäºä»¶æ±éäºå³å®é¡ºåºç **å个é¢å¯¼è èç¹**ãå¦æäºä»¶ååé大äºåå°è®¡ç®æºçå¤çè½åï¼åéè¦å°å ¶ååºå°å¤å°è®¡ç®æºä¸ï¼è¯·åé â[ååºæ¥å¿](ch11.md#ååºæ¥å¿)âï¼ãç¶å两个ä¸åååºä¸çäºä»¶é¡ºåºå ³ç³»å°±ä¸æç¡®äºã * å¦ææå¡å¨åå¸å¨å¤ä¸ª **å°çä½ç½®åæ£** çæ°æ®ä¸å¿ä¸ï¼ä¾å¦ä¸ºäºå®¹å¿æ´ä¸ªæ°æ®ä¸å¿æ线ï¼ä½ é常å¨æ¯ä¸ªæ°æ®ä¸å¿é½æåç¬ç主åºï¼å 为ç½ç»å»¶è¿ä¼å¯¼è´åæ¥çè·¨æ°æ®ä¸å¿åè°æçä½ä¸ï¼è¯·åé â[å¤ä¸»å¤å¶](ch5.md#å¤ä¸»å¤å¶)âï¼ãè¿æå³çæºèªä¸¤ä¸ªä¸åæ°æ®ä¸å¿çäºä»¶é¡ºåºæªå®ä¹ã * å°åºç¨ç¨åºé¨ç½²ä¸ºå¾®æå¡æ¶ï¼è¯·åé â[æå¡ä¸çæ°æ®æµï¼REST ä¸ RPC](ch4.md#æå¡ä¸çæ°æ®æµï¼RESTä¸RPC)âï¼ï¼å¸¸è§ç设计éæ©æ¯å°æ¯ä¸ªæå¡åå ¶æä¹ ç¶æä½ä¸ºç¬ç«åå è¿è¡é¨ç½²ï¼æå¡ä¹é´ä¸å ±äº«æä¹ ç¶æãå½ä¸¤ä¸ªäºä»¶æ¥èªä¸åçæå¡æ¶ï¼è¿äºäºä»¶é´ç顺åºæªå®ä¹ã * æäºåºç¨ç¨åºå¨å®¢æ·ç«¯ä¿åç¶æï¼è¯¥ç¶æå¨ç¨æ·è¾å ¥æ¶ç«å³æ´æ°ï¼æ éçå¾ æå¡å¨ç¡®è®¤ï¼ï¼çè³å¯ä»¥ç»§ç»è±æºå·¥ä½ï¼è¯·åé â[éè¦ç¦»çº¿æä½ç客æ·ç«¯](ch5.md#éè¦ç¦»çº¿æä½ç客æ·ç«¯)âï¼ã对äºè¿æ ·çåºç¨ç¨åºï¼å®¢æ·ç«¯åæå¡å¨å¾å¯è½ä»¥ä¸åç顺åºçå°äºä»¶ã å¨å½¢å¼ä¸ï¼å³å®äºä»¶çå ¨å±é¡ºåºç§°ä¸º **å ¨åºå¹¿æ**ï¼ç¸å½äº **å ±è¯**ï¼è¯·åé â[å ±è¯ç®æ³åå ¨åºå¹¿æ](ch9.md#å ±è¯ç®æ³åå ¨åºå¹¿æ)âï¼ã大å¤æ°å ±è¯ç®æ³é½æ¯é对å个èç¹çååé足以å¤çæ´ä¸ªäºä»¶æµçæ åµè设计çï¼å¹¶ä¸è¿äºç®æ³ä¸æä¾å¤ä¸ªèç¹å ±äº«äºä»¶æåºå·¥ä½çæºå¶ã设计å¯ä»¥ä¼¸ç¼©è³å个èç¹çååéä¹ä¸ï¼ä¸å¨å°çä½ç½®åæ£çç¯å¢ä¸ä»ç¶å·¥ä½è¯å¥½ççå ±è¯ç®æ³ä»ç¶æ¯ä¸ä¸ªå¼æ¾çç 究é®é¢ã #### æåºäºä»¶ä»¥æè·å æå ³ç³» å¨äºä»¶ä¹é´ä¸åå¨å æå ³ç³»çæ åµä¸ï¼å ¨åºç缺ä¹å¹¶ä¸æ¯ä¸ä¸ªå¤§é®é¢ï¼å 为并åäºä»¶å¯ä»¥ä»»ææåºãå ¶ä»ä¸äºæ åµå¾å®¹æå¤çï¼ä¾å¦ï¼å½åä¸å¯¹è±¡æå¤ä¸ªæ´æ°æ¶ï¼å®ä»¬å¯ä»¥éè¿å°ç¹å®å¯¹è±¡ ID çæææ´æ°è·¯ç±å°ç¸åçæ¥å¿ååºæ¥å®å ¨æåºãç¶èï¼å æå ³ç³»ææ¶ä¼ä»¥æ´å¾®å¦çæ¹å¼åºç°ï¼è¯·åé â[顺åºä¸å æå ³ç³»](ch9.md#顺åºä¸å æå ³ç³»)âï¼ã ä¾å¦ï¼èèä¸ä¸ªç¤¾äº¤ç½ç»æå¡ï¼ä»¥åä¸å¯¹æ¾å¤äºæç±å ³ç³»ä½ååæçç¨æ·ãå ¶ä¸ä¸ä¸ªç¨æ·å°å¦ä¸ä¸ªç¨æ·ä»å¥½åä¸ç§»é¤ï¼ç¶ååå©ä½ç好ååéæ¶æ¯ï¼æ±æ¨ä»ä»¬çåä»»ãç¨æ·çå¿ææ¯ä»ä»¬çåä»»ä¸åºè¯¥çå°è¿äºç²é²çæ¶æ¯ï¼å 为æ¶æ¯æ¯å¨å¥½åç¶æ解é¤ååéçã ä½æ¯å¦æ好åå ³ç³»ç¶æä¸æ¶æ¯åå¨å¨ä¸åçå°æ¹ï¼å¨è¿æ ·ä¸ä¸ªç³»ç»ä¸ï¼å¯è½ä¼åºç° **解é¤å¥½å** äºä»¶ä¸ **åéæ¶æ¯** äºä»¶ä¹é´çå æä¾èµä¸¢å¤±çæ åµãå¦æå æä¾èµå ³ç³»æ²¡æ被ææå°ï¼ååéæå ³æ°æ¶æ¯çéç¥çæå¡å¯è½ä¼å¨ **解é¤å¥½å** äºä»¶ä¹åå¤ç **åéæ¶æ¯** äºä»¶ï¼ä»èé误å°ååä»»åééç¥ã å¨æ¬ä¾ä¸ï¼éç¥å®é ä¸æ¯æ¶æ¯å好åå表ä¹é´çè¿æ¥ï¼ä½¿å¾å®ä¸æ们å å讨论çè¿æ¥çæ¶åºé®é¢æå ³ï¼è¯·åé â[è¿æ¥çæ¶é´ä¾èµæ§](ch11.md#è¿æ¥çæ¶é´ä¾èµæ§)âï¼ãä¸å¹¸çæ¯ï¼è¿ä¸ªé®é¢ä¼¼ä¹å¹¶æ²¡æä¸ä¸ªç®åççæ¡ã2,3ããèµ·ç¹å æ¬ï¼ * é»è¾æ¶é´æ³å¯ä»¥æä¾æ éåè°çå ¨å±é¡ºåºï¼è¯·åé â[åºåå·é¡ºåº](ch9.md#åºåå·é¡ºåº)âï¼ï¼å æ¤å®ä»¬å¯è½æå©äºå ¨åºå¹¿æä¸å¯è¡çæ åµãä½æ¯ï¼ä»ä»¬ä»ç¶è¦æ±æ¶ä»¶äººå¤çä¸æ顺åºåéçäºä»¶ï¼å¹¶ä¸éè¦ä¼ éå ¶ä»å æ°æ®ã * å¦æä½ å¯ä»¥è®°å½ä¸ä¸ªäºä»¶æ¥è®°å½ç¨æ·å¨ååºå³å®ä¹åæçå°çç³»ç»ç¶æï¼å¹¶ç»è¯¥äºä»¶ä¸ä¸ªå¯ä¸çæ è¯ç¬¦ï¼é£ä¹åé¢çä»»ä½äºä»¶é½å¯ä»¥å¼ç¨è¯¥äºä»¶æ è¯ç¬¦æ¥è®°å½å æå ³ç³»ã4ããæ们å°å¨ â[读ä¹æ¯äºä»¶](#读ä¹æ¯äºä»¶)â ä¸åå°è¿ä¸ªæ³æ³ã * å²çªè§£å³ç®æ³ï¼è¯·åé â[èªå¨å²çªè§£å³](ch5.md#èªå¨å²çªè§£å³)âï¼æå©äºå¤ç以æå¤é¡ºåºä¼ éçäºä»¶ãå®ä»¬å¯¹äºç»´æ¤ç¶æå¾æç¨ï¼ä½å¦æè¡ä¸ºæå¤é¨å¯ä½ç¨ï¼ä¾å¦ï¼ç»ç¨æ·åééç¥ï¼ï¼å°±æ²¡ä»ä¹å¸®å©äºã ä¹è®¸ï¼éçæ¶é´çæ¨ç§»ï¼åºç¨å¼å模å¼å°åºç°ï¼ä½¿å¾è½å¤ææå°æè·å æä¾èµå ³ç³»ï¼å¹¶ä¸ä¿ææ£ç¡®çè¡çç¶æï¼èä¸ä¼è¿«ä½¿ææäºä»¶ç»åå ¨åºå¹¿æçç¶é¢ï¼ã ### æ¹å¤çä¸æµå¤ç æä¼è¯´æ°æ®éæçç®æ æ¯ï¼ç¡®ä¿æ°æ®æç»è½å¨æææ£ç¡®çå°æ¹è¡¨ç°åºæ£ç¡®çå½¢å¼ãè¿æ ·åéè¦æ¶è´¹è¾å ¥ã转æ¢ãè¿æ¥ãè¿æ»¤ãèåãè®ç»æ¨¡åãè¯ä¼°ã以åæç»ååºéå½çè¾åºãæ¹å¤çåæµå¤çæ¯å®ç°è¿ä¸ç®æ çå·¥å ·ã æ¹å¤çåæµå¤ççè¾åºæ¯è¡çæ°æ®éï¼ä¾å¦æ索索å¼ãç©åè§å¾ãåç¨æ·æ¾ç¤ºç建议ãèåææ çï¼è¯·åé â[æ¹å¤çå·¥ä½æµçè¾åº](ch10.md#æ¹å¤çå·¥ä½æµçè¾åº)â å â[æµå¤ççåºç¨](ch11.md#æµå¤ççåºç¨)âï¼ã æ£å¦æä»¬å¨ [第åç« ](ch10.md) å [第åä¸ç« ](ch11.md) ä¸çå°çï¼æ¹å¤çåæµå¤çæ许å¤å ±åçååï¼ä¸»è¦çæ ¹æ¬åºå«å¨äºæµå¤çå¨å¨æ éæ°æ®éä¸è¿è¡ï¼èæ¹å¤çè¾å ¥æ¯å·²ç¥çæé大å°ãå¤çå¼æçå®ç°æ¹å¼ä¹æå¾å¤ç»èä¸çå·®å¼ï¼ä½æ¯è¿äºåºå«å·²ç»å¼å§æ¨¡ç³ã Spark å¨æ¹å¤çå¼æä¸æ§è¡æµå¤çï¼å°æµå解为 **å¾®æ¹æ¬¡ï¼microbatchesï¼**ï¼è Apache Flink åå¨æµå¤çå¼æä¸æ§è¡æ¹å¤çã5ããååä¸ï¼ä¸ç§ç±»åçå¤çå¯ä»¥ç¨å¦ä¸ç§ç±»åæ¥æ¨¡æï¼ä½æ¯æ§è½ç¹å¾ä¼ææä¸åï¼ä¾å¦ï¼å¨è·³è·ææ»å¨çªå£ä¸ï¼å¾®æ¹æ¬¡å¯è½è¡¨ç°ä¸ä½³ã6ãã #### ç»´æ¤è¡çç¶æ æ¹å¤çæçå¾å¼ºçå½æ°å¼é£æ ¼ï¼å³ä½¿å ¶ä»£ç ä¸æ¯ç¨å½æ°å¼è¯è¨ç¼åçï¼ï¼å®é¼å±ç¡®å®æ§ç纯å½æ°ï¼å ¶è¾åºä» ä¾èµäºè¾å ¥ï¼é¤äºæ¾å¼è¾åºå¤æ²¡æå¯ä½ç¨ï¼å°è¾å ¥è§ä½ä¸å¯åçï¼ä¸è¾åºæ¯ä» 追å çãæµå¤çä¸ä¹ç±»ä¼¼ï¼ä½å®æ©å±äºç®å以å 许å管ççã容éçç¶æï¼è¯·åé â[失败åé建ç¶æâ](ch11.md#失败åé建ç¶æ)ï¼ã å ·æè¯å¥½å®ä¹çè¾å ¥åè¾åºçç¡®å®æ§å½æ°çåçä¸ä» æå©äºå®¹éï¼è¯·åé â[å¹çæ§](ch11.md#å¹çæ§)âï¼ï¼ä¹ç®åäºæå ³ç»ç»ä¸æ°æ®æµçæ¨çã7ããæ 论è¡çæ°æ®æ¯æ索索å¼ãç»è®¡æ¨¡åè¿æ¯ç¼åï¼éç¨è¿ç§è§ç¹æèé½æ¯å¾æ帮å©çï¼å°å ¶è§ä¸ºä»ä¸ä¸ªä¸è¥¿è¡çåºå¦ä¸ä¸ªçæ°æ®ç®¡éï¼éè¿å½æ°å¼åºç¨ä»£ç æ¨éä¸ä¸ªç³»ç»çç¶æåæ´ï¼å¹¶å°å ¶ææåºç¨è³è¡çç³»ç»ä¸ã ååä¸ï¼è¡çæ°æ®ç³»ç»å¯ä»¥åæ¥å°ç»´æ¤ï¼å°±åå ³ç³»æ°æ®åºå¨ä¸ç´¢å¼è¡¨åå ¥æä½ç¸åçäºå¡ä¸åæ¥æ´æ°æ¬¡çº§ç´¢å¼ä¸æ ·ãç¶èï¼å¼æ¥æ¯ä½¿åºäºäºä»¶æ¥å¿çç³»ç»ç¨³å¥çåå ï¼å®å 许系ç»çä¸é¨åæ é被æå¶å¨æ¬å°ãèå¦æä»»ä½ä¸ä¸ªåä¸è 失败ï¼åå¸å¼äºå¡å°ä¸æ¢ï¼å æ¤å®ä»¬å¾åäºéè¿å°æ éä¼ æå°ç³»ç»çå ¶ä½é¨åæ¥æ¾å¤§æ éï¼è¯·åé â[åå¸å¼äºå¡çéå¶](ch9.md#åå¸å¼äºå¡çéå¶)âï¼ã æä»¬å¨ â[ååºä¸æ¬¡çº§ç´¢å¼](ch6.md#ååºä¸æ¬¡çº§ç´¢å¼)â ä¸çå°ï¼æ¬¡çº§ç´¢å¼ç»å¸¸è·¨è¶ååºè¾¹çãå ·æ次级索å¼çååºç³»ç»éè¦å°åå ¥åéå°å¤ä¸ªååºï¼å¦æç´¢å¼æå ³é®è¯ååºçè¯ï¼æå°è¯»ååéå°ææååºï¼å¦æç´¢å¼æ¯æææ¡£ååºçè¯ï¼ãå¦æç´¢å¼æ¯å¼æ¥ç»´æ¤çï¼è¿ç§è·¨ååºéä¿¡ä¹æ¯æå¯é åæå¯ä¼¸ç¼©çã8ãï¼å¦è¯·åé â[å¤ååºæ°æ®å¤ç](#å¤ååºæ°æ®å¤ç)âï¼ã #### åºç¨æ¼ååéæ°å¤çæ°æ® å¨ç»´æ¤è¡çæ°æ®æ¶ï¼æ¹å¤çåæµå¤çé½æ¯æç¨çãæµå¤çå 许å°è¾å ¥ä¸çåå以ä½å»¶è¿åæ å¨è¡çè§å¾ä¸ï¼èæ¹å¤çå 许éæ°å¤ç大é累积çåå²æ°æ®ä»¥ä¾¿å°æ°è§å¾å¯¼åºå°ç°ææ°æ®éä¸ã ç¹å«æ¯ï¼éæ°å¤çç°ææ°æ®ä¸ºç»´æ¤ç³»ç»ãæ¼å并æ¯ææ°åè½åéæ±åæ´æä¾äºä¸ä¸ªè¯å¥½çæºå¶ï¼è¯·åé [第åç« ](ch4.md)ï¼ã没æéæ°è¿è¡å¤çï¼æ¨¡å¼æ¼åå°ä» éäºç®åçååï¼ä¾å¦åè®°å½ä¸æ·»å æ°çå¯éå段ææ·»å æ°ç±»åçè®°å½ãæ 论æ¯å¨åæ¶æ¨¡å¼è¿æ¯å¨è¯»æ¶æ¨¡å¼ä¸é½æ¯å¦æ¤ï¼è¯·åé â[æ档模åä¸ç模å¼çµæ´»æ§](ch2.md#æ档模åä¸ç模å¼çµæ´»æ§)âï¼ãå¦ä¸æ¹é¢ï¼éè¿éæ°å¤çï¼å¯ä»¥å°æ°æ®ééç»ä¸ºä¸ä¸ªå®å ¨ä¸åç模åï¼ä»¥ä¾¿æ´å¥½å°æ»¡è¶³æ°çè¦æ±ã > ### éè·¯ä¸ç模å¼è¿ç§» > > 大è§æ¨¡ç â模å¼è¿ç§»â ä¹åçå¨é计ç®æºç³»ç»ä¸ãä¾å¦ï¼å¨ 19 ä¸çºªè±å½é路建设åæï¼è½¨è·ï¼ä¸¤è½¨ä¹é´çè·ç¦»ï¼å°±æäºåç§åæ ·çç«äºæ åã为ä¸ç§è½¨è·è建çå车ä¸è½å¨å¦ä¸ç§è½¨è·ç轨éä¸è¿è¡ï¼è¿éå¶äºç«è½¦ç½ç»ä¸å¯è½çç¸äºè¿æ¥ã9ãã > > å¨ 1846 å¹´æç»ç¡®å®äºä¸ä¸ªæ å轨è·ä¹åï¼å ¶ä»è½¨è·ç轨éå¿ é¡»è½¬æ¢ ââ ä½æ¯å¦ä½å¨ä¸åè¿ç«è½¦çº¿è·¯çæ åµä¸è¿è¡æ°æçè³æ°å¹´çè¿ç§»ï¼è§£å³çåæ³æ¯é¦å éè¿æ·»å 第ä¸æ¡è½¨éå°è½¨é转æ¢ä¸º **å轨è·ï¼dual guageï¼** æ **æ··å轨è·**ãè¿ç§è½¬æ¢å¯ä»¥éæ¸å®æï¼å½å®ææ¶ï¼ä¸¤ç§è½¨è·çå车é½å¯ä»¥å¨çº¿è·¯ä¸è·ï¼ä½¿ç¨ä¸æ¡è½¨éä¸ç两æ¡ãäºå®ä¸ï¼ä¸æ¦ææçå车é½è½¬æ¢ææ å轨è·ï¼é£ä¹å¯ä»¥ç§»é¤æä¾éæ å轨è·ç轨éã > > 以è¿ç§æ¹å¼ âåå å·¥â ç°æç轨éï¼è®©æ°æ§çæ¬å¹¶åï¼å¯ä»¥å¨å å¹´çæ¶é´å éæ¸æ¹å轨è·ãç¶èï¼è¿æ¯ä¸é¡¹æè´µçäºä¸ï¼è¿å°±æ¯ä»å¤©éæ å轨è·ä»ç¶åå¨çåå ãä¾å¦ï¼æ§é山湾åºç BART ç³»ç»ä½¿ç¨äºä¸ç¾å½å¤§é¨åå°åºä¸åç轨è·ã è¡çè§å¾å 许 **æ¸è¿æ¼åï¼gradual evolutionï¼**ãå¦æä½ æ³éæ°æ建æ°æ®éï¼ä¸éè¦æ§è¡çªç¶åæ¢å¼çè¿ç§»ãåè代ä¹çæ¯ï¼ä½ å¯ä»¥å°æ§æ¶æåæ°æ¶æ并æç»´æ¤ä¸ºç¸ååºç¡æ°æ®ä¸ç两个ç¬ç«è¡çè§å¾ãç¶åå¯ä»¥å¼å§å°å°éç¨æ·è½¬ç§»å°æ°è§å¾ï¼ä»¥æµè¯å ¶æ§è½å¹¶åç°ä»»ä½é误ï¼è大å¤æ°ç¨æ·ä»ç¶ä¼è¢«è·¯ç±å°æ§è§å¾ãä½ å¯ä»¥éæ¸å°å¢å 访é®æ°è§å¾çç¨æ·æ¯ä¾ï¼æç»å¯ä»¥å é¤æ§è§å¾ã10ãã è¿ç§éæ¸è¿ç§»çç¾å¦ä¹å¤å¨äºï¼å¦æåºç°é®é¢ï¼æ¯ä¸ªé¶æ®µçè¿ç¨é½å¾å®¹æé转ï¼ä½ å§ç»æä¸ä¸ªå¯ä»¥åæ»çå¯ç¨ç³»ç»ãéè¿éä½ä¸å¯éæ害çé£é©ï¼ä½ è½å¯¹ç»§ç»åè¿æ´æä¿¡å¿ï¼ä»èæ´å¿«å°æ¹åç³»ç»ã11ãã #### Lambdaæ¶æ å¦ææ¹å¤çç¨äºéæ°å¤çåå²æ°æ®ï¼èæµå¤çç¨äºå¤çæè¿çæ´æ°ï¼é£ä¹å¦ä½å°è¿ä¸¤è ç»åèµ·æ¥ï¼Lambda æ¶æã12ãæ¯è¿æ¹é¢çä¸ä¸ªå»ºè®®ï¼å¼èµ·äºå¾å¤å ³æ³¨ã Lambda æ¶æçæ ¸å¿ææ³æ¯éè¿å°ä¸å¯åäºä»¶éå å°ä¸æå¢é¿çæ°æ®éæ¥è®°å½ä¼ å ¥æ°æ®ï¼è¿ç±»ä¼¼äºäºä»¶æº¯æºï¼è¯·åé â[äºä»¶æº¯æº](ch11.md#äºä»¶æº¯æº)âï¼ã为äºä»è¿äºäºä»¶ä¸è¡çåºè¯»åä¼åçè§å¾ï¼Lambda æ¶æ建议并è¡è¿è¡ä¸¤ä¸ªä¸åçç³»ç»ï¼æ¹å¤çç³»ç»ï¼å¦ Hadoop MapReduceï¼åç¬ç«çæµå¤çç³»ç»ï¼å¦ Stormï¼ã å¨ Lambda æ¹æ³ä¸ï¼æµå¤çå¨æ¶èäºä»¶å¹¶å¿«éçæ对è§å¾çè¿ä¼¼æ´æ°ï¼æ¹å¤çå¨ç¨åå°ä½¿ç¨åä¸ç»äºä»¶å¹¶çæè¡çè§å¾çæ´æ£çæ¬ãè¿ä¸ªè®¾è®¡èåçåå æ¯æ¹å¤çæ´ç®åï¼å æ¤ä¸æåºéï¼èæµå¤çå¨è¢«è®¤ä¸ºæ¯ä¸å¤ªå¯é åé¾ä»¥å®¹éçï¼è¯·åé â[容é](ch11.md#容é)âï¼ãèä¸ï¼æµå¤çå¯ä»¥ä½¿ç¨å¿«éè¿ä¼¼ç®æ³ï¼èæ¹å¤ç使ç¨è¾æ ¢ç精确ç®æ³ã Lambda æ¶ææ¯ä¸ç§æå½±ååçæ³æ³ï¼å®å°æ°æ®ç³»ç»ç设计åå¾æ´å¥½ï¼å°¤å ¶æ¯éè¿æ¨å¹¿è¿æ ·çååï¼å¨ä¸å¯åäºä»¶æµä¸å»ºç«è¡çè§å¾ï¼å¹¶å¨éè¦æ¶éæ°å¤çäºä»¶ãä½æ¯æä¹è®¤ä¸ºå®æä¸äºå®é é®é¢ï¼ * å¨æ¹å¤çåæµå¤çæ¡æ¶ä¸ç»´æ¤ç¸åçé»è¾æ¯å¾æ¾èçé¢å¤å·¥ä½ãè½ç¶å Summingbirdã13ãè¿æ ·çåºæä¾äºä¸ç§å¯ä»¥å¨æ¹å¤çåæµå¤ççä¸ä¸æä¸è¿è¡ç计ç®æ½è±¡ãè°è¯ãè°æ´åç»´æ¤ä¸¤ä¸ªä¸åç³»ç»çæä½å¤ææ§ä¾ç¶åå¨ã14ãã * ç±äºæµç®¡éåæ¹å¤ç管é产çç¬ç«çè¾åºï¼å æ¤éè¦å并å®ä»¬ä»¥ååºç¨æ·è¯·æ±ãå¦æ计ç®æ¯åºäºæ»å¨çªå£çç®åèåï¼åå并ç¸å½å®¹æï¼ä½å¦æè§å¾åºäºæ´å¤æçæä½ï¼ä¾å¦è¿æ¥åä¼è¯åï¼è导åºï¼æè è¾åºä¸æ¯æ¶é´åºåï¼åä¼åå¾é常å°é¾ã * 尽管æè½åéæ°å¤çæ´ä¸ªåå²æ°æ®éæ¯å¾å¥½çï¼ä½å¨å¤§åæ°æ®éä¸è¿æ ·åç»å¸¸ä¼å¼é巨大ãå æ¤ï¼æ¹å¤çæµæ°´çº¿é常éè¦è®¾ç½®ä¸ºå¤çå¢éæ¹å¤çï¼ä¾å¦ï¼å¨æ¯å°æ¶ç»ææ¶å¤çä¸å°æ¶çæ°æ®ï¼ï¼èä¸æ¯éæ°å¤çææå 容ãè¿å¼åäº â[æ¶é´æ¨ç](ch11.md#æ¶é´æ¨ç)â ä¸è®¨è®ºçé®é¢ï¼ä¾å¦å¤çæ»çäºä»¶åå¤çè·¨æ¹æ¬¡è¾¹çççªå£ãå¢éåæ¹å¤ç计ç®ä¼å¢å å¤ææ§ï¼ä½¿å ¶æ´ç±»ä¼¼äºæµå¼ä¼ è¾å±ï¼è¿ä¸ä¿ææ¹å¤çå±å°½å¯è½ç®åçç®æ èéèé©°ã #### ç»ä¸æ¹å¤çåæµå¤ç æè¿çå·¥ä½ä½¿å¾ Lambda æ¶æçä¼ç¹å¨æ²¡æå ¶ç¼ºç¹çæ åµä¸å¾ä»¥å®ç°ï¼å 许æ¹å¤ç计ç®ï¼éæ°å¤çåå²æ°æ®ï¼åæµè®¡ç®ï¼å¨äºä»¶å°è¾¾æ¶å³å¤çï¼å¨åä¸ä¸ªç³»ç»ä¸å®ç°ã15ãã å¨ä¸ä¸ªç³»ç»ä¸ç»ä¸æ¹å¤çåæµå¤çéè¦ä»¥ä¸åè½ï¼è¿äºåè½ä¹æ£å¨è¶æ¥è¶å¹¿æ³å°è¢«æä¾ï¼ * éè¿å¤çæè¿äºä»¶æµçç¸åå¤çå¼ææ¥éæåå²äºä»¶çè½åãä¾å¦ï¼åºäºæ¥å¿çæ¶æ¯ä»£çå¯ä»¥éææ¶æ¯ï¼è¯·åé â[éææ§æ¶æ¯](ch11.md#éææ§æ¶æ¯)âï¼ï¼æäºæµå¤çå¨å¯ä»¥ä» HDFS çåå¸å¼æ件系ç»è¯»åè¾å ¥ã * 对äºæµå¤çå¨æ¥è¯´ï¼æ°å¥½ä¸æ¬¡è¯ä¹ ââ å³ç¡®ä¿è¾åºä¸æªåçæ éçè¾åºç¸åï¼å³ä½¿äºå®ä¸åçæ éï¼è¯·åé â[容é](ch11.md#容é)âï¼ãä¸æ¹å¤çä¸æ ·ï¼è¿éè¦ä¸¢å¼ä»»ä½å¤±è´¥ä»»å¡çé¨åè¾åºã * æäºä»¶æ¶é´è¿è¡çªå£åçå·¥å ·ï¼èä¸æ¯æå¤çæ¶é´è¿è¡çªå£åï¼å 为å¤çåå²äºä»¶æ¶ï¼å¤çæ¶é´æ¯«æ æä¹ï¼è¯·åé â[æ¶é´æ¨ç](ch11.md#æ¶é´æ¨ç)âï¼ãä¾å¦ï¼Apache Beam æä¾äºç¨äºè¡¨è¾¾è¿ç§è®¡ç®ç APIï¼å¯ä»¥å¨ Apache Flink æ Google Cloud Dataflow 使ç¨ã ## åææ°æ®åº å¨ææ½è±¡çå±é¢ä¸ï¼æ°æ®åºï¼Hadoop åæä½ç³»ç»é½åæ¥ç¸åçåè½ï¼å®ä»¬åå¨ä¸äºæ°æ®ï¼å¹¶å è®¸ä½ å¤çåæ¥è¯¢è¿äºæ°æ®ã16ããæ°æ®åºå°æ°æ®åå¨ä¸ºç¹å®æ°æ®æ¨¡åçè®°å½ï¼è¡¨ä¸çè¡ãææ¡£ãå¾ä¸ç顶ç¹çï¼ï¼èæä½ç³»ç»çæ件系ç»åå°æ°æ®åå¨å¨æä»¶ä¸ ââ ä½å ¶æ ¸å¿é½æ¯ âä¿¡æ¯ç®¡çâ ç³»ç»ã17ããæ£å¦æä»¬å¨ [第åç« ](ch10.md) ä¸çå°çï¼Hadoop çæç³»ç»æç¹å Unix çåå¸å¼çæ¬ã å½ç¶ï¼æå¾å¤å®é çå·®å¼ãä¾å¦ï¼è®¸å¤æ件系ç»é½ä¸è½å¾å¥½å°å¤çå å« 1000 ä¸ä¸ªå°æ件çç®å½ï¼èå å« 1000 ä¸ä¸ªå°è®°å½çæ°æ®åºå®å ¨æ¯å¯»å¸¸èä¸èµ·ç¼çãæ 论å¦ä½ï¼æä½ç³»ç»åæ°æ®åºä¹é´çç¸ä¼¼ä¹å¤åå·®å¼å¼å¾æ¢è®¨ã Unix åå ³ç³»æ°æ®åºä»¥é常ä¸åçå²å¦æ¥å¤çä¿¡æ¯ç®¡çé®é¢ãUnix 认为å®çç®çæ¯ä¸ºç¨åºåæä¾ä¸ç§ç¸å½ä½å±æ¬¡ç硬件çé»è¾æ½è±¡ï¼èå ³ç³»æ°æ®åºåå¸æ为åºç¨ç¨åºåæä¾ä¸ç§é«å±æ¬¡çæ½è±¡ï¼ä»¥éèç£çä¸æ°æ®ç»æçå¤ææ§ï¼å¹¶åæ§ï¼å´©æºæ¢å¤ççãUnix åå±åºç管éåæ件åªæ¯åèåºåï¼èæ°æ®åºååå±åºäº SQL åäºå¡ã åªç§æ¹æ³æ´å¥½ï¼å½ç¶è¿åå³äºä½ æ³è¦çæ¯ä»ä¹ã Unix æ¯ âç®åçâï¼å 为å®æ¯å¯¹ç¡¬ä»¶èµæºç¸å½èçå è£ ï¼å ³ç³»æ°æ®åºæ¯ âæ´ç®åâ çï¼å 为ä¸ä¸ªç®çç声ææ§æ¥è¯¢å¯ä»¥å©ç¨å¾å¤å¼ºå¤§çåºç¡è®¾æ½ï¼æ¥è¯¢ä¼åãç´¢å¼ãè¿æ¥æ¹æ³ã并åæ§å¶ãå¤å¶çï¼ï¼èä¸éè¦æ¥è¯¢çä½è çè§£å ¶å®ç°ç»èã è¿äºå²å¦ä¹é´ççç¾å·²ç»æç»äºå åå¹´ï¼Unix åå ³ç³»æ¨¡åé½åºç°å¨ 70 年代åï¼ï¼ä»ç¶æ²¡æ解å³ãä¾å¦ï¼æå° NoSQL è¿å¨è§£é为ï¼å¸æå°ç±» Unix çä½çº§å«æ½è±¡æ¹æ³åºç¨äºåå¸å¼ OLTP æ°æ®åå¨çé¢åã å¨è¿ä¸é¨åæå°è¯å¾è°åè¿ä¸¤ä¸ªå²å¦ï¼å¸ææ们è½ååå ¶ç¾ã ### ç»å使ç¨æ°æ®åå¨ææ¯ å¨æ¬ä¹¦çè¿ç¨ä¸ï¼æ们讨论äºæ°æ®åºæä¾çåç§åè½åå ¶å·¥ä½åçï¼å ¶ä¸å æ¬ï¼ * 次级索å¼ï¼ä½¿ä½ å¯ä»¥æ ¹æ®å段çå¼ææå°æ索记å½ï¼è¯·åé â[å ¶ä»ç´¢å¼ç»æ](ch3.md#å ¶ä»ç´¢å¼ç»æ)âï¼ * ç©åè§å¾ï¼è¿æ¯ä¸ç§é¢è®¡ç®çæ¥è¯¢ç»æç¼åï¼è¯·åé â[èåï¼æ°æ®ç«æ¹ä½åç©åè§å¾](ch3.md#èåï¼æ°æ®ç«æ¹ä½åç©åè§å¾)âï¼ * å¤å¶æ¥å¿ï¼ä¿æå ¶ä»èç¹ä¸æ°æ®çå¯æ¬ææ°ï¼è¯·åé â[å¤å¶æ¥å¿çå®ç°](ch5.md#å¤å¶æ¥å¿çå®ç°)âï¼ * å ¨ææ索索å¼ï¼å 许å¨ææ¬ä¸è¿è¡å ³é®åæç´¢ï¼è¯·åé â[å ¨ææç´¢å模ç³ç´¢å¼](ch3.md#å ¨ææç´¢å模ç³ç´¢å¼)âï¼ï¼ä¹å ç½®äºæäºå ³ç³»æ°æ®åºã1ã å¨ [第åç« ](ch10.md) å [第åä¸ç« ](ch11.md) ä¸ï¼åºç°äºç±»ä¼¼ç主é¢ãæ们讨论äºå¦ä½æå»ºå ¨ææ索索å¼ï¼è¯·åé â[æ¹å¤çå·¥ä½æµçè¾åº](ch10.md#æ¹å¤çå·¥ä½æµçè¾åº)âï¼ï¼äºè§£äºå¦ä½ç»´æ¤ç©åè§å¾ï¼è¯·åé â[ç»´æ¤ç©åè§å¾](ch11.md#ç»´æ¤ç©åè§å¾)âï¼ä»¥åå¦ä½å°åæ´ä»æ°æ®åºå¤å¶å°è¡çæ°æ®ç³»ç»ï¼è¯·åé â[åæ´æ°æ®æè·](ch11.md#åæ´æ°æ®æè·)âï¼ã æ°æ®åºä¸å ç½®çåè½ä¸äººä»¬ç¨æ¹å¤çåæµå¤çå¨æ建çè¡çæ°æ®ç³»ç»ä¼¼ä¹æç¸ä¼¼ä¹å¤ã #### åå»ºç´¢å¼ æ³æ³å½ä½ è¿è¡ `CREATE INDEX` å¨å ³ç³»æ°æ®åºä¸å建ä¸ä¸ªæ°çç´¢å¼æ¶ä¼åçä»ä¹ãæ°æ®åºå¿ é¡»æ«æ表çä¸è´æ§å¿«ç §ï¼æéåºææ被索å¼çå段å¼ï¼å¯¹å®ä»¬è¿è¡æåºï¼ç¶åååºç´¢å¼ãç¶åå®å¿ é¡»å¤çèªä¸è´å¿«ç §ä»¥æ¥æåçåå ¥æä½ï¼å设表å¨å建索å¼æ¶æªè¢«éå®ï¼æ以åæä½å¯è½ä¼ç»§ç»ï¼ãä¸æ¦å®æï¼åªè¦äºå¡åå ¥è¡¨ä¸ï¼æ°æ®åºå°±å¿ 须继ç»ä¿æç´¢å¼ææ°ã æ¤è¿ç¨é常类似äºè®¾ç½®æ°çä»åºå¯æ¬ï¼è¯·åé â[设置æ°ä»åº](ch5.md#设置æ°ä»åº)âï¼ï¼ä¹é常类似äºæµå¤çç³»ç»ä¸ç **å¼å¯¼ï¼bootstrapï¼** åæ´æ°æ®æè·ï¼è¯·åé â[åå§å¿«ç §](ch11.md#åå§å¿«ç §)âï¼ã æ 论ä½æ¶è¿è¡ `CREATE INDEX`ï¼æ°æ®åºé½ä¼éæ°å¤çç°ææ°æ®éï¼å¦ â[åºç¨æ¼ååéæ°å¤çæ°æ®](#åºç¨æ¼ååéæ°å¤çæ°æ®)â ä¸æè¿°ï¼ï¼å¹¶å°è¯¥ç´¢å¼ä½ä¸ºæ°è§å¾å¯¼åºå°ç°ææ°æ®ä¸ãç°ææ°æ®å¯è½æ¯ç¶æçå¿«ç §ï¼èä¸æ¯ææåçååçæ¥å¿ï¼ä½ä¸¤è å¯åç¸å ³ï¼è¯·åé â[ç¶æãæµåä¸åæ§](ch11.md#ç¶æãæµåä¸åæ§)âï¼ã #### ä¸åçå æ°æ®åº æé´äºæ¤ï¼æ认为æ´ä¸ªç»ç»çæ°æ®æµå¼å§åä¸ä¸ªå·¨å¤§çæ°æ®åºã7ããæ¯å½æ¹å¤çãæµæ ETL è¿ç¨å°æ°æ®ä»ä¸ä¸ªå°æ¹ä¼ è¾å°å¦ä¸ä¸ªå°æ¹å¹¶ç»è£ æ¶ï¼å®è¡¨ç°å°å°±åæ°æ®åºåç³»ç»ä¸æ ·ï¼ä½¿ç´¢å¼æç©åè§å¾ä¿æææ°ã ä»è¿ç§è§åº¦æ¥çï¼æ¹å¤çåæµå¤çå¨å°±åç²¾å¿å®ç°ç触åå¨ãåå¨è¿ç¨åç©åè§å¾ç»´æ¤ä¾ç¨ãå®ä»¬ç»´æ¤çè¡çæ°æ®ç³»ç»å°±åä¸åçç´¢å¼ç±»åãä¾å¦ï¼å ³ç³»æ°æ®åºå¯è½æ¯æ B æ ç´¢å¼ãæ£åç´¢å¼ã空é´ç´¢å¼ï¼è¯·åé â[å¤åç´¢å¼](ch3.md#å¤åç´¢å¼)âï¼ä»¥åå ¶ä»ç±»åçç´¢å¼ãå¨æ°å ´çè¡çæ°æ®ç³»ç»æ¶æä¸ï¼ä¸æ¯å°è¿äºè®¾æ½ä½ä¸ºå个éææ°æ®åºäº§åçåè½å®ç°ï¼èæ¯ç±åç§ä¸åç软件æä¾ï¼è¿è¡å¨ä¸åçæºå¨ä¸ï¼ç±ä¸åçå¢é管çã è¿äºåå±å¨æªæ¥å°ä¼ææ们带å°åªéï¼å¦ææ们ä»æ²¡æéåææ访é®æ¨¡å¼çåä¸æ°æ®æ¨¡åæåå¨æ ¼å¼çåæåºåï¼ææ¨æµæ两ç§éå¾å¯ä»¥å°ä¸åçåå¨åå¤çå·¥å ·ç»åæä¸ä¸ªæåèåçç³»ç»ï¼ **èåæ°æ®åºï¼ç»ä¸è¯»å** å¯ä»¥ä¸ºåç§åæ ·çåºå±åå¨å¼æåå¤çæ¹æ³æä¾ä¸ä¸ªç»ä¸çæ¥è¯¢æ¥å£ ââ ä¸ç§ç§°ä¸º **èåæ°æ®åºï¼federated databaseï¼** æ **å¤æåå¨ï¼polystoreï¼** çæ¹æ³ã18,19ããä¾å¦ï¼PostgreSQL ç **å¤é¨æ°æ®å è£ å¨ï¼foreign data wrapperï¼** åè½ç¬¦åè¿ç§æ¨¡å¼ã20ããéè¦ä¸ç¨æ°æ®æ¨¡åææ¥è¯¢æ¥å£çåºç¨ç¨åºä»ç¶å¯ä»¥ç´æ¥è®¿é®åºå±åå¨å¼æï¼èæ³è¦ç»åæ¥èªä¸åä½ç½®çæ°æ®çç¨æ·å¯ä»¥éè¿èåæ¥å£è½»æ¾å®ææä½ã èåæ¥è¯¢æ¥å£éµå¾ªçåä¸éæç³»ç»çå ³ç³»åä¼ ç»ï¼å¸¦æé«çº§æ¥è¯¢è¯è¨åä¼é çè¯ä¹ï¼ä½å®ç°èµ·æ¥é常å¤æã **åææ°æ®åºï¼ç»ä¸åå ¥** è½ç¶èåè½è§£å³è·¨å¤ä¸ªä¸åç³»ç»çåªè¯»æ¥è¯¢é®é¢ï¼ä½å®å¹¶æ²¡æå¾å¥½ç解å³è·¨ç³»ç» **åæ¥** åå ¥çé®é¢ãæ们说è¿ï¼å¨å个æ°æ®åºä¸ï¼å建ä¸è´çç´¢å¼æ¯ä¸é¡¹å ç½®åè½ãå½æ们æ建å¤ä¸ªåå¨ç³»ç»æ¶ï¼æ们åæ ·éè¦ç¡®ä¿æææ°æ®åæ´é½ä¼å¨æææ£ç¡®çä½ç½®ç»æï¼å³ä½¿å¨åºç°æ éæ¶ä¹æ¯å¦æ¤ãæ³è¦æ´å®¹æå°å°åå¨ç³»ç»å¯é å°ææ¥å¨ä¸èµ·ï¼ä¾å¦ï¼éè¿åæ´æ°æ®æè·åäºä»¶æ¥å¿ï¼ï¼å°±åå°æ°æ®åºçç´¢å¼ç»´æ¤åè½ä»¥å¯ä»¥è·¨ä¸åææ¯åæ¥åå ¥çæ¹å¼åå¼ã7,21ãã åææ¹æ³éµå¾ª Unix ä¼ ç»çå°åå·¥å ·ï¼å®å¯ä»¥å¾å¥½å°å®æä¸ä»¶äºã22ãï¼éè¿ç»ä¸çä½å±çº§ APIï¼ç®¡éï¼è¿è¡éä¿¡ï¼å¹¶ä¸å¯ä»¥ä½¿ç¨æ´é«å±çº§çè¯è¨è¿è¡ç»åï¼shellï¼ã16ã ã #### å¼å±åæå·¥ä½ èåååææ¯ä¸ä¸ªç¡¬å¸ç两é¢ï¼ç¨ä¸åçç»ä»¶ææå¯é ã å¯ä¼¸ç¼©åå¯ç»´æ¤çç³»ç»ãèååªè¯»æ¥è¯¢éè¦å°ä¸ä¸ªæ°æ®æ¨¡åæ å°å°å¦ä¸ä¸ªæ°æ®æ¨¡åï¼è¿éè¦ä¸äºæèï¼ä½æç»è¿æ¯ä¸ä¸ªå¯è§£å³çé®é¢ãèæ认为åæ¥åå ¥å°å 个åå¨ç³»ç»æ¯æ´å°é¾çå·¥ç¨é®é¢ï¼æ以æå°éç¹å ³æ³¨å®ã ä¼ ç»çåæ¥åå ¥æ¹æ³éè¦è·¨å¼æåå¨ç³»ç»çåå¸å¼äºå¡ã18ãï¼æ认为è¿æ¯é误ç解å³æ¹æ¡ï¼è¯·åé â[è¡çæ°æ®ä¸åå¸å¼äºå¡](#è¡çæ°æ®ä¸åå¸å¼äºå¡)âï¼ãå个åå¨ææµå¤çç³»ç»å çäºå¡æ¯å¯è¡çï¼ä½æ¯å½æ°æ®è·¨è¶ä¸åææ¯ä¹é´çè¾¹çæ¶ï¼æè®¤ä¸ºå ·æå¹çåå ¥çå¼æ¥äºä»¶æ¥å¿æ¯ä¸ç§æ´å å¥å£®åå®ç¨çæ¹æ³ã ä¾å¦ï¼åå¸å¼äºå¡å¨æäºæµå¤çç»ä»¶å é¨ä½¿ç¨ï¼ä»¥å¹é **æ°å¥½ä¸æ¬¡ï¼exactly-onceï¼** è¯ä¹ï¼è¯·åé â[ååæ交åç°](ch11.md#ååæ交åç°)âï¼ï¼è¿å¯ä»¥å¾å¥½å°å·¥ä½ãç¶èï¼å½äºå¡éè¦æ¶åç±ä¸å人群ç¼åçç³»ç»æ¶ï¼ä¾å¦ï¼å½æ°æ®ä»æµå¤çç»ä»¶åå ¥åå¸å¼é®å¼åå¨ææ索索å¼æ¶ï¼ï¼ç¼ºä¹æ ååçäºå¡åè®®ä¼ä½¿éææ´é¾ãæå¹çæ¶è´¹è çæåºäºä»¶æ¥å¿ï¼è¯·åé â[å¹çæ§](ch11.md#å¹çæ§)âï¼æ¯ä¸ç§æ´ç®åçæ½è±¡ï¼å æ¤å¨å¼æç³»ç»ä¸å®ç°æ´å å¯è¡ã7ãã åºäºæ¥å¿çéæçä¸å¤§ä¼å¿æ¯å个ç»ä»¶ä¹é´ç **æ¾æ£è¦åï¼loose couplingï¼**ï¼è¿ä½ç°å¨ä¸¤ä¸ªæ¹é¢ï¼ 1. å¨ç³»ç»çº§å«ï¼å¼æ¥äºä»¶æµä½¿æ´ä¸ªç³»ç»å¨ä¸ªå«ç»ä»¶çä¸æææ§è½ä¸éæ¶æ´å 稳å¥ãå¦ææ¶è´¹è è¿è¡ç¼æ ¢æ失败ï¼é£ä¹äºä»¶æ¥å¿å¯ä»¥ç¼å²æ¶æ¯ï¼è¯·åé â[ç£ç空é´ä½¿ç¨](ch11.md#ç£ç空é´ä½¿ç¨)âï¼ï¼ä»¥ä¾¿ç产è åä»»ä½å ¶ä»æ¶è´¹è å¯ä»¥ç»§ç»ä¸åå½±åå°è¿è¡ãæé®é¢çæ¶è´¹è å¯ä»¥å¨é®é¢ä¿®å¤å赶ä¸ï¼å æ¤ä¸ä¼éè¿ä»»ä½æ°æ®ï¼å¹¶ä¸å å«æ éãç¸æ¯ä¹ä¸ï¼åå¸å¼äºå¡çåæ¥äº¤äºå¾å¾ä¼å°æ¬å°æ éå级为大è§æ¨¡æ éï¼è¯·åé â[åå¸å¼äºå¡çéå¶](ch9.md#åå¸å¼äºå¡çéå¶)âï¼ã 2. å¨äººåæ¹é¢ï¼åææ°æ®ç³»ç»å 许ä¸åçå¢éç¬ç«å¼åï¼æ¹è¿åç»´æ¤ä¸åç软件ç»ä»¶åæå¡ãä¸ä¸å使å¾æ¯ä¸ªå¢éé½å¯ä»¥ä¸æ³¨äºå好ä¸ä»¶äºï¼å¹¶ä¸å ¶ä»å¢éçç³»ç»ä»¥æç¡®çæ¥å£äº¤äºãäºä»¶æ¥å¿æä¾äºä¸ä¸ªè¶³å¤å¼ºå¤§çæ¥å£ï¼ä»¥æè·ç¸å½å¼ºçä¸è´æ§å±æ§ï¼ç±äºæä¹ æ§åäºä»¶ç顺åºï¼ï¼ä½ä¹è¶³å¤æ®éäºå ä¹ä»»ä½ç±»åçæ°æ®ã #### åæç³»ç»vséæç³»ç» å¦æåæç¡®å®æ为æªæ¥çæ¹å¼ï¼å®ä¹ä¸ä¼å代ç®åå½¢å¼çæ°æ®åº ââ å®ä»¬ä»ç¶ä¼å以å¾ä¸æ ·è¢«éè¦ã为äºç»´æ¤æµå¤çç»ä»¶ä¸çç¶æï¼æ°æ®åºä»ç¶æ¯éè¦çï¼å¹¶ä¸ä¸ºæ¹å¤çåæµå¤çå¨çè¾åºæä¾æ¥è¯¢æå¡ï¼è¯·åé â[æ¹å¤çå·¥ä½æµçè¾åº](ch10.md#æ¹å¤çå·¥ä½æµçè¾åº)â ä¸ â[æµå¤ç](ch11.md#æµå¤ç)âï¼ãä¸ç¨æ¥è¯¢å¼æ对äºç¹å®çå·¥ä½è´è½½ä»ç¶é常éè¦ï¼ä¾å¦ï¼MPP æ°æ®ä»åºä¸çæ¥è¯¢å¼æé对æ¢ç´¢æ§åææ¥è¯¢è¿è¡äºä¼åï¼å¹¶ä¸è½å¤å¾å¥½å°å¤çè¿ç§ç±»åçå·¥ä½è´è½½ï¼è¯·åé â[Hadoop ä¸åå¸å¼æ°æ®åºç对æ¯](ch10.md#Hadoopä¸åå¸å¼æ°æ®åºç对æ¯)â ã è¿è¡å ç§ä¸ååºç¡è®¾æ½çå¤ææ§å¯è½æ¯ä¸ä¸ªé®é¢ï¼æ¯ç§è½¯ä»¶é½æä¸ä¸ªå¦ä¹ æ²çº¿ï¼é ç½®é®é¢åæä½æªçï¼å æ¤é¨ç½²å°½å¯è½å°ç移å¨é¨ä»¶æ¯å¾æå¿ è¦çãæ¯èµ·ä½¿ç¨åºç¨ä»£ç æ¼æ¥å¤ä¸ªå·¥å ·èæçç³»ç»ï¼åä¸éæ软件产åä¹å¯ä»¥å¨å ¶è®¾è®¡åºå¯¹çå·¥ä½è´è½½ç±»åä¸å®ç°æ´å¥½ãæ´å¯é¢æµçæ§è½ã23ããæ£å¦å¨åè¨ä¸æ说çé£æ ·ï¼ä¸ºäºä¸éè¦çè§æ¨¡èæ建系ç»æ¯ç½è´¹ç²¾åï¼èä¸å¯è½ä¼å°ä½ éæ»å¨ä¸ä¸ªä¸çµæ´»ç设计ä¸ãå®é ä¸ï¼è¿æ¯ä¸ç§è¿æ©ä¼åçå½¢å¼ã åæçç®æ ä¸æ¯è¦é对个å«æ°æ®åºä¸ç¹å®å·¥ä½è´è½½çæ§è½è¿è¡ç«äºï¼æ们çç®æ æ¯å è®¸ä½ ç»åå¤ä¸ªä¸åçæ°æ®åºï¼ä»¥ä¾¿å¨æ¯å个软件å¯è½å®ç°çæ´å¹¿æ³çå·¥ä½è´è½½èå´å å®ç°æ´å¥½çæ§è½ãè¿æ¯å ³äºå¹¿åº¦ï¼èä¸æ¯æ·±åº¦ ââ ä¸æä»¬å¨ â[Hadoop ä¸åå¸å¼æ°æ®åºç对æ¯](ch10.md#Hadoopä¸åå¸å¼æ°æ®åºç对æ¯)â ä¸è®¨è®ºçåå¨åå¤ç模åçå¤æ ·æ§ä¸æ ·ã å æ¤ï¼å¦ææä¸é¡¹ææ¯å¯ä»¥æ»¡è¶³ä½ çææéæ±ï¼é£ä¹æ好使ç¨è¯¥äº§åï¼èä¸æ¯è¯å¾ç¨æ´ä½å±çº§çç»ä»¶éæ°å®ç°å®ãåªæå½æ²¡æåä¸è½¯ä»¶æ»¡è¶³ä½ çææéæ±æ¶ï¼æä¼åºç°æååèåçä¼å¿ã #### å°äºä»ä¹ï¼ ç¨äºç»ææ°æ®ç³»ç»çå·¥å ·æ£å¨åå¾è¶æ¥è¶å¥½ï¼ä½æ认为è¿ç¼ºå°ä¸ä¸ªä¸»è¦çä¸è¥¿ï¼æ们è¿æ²¡æä¸ Unix shell 类似çåææ°æ®åºçä»·ç©ï¼å³ï¼ä¸ç§å£°æå¼çãç®åçãç¨äºç»è£ åå¨åå¤çç³»ç»çé«çº§è¯è¨ï¼ã ä¾å¦ï¼å¦ææ们å¯ä»¥ç®åå°å£°æ `mysql | elasticsearch`ï¼ç±»ä¼¼äº Unix 管éã22ãï¼æ为 `CREATE INDEX` çåæçä»·ç©ï¼å®å°è¯»å MySQL æ°æ®åºä¸çæææ档并å°å ¶ç´¢å¼å° Elasticsearch é群ä¸ãç¶åå®ä¼ä¸ææè·å¯¹æ°æ®åºæåçææåæ´ï¼å¹¶èªå¨å°å®ä»¬åºç¨äºæ索索å¼ï¼èæ éç¼åèªå®ä¹åºç¨ä»£ç ãè¿ç§éæåºå½æ¯æå ä¹ä»»ä½ç±»åçåå¨æç´¢å¼ç³»ç»ã åæ ·ï¼è½å¤æ´å®¹æå°é¢å 计ç®åæ´æ°ç¼åå°æ¯ä¸ä»¶å¥½äºãåæ³ä¸ä¸ï¼ç©åè§å¾æ¬è´¨ä¸æ¯ä¸ä¸ªé¢å 计ç®çç¼åï¼æä»¥ä½ å¯ä»¥éè¿ä¸ºå¤ææ¥è¯¢å£°ææå®ç©åè§å¾æ¥å建ç¼åï¼å æ¬å¾ä¸çéå½æ¥è¯¢ï¼è¯·åé â[å¾æ°æ®æ¨¡å](ch2.md#å¾æ°æ®æ¨¡å)âï¼ååºç¨é»è¾ãå¨è¿æ¹é¢æä¸äºæ趣çæ©æç 究ï¼å¦ **å·®åæ°æ®æµï¼differential dataflowï¼**ã24,25ãï¼æå¸æè¿äºæ³æ³è½å¤å¨ç产系ç»ä¸æ¾å°èªå·±çæ¹æ³ã ### å´ç»æ°æ®æµè®¾è®¡åºç¨ 使ç¨åºç¨ä»£ç ç»åä¸ç¨åå¨ä¸å¤çç³»ç»æ¥åææ°æ®åºçæ¹æ³ï¼ä¹è¢«ç§°ä¸º â**æ°æ®åºç±å èå¤ï¼database inside-outï¼**â æ¹æ³ã26ãï¼è¯¥å称æ¥æºäºæå¨ 2014 å¹´çä¸æ¬¡ä¼è®®æ¼è®²æ é¢ã27ããç¶è称å®ä¸º âæ°æ¶æâ è¿äºå¤¸å¤§ï¼æä» å°å ¶çä½æ¯ä¸ç§è®¾è®¡æ¨¡å¼ï¼ä¸ä¸ªè®¨è®ºçèµ·ç¹ï¼æ们åªæ¯ç®åå°ç»å®èµ·ä¸ä¸ªååï¼ä»¥ä¾¿æ们è½æ´å¥½å°è®¨è®ºå®ã è¿äºæ³æ³ä¸æ¯æçï¼å®ä»¬æ¯å¾å¤äººçææ³çèåï¼è¿äºææ³é常å¼å¾æ们å¦ä¹ ãå°¤å ¶æ¯ï¼ä»¥ Ozã28ãå Juttleã29ã为代表çæ°æ®æµè¯è¨ï¼ä»¥ Elmã30,31ã为代表ç **å½æ°å¼ååºå¼ç¼ç¨ï¼functional reactive programming, FRPï¼**ï¼ä»¥ Bloomã32ã为代表çé»è¾ç¼ç¨è¯è¨ãå¨è¿ä¸è¯å¢ä¸çæ¯è¯ **åæï¼unbundlingï¼** æ¯ç± Jay Kreps æåºçã7ãã å³ä½¿æ¯ **çµåè¡¨æ ¼** ä¹å¨æ°æ®æµç¼ç¨è½åä¸ç©å¼å¤§å¤æ°ä¸»æµç¼ç¨è¯è¨å æ¡è¡ã33ããå¨çµåè¡¨æ ¼ä¸ï¼å¯ä»¥å°å ¬å¼æ¾å ¥ä¸ä¸ªåå æ ¼ä¸ï¼ä¾å¦ï¼å¯¹å¦ä¸åä¸çåå æ ¼æ±åï¼ï¼å¹¶ä¸åªè¦å ¬å¼çä»»ä½è¾å ¥åçåæ´ï¼å ¬å¼çç»æé½ä¼èªå¨éæ°è®¡ç®ãè¿æ£æ¯æ们å¨æ°æ®ç³»ç»å±æ¬¡æéè¦çï¼å½æ°æ®åºä¸çè®°å½åçåæ´æ¶ï¼æ们å¸æèªå¨æ´æ°è¯¥è®°å½çä»»ä½ç´¢å¼ï¼å¹¶ä¸èªå¨å·æ°ä¾èµäºè®°å½çä»»ä½ç¼åè§å¾æèåãä½ ä¸å¿ æ å¿è¿ç§å·æ°å¦ä½åççææ¯ç»èï¼ä½è½å¤ç®åå°ç¸ä¿¡å®å¯ä»¥æ£å¸¸å·¥ä½ã å æ¤ï¼æ认为ç»å¤§å¤æ°æ°æ®ç³»ç»ä»ç¶å¯ä»¥ä» VisiCalc å¨ 1979 å¹´å·²ç»å ·å¤çåè½ä¸å¦ä¹ ã34ããä¸çµåè¡¨æ ¼çä¸åä¹å¤å¨äºï¼ä»å¤©çæ°æ®ç³»ç»éè¦å ·æ容éæ§ï¼å¯ä¼¸ç¼©æ§ä»¥åæä¹ åå¨æ°æ®ãå®ä»¬è¿éè¦è½å¤æ´åä¸å人群ç¼åçä¸åææ¯ï¼å¹¶éç¨ç°æçåºåæå¡ï¼ææ使ç¨æä¸ç§ç¹å®çè¯è¨ãæ¡æ¶æå·¥å ·æ¥å¼åææ软件æ¯ä¸åå®é çã å¨æ¬èä¸ï¼æå°è¯¦ç»ä»ç»è¿äºæ³æ³ï¼å¹¶æ¢è®¨ä¸äºå´ç»åææ°æ®åºåæ°æ®æµçæ³æ³æ建åºç¨çæ¹æ³ã #### åºç¨ä»£ç ä½ä¸ºè¡çå½æ° å½ä¸ä¸ªæ°æ®éè¡çèªå¦ä¸ä¸ªæ°æ®éæ¶ï¼å®ä¼ç»åæç§è½¬æ¢å½æ°ãä¾å¦ï¼ * 次级索å¼æ¯ç±ä¸ç§ç´ç½ç转æ¢å½æ°çæçè¡çæ°æ®éï¼å¯¹äºåºç¡è¡¨ä¸çæ¯è¡ææ¯ä¸ªææ¡£ï¼å®æé被索å¼çåæå段ä¸çå¼ï¼å¹¶æè¿äºå¼æåºï¼åè®¾ä½¿ç¨ B æ æ SSTable ç´¢å¼ï¼æé®æåºï¼å¦ [第ä¸ç« ](ch3.md) æè¿°ï¼ã * å ¨ææ索索å¼æ¯éè¿åºç¨åç§èªç¶è¯è¨å¤çå½æ°èå建çï¼è¯¸å¦è¯è¨æ£æµãåè¯ãè¯å¹²æè¯æ±åãæ¼åçº æ£ååä¹è¯è¯å«ï¼ç¶åæ建ç¨äºé«ææ¥æ¾çæ°æ®ç»æï¼ä¾å¦åæç´¢å¼ï¼ã * å¨æºå¨å¦ä¹ ç³»ç»ä¸ï¼æ们å¯ä»¥å°æ¨¡åè§ä½ä»è®ç»æ°æ®éè¿åºç¨åç§ç¹å¾æåãç»è®¡åæå½æ°è¡ççæ°æ®ï¼å½æ¨¡ååºç¨äºæ°çè¾å ¥æ°æ®æ¶ï¼æ¨¡åçè¾åºæ¯ä»è¾å ¥å模åï¼å æ¤é´æ¥å°ä»è®ç»æ°æ®ï¼ä¸è¡ççã * ç¼åé常å å«å°ä»¥ç¨æ·çé¢ï¼UIï¼æ¾ç¤ºçå½¢å¼çæ°æ®èåãå æ¤å¡«å ç¼åéè¦ç¥é UI ä¸å¼ç¨çå段ï¼UI ä¸çåæ´å¯è½éè¦æ´æ°ç¼åå¡«å æ¹å¼çå®ä¹ï¼å¹¶é建ç¼åã ç¨äºæ¬¡çº§ç´¢å¼çè¡çå½æ°æ¯å¦æ¤å¸¸ç¨çéæ±ï¼ä»¥è´äºå®ä½ä¸ºæ ¸å¿åè½è¢«å 建è³è®¸å¤æ°æ®åºä¸ï¼ä½ å¯ä»¥ç®åå°éè¿ `CREATE INDEX` æ¥è°ç¨å®ã对äºå ¨æç´¢å¼ï¼å¸¸è§è¯è¨çåºæ¬è¯è¨ç¹å¾å¯è½å ç½®å°æ°æ®åºä¸ï¼ä½æ´å¤æçç¹å¾é常éè¦é¢åç¹å®çè°æ´ãå¨æºå¨å¦ä¹ ä¸ï¼ç¹å¾å·¥ç¨æ¯ä¼æå¨ç¥çç¹å®äºåºç¨çç¹å¾ï¼é常éè¦å å«å¾å¤å ³äºç¨æ·äº¤äºä¸åºç¨é¨ç½²ç详ç»ç¥è¯ã35ãã å½å建è¡çæ°æ®éçå½æ°ä¸æ¯åå建次级索å¼é£æ ·çæ åæ¬ç å½æ°æ¶ï¼éè¦èªå®ä¹ä»£ç æ¥å¤çç¹å®äºåºç¨çä¸è¥¿ãèè¿ä¸ªèªå®ä¹ä»£ç æ¯è®©è®¸å¤æ°æ®åºæ£æçå°æ¹ï¼è½ç¶å ³ç³»æ°æ®åºé常æ¯æ触åå¨ãåå¨è¿ç¨åç¨æ·å®ä¹çå½æ°ï¼å¯ä»¥ç¨å®ä»¬æ¥å¨æ°æ®åºä¸æ§è¡åºç¨ä»£ç ï¼ä½å®ä»¬æç¹åæ°æ®åºè®¾è®¡éçäºååæãï¼è¯·åé â[ä¼ éäºä»¶æµ](ch11.md#ä¼ éäºä»¶æµ)âï¼ã #### åºç¨ä»£ç åç¶æçå离 ç论ä¸ï¼æ°æ®åºå¯ä»¥æ¯ä»»æåºç¨ä»£ç çé¨ç½²ç¯å¢ï¼å°±å¦åæä½ç³»ç»ä¸æ ·ãç¶èå®è·µä¸å®ä»¬å¯¹è¿ä¸ç®æ éé çå¾å·®ãå®ä»¬ä¸æ»¡è¶³ç°ä»£åºç¨å¼åçè¦æ±ï¼ä¾å¦ä¾èµå软件å 管çãçæ¬æ§å¶ãæ»å¨å级ãå¯æ¼åæ§ãçæ§ãææ ã对ç½ç»æå¡çè°ç¨ä»¥åä¸å¤é¨ç³»ç»çéæã å¦ä¸æ¹é¢ï¼MesosãYARNãDockerãKubernetes çé¨ç½²åé群管çå·¥å ·ä¸ä¸ºè¿è¡åºç¨ä»£ç è设计ãéè¿ä¸æ³¨äºå好ä¸ä»¶äºæ ï¼ä»ä»¬è½å¤åå¾æ¯å°æ°æ®åºä½ä¸ºå ¶ä¼å¤åè½ä¹ä¸æ§è¡ç¨æ·å®ä¹çåè½è¦å¥½å¾å¤ã æ认为让系ç»çæäºé¨åä¸é¨ç¨äºæä¹ æ°æ®åå¨å¹¶è®©å ¶ä»é¨åä¸é¨è¿è¡åºç¨ç¨åºä»£ç æ¯ææä¹çãè¿ä¸¤è å¯ä»¥å¨ä¿æç¬ç«çåæ¶äºå¨ã ç°å¨å¤§å¤æ° Web åºç¨ç¨åºé½æ¯ä½ä¸ºæ ç¶ææå¡é¨ç½²çï¼å ¶ä¸ä»»ä½ç¨æ·è¯·æ±é½å¯ä»¥è·¯ç±å°ä»»ä½åºç¨ç¨åºæå¡å¨ï¼å¹¶ä¸æå¡å¨å¨åéååºåä¼å¿è®°ææ请æ±ãè¿ç§é¨ç½²æ¹å¼å¾æ¹ä¾¿ï¼å 为å¯ä»¥éææ·»å æå é¤æå¡å¨ï¼ä½ç¶æå¿ é¡»å°æ个å°æ¹ï¼é常æ¯æ°æ®åºãè¶å¿æ¯å°æ ç¶æåºç¨ç¨åºé»è¾ä¸ç¶æ管çï¼æ°æ®åºï¼åå¼ï¼ä¸å°åºç¨ç¨åºé»è¾æ¾å ¥æ°æ®åºä¸ï¼ä¹ä¸å°æä¹ ç¶æç½®äºåºç¨ç¨åºä¸ã36ããæ£å¦å½æ°å¼ç¼ç¨ç¤¾åºå欢å¼ç©ç¬è¯´çé£æ ·ï¼âæ们ç¸ä¿¡ **æä¼ï¼Churchï¼** ä¸ **å½å®¶ï¼stateï¼** çå离âã37ã [^i] [^i]: 解éç¬è¯å¾å°ä¼è®©äººæè§æ´å¥½ï¼ä½æä¸æ³è®©ä»»ä½äººæå°è¢«éæ¼ã å¨è¿éï¼Church æ代çæ¯æ°å¦å®¶çé¿éä½ã»é±å¥ï¼ä»åç«äº lambda æ¼ç®ï¼è¿æ¯è®¡ç®çæ©æå½¢å¼ï¼æ¯å¤§å¤æ°å½æ°å¼ç¼ç¨è¯è¨çåºç¡ã lambda æ¼ç®ä¸å ·æå¯åç¶æï¼å³æ²¡æåéå¯ä»¥è¢«è¦çï¼ï¼æ以å¯ä»¥è¯´å¯åç¶æä¸ Church çå·¥ä½æ¯å离çã å¨è¿ä¸ªå ¸åç Web åºç¨æ¨¡åä¸ï¼æ°æ®åºå å½ä¸ç§å¯ä»¥éè¿ç½ç»åæ¥è®¿é®çå¯åå ±äº«åéãåºç¨ç¨åºå¯ä»¥è¯»ååæ´æ°åéï¼èæ°æ®åºè´è´£ç»´æå®çæä¹ æ§ï¼æä¾ä¸äºè¯¸å¦å¹¶åæ§å¶å容éçåè½ã ä½æ¯ï¼å¨å¤§å¤æ°ç¼ç¨è¯è¨ä¸ï¼ä½ æ æ³è®¢é å¯ååéä¸çåæ´ ââ ä½ åªè½å®æ读åå®ãä¸çµåè¡¨æ ¼ä¸åï¼å¦æåéçå¼åçååï¼åéç读è ä¸ä¼æ¶å°éç¥ï¼ä½ å¯ä»¥å¨èªå·±ç代ç ä¸å®ç°è¿æ ·çéç¥ ââ è¿è¢«ç§°ä¸º **è§å¯è 模å¼** ââ ä½å¤§å¤æ°è¯è¨æ²¡æå°è¿ç§æ¨¡å¼ä½ä¸ºå ç½®åè½ï¼ã æ°æ®åºç»§æ¿äºè¿ç§å¯åæ°æ®ç被å¨æ¹æ³ï¼å¦æä½ æ³ç¥éæ°æ®åºçå 容æ¯å¦åçäºååï¼éå¸¸ä½ å¯ä¸çéæ©å°±æ¯è½®è¯¢ï¼å³å®æéå¤ä½ çæ¥è¯¢ï¼ã 订é åæ´åªæ¯ååå¼å§åºç°çåè½ï¼è¯·åé â[åæ´æµç API æ¯æ](ch11.md#åæ´æµçAPIæ¯æ)âï¼ã #### æ°æ®æµï¼åºç¨ä»£ç ä¸ç¶æååçäº¤äº ä»æ°æ®æµçè§åº¦æèåºç¨ç¨åºï¼æå³çéæ°åè°åºç¨ä»£ç åç¶æ管çä¹é´çå ³ç³»ãæ们ä¸åå°æ°æ®åºè§ä½è¢«åºç¨æ纵ç被å¨åéï¼åè代ä¹çæ¯æ´å¤å°èèç¶æï¼ç¶æåæ´åå¤çå®ä»¬ç代ç ä¹é´çç¸äºä½ç¨ä¸ååå ³ç³»ãåºç¨ä»£ç éè¿å¨å¦ä¸ä¸ªå°æ¹è§¦åç¶æåæ´æ¥ååºç¶æåæ´ã æä»¬å¨ â[æ°æ®åºä¸æµ](ch11.md#æ°æ®åºä¸æµ)â ä¸çå°äºè¿ä¸æè·¯ï¼æ们讨论äºå°æ°æ®åºçåæ´æ¥å¿è§ä¸ºä¸ç§æ们å¯ä»¥è®¢é çäºä»¶æµãè¯¸å¦ Actor çæ¶æ¯ä¼ éç³»ç»ï¼è¯·åé â[æ¶æ¯ä¼ éä¸çæ°æ®æµ](ch4.md#æ¶æ¯ä¼ éä¸çæ°æ®æµ)âï¼ä¹å ·æååºäºä»¶çæ¦å¿µãæ©å¨ 20 ä¸çºª 80 年代ï¼**å ç»ç©ºé´ï¼tuple spaceï¼** 模å就已ç»æ¢ç´¢äºè¡¨è¾¾åå¸å¼è®¡ç®çæ¹å¼ï¼è§å¯ç¶æåæ´å¹¶ä½åºååºçè¿ç¨ã38,39ãã å¦åæè¿°ï¼å½è§¦åå¨ç±äºæ°æ®åæ´è被触åæ¶ï¼æ次级索å¼æ´æ°ä»¥åæ ç´¢å¼è¡¨ä¸çåæ´æ¶ï¼æ°æ®åºå é¨ä¹åçç类似çæ åµãåææ°æ®åºæå³çå°è¿ä¸ªæ³æ³åºç¨äºå¨ä¸»æ°æ®åºä¹å¤ï¼ç¨äºå建è¡çæ°æ®éï¼ç¼åãå ¨ææ索索å¼ãæºå¨å¦ä¹ æåæç³»ç»ãæ们å¯ä»¥ä¸ºæ¤ä½¿ç¨æµå¤çåæ¶æ¯ä¼ éç³»ç»ã éè¦è®°ä½çéè¦ä¸ç¹æ¯ï¼ç»´æ¤è¡çæ°æ®ä¸åäºæ§è¡å¼æ¥ä»»å¡ãä¼ ç»çæ¶æ¯ä¼ éç³»ç»é常æ¯ä¸ºæ§è¡å¼æ¥ä»»å¡è®¾è®¡çï¼è¯·åé â[æ¥å¿ä¸ä¼ ç»çæ¶æ¯ä¼ éç¸æ¯](ch11.md#æ¥å¿ä¸ä¼ ç»çæ¶æ¯ä¼ éç¸æ¯)âï¼ï¼ * å¨ç»´æ¤è¡çæ°æ®æ¶ï¼ç¶æåæ´ç顺åºé常å¾éè¦ï¼å¦æå¤ä¸ªè§å¾æ¯ä»äºä»¶æ¥å¿è¡ççï¼åéè¦æç §ç¸åç顺åºå¤çäºä»¶ï¼ä»¥ä¾¿å®ä»¬ä¹é´ä¿æä¸è´ï¼ãå¦ â[确认ä¸éæ°ä¼ é](ch11.md#确认ä¸éæ°ä¼ é)â ä¸æè¿°ï¼è®¸å¤æ¶æ¯ä»£çå¨éä¼ æªç¡®è®¤æ¶æ¯æ¶æ²¡ææ¤å±æ§ï¼ååä¹è¢«æé¤å¨å¤ï¼è¯·åé â[ä¿æç³»ç»åæ¥](ch11.md#ä¿æç³»ç»åæ¥)âï¼ã * 容éæ¯è¡çæ°æ®çå ³é®ï¼ä» ä» ä¸¢å¤±å个æ¶æ¯å°±ä¼å¯¼è´è¡çæ°æ®éæ°¸è¿ä¸å ¶æ°æ®æºå¤±å»åæ¥ãæ¶æ¯ä¼ éåè¡çç¶ææ´æ°é½å¿ é¡»å¯é ãä¾å¦ï¼è®¸å¤ Actor ç³»ç»é»è®¤å¨å åä¸ç»´æ¤ Actor çç¶æåæ¶æ¯ï¼æ以å¦æè¿è¡ Actor çæºå¨å´©æºï¼ç¶æåæ¶æ¯å°±ä¼ä¸¢å¤±ã 稳å®çæ¶æ¯æåºå容éæ¶æ¯å¤çæ¯ç¸å½ä¸¥æ ¼çè¦æ±ï¼ä½ä¸åå¸å¼äºå¡ç¸æ¯ï¼å®ä»¬å¼éæ´å°ï¼è¿è¡æ´ç¨³å®ãç°ä»£æµå¤çç»ä»¶å¯ä»¥æä¾è¿äºæåºåå¯é æ§ä¿è¯ï¼å¹¶å 许åºç¨ä»£ç 以æµç®åçå½¢å¼è¿è¡ã è¿äºåºç¨ä»£ç å¯ä»¥æ§è¡ä»»æå¤çï¼å æ¬æ°æ®åºå ç½®è¡çå½æ°é常ä¸æä¾çåè½ãå°±åéè¿ç®¡éé¾æ¥ç Unix å·¥å ·ä¸æ ·ï¼æµç®åå¯ä»¥å´ç»çæ°æ®æµæ建大åç³»ç»ãæ¯ä¸ªç®åæ¥åç¶æåæ´çæµä½ä¸ºè¾å ¥ï¼å¹¶äº§çå ¶ä»ç¶æååçæµä½ä¸ºè¾åºã #### æµå¤çå¨åæå¡ å½ä»æµè¡çåºç¨å¼åé£æ ¼æ¶åå°åè½å解为ä¸ç»éè¿åæ¥ç½ç»è¯·æ±ï¼å¦ REST APIï¼è¿è¡éä¿¡ç **æå¡**ï¼serviceï¼è¯·åé â[æå¡ä¸çæ°æ®æµï¼REST ä¸ RPC](ch4.md#æå¡ä¸çæ°æ®æµï¼RESTä¸RPC)âï¼ãè¿ç§é¢åæå¡çæ¶æä¼äºåä¸åºå¤§åºç¨çä¼å¿ä¸»è¦å¨äºï¼éè¿æ¾æ£è¦åæ¥æä¾ç»ç»ä¸çå¯ä¼¸ç¼©æ§ï¼ä¸åçå¢éå¯ä»¥ä¸èäºä¸åçæå¡ä¸ï¼ä»èåå°å¢éä¹é´çåè°å·¥ä½ï¼å 为æå¡å¯ä»¥ç¬ç«é¨ç½²åæ´æ°ï¼ã å¨æ°æ®æµä¸ç»è£ æµç®åä¸å¾®æå¡æ¹æ³æå¾å¤ç¸ä¼¼ä¹å¤ã40ããä½åºå±éä¿¡æºå¶æ¯æå¾å¤§åºå«ï¼æ°æ®æµéç¨ååå¼æ¥æ¶æ¯æµï¼èä¸æ¯åæ¥çè¯·æ± / ååºå¼äº¤äºã é¤äºå¨ â[æ¶æ¯ä¼ éä¸çæ°æ®æµ](ch4.md#æ¶æ¯ä¼ éä¸çæ°æ®æµ)â ä¸ååºçä¼ç¹ï¼å¦æ´å¥½ç容éæ§ï¼ï¼æ°æ®æµç³»ç»è¿è½å®ç°æ´å¥½çæ§è½ãä¾å¦ï¼å设客æ·æ£å¨è´ä¹°ä»¥ä¸ç§è´§å¸å®ä»·ï¼ä½ä»¥å¦ä¸ç§è´§å¸æ¯ä»çååã为äºæ§è¡è´§å¸æ¢ç®ï¼ä½ éè¦ç¥éå½åçæ±çãè¿ä¸ªæä½å¯ä»¥éè¿ä¸¤ç§æ¹å¼å®ç°ã40,41ãï¼ 1. å¨å¾®æå¡æ¹æ³ä¸ï¼å¤çè´ä¹°ç代ç å¯è½ä¼æ¥è¯¢æ±çæå¡ææ°æ®åºï¼ä»¥è·åç¹å®è´§å¸çå½åæ±çã 2. å¨æ°æ®æµæ¹æ³ä¸ï¼å¤ç订åç代ç ä¼æå订é æ±çåæ´æµï¼å¹¶å¨æ±çåçåå¨æ¶å°å½åæ±çåå¨å¨æ¬å°æ°æ®åºä¸ãå¤ç订åæ¶åªéæ¥è¯¢æ¬å°æ°æ®åºå³å¯ã 第äºç§æ¹æ³è½å°å¯¹å¦ä¸æå¡çåæ¥ç½ç»è¯·æ±æ¿æ¢ä¸ºå¯¹æ¬å°æ°æ®åºçæ¥è¯¢ï¼å¯è½å¨åä¸å°æºå¨çè³åä¸ä¸ªè¿ç¨ä¸ï¼[^ii]ãæ°æ®æµæ¹æ³ä¸ä» æ´å¿«ï¼èä¸å½å ¶ä»æå¡å¤±ææ¶ä¹æ´ç¨³å¥ãæå¿«ä¸æå¯é çç½ç»è¯·æ±å°±æ¯åæ ¹æ²¡æç½ç»è¯·æ±ï¼æ们ç°å¨ä¸åä½¿ç¨ RPCï¼èæ¯å¨è´ä¹°äºä»¶åæ±çæ´æ°äºä»¶ä¹é´å»ºç«æµèæ¥ï¼è¯·åé â[æµè¡¨è¿æ¥ï¼æµæ©å ï¼](ch11.md#æµè¡¨è¿æ¥ï¼æµæ©å ï¼)âï¼ã [^ii]: å¨å¾®æå¡æ¹æ³ä¸ï¼ä½ ä¹å¯ä»¥éè¿å¨å¤çè´ä¹°çæå¡ä¸æ¬å°ç¼åæ±çæ¥é¿å åæ¥ç½ç»è¯·æ±ã ä½æ¯ä¸ºäºä¿è¯ç¼åçæ°é²åº¦ï¼ä½ éè¦å®æ轮询æ±ç以è·åå ¶æ´æ°ï¼æ订é åæ´æµ ââ è¿æ°å¥½æ¯æ°æ®æµæ¹æ³ä¸åççäºæ ã è¿æ¥æ¯æ¶é´ç¸å ³çï¼å¦æè´ä¹°äºä»¶å¨ç¨åçæ¶é´ç¹è¢«éæ°å¤çï¼æ±çå¯è½å·²ç»æ¹åãå¦æè¦é建åå§è¾åºï¼åéè¦è·ååå§è´ä¹°æ¶çåå²æ±çãæ 论æ¯æ¥è¯¢æå¡è¿æ¯è®¢é æ±çæ´æ°æµï¼ä½ é½éè¦å¤çè¿ç§æ¶é´ç¸å ³æ§ï¼è¯·åé â[è¿æ¥çæ¶é´ä¾èµæ§](ch11.md#è¿æ¥çæ¶é´ä¾èµæ§)âï¼ã 订é åæ´æµï¼èä¸æ¯å¨éè¦æ¶æ¥è¯¢å½åç¶æï¼ä½¿æ们æ´æ¥è¿ç±»ä¼¼çµåè¡¨æ ¼ç计ç®æ¨¡åï¼å½æäºæ°æ®åçåæ´æ¶ï¼ä¾èµäºæ¤çææè¡çæ°æ®é½å¯ä»¥å¿«éæ´æ°ãè¿æå¾å¤æªè§£å³çé®é¢ï¼ä¾å¦å ³äºæ¶é´ç¸å ³è¿æ¥çé®é¢ï¼ä½æ认为å´ç»æ°æ®æµæ建åºç¨çæ³æ³æ¯ä¸ä¸ªé常æå¸æçæ¹åã ### è§å¯è¡çæ°æ®ç¶æ å¨æ½è±¡å±é¢ï¼ä¸ä¸è讨论çæ°æ®æµç³»ç»æä¾äºå建è¡çæ°æ®éï¼ä¾å¦æ索索å¼ãç©åè§å¾åé¢æµæ¨¡åï¼å¹¶ä½¿å ¶ä¿ææ´æ°çè¿ç¨ãæ们å°è¿ä¸ªè¿ç¨ç§°ä¸º **åè·¯å¾ï¼write pathï¼**ï¼åªè¦æäºä¿¡æ¯è¢«åå ¥ç³»ç»ï¼å®å¯è½ä¼ç»åæ¹å¤çä¸æµå¤ççå¤ä¸ªé¶æ®µï¼èæç»æ¯ä¸ªè¡çæ°æ®éé½ä¼è¢«æ´æ°ï¼ä»¥éé åå ¥çæ°æ®ã[å¾ 12-1](img/fig12-1.png) æ¾ç¤ºäºä¸ä¸ªæ´æ°æ索索å¼çä¾åã ![](img/fig12-1.png) **å¾ 12-1 å¨æ索索å¼ä¸ï¼åï¼ææ¡£æ´æ°ï¼éä¸è¯»ï¼æ¥è¯¢ï¼** ä½ä½ 为ä»ä¹ä¸å¼å§å°±è¦å建è¡çæ°æ®éï¼å¾å¯è½æ¯å ä¸ºä½ æ³å¨ä»¥åå次æ¥è¯¢å®ãè¿å°±æ¯ **读路å¾ï¼read pathï¼**ï¼å½æå¡ç¨æ·è¯·æ±æ¶ï¼ä½ éè¦ä»è¡çæ°æ®éä¸è¯»åï¼ä¹è®¸è¿è¦å¯¹ç»æè¿è¡ä¸äºé¢å¤å¤çï¼ç¶åæ建ç»ç¨æ·çååºã æ»èè¨ä¹ï¼åè·¯å¾å读路å¾æ¶µçäºæ°æ®çæ´ä¸ªæ ç¨ï¼ä»æ¶éæ°æ®å¼å§ï¼å°ä½¿ç¨æ°æ®ç»æï¼å¯è½æ¯ç±å¦ä¸ä¸ªäººï¼ãåè·¯å¾æ¯é¢è®¡ç®è¿ç¨çä¸é¨å ââ å³ï¼ä¸æ¦æ°æ®è¿å ¥ï¼å³å»å®æï¼æ 论æ¯å¦æ人éè¦çå®ã读路å¾æ¯è¿ä¸ªè¿ç¨ä¸åªæå½æ人请æ±æ¶æä¼åççé¨åãå¦æä½ çæå½æ°å¼ç¼ç¨è¯è¨ï¼åå¯è½ä¼æ³¨æå°åè·¯å¾ç±»ä¼¼äºç«å³æ±å¼ï¼è¯»è·¯å¾ç±»ä¼¼äºæ°æ§æ±å¼ã å¦ [å¾ 12-1](img/fig12-1.png) æ示ï¼è¡çæ°æ®éæ¯åè·¯å¾å读路å¾ç¸éçå°æ¹ãå®ä»£è¡¨äºå¨åå ¥æ¶éè¦å®æçå·¥ä½éä¸å¨è¯»åæ¶éè¦å®æçå·¥ä½éä¹é´çæè¡¡ã #### ç©åè§å¾åç¼å å ¨ææ索索å¼å°±æ¯ä¸ä¸ªå¾å¥½çä¾åï¼åè·¯å¾æ´æ°ç´¢å¼ï¼è¯»è·¯å¾å¨ç´¢å¼ä¸æç´¢å ³é®åã读åé½éè¦åä¸äºå·¥ä½ãåå ¥éè¦æ´æ°ææ¡£ä¸åºç°çææå ³é®è¯çç´¢å¼æ¡ç®ã读åéè¦æç´¢æ¥è¯¢ä¸çæ¯ä¸ªåè¯ï¼å¹¶åºç¨å¸å°é»è¾æ¥æ¥æ¾å å«æ¥è¯¢ä¸ææåè¯ï¼AND è¿ç®ç¬¦ï¼çææ¡£ï¼æè æ¯ä¸ªåè¯ï¼OR è¿ç®ç¬¦ï¼çä»»ä½åä¹è¯ã å¦æ没æç´¢å¼ï¼æç´¢æ¥è¯¢å°ä¸å¾ä¸æ«æææææ¡£ï¼å¦ grepï¼ï¼å¦ææç大éææ¡£ï¼è¿æ ·åçå¼é巨大ã没æç´¢å¼æå³çåå ¥è·¯å¾ä¸çå·¥ä½éè¾å°ï¼æ²¡æè¦æ´æ°çç´¢å¼ï¼ï¼ä½æ¯å¨è¯»åè·¯å¾ä¸éè¦æ´å¤å·¥ä½ã å¦ä¸æ¹é¢ï¼å¯ä»¥æ³è±¡ä¸ºææå¯è½çæ¥è¯¢é¢å 计ç®æç´¢ç»æãå¨è¿ç§æ åµä¸ï¼è¯»è·¯å¾ä¸çå·¥ä½éä¼åå°ï¼ä¸éè¦å¸å°é»è¾ï¼åªéæ¥æ¾æ¥è¯¢ç»æ并è¿åå³å¯ãä½åè·¯å¾ä¼æ´å æè´µï¼å¯è½çæç´¢æ¥è¯¢éåæ¯æ é大çï¼å æ¤é¢å 计ç®ææå¯è½çæç´¢ç»æå°éè¦æ éçæ¶é´ååå¨ç©ºé´ãé£è¯å®æ²¡æ [^iii]ã [^iii]: å设ä¸ä¸ªæéçè¯æåºï¼é£ä¹è¿åé空æç´¢ç»æçæç´¢æ¥è¯¢éåæ¯æéçãç¶èï¼å®æ¯ä¸è¯æåºä¸çæ¯è¯æ°éåææ°å ³ç³»ï¼è¿ä»æ¯ä¸ä¸ªåæ¶æ¯ã å¦ä¸ç§éæ©æ¯é¢å 计ç®ä¸ç»åºå®çæ常è§æ¥è¯¢çæç´¢ç»æï¼ä»¥ä¾¿å¯ä»¥å¿«éæä¾å®ä»¬èæ é转å°ç´¢å¼ãä¸å¸¸è§çæ¥è¯¢ä»ç¶å¯ä»¥éè¿ç´¢å¼æ¥æä¾æå¡ãè¿é常被称为常è§æ¥è¯¢ç **ç¼åï¼cacheï¼**ï¼å°½ç®¡æ们ä¹å¯ä»¥ç§°ä¹ä¸º **ç©åè§å¾ï¼materialized viewï¼**ï¼å 为å½æ°ææ¡£åºç°ï¼ä¸éè¦è¢«å å«å¨è¿äºå¸¸è§æ¥è¯¢çæç´¢ç»æä¹ä¸æ¶ï¼è¿äºç´¢å¼å°±éè¦æ´æ°ã ä»è¿ä¸ªä¾åä¸æ们å¯ä»¥çå°ï¼ç´¢å¼ä¸æ¯åè·¯å¾å读路å¾ä¹é´å¯ä¸å¯è½çè¾¹çï¼ç¼å常è§æç´¢ç»æä¹æ¯å¯è¡çï¼èå¨å°éææ¡£ä¸ä½¿ç¨æ²¡æç´¢å¼çç±» grep æ«æä¹æ¯å¯è¡çãç±æ¤æ¥çï¼ç¼åï¼ç´¢å¼åç©åè§å¾çä½ç¨å¾ç®åï¼å®ä»¬æ¹åäºè¯»è·¯å¾ä¸åè·¯å¾ä¹é´çè¾¹çãéè¿é¢å 计ç®ç»æï¼ä»èå 许æ们å¨åè·¯å¾ä¸åæ´å¤çå·¥ä½ï¼ä»¥èç读路å¾ä¸çå·¥ä½éã å¨åè·¯å¾ä¸å®æçå·¥ä½å读路å¾ä¹é´ççéï¼å®é ä¸æ¯æ¬ä¹¦å¼å§å¤å¨ â[æè¿°è´è½½](ch1.md#æè¿°è´è½½)â ä¸æ¨ç¹ä¾åéè°å°ç主é¢ãå¨è¯¥ä¾ä¸ï¼æ们è¿çå°äºä¸æ®éç¨æ·ç¸æ¯ï¼å人çåè·¯å¾å读路å¾å¯è½ææä¸åãå¨ 500 页ä¹åï¼æ们已ç»ç»åäºèµ·ç¹ï¼ #### æç¶æãå¯ç¦»çº¿ç客æ·ç«¯ æåç°åè·¯å¾å读路å¾ä¹é´çè¾¹çå¾æ趣ï¼å 为æ们å¯ä»¥è¯çæ¹åè¿ä¸ªè¾¹çï¼å¹¶æ¢è®¨è¿ç§æ¹åçå®é æä¹ãæ们æ¥ççä¸åä¸ä¸æä¸çè¿ä¸æ³æ³ã è¿å»äºåå¹´æ¥ï¼Web åºç¨çç«ç让æ们对åºç¨å¼åä½åºäºä¸äºå¾å®¹æè§ä½çæå½ç¶çå设ãå ·ä½æ¥è¯´å°±æ¯ï¼å®¢æ·ç«¯ / æå¡å¨æ¨¡å ââ 客æ·ç«¯å¤§å¤æ¯æ ç¶æçï¼èæå¡å¨æ¥ææ°æ®çæå¨ ââ å·²ç»æ®éå°æ们å ä¹å¿æäºè¿æå ¶ä»ä»»ä½æ¨¡åçåå¨ãä½æ¯ææ¯å¨ä¸æå°åå±ï¼æ认为ä¸æ¶å°è´¨çç°ç¶é常éè¦ã ä¼ ç»ä¸ï¼ç½ç»æµè§å¨æ¯æ ç¶æç客æ·ç«¯ï¼åªæå½è¿æ¥å°äºèç½æ¶æè½åä¸äºæç¨çäºæ ï¼è½ç¦»çº¿æ§è¡çå¯ä¸äºæ åºæ¬ä¸å°±æ¯ä¸ä¸æ»å¨ä¹åå¨çº¿æ¶å 载好ç页é¢ï¼ãç¶èï¼æè¿ç âå页é¢â JavaScript Web åºç¨å·²ç»è·å¾äºå¾å¤æç¶æçåè½ï¼å æ¬å®¢æ·ç«¯ç¨æ·çé¢äº¤äºï¼ä»¥å Web æµè§å¨ä¸çæä¹ åæ¬å°åå¨ã移å¨åºç¨å¯ä»¥ç±»ä¼¼å°å¨è®¾å¤ä¸åå¨å¤§éç¶æï¼èä¸å¤§å¤æ°ç¨æ·äº¤äºé½ä¸éè¦ä¸æå¡å¨å¾è¿äº¤äºã è¿äºä¸æååçåè½éæ°å¼åäºå¯¹ **离线ä¼å ï¼offline-firstï¼** åºç¨çå ´è¶£ï¼è¿äºåºç¨å°½å¯è½å°å¨åä¸è®¾å¤ä¸ä½¿ç¨æ¬å°æ°æ®åºï¼æ éè¿æ¥äºèç½ï¼å¹¶å¨åå°ç½ç»è¿æ¥å¯ç¨æ¶ä¸è¿ç¨æå¡å¨åæ¥ã42ããç±äºç§»å¨è®¾å¤éå¸¸å ·æç¼æ ¢ä¸ä¸å¯é çèçªç½ç»è¿æ¥ï¼å æ¤ï¼å¦æç¨æ·çç¨æ·çé¢ä¸å¿ çå¾ åæ¥ç½ç»è¯·æ±ï¼ä¸åºç¨ä¸»è¦æ¯ç¦»çº¿å·¥ä½çï¼åè¿æ¯ä¸ä¸ªå·¨å¤§ä¼å¿ï¼è¯·åé â[éè¦ç¦»çº¿æä½ç客æ·ç«¯](ch5.md#éè¦ç¦»çº¿æä½ç客æ·ç«¯)âï¼ã å½æ们æè±æ ç¶æ客æ·ç«¯ä¸ä¸å¤®æ°æ®åºäº¤äºçå设ï¼å¹¶è½¬åå¨ç»ç«¯ç¨æ·è®¾å¤ä¸ç»´æ¤ç¶ææ¶ï¼è¿å°±å¼å¯äºæ°ä¸çç大é¨ãç¹å«æ¯ï¼æ们å¯ä»¥å°è®¾å¤ä¸çç¶æè§ä¸º **æå¡å¨ç¶æçç¼å**ãå±å¹ä¸çåç´ æ¯å®¢æ·ç«¯åºç¨ä¸æ¨¡å对象çç©åè§å¾ï¼æ¨¡å对象æ¯è¿ç¨æ°æ®ä¸å¿çæ¬å°ç¶æå¯æ¬ã27ãã #### å°ç¶æåæ´æ¨éç»å®¢æ·ç«¯ å¨å ¸åçç½é¡µä¸ï¼å¦æä½ å¨ Web æµè§å¨ä¸å 载页é¢ï¼å¹¶ä¸éåæå¡å¨ä¸çæ°æ®åçåæ´ï¼åæµè§å¨å¨éæ°å 载页é¢ä¹å对æ¤ä¸æ æç¥ãæµè§å¨åªè½å¨ä¸ä¸ªæ¶é´ç¹è¯»åæ°æ®ï¼å设å®æ¯éæç ââ å®ä¸ä¼è®¢é æ¥èªæå¡å¨çæ´æ°ãå æ¤è®¾å¤ä¸çç¶ææ¯éæ§çç¼åï¼é¤éä½ æ¾å¼è½®è¯¢åæ´å¦åä¸ä¼æ´æ°ãï¼å RSS è¿æ ·åºäº HTTP ç Feed 订é åè®®å®é ä¸åªæ¯ä¸ç§åºæ¬ç轮询形å¼ï¼ æè¿çå议已ç»è¶ è¶äº HTTP çåºæ¬è¯·æ± / ååºæ¨¡å¼ï¼æå¡ç«¯åéçäºä»¶ï¼EventSource APIï¼å WebSockets æä¾äºéä¿¡ä¿¡éï¼éè¿è¿äºä¿¡éï¼Web æµè§å¨å¯ä»¥ä¸æå¡å¨ä¿ææå¼ç TCP è¿æ¥ï¼åªè¦æµè§å¨ä»ç¶è¿æ¥çï¼æå¡å¨å°±è½ä¸»å¨åæµè§å¨æ¨éä¿¡æ¯ãè¿ä¸ºæå¡å¨æä¾äºä¸»å¨éç¥ç»ç«¯ç¨æ·å®¢æ·ç«¯çæºä¼ï¼æå¡å¨è½åç¥å®¢æ·ç«¯å ¶æ¬å°åå¨ç¶æçä»»ä½ååï¼ä»èåå°å®¢æ·ç«¯ç¶æçéæ§ç¨åº¦ã ç¨æ们çåè·¯å¾ä¸è¯»è·¯å¾æ¨¡åæ¥è®²ï¼ä¸»å¨å°ç¶æåæ´æ¨è³å°å®¢æ·ç«¯è®¾å¤ï¼æå³çå°åè·¯å¾ä¸ç´å»¶ä¼¸å°ç»ç«¯ç¨æ·ãå½å®¢æ·ç«¯é¦æ¬¡åå§åæ¶ï¼å®ä»ç¶éè¦ä½¿ç¨è¯»è·¯å¾æ¥è·åå ¶åå§ç¶æï¼ä½æ¤åå®å°±è½å¤ä¾èµæå¡å¨åéçç¶æåæ´æµäºãæ们å¨æµå¤çåæ¶æ¯ä¼ éé¨å讨论çæ³æ³å¹¶ä¸å±éäºæ°æ®ä¸å¿ä¸ï¼æ们å¯ä»¥è¿ä¸æ¥é纳è¿äºæ³æ³ï¼å¹¶å°å®ä»¬ä¸ç´å»¶ä¼¸å°ç»ç«¯ç¨æ·è®¾å¤ã43ãã è¿äºè®¾å¤ææ¶ä¼ç¦»çº¿ï¼å¹¶å¨æ¤æé´æ æ³æ¶å°æå¡å¨ç¶æåæ´çä»»ä½éç¥ãä½æ¯æ们已ç»è§£å³äºè¿ä¸ªé®é¢ï¼å¨ â[æ¶è´¹è å移é](ch11.md#æ¶è´¹è å移é)â ä¸ï¼æ们讨论äºåºäºæ¥å¿çæ¶æ¯ä»£ççæ¶è´¹è è½å¨å¤±è´¥ææå¼è¿æ¥åéè¿ï¼å¹¶ç¡®ä¿å®ä¸ä¼éè¿æ线æé´ä»»ä½å°è¾¾çæ¶æ¯ãåæ ·çææ¯éç¨äºå个ç¨æ·ï¼æ¯ä¸ªè®¾å¤é½æ¯ä¸ä¸ªå°äºä»¶æµçå°å°è®¢é è ã #### 端å°ç«¯çäºä»¶æµ æè¿ç¨äºå¼åæç¶æç客æ·ç«¯ä¸ç¨æ·çé¢çå·¥å ·ï¼ä¾å¦å¦ Elm è¯è¨ã30ãå Facebook ç ReactãFlux å Redux å·¥å ·é¾ï¼å·²ç»éè¿è®¢é 表示ç¨æ·è¾å ¥ææå¡å¨ååºçäºä»¶æµæ¥ç®¡ç客æ·ç«¯çå é¨ç¶æï¼å ¶ç»æä¸äºä»¶æº¯æºç¸ä¼¼ï¼è¯·åé â[äºä»¶æº¯æº](ch11.md#äºä»¶æº¯æº)âï¼ã å°è¿ç§ç¼ç¨æ¨¡åæ©å±ä¸ºï¼å 许æå¡å¨å°ç¶æåæ´äºä»¶æ¨éå°å®¢æ·ç«¯çäºä»¶ç®¡éä¸ï¼æ¯é常èªç¶çãå æ¤ï¼ç¶æååå¯ä»¥éè¿ **端å°ç«¯ï¼end-to-endï¼** çåè·¯å¾æµå¨ï¼ä»ä¸ä¸ªè®¾å¤ä¸ç交äºè§¦åç¶æåæ´å¼å§ï¼ç»ç±äºä»¶æ¥å¿ï¼å¹¶ç©¿è¿å 个è¡çæ°æ®ç³»ç»ä¸æµå¤çå¨ï¼ä¸ç´å°å¦ä¸å°è®¾å¤ä¸çç¨æ·çé¢ï¼èæ人æ£å¨è§å¯ç¨æ·çé¢ä¸çç¶æååãè¿äºç¶æååè½ä»¥ç¸å½ä½ç延è¿ä¼ æ ââ æ¯å¦è¯´ï¼å¨ä¸ç§å ä»ä¸ç«¯å°å¦ä¸ç«¯ã ä¸äºåºç¨ï¼å¦å³æ¶æ¶æ¯ä¼ éä¸å¨çº¿æ¸¸æï¼å·²ç»å ·æè¿ç§ âå®æ¶â æ¶æï¼å¨ä½å»¶è¿äº¤äºçæä¹ä¸ï¼ä¸æ¯å¨ â[ååºæ¶é´ä¿è¯](ch8.md#ååºæ¶é´ä¿è¯)â ä¸çæä¹ä¸ï¼ãä½æ们为ä»ä¹ä¸ç¨è¿ç§æ¹å¼æ建ææçåºç¨ï¼ ææå¨äºï¼å ³äºæ ç¶æ客æ·ç«¯åè¯·æ± / ååºäº¤äºçå设已ç»æ ¹æ·±èåºå°æ¤å ¥å¨å¨æ们çæ°æ®åºãåºãæ¡æ¶ä»¥ååè®®ä¹ä¸ã许å¤æ°æ®åå¨æ¯æ读åä¸åå ¥æä½ï¼ä¸ºè¯·æ±è¿åä¸ä¸ªååºï¼ä½åªææå°æ°æä¾è®¢é åæ´çè½å ââ 请æ±è¿åä¸ä¸ªéæ¶é´æ¨ç§»çååºæµï¼è¯·åé â[åæ´æµç API æ¯æ](ch11.md#åæ´æµçAPIæ¯æ)â ï¼ã 为äºå°åè·¯å¾å»¶ä¼¸è³ç»ç«¯ç¨æ·ï¼æ们éè¦ä»æ ¹æ¬ä¸éæ°æèæ们æ建è¿äºç³»ç»çæ¹å¼ï¼ä»è¯·æ± / ååºäº¤äºè½¬ååå¸ / 订é æ°æ®æµã27ããæ´å ·ååºæ§çç¨æ·çé¢ä¸æ´å¥½ç离线æ¯æï¼æ认为è¿äºä¼å¿å¼å¾æ们ä»åºåªåãå¦æä½ æ£å¨è®¾è®¡æ°æ®ç³»ç»ï¼æå¸æä½ å¯¹è®¢é åæ´çé项çæå°è±¡ï¼èä¸åªæ¯æ¥è¯¢å½åç¶æã #### 读ä¹æ¯äºä»¶ æ们讨论è¿ï¼å½æµå¤çå¨å°è¡çæ°æ®åå ¥åå¨ï¼æ°æ®åºï¼ç¼åæç´¢å¼ï¼æ¶ï¼ä»¥åå½ç¨æ·è¯·æ±æ¥è¯¢è¯¥åå¨æ¶ï¼åå¨å°å å½åè·¯å¾å读路å¾ä¹é´çè¾¹çã该åå¨åºå½å 许对æ°æ®è¿è¡éæºè®¿é®ç读åæ¥è¯¢ï¼å¦åè¿äºæ¥è¯¢å°éè¦æ«ææ´ä¸ªäºä»¶æ¥å¿ã å¨å¾å¤æ åµä¸ï¼æ°æ®åå¨ä¸æµå¤çç³»ç»æ¯åå¼çãä½åæ³ä¸ä¸ï¼æµå¤çå¨è¿æ¯éè¦ç»´æ¤ç¶æ以æ§è¡èååè¿æ¥çï¼è¯·åé â[æµè¿æ¥](ch11.md#æµè¿æ¥)âï¼ãè¿ç§ç¶æé常éèå¨æµå¤çå¨å é¨ï¼ä½ä¸äºæ¡æ¶ä¹å 许è¿äºç¶æ被å¤é¨å®¢æ·ç«¯æ¥è¯¢ã45ãï¼å°æµå¤çå¨æ¬èº«åæä¸ç§ç®åçæ°æ®åºã ææ¿æè¿ä¸æ¥æèè¿ä¸ªæ³æ³ãæ£å¦å°ç®å为æ¢æ讨论çé£æ ·ï¼å¯¹åå¨çåå ¥æ¯éè¿äºä»¶æ¥å¿è¿è¡çï¼è读åæ¯ä¸´æ¶çç½ç»è¯·æ±ï¼ç´æ¥æµååå¨çå¾ æ¥æ°æ®çèç¹ãè¿æ¯ä¸ä¸ªåçç设计ï¼ä½ä¸æ¯å¯ä¸å¯è¡ç设计ãä¹å¯ä»¥å°è¯»å请æ±è¡¨ç¤ºä¸ºäºä»¶æµï¼å¹¶åæ¶å°è¯»äºä»¶ä¸åäºä»¶éå¾æµå¤çå¨ï¼æµå¤çå¨éè¿å°è¯»åç»æåéå°è¾åºæµæ¥ååºè¯»åäºä»¶ã46ãã å½åå ¥å读åé½è¢«è¡¨ç¤ºä¸ºäºä»¶ï¼å¹¶ä¸è¢«è·¯ç±å°åä¸ä¸ªæµç®å以便å¤çæ¶ï¼æ们å®é ä¸æ¯å¨è¯»åæ¥è¯¢æµåæ°æ®åºä¹é´æ§è¡æµè¡¨è¿æ¥ã读åäºä»¶éè¦è¢«éå¾ä¿åæ°æ®çæ°æ®åºååºï¼è¯·åé â[请æ±è·¯ç±](ch6.md#请æ±è·¯ç±)âï¼ï¼å°±åæ¹å¤çåæµå¤çå¨å¨è¿æ¥æ¶éè¦å¨åä¸ä¸ªé®ä¸å¯¹è¾å ¥ååºä¸æ ·ï¼è¯·åé â[Reduce 侧è¿æ¥ä¸åç»](ch10.md#Reduce侧è¿æ¥ä¸åç»)âï¼ã æå¡è¯·æ±ä¸æ§è¡è¿æ¥ä¹é´çè¿ç§ç¸ä¼¼ä¹å¤æ¯éå¸¸å ³é®çã47ããä¸æ¬¡æ§è¯»å请æ±åªæ¯å°è¯·æ±ä¼ è¿è¿æ¥ç®åï¼ç¶å请æ±é©¬ä¸å°±è¢«å¿æäºï¼èä¸ä¸ªè®¢é 请æ±ï¼åæ¯ä¸è¿æ¥å¦ä¸ä¾§è¿å»ä¸æªæ¥äºä»¶çæä¹ åè¿æ¥ã è®°å½è¯»åäºä»¶çæ¥å¿å¯è½å¯¹äºè¿½è¸ªæ´ä¸ªç³»ç»ä¸çå æå ³ç³»ä¸æ°æ®æ¥æºä¹æ好å¤ï¼å®å¯ä»¥è®©ä½ éç°åºå½ç¨æ·ååºç¹å®å³çä¹åçè§äºä»ä¹ãä¾å¦å¨ç½åä¸ï¼å客æ·æ¾ç¤ºçé¢æµéè¾¾æ¥æä¸åºåç¶æï¼å¯è½ä¼å½±åä»ä»¬æ¯å¦éæ©è´ä¹°ä¸ä»¶ååã4ããè¦åæè¿ç§èç³»ï¼åéè¦è®°å½ç¨æ·æ¥è¯¢è¿è¾ä¸åºåç¶æçç»æã å°è¯»åäºä»¶åå ¥æä¹ åå¨å¯ä»¥æ´å¥½å°è·è¸ªå æå ³ç³»ï¼è¯·åé â[æåºäºä»¶ä»¥æè·å æå ³ç³»](#æåºäºä»¶ä»¥æè·å æå ³ç³»)âï¼ï¼ä½ä¼äº§çé¢å¤çåå¨ä¸ I/O ææ¬ãä¼åè¿äºç³»ç»ä»¥åå°å¼éä»ç¶æ¯ä¸ä¸ªå¼æ¾çç 究é®é¢ã2ããä½å¦æä½ å·²ç»åºäºè¿ç»´ç®ççä¸äºè¯»å请æ±æ¥å¿ï¼å°å ¶ä½ä¸ºè¯·æ±å¤ççå¯ä½ç¨ï¼é£ä¹å°è¿ä»½æ¥å¿ä½ä¸ºè¯·æ±äºä»¶æºå¹¶ä¸æ¯ä»ä¹ç¹å«å¤§çåæ´ã #### å¤ååºæ°æ®å¤ç 对äºåªæ¶åå个ååºçæ¥è¯¢ï¼éè¿æµæ¥åéæ¥è¯¢ä¸æ¶éååºå¯è½æ¯æ鸡ç¨çåäºãç¶èï¼è¿ä¸ªæ³æ³å¼å¯äºåå¸å¼æ§è¡å¤ææ¥è¯¢çå¯è½æ§ï¼è¿éè¦å并æ¥èªå¤ä¸ªååºçæ°æ®ï¼å©ç¨äºæµå¤çå¨å·²ç»æä¾çæ¶æ¯è·¯ç±ãååºåè¿æ¥çåºç¡è®¾æ½ã Storm çåå¸å¼ RPC åè½æ¯æè¿ç§ä½¿ç¨æ¨¡å¼ï¼è¯·åé â[æ¶æ¯ä¼ éå RPC](ch11.md#æ¶æ¯ä¼ éåRPC)âï¼ãä¾å¦ï¼å®å·²ç»è¢«ç¨æ¥è®¡ç®æµè§è¿æ个æ¨ç¹ URL çäººæ° ââ å³ï¼åæ¨å å«è¯¥ URL çææ人çç²ä¸éåç并éã48ããç±äºæ¨ç¹çç¨æ·æ¯ååºçï¼å æ¤è¿ç§è®¡ç®éè¦å并æ¥èªå¤ä¸ªååºçç»æã è¿ç§æ¨¡å¼çå¦ä¸ä¸ªä¾åæ¯æ¬ºè¯é¢é²ï¼ä¸ºäºè¯ä¼°ç¹å®è´ä¹°äºä»¶æ¯å¦å ·æ欺è¯é£é©ï¼ä½ å¯ä»¥æ£æ¥è¯¥ç¨æ· IP å°åï¼çµåé®ä»¶å°åï¼å¸åå°åï¼éè´§å°åçä¿¡ç¨åãè¿äºä¿¡ç¨æ°æ®åºä¸çæ¯ä¸ä¸ªé½æ¯æååºçï¼å æ¤ä¸ºç¹å®è´ä¹°äºä»¶ééåæ°éè¦è¿æ¥ä¸ç³»åä¸åçååºæ°æ®éã49ãã MPP æ°æ®åºçå é¨æ¥è¯¢æ§è¡å¾æç类似çç¹å¾ï¼è¯·åé â[Hadoop ä¸åå¸å¼æ°æ®åºç对æ¯](ch10.md#Hadoopä¸åå¸å¼æ°æ®åºç对æ¯)âï¼ãå¦æéè¦æ§è¡è¿ç§å¤ååºè¿æ¥ï¼åç´æ¥ä½¿ç¨æä¾æ¤åè½çæ°æ®åºï¼å¯è½è¦æ¯ä½¿ç¨æµå¤çå¨å®ç°å®è¦æ´ç®åãç¶èå°æ¥è¯¢è§ä¸ºæµæä¾äºä¸ç§é项ï¼å¯ä»¥ç¨äºå®ç°è¶ åºä¼ ç»ç°æ解å³æ¹æ¡ç大è§æ¨¡åºç¨ã ## å°äºæ åæ£ç¡® 对äºåªè¯»åæ°æ®çæ ç¶ææå¡ï¼åºé®é¢ä¹æ²¡ä»ä¹å¤§ä¸äºçï¼ä½ å¯ä»¥ä¿®å¤è¯¥é误并éå¯æå¡ï¼èä¸åé½æ¢å¤æ£å¸¸ãåæ°æ®åºè¿æ ·çæç¶æç³»ç»å°±æ²¡é£ä¹ç®åäºï¼å®ä»¬è¢«è®¾è®¡ä¸ºæ°¸è¿è®°ä½äºç©ï¼æå¤æå°ï¼ï¼æ以å¦æåºç°é®é¢ï¼è¿ç§ï¼é误çï¼ææä¹å°æ½å¨å°æ°¸è¿æç»ä¸å»ï¼è¿æå³çå®ä»¬éè¦æ´ä»ç»çæèã50ãã æ们å¸ææ建å¯é ä¸ **æ£ç¡®** çåºç¨ï¼å³ä½¿é¢å¯¹åç§æ éï¼ç¨åºçè¯ä¹ä¹è½è¢«å¾å¥½å°å®ä¹ä¸ç解ï¼ã约ååå¹´æ¥ï¼ååæ§ãé离æ§åæä¹ æ§ï¼[第ä¸ç« ](ch7.md)ï¼çäºå¡ç¹æ§ä¸ç´æ¯æ建æ£ç¡®åºç¨çé¦éå·¥å ·ãç¶èè¿äºå°åºæ²¡æçä¸å»é£ä¹ç¢åºï¼ä¾å¦å¼±é离级å«å¸¦æ¥çå°æå¯ä»¥ä½è¯ï¼è¯·åé â[å¼±é离级å«](ch7.md#å¼±é离级å«)âï¼ã äºå¡å¨æäºé¢å被å®å ¨æå¼ï¼å¹¶è¢«æä¾æ´å¥½æ§è½ä¸å¯ä¼¸ç¼©æ§ç模åå代ï¼ä½åè ææ´å¤æçè¯ä¹ï¼ä¾å¦ï¼è¯·åé â[æ 主å¤å¶](ch5.md#æ 主å¤å¶)âï¼ã**ä¸è´æ§ï¼Consistencyï¼** ç»å¸¸è¢«è°èµ·ï¼ä½å ¶å®ä¹å¹¶ä¸æç¡®ï¼è¯·åé â[ä¸è´æ§](ch7.md#ä¸è´æ§)â å [第ä¹ç« ](ch9.md)ï¼ãæäºäººæè¨æ们åºå½ä¸ºäºé«å¯ç¨è âæ¥æ±å¼±ä¸è´æ§âï¼ä½å´å¯¹è¿äºæ¦å¿µå®é ä¸æå³çä»ä¹ç¼ºä¹æ¸ æ°ç认è¯ã 对äºå¦æ¤éè¦çè¯é¢ï¼æ们çç解ï¼ä»¥åæ们çå·¥ç¨æ¹æ³å´æ¯æ人å°èå¼±ãä¾å¦ï¼ç¡®å®å¨ç¹å®äºå¡é离ç级æå¤å¶é ç½®ä¸è¿è¡ç¹å®åºç¨æ¯å¦å®å ¨æ¯é常å°é¾çã51,52ããé常ç®åç解å³æ¹æ¡ä¼¼ä¹å¨ä½å¹¶åæ§çæ åµä¸å·¥ä½æ£å¸¸ï¼å¹¶ä¸æ²¡æé误ï¼ä½å¨è¦æ±æ´é«çæ åµä¸å´ä¼åºç°è®¸å¤å¾®å¦çé误ã ä¾å¦ï¼Kyle Kingsbury ç Jepsen å®éªã53ãæ åºäºä¸äºäº§å声称çå®å ¨ä¿è¯ä¸å ¶å¨ç½ç»é®é¢ä¸å´©æºæ¶çå®é è¡ä¸ºä¹é´çææ¾å·®å¼ãå³ä½¿åæ°æ®åºè¿æ ·çåºç¡è®¾æ½äº§å没æé®é¢ï¼åºç¨ä»£ç ä»ç¶éè¦æ£ç¡®ä½¿ç¨å®ä»¬æä¾çåè½æè¡ï¼å¦æé ç½®å¾é¾ç解ï¼è¿æ¯å¾å®¹æåºéçï¼å¨è¿ç§æ åµä¸æçæ¯å¼±é离级å«ï¼æ³å®äººæ°é ç½®çï¼ã å¦æä½ çåºç¨å¯ä»¥å®¹å¿å¶å°çå´©æºï¼ä»¥å以ä¸å¯é¢æçæ¹å¼æåæ丢失æ°æ®ï¼é£ç活就è¦ç®åå¾å¤ï¼èä½ å¯è½åªè¦åæåå念é¿å¼¥éä½ï¼ææä½ç¥è½ä¿ä½æ好çç»æãå¦ä¸æ¹é¢ï¼å¦æä½ éè¦æ´å¼ºçæ£ç¡®æ§ä¿è¯ï¼é£ä¹å¯ä¸²è¡åä¸ååæ交就æ¯ä¹ ç»èéªçæ¹æ³ï¼ä½å®ä»¬æ¯æ代价çï¼å®ä»¬é常åªå¨å个æ°æ®ä¸å¿ä¸å·¥ä½ï¼è¿å°±æé¤äºå°çä½ç½®åæ£çæ¶æï¼ï¼å¹¶éå¶äºç³»ç»è½å¤å®ç°çè§æ¨¡ä¸å®¹éç¹æ§ã è½ç¶ä¼ ç»çäºå¡æ¹æ³å¹¶æ²¡æèµ°è¿ï¼ä½æä¹ç¸ä¿¡å¨ä½¿åºç¨æ£ç¡®èçµæ´»å°å¤çé误æ¹é¢ä¸ï¼äºå¡ä¹ä¸æ¯æåä¸ä¸ªå¯ä»¥è°çãå¨æ¬èä¸ï¼æå°æåºä¸äºå¨æ°æ®æµæ¶æä¸èéæ£ç¡®æ§çæ¹å¼ã ### æ°æ®åºç端å°ç«¯åå ä» ä» å 为ä¸ä¸ªåºç¨ç¨åºä½¿ç¨äºå ·æç¸å¯¹è¾å¼ºå®å ¨å±æ§çæ°æ®ç³»ç»ï¼ä¾å¦å¯ä¸²è¡åçäºå¡ï¼ï¼å¹¶ä¸æå³çå°±å¯ä»¥ä¿è¯æ²¡ææ°æ®ä¸¢å¤±ææåãä¾å¦ï¼å¦ææ个åºç¨æ个 Bugï¼å¯¼è´å®åå ¥ä¸æ£ç¡®çæ°æ®ï¼æè ä»æ°æ®åºä¸å é¤æ°æ®ï¼é£ä¹å¯ä¸²è¡åçäºå¡ä¹æä¸äºä½ ã è¿ä¸ªä¾åå¯è½çèµ·æ¥å¾æ èï¼ä½å¼å¾è®¤çå¯¹å¾ ï¼åºç¨ä¼åº Bugï¼è人ä¹ä¼ç¯é误ãæå¨ â[ç¶æãæµåä¸åæ§](ch11.md#ç¶æãæµåä¸åæ§)â ä¸ä½¿ç¨äºè¿ä¸ªä¾åæ¥æ¯æä¸å¯ååä» è¿½å çæ°æ®ï¼éå²æé误代ç æ§æ¯è¯å¥½æ°æ®çè½åï¼è½è®©ä»é误ä¸æ¢å¤æ´ä¸ºå®¹æã è½ç¶ä¸åæ§å¾æç¨ï¼ä½å®æ¬èº«å¹¶éä¸çµè¯ã让æ们æ¥çä¸ä¸ªå¯è½åççãé常微å¦çæ°æ®æåæ¡ä¾ã #### æ£å¥½æ§è¡ä¸æ¬¡æä½ å¨ â[容é](ch11.md#容é)â ä¸ï¼æ们è§å°äº **æ°å¥½ä¸æ¬¡**ï¼æ **çæä¸æ¬¡**ï¼è¯ä¹çæ¦å¿µãå¦æå¨å¤çæ¶æ¯æ¶åºç°é®é¢ï¼ä½ å¯ä»¥éæ©æ¾å¼ï¼ä¸¢å¼æ¶æ¯ ââ 导è´æ°æ®ä¸¢å¤±ï¼æéè¯ãå¦æéè¯ï¼å°±ä¼æè¿ç§é£é©ï¼ç¬¬ä¸æ¬¡å®é ä¸æåäºï¼åªä¸è¿ä½ 没æåç°ãç»æè¿ä¸ªæ¶æ¯å°±è¢«å¤çäºä¸¤æ¬¡ã å¤ç两次æ¯æ°æ®æåçä¸ç§å½¢å¼ï¼ä¸ºåæ ·çæå¡å客æ·æ¶è´¹ä¸¤æ¬¡ï¼æ¶è´¹å¤ªå¤ï¼æå¢é¿è®¡æ°å¨ä¸¤æ¬¡ï¼å¤¸å¤§ææ ï¼é½ä¸æ¯æ们æ³è¦çãå¨è¿ç§æ åµä¸ï¼æ°å¥½ä¸æ¬¡æå³çå®æ计ç®ï¼ä½¿å¾æç»ææä¸æ²¡æåçé误çæ åµä¸æ ·ï¼å³ä½¿æä½å®é ä¸å 为æç§é误èéè¯ãæ们å å讨论è¿å®ç°è¿ä¸ç®æ çå ç§æ¹æ³ã æææçæ¹æ³ä¹ä¸æ¯ä½¿æä½ **å¹ç**ï¼idempotentï¼è¯·åé â[å¹çæ§](ch11.md#å¹çæ§)âï¼ï¼å³ç¡®ä¿å®æ 论æ¯æ§è¡ä¸æ¬¡è¿æ¯æ§è¡å¤æ¬¡é½å ·æç¸åçææãä½æ¯ï¼å°ä¸æ¯å¤©çå¹ççæä½å为å¹ççæä½éè¦ä¸äºé¢å¤çåªåä¸å ³æ³¨ï¼ä½ å¯è½éè¦ç»´æ¤ä¸äºé¢å¤çå æ°æ®ï¼ä¾å¦æ´æ°äºå¼çæä½ ID éåï¼ï¼å¹¶å¨ä»ä¸ä¸ªèç¹æ éåæ¢è³å¦ä¸ä¸ªèç¹æ¶å好é²æ¤ï¼è¯·åé â[é¢å¯¼è åé](ch8.md#é¢å¯¼è åé)âï¼ã #### æå¶éå¤ é¤äºæµå¤çä¹å¤ï¼å ¶ä»è®¸å¤å°æ¹ä¹éè¦æå¶éå¤ç模å¼ãä¾å¦ï¼TCP 使ç¨äºæ°æ®å ä¸çåºåå·ï¼ä»¥ä¾¿æ¥æ¶æ¹å¯ä»¥å°å®ä»¬æ£ç¡®æåºï¼å¹¶ç¡®å®ç½ç»ä¸æ¯å¦ææ°æ®å 丢失æéå¤ãå¨å°æ°æ®äº¤ä»åºç¨åï¼TCP åè®®æ ä¼éæ°ä¼ è¾ä»»ä½ä¸¢å¤±çæ°æ®å ï¼ä¹ä¼ç§»é¤ä»»ä½éå¤çæ°æ®å ã ä½æ¯ï¼è¿ç§éå¤æå¶ä» éç¨äºåæ¡ TCP è¿æ¥çåºæ¯ä¸ãå设 TCP è¿æ¥æ¯ä¸ä¸ªå®¢æ·ç«¯ä¸æ°æ®åºçè¿æ¥ï¼å¹¶ä¸å®æ£å¨æ§è¡ [ä¾ 12-1]() ä¸çäºå¡ãå¨è®¸å¤æ°æ®åºä¸ï¼äºå¡æ¯ç»å®å¨å®¢æ·ç«¯è¿æ¥ä¸çï¼å¦æ客æ·ç«¯åéäºå¤ä¸ªæ¥è¯¢ï¼æ°æ®åºå°±ç¥éå®ä»¬å±äºåä¸ä¸ªäºå¡ï¼å 为å®ä»¬æ¯å¨åä¸ä¸ª TCP è¿æ¥ä¸åéçï¼ãå¦æ客æ·ç«¯å¨åé `COMMIT` ä¹å并å¨ä»æ°æ®åºæå¡å¨æ¶å°ååºä¹åéå°ç½ç»ä¸æä¸è¿æ¥è¶ æ¶ï¼å®¢æ·ç«¯æ¯ä¸ç¥éäºå¡æ¯å¦å·²ç»è¢«æ交çï¼[å¾ 8-1](img/fig8-1.png)ï¼ã **ä¾ 12-1 èµéä»ä¸ä¸ªè´¦æ·å°å¦ä¸ä¸ªè´¦æ·çéå¹ç转移** ```sql BEGIN TRANSACTION; UPDATE accounts SET balance = balance + 11.00 WHERE account_id = 1234; UPDATE accounts SET balance = balance - 11.00 WHERE account_id = 4321; COMMIT; ``` 客æ·ç«¯å¯ä»¥éè¿å°æ°æ®åºå¹¶éè¯äºå¡ï¼ä½ç°å¨å·²ç»å¤äº TCP éå¤æå¶çèå´ä¹å¤äºãå 为 [ä¾ 12-1]() ä¸çäºå¡ä¸æ¯å¹ççï¼å¯è½ä¼åçè½¬äº \$22 èä¸æ¯ææç \$11ãå æ¤ï¼å°½ç®¡ [ä¾ 12-1]() æ¯ä¸ä¸ªäºå¡ååæ§çæ åæ ·ä¾ï¼ä½å®å®é ä¸å¹¶ä¸æ£ç¡®ï¼èçæ£çé¶è¡å¹¶ä¸ä¼è¿æ ·åäºã3ãã 两é¶æ®µæ交ï¼è¯·åé â[ååæ交ä¸ä¸¤é¶æ®µæ交](ch9.md#ååæ交ä¸ä¸¤é¶æ®µæ交)âï¼åè®®ä¼ç ´å TCP è¿æ¥ä¸äºå¡ä¹é´ç 1:1 æ å°ï¼å 为å®ä»¬å¿ é¡»å¨æ éåå 许äºå¡åè°å¨éè¿å°æ°æ®åºï¼åè¯æ°æ®åºå°åçäºå¡æ交è¿æ¯ä¸æ¢ãè¿è¶³ä»¥ç¡®ä¿äºå¡åªè¢«æ°å¥½æ§è¡ä¸æ¬¡åï¼ä¸å¹¸çæ¯ï¼å¹¶ä¸è½ã å³ä½¿æ们å¯ä»¥æå¶æ°æ®åºå®¢æ·ç«¯ä¸æå¡å¨ä¹é´çéå¤äºå¡ï¼æ们ä»ç¶éè¦æ å¿ç»ç«¯ç¨æ·è®¾å¤ä¸åºç¨æå¡å¨ä¹é´çç½ç»ãä¾å¦ï¼å¦æç»ç«¯ç¨æ·ç客æ·ç«¯æ¯ Web æµè§å¨ï¼åå®å¯è½ä¼ä½¿ç¨ HTTP POST 请æ±åæå¡å¨æ交æ令ãä¹è®¸ç¨æ·æ£å¤äºä¸ä¸ªä¿¡å·å¾®å¼±çèçªæ°æ®ç½ç»è¿æ¥ä¸ï¼å®ä»¬æåå°åéäº POSTï¼ä½å´å¨è½å¤ä»æå¡å¨æ¥æ¶ååºä¹å没äºä¿¡å·ã å¨è¿ç§æ åµä¸ï¼å¯è½ä¼åç¨æ·æ¾ç¤ºé误æ¶æ¯ï¼èä»ä»¬å¯è½ä¼æå¨éè¯ã Web æµè§å¨è¦å说ï¼âä½ ç¡®å®è¦å次æ交è¿ä¸ªè¡¨ååï¼â ââ ç¨æ·é âæ¯âï¼å 为ä»ä»¬å¸ææä½åçï¼Post/Redirect/Get 模å¼ã54ãå¯ä»¥é¿å å¨æ£å¸¸æä½ä¸åºç°æ¤è¦åæ¶æ¯ï¼ä½ POST 请æ±è¶ æ¶å°±æ²¡åæ³äºï¼ãä» Web æå¡å¨çè§åº¦æ¥çï¼éè¯æ¯ä¸ä¸ªç¬ç«ç请æ±ï¼ä»æ°æ®åºçè§åº¦æ¥çï¼è¿æ¯ä¸ä¸ªç¬ç«çäºå¡ãé常çé¤éæºå¶æ æµäºäºã #### æä½æ è¯ç¬¦ è¦å¨éè¿å è·³çç½ç»éä¿¡ä¸ä½¿æä½å ·æå¹çæ§ï¼ä» ä» ä¾èµæ°æ®åºæä¾çäºå¡æºå¶æ¯ä¸å¤ç ââ ä½ éè¦èè **端å°ç«¯ï¼end-to-endï¼** ç请æ±æµã ä¾å¦ï¼ä½ å¯ä»¥ä¸ºæä½çæä¸ä¸ªå¯ä¸çæ è¯ç¬¦ï¼ä¾å¦ UUIDï¼ï¼å¹¶å°å ¶ä½ä¸ºéè表åå段å å«å¨å®¢æ·ç«¯åºç¨ä¸ï¼æéè¿è®¡ç®ææ表åç¸å ³å段çæ£åæ¥çææä½ ID ã3ããå¦æ Web æµè§å¨æ交äºä¸¤æ¬¡ POST 请æ±ï¼è¿ä¸¤ä¸ªè¯·æ±å°å ·æç¸åçæä½ IDãç¶åï¼ä½ å¯ä»¥å°è¯¥æä½ ID ä¸è·¯ä¼ éå°æ°æ®åºï¼å¹¶æ£æ¥ä½ æ¯å¦æ¾ç»ä½¿ç¨ç»å®ç ID æ§è¡è¿ä¸ä¸ªæä½ï¼å¦ [ä¾ 12-2]() ä¸æ示ã **ä¾ 12-2 使ç¨å¯ä¸ ID æ¥æå¶éå¤è¯·æ±** ```sql ALTER TABLE requests ADD UNIQUE (request_id); BEGIN TRANSACTION; INSERT INTO requests (request_id, from_account, to_account, amount) VALUES('0286FDB8-D7E1-423F-B40B-792B3608036C', 4321, 1234, 11.00); UPDATE accounts SET balance = balance + 11.00 WHERE account_id = 1234; UPDATE accounts SET balance = balance - 11.00 WHERE account_id = 4321; COMMIT; ``` [ä¾ 12-2]() ä¾èµäº `request_id` åä¸çå¯ä¸çº¦æãå¦æä¸ä¸ªäºå¡å°è¯æå ¥ä¸ä¸ªå·²ç»åå¨ç IDï¼é£ä¹ `INSERT` 失败ï¼äºå¡è¢«ä¸æ¢ï¼ä½¿å ¶æ æ³çæ两次ãå³ä½¿å¨è¾å¼±çé离级å«ä¸ï¼å ³ç³»æ°æ®åºä¹è½æ£ç¡®å°ç»´æ¤å¯ä¸æ§çº¦æï¼èå¨ â[åå ¥åæä¸å¹»è¯»](ch7.md#åå ¥åæä¸å¹»è¯»)â ä¸è®¨è®ºè¿ï¼åºç¨çº§å«ç **æ£æ¥ - ç¶å - æå ¥** å¯è½ä¼å¨ä¸å¯ä¸²è¡åçé离ä¸å¤±è´¥ï¼ã é¤äºæå¶éå¤ç请æ±ä¹å¤ï¼[ä¾ 12-2]() ä¸ç请æ±è¡¨è¡¨ç°å¾å°±åä¸ç§äºä»¶æ¥å¿ï¼æ示çäºä»¶æº¯æºçæ³æ³ï¼è¯·åé â[äºä»¶æº¯æº](ch11.md#äºä»¶æº¯æº)âï¼ãæ´æ°è´¦æ·ä½é¢äºå®ä¸ä¸å¿ ä¸æå ¥äºä»¶åçå¨åä¸ä¸ªäºå¡ä¸ï¼å 为å®ä»¬æ¯åä½çï¼èè½ç±ä¸æ¸¸æ¶è´¹è ä»è¯·æ±äºä»¶ä¸è¡çåºæ¥ ââ åªè¦è¯¥äºä»¶è¢«æ°å¥½å¤çä¸æ¬¡ï¼è¿åä¸æ¬¡å¯ä»¥ä½¿ç¨è¯·æ± ID æ¥å¼ºå¶æ§è¡ã #### 端å°ç«¯åå æå¶éå¤äºå¡çè¿ç§æ åµåªæ¯ä¸ä¸ªæ´æ®éçååçä¸ä¸ªä¾åï¼è¿ä¸ªåå被称为 **端å°ç«¯ååï¼end-to-end argumentï¼**ï¼å®å¨ 1984 å¹´ç± SaltzerãReed å Clark éè¿°ã55ãï¼ > åªæå¨éä¿¡ç³»ç»ä¸¤ç«¯åºç¨çç¥è¯ä¸å¸®å©ä¸ï¼æ讨论çåè½æè½å®å ¨å°æ£ç¡®å°å®ç°ãå èå°è¿ç§è¢«è´¨ççåè½ä½ä¸ºéä¿¡ç³»ç»æ¬èº«çåè½æ¯ä¸å¯è½çï¼ææ¶ï¼éä¿¡ç³»ç»å¯ä»¥æä¾è¿ç§åè½çä¸å®å¤çæ¬ï¼å¯è½æå©äºæé«æ§è½ï¼ã > å¨æ们çä¾åä¸ **æ讨论çåè½** æ¯éå¤æå¶ãæ们çå° TCP å¨ TCP è¿æ¥å±æ¬¡æå¶äºéå¤çæ°æ®å ï¼ä¸äºæµå¤çå¨å¨æ¶æ¯å¤çå±æ¬¡æä¾äºæè°çæ°å¥½ä¸æ¬¡è¯ä¹ï¼ä½è¿äºé½æ æ³é»æ¢å½ä¸ä¸ªè¯·æ±è¶ æ¶æ¶ï¼ç¨æ·äº²èªæ交éå¤ç请æ±ãTCPï¼æ°æ®åºäºå¡ï¼ä»¥åæµå¤çå¨æ¬èº«å¹¶ä¸è½å®å ¨æé¤è¿äºéå¤ã解å³è¿ä¸ªé®é¢éè¦ä¸ä¸ªç«¯å°ç«¯ç解å³æ¹æ¡ï¼ä»ç»ç«¯ç¨æ·ç客æ·ç«¯ä¸è·¯ä¼ éå°æ°æ®åºçäºå¡æ è¯ç¬¦ã 端å°ç«¯ååä¹éç¨äºæ£æ¥æ°æ®çå®æ´æ§ï¼ä»¥å¤ªç½ï¼TCP å TLS ä¸å ç½®çæ ¡éªåå¯ä»¥æ£æµç½ç»ä¸æ°æ®å çæåæ åµï¼ä½æ¯å®ä»¬æ æ³æ£æµå°ç±è¿æ¥ä¸¤ç«¯åé / æ¥æ¶è½¯ä»¶ä¸ Bug 导è´çæåãææ°æ®åå¨æå¨ç£çä¸çæåãå¦æä½ æ³æè·æ°æ®ææå¯è½çæåæ¥æºï¼ä½ ä¹éè¦ç«¯å°ç«¯çæ ¡éªåã 类似çååä¹éç¨äºå å¯ã55ãï¼å®¶åº WiFi ç½ç»ä¸çå¯ç å¯ä»¥é²æ¢äººä»¬çªå¬ä½ ç WiFi æµéï¼ä½æ æ³é»æ¢äºèç½ä¸å ¶ä»å°æ¹æ»å»è ç窥æ¢ï¼å®¢æ·ç«¯ä¸æå¡å¨ä¹é´ç TLS/SSL å¯ä»¥é»æ¡ç½ç»æ»å»è ï¼ä½æ æ³é»æ¢æ¶ææå¡å¨ãåªæ端å°ç«¯çå å¯å认è¯å¯ä»¥é²æ¢ææè¿äºäºæ ã 尽管ä½å±çº§çåè½ï¼TCP éå¤æå¶ã以太ç½æ ¡éªåãWiFi å å¯ï¼æ æ³åç¬æä¾æéç端å°ç«¯åè½ï¼ä½å®ä»¬ä»ç¶å¾æç¨ï¼å 为å®ä»¬è½éä½è¾é«å±çº§åºç°é®é¢çå¯è½æ§ãä¾å¦ï¼å¦ææ们没æ TCP æ¥å°æ°æ®å æææ£ç¡®ç顺åºï¼é£ä¹ HTTP 请æ±é常就ä¼è¢«æ çãæ们åªéè¦è®°ä½ï¼ä½çº§å«çå¯é æ§åè½æ¬èº«å¹¶ä¸è¶³ä»¥ç¡®ä¿ç«¯å°ç«¯çæ£ç¡®æ§ã #### å¨æ°æ®ç³»ç»ä¸åºç¨ç«¯å°ç«¯æè è¿å°æ带åæåç论ç¹ï¼ä» ä» å 为åºç¨ä½¿ç¨äºæä¾ç¸å¯¹è¾å¼ºå®å ¨å±æ§çæ°æ®ç³»ç»ï¼ä¾å¦å¯ä¸²è¡åçäºå¡ï¼å¹¶ä¸æå³çåºç¨çæ°æ®å°±ä¸ä¼ä¸¢å¤±ææåäºãåºç¨æ¬èº«ä¹éè¦éå端å°ç«¯çæªæ½ï¼ä¾å¦é¤éã è¿å®å¨æ¯ä¸ä¸ªéæ¾ï¼å 为容éæºå¶å¾é¾å¼å¥½ãä½å±çº§çå¯é æºå¶ï¼æ¯å¦ TCP ä¸çé£äºï¼è¿è¡çç¸å½å¥½ï¼å èå©ä¸çé«å±çº§é误åºæ¬å¾å°åºç°ãå¦æè½å°è¿äºå©ä¸çé«å±çº§å®¹éæºå¶æå ææ½è±¡ï¼èåºç¨ä¸éè¦åå»æå¿ï¼é£è¯¥å¤å¥½å ââ ä½æææ们è¿æ²¡ææ¾å°è¿ä¸æ£ç¡®çæ½è±¡ã é¿æ以æ¥ï¼äºå¡è¢«è®¤ä¸ºæ¯ä¸ä¸ªå¾å¥½çæ½è±¡ï¼æç¸ä¿¡å®ä»¬ç¡®å®æ¯å¾æç¨çãæ£å¦ [第ä¸ç« ](ch7.md) 导è¨ä¸æ讨论çï¼å®ä»¬å°åç§å¯è½çé®é¢ï¼å¹¶ååå ¥ãè¿è约æãå´©æºãç½ç»ä¸æãç£çæ éï¼å并为两ç§å¯è½ç»æï¼æ交æä¸æ¢ãè¿æ¯å¯¹ç¼ç¨æ¨¡åèè¨æ¯ä¸ç§å·¨å¤§çç®åï¼ä½ææè¿è¿ä¸å¤ã äºå¡æ¯ä»£ä»·é«æçï¼å½æ¶åå¼æåå¨ææ¯æ¶å°¤ä¸ºçï¼è¯·åé â[å®è·µä¸çåå¸å¼äºå¡](ch9.md#å®è·µä¸çåå¸å¼äºå¡)âï¼ãæ们æç»ä½¿ç¨åå¸å¼äºå¡æ¯å 为å®å¼é太大ï¼ç»ææ们æåä¸å¾ä¸å¨åºç¨ä»£ç ä¸éæ°å®ç°å®¹éæºå¶ãæ£å¦æ¬ä¹¦ä¸å¤§éçä¾åæ示ï¼å¯¹å¹¶åæ§ä¸é¨å失败çæ¨çæ¯å°é¾ä¸è¿åç´è§çï¼æ以ææç大å¤æ°åºç¨çº§å«çæºå¶é½ä¸è½æ£ç¡®å·¥ä½ï¼æç»ç»ææ¯æ°æ®ä¸¢å¤±ææåã åºäºè¿äºåå ï¼æ认为æ¢ç´¢å¯¹å®¹éçæ½è±¡æ¯å¾æä»·å¼çãå®ä½¿æä¾åºç¨ç¹å®ç端å°ç«¯çæ£ç¡®æ§å±æ§åå¾æ´ç®åï¼èä¸è¿è½å¨å¤§è§æ¨¡åå¸å¼ç¯å¢ä¸æä¾è¯å¥½çæ§è½ä¸è¿ç»´ç¹æ§ã ### 强å¶çº¦æ 让æ们æèä¸ä¸å¨ [åææ°æ®åº](#åææ°æ®åº) ä¸ä¸æä¸ç **æ£ç¡®æ§ï¼correctnessï¼**ãæ们çå°ç«¯å°ç«¯çé¤éå¯ä»¥éè¿ä»å®¢æ·ç«¯ä¸è·¯éä¼ å°æ°æ®åºçè¯·æ± ID å®ç°ãé£ä¹å ¶ä»ç±»åç约æå¢ï¼ æ们å æ¥ç¹å«å ³æ³¨ä¸ä¸ **å¯ä¸æ§çº¦æ** ââ ä¾å¦æä»¬å¨ [ä¾ 12-2]() ä¸æä¾èµç约æãå¨ â[约æåå¯ä¸æ§ä¿è¯](ch9.md#约æåå¯ä¸æ§ä¿è¯)â ä¸ï¼æ们çå°äºå ä¸ªå ¶ä»éè¦å¼ºå¶å®æ½å¯ä¸æ§çåºç¨åè½ä¾åï¼ç¨æ·åæçµåé®ä»¶å°åå¿ é¡»å¯ä¸æ è¯ç¨æ·ï¼æ件åå¨æå¡ä¸è½å å«å¤ä¸ªéåæ件ï¼ä¸¤ä¸ªäººä¸è½å¨èªçæå§é¢é¢è®¢åä¸ä¸ªåº§ä½ã å ¶ä»ç±»åç约æä¹é常类似ï¼ä¾å¦ï¼ç¡®ä¿å¸æ·ä½é¢æ°¸è¿ä¸ä¼å为è´æ°ï¼ç¡®ä¿ä¸ä¼è¶ ååºåï¼æè ä¼è®®å®¤æ²¡æéå¤çé¢è®¢ãæ§è¡å¯ä¸æ§çº¦æçææ¯é常ä¹å¯ä»¥ç¨äºè¿äºçº¦æã #### å¯ä¸æ§çº¦æéè¦è¾¾æå ±è¯ å¨ [第ä¹ç« ](ch9.md) ä¸æ们çå°ï¼å¨åå¸å¼ç¯å¢ä¸ï¼å¼ºå¶æ§è¡å¯ä¸æ§çº¦æéè¦å ±è¯ï¼å¦æåå¨å¤ä¸ªå ·æç¸åå¼ç并å请æ±ï¼åç³»ç»éè¦å³å®å²çªæä½ä¸çåªä¸ä¸ªè¢«æ¥åï¼å¹¶æç»å ¶ä»è¿è约æçæä½ã è¾¾æè¿ä¸å ±è¯çæ常è§æ¹å¼æ¯ä½¿å个èç¹ä½ä¸ºé¢å¯¼ï¼å¹¶ä½¿å ¶è´è´£ææå³çãåªè¦ä½ ä¸ä»æææ请æ±é½æ¤è¿å个èç¹ï¼å³ä½¿å®¢æ·ç«¯ä½äºä¸ççå¦ä¸ç«¯ï¼ï¼åªè¦è¯¥èç¹æ²¡æ失æï¼ç³»ç»å°±è½æ£å¸¸å·¥ä½ãå¦æä½ éè¦å®¹å¿é¢å¯¼è 失æï¼é£ä¹å°±ååå°äºå ±è¯é®é¢ï¼è¯·åé â[å主å¤å¶ä¸å ±è¯](ch9.md#å主å¤å¶ä¸å ±è¯)âï¼ã å¯ä¸æ§æ£æ¥å¯ä»¥éè¿å¯¹å¯ä¸æ§å段ååºå横å伸缩ãä¾å¦ï¼å¦æéè¦éè¿è¯·æ± ID ç¡®ä¿å¯ä¸æ§ï¼å¦ [ä¾ 12-2]() æ示ï¼ï¼ä½ å¯ä»¥ç¡®ä¿ææå ·æç¸åè¯·æ± ID ç请æ±é½è¢«è·¯ç±å°åä¸ååºï¼è¯·åé [第å ç« ](ch6.md)ï¼ãå¦æä½ éè¦è®©ç¨æ·åæ¯å¯ä¸çï¼åå¯ä»¥æç¨æ·åçæ£åå¼åååºã ä½å¼æ¥å¤ä¸»å¤å¶æé¤å¨å¤ï¼å 为å¯è½ä¼åçä¸å主åºåæ¶æ¥åå²çªåæä½çæ åµï¼å èè¿äºå¼ä¸åæ¯å¯ä¸çï¼è¯·åé â[å®ç°çº¿æ§ä¸è´çç³»ç»](ch9.md#å®ç°çº¿æ§ä¸è´çç³»ç»)âï¼ãå¦æä½ æ³ç«å»æç»ä»»ä½è¿è约æçåå ¥ï¼åæ¥åè°æ¯æ æ³é¿å çã56ãã #### åºäºæ¥å¿æ¶æ¯ä¼ éä¸çå¯ä¸æ§ æ¥å¿ç¡®ä¿æææ¶è´¹è 以ç¸åç顺åºçè§æ¶æ¯ ââ è¿ç§ä¿è¯å¨å½¢å¼ä¸è¢«ç§°ä¸º **å ¨åºå¹¿æï¼total order boardcastï¼** 并ä¸çä»·äºå ±è¯ï¼è¯·åé â[å ¨åºå¹¿æ](ch9.md#å ¨åºå¹¿æ)âï¼ãå¨ä½¿ç¨åºäºæ¥å¿çæ¶æ¯ä¼ éçåææ°æ®åºæ¹æ³ä¸ï¼æ们å¯ä»¥ä½¿ç¨é常类似çæ¹æ³æ¥æ§è¡å¯ä¸æ§çº¦æã æµå¤çå¨å¨å个线ç¨ä¸ä¾æ¬¡æ¶è´¹å个æ¥å¿ååºä¸çæææ¶æ¯ï¼è¯·åé â[æ¥å¿ä¸ä¼ ç»çæ¶æ¯ä¼ éç¸æ¯](ch11.md#æ¥å¿ä¸ä¼ ç»çæ¶æ¯ä¼ éç¸æ¯)âï¼ãå æ¤ï¼å¦ææ¥å¿æ¯æéè¦ç¡®ä¿å¯ä¸çå¼åçååºï¼åæµå¤çå¨å¯ä»¥æ æ§ä¹å°ãç¡®å®æ§å°å³å®å 个å²çªæä½ä¸çåªä¸ä¸ªå å°è¾¾ãä¾å¦ï¼å¨å¤ä¸ªç¨æ·å°è¯å®£åç¸åç¨æ·åçæ åµä¸ã57ãï¼ 1. æ¯ä¸ªå¯¹ç¨æ·åç请æ±é½è¢«ç¼ç 为ä¸æ¡æ¶æ¯ï¼å¹¶è¿½å å°æç¨æ·åæ£åå¼ç¡®å®çååºã 2. æµå¤çå¨ä¾åºè¯»åæ¥å¿ä¸ç请æ±ï¼å¹¶ä½¿ç¨æ¬å°æ°æ®åºæ¥è¿½è¸ªåªäºç¨æ·åå·²ç»è¢«å ç¨äºã对äºææç³è¯·å¯ç¨ç¨æ·åç请æ±ï¼å®é½ä¼è®°å½è¯¥ç¨æ·åï¼å¹¶åè¾åºæµåéä¸æ¡æåæ¶æ¯ã对äºææç³è¯·å·²å ç¨ç¨æ·åç请æ±ï¼å®é½ä¼åè¾åºæµåéä¸æ¡æç»æ¶æ¯ã 3. 请æ±ç¨æ·åç客æ·ç«¯çè§è¾åºæµï¼çå¾ ä¸å ¶è¯·æ±ç¸å¯¹åºçæåææç»æ¶æ¯ã 该ç®æ³åºæ¬ä¸ä¸ â[使ç¨å ¨åºå¹¿æå®ç°çº¿æ§ä¸è´çåå¨](ch9.md#使ç¨å ¨åºå¹¿æå®ç°çº¿æ§ä¸è´çåå¨)â ä¸çç®æ³ç¸åãå®å¯ä»¥ç®åå°éè¿å¢å ååºæ°ä¼¸ç¼©è³è¾å¤§ç请æ±ååéï¼å 为æ¯ä¸ªååºé½å¯ä»¥è¢«ç¬ç«å¤çã 该æ¹æ³ä¸ä» éç¨äºå¯ä¸æ§çº¦æï¼èä¸éç¨äºè®¸å¤å ¶ä»ç±»åç约æãå ¶åºæ¬åçæ¯ï¼ä»»ä½å¯è½å²çªçåå ¥é½ä¼è·¯ç±å°ç¸åçååºå¹¶æ顺åºå¤çãæ£å¦ â[ä»ä¹æ¯å²çªï¼](ch5.md#ä»ä¹æ¯å²çªï¼)â ä¸ â[åå ¥åæä¸å¹»è¯»](ch7.md#åå ¥åæä¸å¹»è¯»)â ä¸æè¿°ï¼å²çªçå®ä¹å¯è½åå³äºåºç¨ï¼ä½æµå¤çå¨å¯ä»¥ä½¿ç¨ä»»æé»è¾æ¥éªè¯è¯·æ±ãè¿ä¸ªæ³æ³ä¸ Bayou å¨ 90 年代å¼åçæ¹æ³ç±»ä¼¼ã58ãã #### å¤ååºè¯·æ±å¤ç å½æ¶åå¤ä¸ªååºæ¶ï¼ç¡®ä¿æä½ä»¥ååæ¹å¼æ§è¡ä¸åæ¶æ»¡è¶³çº¦æå°±åå¾å¾æ趣äºãå¨ [ä¾ 12-2]() ä¸ï¼å¯è½æä¸ä¸ªååºï¼ä¸ä¸ªå å«è¯·æ± IDï¼ä¸ä¸ªå å«æ¶æ¬¾äººè´¦æ·ï¼å¦ä¸ä¸ªå å«ä»æ¬¾äººè´¦æ·ã没æçç±æè¿ä¸ç§ä¸è¥¿æ¾å ¥åä¸ä¸ªååºï¼å 为å®ä»¬é½æ¯ç¸äºç¬ç«çã å¨æ°æ®åºçä¼ ç»æ¹æ³ä¸ï¼æ§è¡æ¤äºå¡éè¦è·¨å ¨é¨ä¸ä¸ªååºè¿è¡ååæ交ï¼å°±è¿äºååºä¸çææå ¶ä»äºå¡èè¨ï¼è¿å®è´¨ä¸æ¯å°è¯¥äºå¡åµå ¥ä¸ä¸ªå ¨åºãèè¿æ ·å°±è¦æ±è·¨ååºåè°ï¼ä¸åçååºæ æ³åç¬ç«å°è¿è¡å¤çï¼å æ¤ååéå¾å¯è½ä¼åå°å½±åã ä½äºå®è¯æï¼ä½¿ç¨ååºæ¥å¿å¯ä»¥è¾¾å°çä»·çæ£ç¡®æ§èæ éååæäº¤ï¼ 1. ä»è´¦æ· A åè´¦æ· B 转账ç请æ±ç±å®¢æ·ç«¯æä¾ä¸ä¸ªå¯ä¸çè¯·æ± IDï¼å¹¶æè¯·æ± ID 追å åå ¥ç¸åºæ¥å¿ååºã 2. æµå¤çå¨è¯»å请æ±æ¥å¿ã对äºæ¯ä¸ªè¯·æ±æ¶æ¯ï¼å®åè¾åºæµååºä¸¤æ¡æ¶æ¯ï¼ä»æ¬¾äººè´¦æ· A çåè®°æ令ï¼æ A ååºï¼ï¼æ¶æ¬¾äºº B çè´·è®°æ令ï¼æ B ååºï¼ã被ååºçæ¶æ¯ä¸ä¼å¸¦æåå§çè¯·æ± IDã 3. åç»å¤çå¨æ¶è´¹åè®° / è´·è®°æ令æµï¼æç §è¯·æ± ID é¤éï¼å¹¶å°åæ´åºç¨è³è´¦æ·ä½é¢ã æ¥éª¤ 1 åæ¥éª¤ 2 æ¯å¿ è¦çï¼å 为å¦æ客æ·ç´æ¥åéè´·è®°ä¸åè®°æ令ï¼åéè¦å¨è¿ä¸¤ä¸ªååºä¹é´è¿è¡ååæ交ï¼ä»¥ç¡®ä¿ä¸¤è è¦ä¹é½åçæé½ä¸åçã为äºé¿å 对åå¸å¼äºå¡çéè¦ï¼æ们é¦å å°è¯·æ±æä¹ åè®°å½ä¸ºåæ¡æ¶æ¯ï¼ç¶åä»è¿ç¬¬ä¸æ¡æ¶æ¯ä¸è¡çåºè´·è®°æ令ä¸åè®°æ令ãå ä¹å¨æææ°æ®ç³»ç»ä¸ï¼å对象åå ¥é½æ¯ååæ§çï¼è¯·åé â[å对象åå ¥](ch7.md#å对象åå ¥)ï¼ï¼å æ¤è¯·æ±è¦ä¹åºç°å¨æ¥å¿ä¸ï¼è¦ä¹å°±ä¸åºç°ï¼æ éå¤ååºååæ交ã å¦ææµå¤çå¨å¨æ¥éª¤ 2 ä¸å´©æºï¼åå®ä¼ä»ä¸ä¸ä¸ªåæ¡£ç¹æ¢å¤å¤çãè¿æ ·åæ¶ï¼å®ä¸ä¼è·³è¿ä»»ä½è¯·æ±æ¶æ¯ï¼ä½å¯è½ä¼å¤æ¬¡å¤ç请æ±å¹¶äº§çéå¤çè´·è®°ä¸åè®°æ令ãä½ç±äºå®æ¯ç¡®å®æ§çï¼å æ¤å®åªæ¯å次çæç¸åçæ令ï¼èæ¥éª¤ 3 ä¸çå¤çå¨å¯ä»¥ä½¿ç¨ç«¯å°ç«¯è¯·æ± ID è½»æ¾å°å¯¹å ¶é¤éã å¦æä½ æ³ç¡®ä¿ä»æ¬¾äººçå¸æ·ä¸ä¼å æ¤æ¬¡è½¬è´¦èéæ¯ï¼åå¯ä»¥ä½¿ç¨ä¸ä¸ªé¢å¤çæµå¤çå¨æ¥ç»´æ¤è´¦æ·ä½é¢å¹¶æ ¡éªäºå¡ï¼æä»æ¬¾äººè´¦æ·ååºï¼ï¼åªæææçäºå¡ä¼è¢«è®°å½å¨æ¥éª¤ 1 ä¸ç请æ±æ¥å¿ä¸ã éè¿å°å¤ååºäºå¡å解为两个ä¸åååºæ¹å¼çé¶æ®µï¼å¹¶ä½¿ç¨ç«¯å°ç«¯çè¯·æ± IDï¼æ们å®ç°äºåæ ·çæ£ç¡®æ§å±æ§ï¼æ¯ä¸ªè¯·æ±å¯¹ä»æ¬¾äººä¸æ¶æ¬¾äººé½æ°å¥½çæä¸æ¬¡ï¼ï¼å³ä½¿å¨åºç°æ éï¼ä¸æ²¡æ使ç¨ååæ交åè®®çæ åµä¸ä¾ç¶å¦æ¤ã使ç¨å¤ä¸ªä¸åååºé¶æ®µçæ³æ³ä¸æä»¬å¨ â[å¤ååºæ°æ®å¤ç](#å¤ååºæ°æ®å¤ç)â ä¸è®¨è®ºçæ³æ³ç±»ä¼¼ï¼ä¹è¯·åé â[并åæ§å¶](ch11.md#并åæ§å¶)âï¼ã ### åæ¶æ§ä¸å®æ´æ§ äºå¡çä¸ä¸ªä¾¿å©å±æ§æ¯ï¼å®ä»¬é常æ¯çº¿æ§ä¸è´çï¼è¯·åé â[线æ§ä¸è´æ§](ch9.md#线æ§ä¸è´æ§)âï¼ï¼ä¹å°±æ¯è¯´ï¼åå ¥è ä¼çå°äºå¡æ交ï¼èä¹åå ¶åå ¥ç«å»å¯¹ææ读åè å¯è§ã å½æ们æä¸ä¸ªæä½æå为跨è¶å¤ä¸ªé¶æ®µçæµå¤çå¨æ¶ï¼å´å¹¶éå¦æ¤ï¼æ¥å¿çæ¶è´¹è å¨è®¾è®¡ä¸å°±æ¯å¼æ¥çï¼å æ¤åéè ä¸ä¼çå ¶æ¶æ¯è¢«æ¶è´¹è å¤çå®ãä½æ¯ï¼å®¢æ·ç«¯çå¾ è¾åºæµä¸çç¹å®æ¶æ¯æ¯å¯è½çãè¿æ£æ¯æä»¬å¨ â[åºäºæ¥å¿æ¶æ¯ä¼ éä¸çå¯ä¸æ§](#åºäºæ¥å¿æ¶æ¯ä¼ éä¸çå¯ä¸æ§)â ä¸èä¸æ£æ¥å¯ä¸æ§çº¦ææ¶æåçäºæ ã å¨è¿ä¸ªä¾åä¸ï¼å¯ä¸æ§æ£æ¥çæ£ç¡®æ§ä¸åå³äºæ¶æ¯åéè æ¯å¦çå¾ ç»æãçå¾ çç®çä» ä» æ¯åæ¥éç¥åéè å¯ä¸æ§æ£æ¥æ¯å¦æåãä½è¯¥éç¥å¯ä»¥ä¸æ¶æ¯å¤ççç»æç¸è§£è¦ã æ´ä¸è¬å°æ¥è®²ï¼æ认为æ¯è¯ **ä¸è´æ§ï¼consistencyï¼** è¿ä¸ªæ¯è¯æ··æ·äºä¸¤ä¸ªå¼å¾åå«èèçéæ±ï¼ * åæ¶æ§ï¼Timelinessï¼ åæ¶æ§æå³çç¡®ä¿ç¨æ·è§å¯å°ç³»ç»çææ°ç¶æãæ们ä¹åçå°ï¼å¦æç¨æ·ä»éæ§çæ°æ®å¯æ¬ä¸è¯»åæ°æ®ï¼å®ä»¬å¯è½ä¼è§å¯å°ç³»ç»å¤äºä¸ä¸è´çç¶æï¼è¯·åé â[å¤å¶å»¶è¿é®é¢](ch5.md#å¤å¶å»¶è¿é®é¢)âï¼ãä½è¿ç§ä¸ä¸è´æ¯ææ¶çï¼èæç»ä¼éè¿çå¾ ä¸éè¯ç®åå°å¾å°è§£å³ã CAP å®çï¼è¯·åé â[线æ§ä¸è´æ§ç代价](ch9.md#线æ§ä¸è´æ§ç代价)âï¼ä½¿ç¨ **线æ§ä¸è´æ§ï¼linearizabilityï¼** æä¹ä¸çä¸è´æ§ï¼è¿æ¯å®ç°åæ¶æ§ç强æåæ¹æ³ãå **åå读** è¿æ ·åæ¶æ§æ´å¼±çä¸è´æ§ä¹å¾æç¨ï¼è¯·åé â[读己ä¹å](ch5.md#读己ä¹å)âï¼ã * å®æ´æ§ï¼Integrityï¼ å®æ´æ§æå³ç没ææåï¼å³æ²¡ææ°æ®ä¸¢å¤±ï¼å¹¶ä¸æ²¡æçç¾æé误çæ°æ®ãå°¤å ¶æ¯å¦ææäºè¡çæ°æ®éæ¯ä½ä¸ºåºå±æ°æ®ä¹ä¸çè§å¾èç»´æ¤çï¼è¯·åé â[ä»äºä»¶æ¥å¿ä¸æ´¾çåºå½åç¶æ](ch11.md#ä»äºä»¶æ¥å¿ä¸æ´¾çåºå½åç¶æ)âï¼ï¼è¿ç§è¡çå¿ é¡»æ¯æ£ç¡®çãä¾å¦ï¼æ°æ®åºç´¢å¼å¿ é¡»æ£ç¡®å°åæ æ°æ®åºçå 容 ââ 缺失æäºè®°å½çç´¢å¼å¹¶ä¸æ¯å¾æç¨ã å¦æå®æ´æ§è¢«è¿èï¼è¿ç§ä¸ä¸è´æ¯æ°¸ä¹ çï¼å¨å¤§å¤æ°æ åµä¸ï¼çå¾ ä¸éè¯å¹¶ä¸è½ä¿®å¤æ°æ®åºæåãç¸åçæ¯ï¼éè¦æ¾å¼å°æ£æ¥ä¸ä¿®å¤ãå¨ ACID äºå¡çä¸ä¸æä¸ï¼è¯·åé â[ACID çå«ä¹](ch7.md#ACIDçå«ä¹)âï¼ï¼ä¸è´æ§é常被ç解为æç§ç¹å®äºåºç¨çå®æ´æ§æ¦å¿µãååæ§åæä¹ æ§æ¯ä¿æå®æ´æ§çéè¦å·¥å ·ã å£å·å½¢å¼ï¼è¿ååæ¶æ§ï¼âæç»ä¸è´æ§âï¼è¿åå®æ´æ§ï¼âæ°¸æ ä¸è´æ§âã ææè¨å¨å¤§å¤æ°åºç¨ä¸ï¼å®æ´æ§æ¯åæ¶æ§éè¦å¾å¤ãè¿ååæ¶æ§å¯è½ä»¤äººå°æä¸è®¨åï¼ä½è¿åå®æ´æ§çç»æå¯è½æ¯ç¾é¾æ§çã ä¾å¦å¨ä½ çä¿¡ç¨å¡å¯¹è´¦åä¸ï¼å¦ææä¸ç¬è¿å» 24 å°æ¶å å®æç交æå°æªåºç°å¹¶ä¸ä»¤äººå¥æª ââ è¿äºç³»ç»æä¸å®çæ»åæ¯æ£å¸¸çãæ们ç¥éé¶è¡æ¯å¼æ¥æ ¸ç®ä¸æ²å®äº¤æçï¼è¿éçåæ¶æ§å¹¶ä¸æ¯é常éè¦ã3ããä½æå½æ对账åä½é¢ä¸ä¸æ对账åä½é¢å 交ææ»é¢å¯¹ä¸ä¸ï¼æ±åé误ï¼ï¼æè åºç°ä¸ç¬åä½ æ¶è´¹ä½æªåå家ä»æ¬¾ç交æï¼æ¶å¤±çé±ï¼ï¼é£å®å¨æ¯å¤ªç³ç³äºãè¿æ ·çé®é¢å°±è¿èäºç³»ç»çå®æ´æ§ã #### æ°æ®æµç³»ç»çæ£ç¡®æ§ ACID äºå¡é常æ¢æä¾åæ¶æ§ï¼ä¾å¦çº¿æ§ä¸è´æ§ï¼ä¹æä¾å®æ´æ§ä¿è¯ï¼ä¾å¦ååæ交ï¼ãå æ¤å¦æä½ ä» ACID äºå¡çè§åº¦æ¥çå¾ åºç¨çæ£ç¡®æ§ï¼é£ä¹åæ¶æ§ä¸å®æ´æ§çåºå«æ¯æ å ³ç´§è¦çã å¦ä¸æ¹é¢ï¼å¯¹äºå¨æ¬ç« ä¸è®¨è®ºçåºäºäºä»¶çæ°æ®æµç³»ç»èè¨ï¼å®ä»¬çä¸ä¸ªæ趣ç¹æ§å°±æ¯å°åæ¶æ§ä¸å®æ´æ§åå¼ãå¨å¼æ¥å¤çäºä»¶æµæ¶ä¸è½ä¿è¯åæ¶æ§ï¼é¤éä½ æ¾å¼æ建ä¸ä¸ªå¨è¿åä¹åæç¡®çå¾ ç¹å®æ¶æ¯å°è¾¾çæ¶è´¹è ãä½å®æ´æ§å®é ä¸ææ¯æµå¤çç³»ç»çæ ¸å¿ã **æ°å¥½ä¸æ¬¡** æ **çæä¸æ¬¡** è¯ä¹ï¼è¯·åé â[容é](ch11.md#容é)âï¼æ¯ä¸ç§ä¿æå®æ´æ§çæºå¶ãå¦æäºä»¶ä¸¢å¤±æè çæ两次ï¼å°±æå¯è½è¿èæ°æ®ç³»ç»çå®æ´æ§ãå æ¤å¨åºç°æ éæ¶ï¼å®¹éæ¶æ¯ä¼ éä¸éå¤æå¶ï¼ä¾å¦ï¼å¹çæä½ï¼å¯¹äºç»´æ¤æ°æ®ç³»ç»çå®æ´æ§æ¯å¾éè¦çã æ£å¦æ们å¨ä¸ä¸èçå°çé£æ ·ï¼å¯é çæµå¤çç³»ç»å¯ä»¥å¨æ éåå¸å¼äºå¡ä¸ååæ交åè®®çæ åµä¸ä¿æå®æ´æ§ï¼è¿æå³çå®ä»¬ææ½åè¾¾å°ä¸åè ç¸å½çæ£ç¡®æ§ï¼åæ¶è¿å ·å¤å¥½å¾å¤çæ§è½ä¸è¿ç»´ç¨³å¥æ§ã为äºè¾¾æè¿ç§æ£ç¡®æ§ï¼æ们ç»å使ç¨äºå¤ç§æºå¶ï¼ * å°åå ¥æä½çå 容表示为åæ¡æ¶æ¯ï¼ä»èå¯ä»¥è½»æ¾å°è¢«åååå ¥ ââ ä¸äºä»¶æº¯æºæé æææ群ï¼è¯·åé â[äºä»¶æº¯æº](ch11.md#äºä»¶æº¯æº)âï¼ã * 使ç¨ä¸åå¨è¿ç¨ç±»ä¼¼çç¡®å®æ§è¡çå½æ°ï¼ä»è¿ä¸æ¶æ¯ä¸è¡çåºææå ¶ä»çç¶æåæ´ï¼è¯·åé â[çç串è¡æ§è¡](ch7.md#çç串è¡æ§è¡)â å â[åºç¨ä»£ç ä½ä¸ºè¡çå½æ°](ch12.md#åºç¨ä»£ç ä½ä¸ºè¡çå½æ°)âï¼ * å°å®¢æ·ç«¯çæçè¯·æ± ID ä¼ ééè¿ææçå¤çå±æ¬¡ï¼ä»èå 许端å°ç«¯çé¤éï¼å¸¦æ¥å¹çæ§ã * 使æ¶æ¯ä¸å¯åï¼å¹¶å 许è¡çæ°æ®è½éæ¶è¢«éæ°å¤çï¼è¿ä½¿ä»é误ä¸æ¢å¤æ´å 容æï¼è¯·åé â[ä¸å¯åäºä»¶çä¼ç¹](ch11.md#ä¸å¯åäºä»¶çä¼ç¹)âï¼ è¿ç§æºå¶ç»åå¨æçæ¥ï¼æ¯æªæ¥æ建容éåºç¨çä¸ä¸ªé常æåæ¯çæ¹åã #### 宽æ¾å°è§£é约æ å¦åæè¿°ï¼æ§è¡å¯ä¸æ§çº¦æéè¦å ±è¯ï¼é常éè¿å¨å个èç¹ä¸æ±éç¹å®ååºä¸çææäºä»¶æ¥å®ç°ãå¦ææ们æ³è¦ä¼ ç»çå¯ä¸æ§çº¦æå½¢å¼ï¼è¿ç§éå¶æ¯ä¸å¯é¿å çï¼æµå¤çä¹ä¸ä¾å¤ã ç¶èå¦ä¸ä¸ªéè¦äºè§£çäºå®æ¯ï¼è®¸å¤çå®ä¸ççåºç¨å®é ä¸å¯ä»¥æè±è¿ç§å½¢å¼ï¼æ¥åå¼±å¾å¤çå¯ä¸æ§ï¼ * å¦æ两个人åæ¶æ³¨åäºç¸åçç¨æ·åæé¢è®¢äºç¸åç座ä½ï¼ä½ å¯ä»¥ç»å ¶ä¸ä¸ä¸ªäººåæ¶æ¯éæï¼å¹¶è¦æ±ä»ä»¬æ¢ä¸ä¸ªä¸åçç¨æ·åæ座ä½ãè¿ç§çº æ£é误çåå被称为 **è¡¥å¿æ§äºå¡ï¼compensating transactionï¼**ã59,60ãã * å¦æ客æ·è®¢è´çç©åå¤äºä»åºä¸çç©åï¼ä½ å¯ä»¥ä¸åè¡¥ä»ï¼å¹¶ä¸ºå»¶è¯¯å客æ·éæï¼åä»ä»¬æä¾ææ£ãå®é ä¸ï¼è¿ä¹è¯´å§ï¼å¦æå车å¨ä»åºä¸è½§è¿äºä½ çè´§ç©ï¼å©ä¸çè´§ç©æ¯ä½ æ³è±¡çè¦å°ï¼é£ä¹ä½ ä¹æ¯å¾è¿ä¹åã61ããå æ¤ï¼æ¢ç¶éæå·¥ä½æµæ 论å¦ä½å·²ç»æä¸ºä½ åä¸è¿ç¨ä¸çä¸é¨åäºï¼é£ä¹å¯¹åºåç©åæ°ç®æ·»å 线æ§ä¸è´ç约æå¯è½å°±æ²¡å¿ è¦äºã * ä¸ä¹ç±»ä¼¼ï¼è®¸å¤èªç©ºå ¬å¸é½ä¼è¶ åæºç¥¨ï¼æçä¸äºæ 客å¯è½ä¼éè¿èªççç®çï¼è®¸å¤æ é¦ä¹ä¼è¶ å客æ¿ï¼æ±çé¨å客人å¯è½ä¼åæ¶é¢è®¢çææãå¨è¿äºæ åµä¸ï¼åºäºåä¸åå èæ æè¿åäº âä¸äººä¸åº§â ç约æï¼å½éæ±è¶ è¿ä¾ç»çæ åµåºç°æ¶ï¼å°±ä¼è¿å ¥è¡¥å¿æµç¨ï¼é款ãå级è±ä½ / æ¿åãæä¾éå£é åºçå è´¹çæ¿é´ï¼ãå³ä½¿æ²¡æè¶ åï¼ä¸ºäºåºå¯¹ç±æ¶å£å¤©æ°æå工罢工导è´çèªçåæ¶ï¼ä½ è¿æ¯éè¦éæä¸è¡¥å¿æµç¨ ââ ä»è¿äºé®é¢ä¸æ¢å¤ä» ä» æ¯åä¸æ´»å¨çæ£å¸¸ç»æé¨åã * å¦ææ人ä»è´¦æ·è¶ é¢å款ï¼é¶è¡å¯ä»¥åä»ä»¬æ¶åéæ¯è´¹ç¨ï¼å¹¶è¦æ±ä»ä»¬å¿è¿æ¬ 款ãéè¿éå¶æ¯å¤©çæ款æ»é¢ï¼é¶è¡çé£é©æ¯æéçã å¨è®¸å¤åä¸åºæ¯ä¸ï¼ä¸´æ¶è¿è约æ并ç¨åéè¿éææ¥ä¿®å¤ï¼å®é ä¸æ¯å¯ä»¥æ¥åçãéæçææ¬åä¸ç¸åï¼ä½é常å¾ä½ï¼ä»¥éé±æå声æ¥ç®ï¼ï¼ä½ æ æ³æ¤åå·²åéççµåé®ä»¶ï¼ä½å¯ä»¥åéä¸å°åç»çµåé®ä»¶è¿è¡æ´æ£ãå¦æä½ ä¸å°å¿åä¿¡ç¨å¡æ¶åäºä¸¤æ¬¡è´¹ç¨ï¼åå¯ä»¥å°å ¶ä¸ä¸é¡¹æ¶è´¹é款ï¼èä»£ä»·ä» ä» æ¯æç»è´¹ï¼ä¹è®¸è¿æ客æ·çæè¯ã尽管ä¸æ¦ ATM åäºé±ï¼ä½ æ æ³ç´æ¥ååï¼ä½ååä¸å¦æè´¦æ·éæ¯è客æ·æä¸æ¯ä»ï¼ä½ å¯ä»¥æ´¾å¬æ¶åæ¶åæ¬ æ¬¾ã éæçææ¬æ¯å¦è½æ¥åæ¯ä¸ä¸ªåä¸å³çãå¦æå¯ä»¥æ¥åçè¯ï¼å¨åå ¥æ°æ®ä¹åæ£æ¥ææ约æçä¼ ç»æ¨¡ååèä¼å¸¦æ¥ä¸å¿ è¦çéå¶ï¼è线æ§ä¸è´æ§ç约æä¹ä¸æ¯å¿ é¡»çãä¹è§åå ¥ï¼äºåæ£æ¥å¯è½æ¯ä¸ç§åççéæ©ãä½ ä»ç¶å¯ä»¥å¨åä¸äºæ½åææ¬é«æçäºæ åç¡®ä¿æç¸å ³çéªè¯ï¼ä½è¿å¹¶ä¸æå³çåå ¥æ°æ®ä¹åå¿ é¡»å è¿è¡éªè¯ã è¿äºåºç¨ **ç¡®å®** éè¦å®æ´æ§ï¼ä½ ä¸ä¼å¸æ丢失é¢è®¢ä¿¡æ¯ï¼æè ç±äºåæ¹è´·æ¹ä¸å¹é 导è´èµéæ¶å¤±ãä½æ¯å®ä»¬å¨æ§è¡çº¦ææ¶ **并ä¸éè¦** åæ¶æ§ï¼å¦æä½ éå®çè´§ç©å¤äºä»åºä¸çåºåï¼å¯ä»¥å¨äºåéæå并弥补é®é¢ãè¿ç§åæ³ä¸æä»¬å¨ â[å¤çåå ¥å²çª](ch5.md#å¤çåå ¥å²çª)â ä¸è®¨è®ºçå²çªè§£å³æ¹æ³ç±»ä¼¼ã #### æ åè°æ°æ®ç³»ç» æ们ç°å¨å·²ç»åäºä¸¤ä¸ªæ趣çè§å¯ï¼ 1. æ°æ®æµç³»ç»å¯ä»¥ç»´æè¡çæ°æ®çå®æ´æ§ä¿è¯ï¼èæ éååæ交ã线æ§ä¸è´æ§æè åæ¥çè·¨ååºåè°ã 2. è½ç¶ä¸¥æ ¼çå¯ä¸æ§çº¦æè¦æ±åæ¶æ§ååè°ï¼ä½è®¸å¤åºç¨å®é ä¸å¯ä»¥æ¥å宽æ¾ç约æï¼åªè¦æ´ä¸ªè¿ç¨ä¿æå®æ´æ§ï¼è¿äºçº¦æå¯è½ä¼è¢«ä¸´æ¶è¿å并å¨ç¨å被修å¤ã æ»ä¹è¿äºè§å¯æå³çï¼æ°æ®æµç³»ç»å¯ä»¥ä¸ºè®¸å¤åºç¨æä¾æ éåè°çæ°æ®ç®¡çæå¡ï¼ä¸ä»è½ç»åºå¾å¼ºçå®æ´æ§ä¿è¯ãè¿ç§ **æ åè°ï¼coordination-avoidingï¼** çæ°æ®ç³»ç»æçå¾å¤§çå¸å¼åï¼æ¯èµ·éè¦æ§è¡åæ¥åè°çç³»ç»ï¼å®ä»¬è½è¾¾å°æ´å¥½çæ§è½ä¸æ´å¼ºç容éè½åã56ãã ä¾å¦ï¼è¿ç§ç³»ç»å¯ä»¥ä½¿ç¨å¤é¢å¯¼è é ç½®è¿ç»´ï¼è·¨è¶å¤ä¸ªæ°æ®ä¸å¿ï¼å¨åºåé´å¼æ¥å¤å¶ãä»»ä½ä¸ä¸ªæ°æ®ä¸å¿é½å¯ä»¥æç»ç¬ç«è¿è¡ï¼å 为ä¸éè¦åæ¥çè·¨åºååè°ãè¿æ ·çç³»ç»çåæ¶æ§ä¿è¯ä¼å¾å¼± ââ å¦æä¸å¼å ¥åè°å®æ¯ä¸å¯è½æ¯çº¿æ§ä¸è´ç ââ ä½å®ä»ç¶å¯ä»¥æä¾æåçå®æ´æ§ä¿è¯ã å¨è¿ç§æ åµä¸ï¼å¯ä¸²è¡åäºå¡ä½ä¸ºç»´æ¤è¡çç¶æçä¸é¨åä»ç¶æ¯æç¨çï¼ä½å®ä»¬åªè½å¨å°èå´å è¿è¡ï¼å¨é£éå®ä»¬å·¥ä½å¾å¾å¥½ã8ããå¼æåå¸å¼äºå¡ï¼å¦ XA äºå¡ï¼è¯·åé â[å®è·µä¸çåå¸å¼äºå¡](ch9.md#å®è·µä¸çåå¸å¼äºå¡)âï¼ä¸æ¯å¿ éçãåæ¥åè°ä»ç¶å¯ä»¥å¨éè¦çå°æ¹å¼å ¥ï¼ä¾å¦å¨æ æ³æ¢å¤çæä½ä¹å强å¶æ§è¡ä¸¥æ ¼ç约æï¼ï¼ä½æ¯å¦æåªæ¯åºç¨çä¸å°é¨åå°æ¹éè¦å®ï¼æ²¡å¿ è¦è®©æææä½é½ä»åºåè°ç代价ãã43ãã å¦ä¸ç§å®¡è§åè°ä¸çº¦æçè§åº¦æ¯ï¼å®ä»¬åå°äºç±äºä¸ä¸è´èå¿ é¡»ååºçéææ°éï¼ä½ä¹å¯è½ä¼éä½ç³»ç»çæ§è½åå¯ç¨æ§ï¼ä»èå¯è½å¢å ç±äºå®æºä¸æèéè¦ååºçéææ°éãä½ ä¸å¯è½å°éææ°éåå°å°é¶ï¼ä½å¯ä»¥æ ¹æ®èªå·±çéæ±å¯»æ¾æä½³å¹³è¡¡ç¹ ââ æ¢ä¸åå¨å¤ªå¤ä¸ä¸è´æ§ï¼åä¸åå¨å¤ªå¤å¯ç¨æ§é®é¢ã ### ä¿¡ä»»ä½éªè¯ æ们ææå ³äºæ£ç¡®æ§ï¼å®æ´æ§å容éç讨论é½åºäºä¸äºå设ï¼å设æäºäºæ å¯è½ä¼åºéï¼ä½å ¶ä»äºæ ä¸ä¼ãæ们å°è¿äºå设称为æ们ç **ç³»ç»æ¨¡å**ï¼system modelï¼è¯·åé â[å°ç³»ç»æ¨¡åæ å°å°ç°å®ä¸ç](ch8.md#å°ç³»ç»æ¨¡åæ å°å°ç°å®ä¸ç)âï¼ï¼ä¾å¦ï¼æ们åºè¯¥å设è¿ç¨å¯è½ä¼å´©æºï¼æºå¨å¯è½çªç¶æçµï¼ç½ç»å¯è½ä¼ä»»æ延è¿æ丢å¼æ¶æ¯ãä½æ¯æ们ä¹å¯è½å设åå ¥ç£ççæ°æ®å¨æ§è¡ `fsync` åä¸ä¼ä¸¢å¤±ï¼å åä¸çæ°æ®æ²¡ææåï¼è CPU çä¹æ³æ令æ»æ¯è½è¿åæ£ç¡®çç»æã è¿äºå设æ¯ç¸å½åççï¼å 为大å¤æ°æ¶åå®ä»¬é½æ¯æç«çï¼å¦ææ们ä¸å¾ä¸ç»å¸¸æ å¿è®¡ç®æºåºéï¼é£ä¹åºæ¬ä¸å¯¸æ¥é¾è¡ãå¨ä¼ ç»ä¸ï¼ç³»ç»æ¨¡åéç¨äºå æ¹æ³å¤çæ éï¼æ们å设æäºäºæ å¯è½ä¼åçï¼èå ¶ä»äºæ **æ°¸è¿** ä¸ä¼åçãå®é ä¸ï¼è¿æ´åæ¯ä¸ä¸ªæ¦çé®é¢ï¼æäºäºæ æ´æå¯è½ï¼å ¶ä»äºæ ä¸å¤ªå¯è½ãé®é¢å¨äºè¿åæ们å设çæ åµæ¯å¦ç»å¸¸åçï¼ä»¥è³äºæ们å¯è½å¨å®è·µä¸éå°å®ä»¬ã æ们已ç»çå°ï¼æ°æ®å¯è½ä¼å¨å°æªè½çæ¶æåï¼è¯·åé â[å¤å¶ä¸æä¹ æ§](ch7.md#å¤å¶ä¸æä¹ æ§)âï¼ï¼èç½ç»ä¸çæ°æ®æåææ¶å¯è½è§é¿äº TCP æ ¡éªåï¼è¯·åé â[å¼±è°è¨å½¢å¼](ch8.md#å¼±è°è¨å½¢å¼)â ï¼ãä¹è®¸æ们åºå½æ´å ³æ³¨è¿äºäºæ ï¼ æè¿å»æä»äºçä¸ä¸ªåºç¨æ¶éäºæ¥èªå®¢æ·ç«¯çå´©æºæ¥åï¼æ们æ¶å°çä¸äºæ¥åï¼åªæå¨è¿äºè®¾å¤å åä¸åºç°äºéæºä½ç¿»è½¬æ解éçéãè¿çèµ·æ¥ä¸å¤ªå¯è½ï¼ä½æ¯å¦ææ足å¤å¤ç设å¤è¿è¡ä½ ç软件ï¼é£ä¹å³ä½¿åä¸å¯è½åççäºä¹ç¡®å®ä¼åçãé¤äºç±äºç¡¬ä»¶æ éæè¾å°å¯¼è´çéæºåå¨å¨æåä¹å¤ï¼ä¸äºç æçåå¨å¨è®¿é®æ¨¡å¼çè³å¯ä»¥å¨æ²¡ææ éçåå¨å¨ä¸ç¿»è½¬ä½ã62ã ââ ä¸ç§å¯ç¨äºç ´åæä½ç³»ç»å®å ¨æºå¶çæåºã63ãï¼è¿ç§ææ¯è¢«ç§°ä¸º **Rowhammer**ï¼ãä¸æ¦ä½ ä»ç»è§å¯ï¼ç¡¬ä»¶å¹¶ä¸æ¯çä¸å»é£æ ·å®ç¾çæ½è±¡ã è¦æ¾æ¸ çæ¯ï¼éæºä½ç¿»è½¬å¨ç°ä»£ç¡¬ä»¶ä¸ä»æ¯é常ç½è§çã64ããæåªæ³æåºï¼å®ä»¬å¹¶æ²¡æè¶ è¶å¯è½æ§çèç´ï¼æ以å¼å¾ä¸äºå ³æ³¨ã #### ç»´æ¤å®æ´æ§ï¼å°½ç®¡è½¯ä»¶æBug é¤äºè¿äºç¡¬ä»¶é®é¢ä¹å¤ï¼æ»æ¯åå¨è½¯ä»¶ Bug çé£é©ï¼è¿äºé误ä¸ä¼è¢«è¾ä½å±æ¬¡çç½ç»ãå åææ件系ç»æ ¡éªåææè·ãå³ä½¿å¹¿æ³ä½¿ç¨çæ°æ®åºè½¯ä»¶ä¹æ Bugï¼å³ä½¿å MySQL ä¸ PostgreSQL è¿æ ·ç¨³å¥ãå£ç¢è¯å¥½ãå¤å¹´æ¥è¢«è®¸å¤äººå åæµè¯è¿ç软件ï¼å°±æ个人æè§ä¹æ Bugï¼æ¯å¦ MySQL æªè½æ£ç¡®ç»´æ¤å¯ä¸çº¦æã65ãï¼ä»¥å PostgreSQL çå¯ä¸²è¡åé离ç级åå¨ç¹å®çååæå¼å¸¸ã66ãã对äºä¸é£ä¹æçç软件æ¥è¯´ï¼æ åµå¯è½è¦ç³ç³å¾å¤ã 尽管å¨ä»ç»è®¾è®¡ï¼æµè¯ï¼ä»¥å审æ¥ä¸ååºå¾å¤åªåï¼ä½ Bug ä»ç¶ä¼å¨ä¸ç¥ä¸è§ä¸äº§çã尽管å®ä»¬å¾å°ï¼èä¸æç»ä¼è¢«åç°å¹¶è¢«ä¿®å¤ï¼ä½æ»ä¼æé£ä¹ä¸æ®µæ¶é´ï¼è¿äº Bug å¯è½ä¼æåæ°æ®ã è对äºåºç¨ä»£ç ï¼æ们ä¸å¾ä¸å设ä¼ææ´å¤çé误ï¼å 为ç»å¤§å¤æ°åºç¨ç代ç ç»åçè¯å®¡ä¸æµè¯è¿è¿æ æ³ä¸æ°æ®åºç代ç ç¸æ¯ã许å¤åºç¨çè³æ²¡ææ£ç¡®ä½¿ç¨æ°æ®åºæä¾çç¨äºç»´æå®æ´æ§çåè½ï¼ä¾å¦å¤é®æå¯ä¸æ§çº¦æã36ãã ACID æä¹ä¸çä¸è´æ§ï¼è¯·åé â[ä¸è´æ§](ch7.md#ä¸è´æ§)âï¼åºäºè¿æ ·ä¸ç§æ³æ³ï¼æ°æ®åºä»¥ä¸è´çç¶æå¯å¨ï¼èäºå¡å°å ¶ä»ä¸ä¸ªä¸è´ç¶æ转æ¢è³å¦ä¸ä¸ªä¸è´çç¶æãå æ¤ï¼æ们æææ°æ®åºå§ç»å¤äºä¸è´ç¶æãç¶èï¼åªæå½ä½ å设äºå¡æ²¡æ Bug æ¶ï¼è¿ç§æ³æ³æææä¹ãå¦æåºç¨ä»¥æç§é误çæ¹å¼ä½¿ç¨æ°æ®åºï¼ä¾å¦ï¼ä¸å®å ¨å°ä½¿ç¨å¼±é离ç级ï¼æ°æ®åºçå®æ´æ§å°±æ æ³å¾å°ä¿è¯ã #### ä¸è¦ç²ç®ä¿¡ä»»æ¿è¯º ç±äºç¡¬ä»¶å软件并ä¸æ»æ¯ç¬¦åæ们ççæ³ï¼æ以æ°æ®æåä¼¼ä¹æ©æä¸å¯é¿å ãå æ¤ï¼æ们è³å°åºè¯¥æåæ³æ¥ææ°æ®æ¯å¦å·²ç»æåï¼ä»¥ä¾¿æ们è½å¤ä¿®å¤å®ï¼å¹¶å°è¯è¿½æ¥é误çæ¥æºãæ£æ¥æ°æ®å®æ´æ§ç§°ä¸º **审计ï¼auditingï¼**ã å¦ â[ä¸å¯åäºä»¶çä¼ç¹](ch11.md#ä¸å¯åäºä»¶çä¼ç¹)â ä¸èä¸æè¿°ï¼å®¡è®¡ä¸ä» ä» éç¨äºè´¢å¡åºç¨ç¨åºãä¸è¿ï¼å¯å®¡è®¡æ§å¨è´¢å¡ä¸æ¯é常é常éè¦çï¼å 为æ¯ä¸ªäººé½ç¥éé误æ»ä¼åçï¼æ们ä¹é½è®¤ä¸ºè½å¤æ£æµå解å³é®é¢æ¯åççéæ±ã æççç³»ç»åæ ·å¾åäºèèä¸å¤ªå¯è½çäºæ åºéçå¯è½æ§ï¼å¹¶ç®¡çè¿ç§é£é©ãä¾å¦ï¼HDFS å Amazon S3 ç大è§æ¨¡åå¨ç³»ç»å¹¶ä¸å®å ¨ä¿¡ä»»ç£çï¼å®ä»¬è¿è¡åå°è¿ç¨æç»å读æ件ï¼å¹¶å°å ¶ä¸å ¶ä»å¯æ¬è¿è¡æ¯è¾ï¼å¹¶å°æ件ä»ä¸ä¸ªç£ç移å¨å°å¦ä¸ä¸ªï¼ä»¥ä¾¿éä½éé»æåçé£é©ã67ãã å¦æä½ æ³ç¡®ä¿ä½ çæ°æ®ä»ç¶åå¨ï¼ä½ å¿ é¡»çæ£è¯»åå®å¹¶è¿è¡æ£æ¥ã大å¤æ°æ¶åå®ä»¬ä»ç¶ä¼å¨é£éï¼ä½å¦æä¸æ¯è¿æ ·ï¼ä½ ä¸å®æ³å°½æ©ç¥éçæ¡ï¼èä¸æ¯æ´æãæç §åæ ·çååï¼ä¸æ¶å°å°è¯ä»å¤ä»½ä¸æ¢å¤æ¯é常éè¦ç ââ å¦åå½ä½ åç°å¤ä»½æåæ¶ï¼ä½ å¯è½å·²ç»éå°äºæ°æ®ä¸¢å¤±ï¼é£æ¶åå°±çç太æäºãä¸è¦ç²ç®å°ç¸ä¿¡å®ä»¬å ¨é½ç®¡ç¨ã #### éªè¯çæå å HDFS å S3 è¿æ ·çç³»ç»ä»ç¶éè¦å设ç£ç大é¨åæ¶é´é½è½æ£å¸¸å·¥ä½ ââ è¿æ¯ä¸ä¸ªåççå设ï¼ä½ä¸å®ä»¬ **å§ç»** è½æ£å¸¸å·¥ä½çå设并ä¸ç¸åãç¶èç®åè¿æ²¡æå¤å°ç³»ç»éç¨è¿ç§ âä¿¡ä»»ä½æ¯éªè¯â çæ¹å¼æ¥æç»å®¡è®¡èªå·±ã许å¤äººè®¤ä¸ºæ£ç¡®æ§ä¿è¯æ¯ç»å¯¹çï¼å¹¶ä¸æ²¡æ为ç½è§çæ°æ®æåçå¯è½æ§åè¿åå¤ãæå¸ææªæ¥è½çå°æ´å¤ç **èªæéªè¯ï¼self-validatingï¼** æ **èªæ审计ï¼self-auditingï¼** ç³»ç»ï¼ä¸ææ£æ¥èªå·±çå®æ´æ§ï¼èä¸æ¯ä¾èµç²ç®çä¿¡ä»»ã68ãã ææ å¿ ACID æ°æ®åºçæå导è´æ们å¨ç²ç®ä¿¡ä»»ææ¯ï¼å¦äºå¡æºå¶ï¼çåºç¡ä¸å¼ååºç¨ï¼è忽è§äºè¿ç§è¿ç¨ä¸çä»»ä½å¯å®¡è®¡æ§ãç±äºæ们æä¿¡ä»»çææ¯å¨å¤§å¤æ°æ åµä¸å·¥ä½å¾å¾å¥½ï¼é常ä¼è®¤ä¸ºå®¡è®¡æºå¶å¹¶ä¸å¼å¾æèµã ä½éä¹èæ¥çæ¯ï¼æ°æ®åºçæ ¼å±åçäºååï¼å¨ NoSQL çæå¸ä¸ï¼æ´å¼±çä¸è´æ§ä¿è¯æ为常æï¼æ´ä¸æççåå¨ææ¯è¶æ¥è¶è¢«å¹¿æ³ä½¿ç¨ãä½æ¯ç±äºå®¡è®¡æºå¶è¿æ²¡æ被å¼ååºæ¥ï¼å°½ç®¡è¿ç§æ¹å¼è¶æ¥è¶å±é©ï¼æ们ä»ä¸æå¨ç²ç®ä¿¡ä»»çåºç¡ä¸æ建åºç¨ã让æ们æ³ä¸æ³å¦ä½é对å¯å®¡è®¡æ§è设计å§ã #### 为å¯å®¡è®¡æ§è设计 å¦æä¸ä¸ªäºå¡å¨ä¸ä¸ªæ°æ®åºä¸æ¹åäºå¤ä¸ªå¯¹è±¡ï¼å¨è¿ä¸äºå®åçåï¼å¾é¾è¯´æ¸ è¿ä¸ªäºå¡å°åºæå³çä»ä¹ãå³ä½¿ä½ æè·äºäºå¡æ¥å¿ï¼è¯·åé â[åæ´æ°æ®æè·](ch11.md#åæ´æ°æ®æè·)âï¼ï¼åç§è¡¨ä¸çæå ¥ãæ´æ°åå é¤æä½å¹¶ä¸ä¸å®è½æ¸ æ¥å°è¡¨æ **为ä»ä¹** è¦æ§è¡è¿äºåæ´ãå³å®è¿äºåæ´çæ¯åºç¨é»è¾ä¸çè°ç¨ï¼èè¿ä¸åºç¨é»è¾ç¨çºµå³éï¼æ æ³éç°ã ç¸æ¯ä¹ä¸ï¼åºäºäºä»¶çç³»ç»å¯ä»¥æä¾æ´å¥½çå¯å®¡è®¡æ§ãå¨äºä»¶æº¯æºæ¹æ³ä¸ï¼ç³»ç»çç¨æ·è¾å ¥è¢«è¡¨ç¤ºä¸ºä¸ä¸ªåä¸ä¸å¯åäºä»¶ï¼èä»»ä½å ¶å¯¼è´çç¶æåæ´é½è¡çèªè¯¥äºä»¶ãè¡çå¯ä»¥å®ç°ä¸ºå ·æç¡®å®æ§ä¸å¯éå¤æ§ï¼å èç¸åçäºä»¶æ¥å¿éè¿ç¸åçæ¬çè¡ç代ç æ¶ï¼ä¼å¯¼è´ç¸åçç¶æåæ´ã æ¾å¼å¤çæ°æ®æµï¼è¯·åé â[æ¹å¤çè¾åºçå²å¦](ch10.md#æ¹å¤çè¾åºçå²å¦)âï¼å¯ä»¥ä½¿æ°æ®ç **æ¥é¾å»èï¼provenanceï¼** æ´å æ¸ æ°ï¼ä»è使å®æ´æ§æ£æ¥æ´å ·å¯è¡æ§ã对äºäºä»¶æ¥å¿ï¼æ们å¯ä»¥ä½¿ç¨æ£åæ¥æ£æ¥äºä»¶åå¨æ²¡æè¢«ç ´åã对äºä»»ä½è¡çç¶æï¼æ们å¯ä»¥éæ°è¿è¡ä»äºä»¶æ¥å¿ä¸è¡çå®çæ¹å¤çå¨ä¸æµå¤çå¨ï¼ä»¥æ£æ¥æ¯å¦è·å¾ç¸åçç»æï¼æè ï¼çè³å¹¶è¡è¿è¡åä½çè¡çæµç¨ã å ·æç¡®å®æ§ä¸å®ä¹è¯å¥½çæ°æ®æµï¼ä¹ä½¿è°è¯ä¸è·è¸ªç³»ç»çæ§è¡åå¾å®¹æï¼ä»¥ä¾¿ç¡®å®å® **为ä»ä¹** åäºæäºäºæ ã4,69ããå¦æåºç°ææ³ä¹å¤çäºæ ï¼é£ä¹éç°å¯¼è´æå¤äºä»¶çç¡®åäºæ ç°åºçè¯æè½å ââ ä¸ç§æ¶é´æ è¡è°è¯åè½æ¯é常æä»·å¼çã #### 端å°ç«¯ååéç° å¦ææ们ä¸è½å®å ¨ç¸ä¿¡ç³»ç»çæ¯ä¸ªç»ä»¶é½ä¸ä¼æå ââ æ¯ä¸ä¸ªç¡¬ä»¶é½æ²¡ç¼ºé·ï¼æ¯ä¸ä¸ªè½¯ä»¶é½æ²¡æ Bug ââ é£æ们è³å°å¿ é¡»å®ææ£æ¥æ°æ®çå®æ´æ§ãå¦ææ们ä¸æ£æ¥ï¼æ们就ä¸è½åç°æåï¼ç´å°æ å¯æ½åå°å¯¼è´å¯¹ä¸æ¸¸çç ´åæ¶ï¼é£æ¶ååå»è¿½è¸ªé®é¢å°±è¦é¾å¾å¤ï¼ä¸ä»£ä»·ä¹è¦é«çå¤ã æ£æ¥æ°æ®ç³»ç»çå®æ´æ§ï¼æ好æ¯ä»¥ç«¯å°ç«¯çæ¹å¼è¿è¡ï¼è¯·åé â[æ°æ®åºç端å°ç«¯åå](#æ°æ®åºç端å°ç«¯åå)âï¼ï¼æ们è½å¨å®æ´æ§æ£æ¥ä¸æ¶µççç³»ç»è¶å¤ï¼æäºå¤çé¶ä¸åºç°ä¸è¢«å¯è§æåçå çå°±è¶å°ãå¦ææ们è½æ£æ¥æ´ä¸ªè¡çæ°æ®ç®¡é端å°ç«¯çæ£ç¡®æ§ï¼é£ä¹æ²¿çè¿ä¸è·¯å¾çä»»ä½ç£çãç½ç»ãæå¡ä»¥åç®æ³çæ£ç¡®æ§æ£æ¥é½éå«å¨å ¶ä¸äºã æç»ç端å°ç«¯å®æ´æ§æ£æ¥å¯ä»¥ä¸ææé«ä½ 对系ç»æ£ç¡®æ§çä¿¡å¿ï¼ä»èä½¿ä½ è½æ´å¿«å°è¿æ¥ã70ããä¸èªå¨åæµè¯ä¸æ ·ï¼å®¡è®¡æé«äºå¿«éåç°é误çå¯è½æ§ï¼ä»èéä½äºç³»ç»åæ´ææ°åå¨ææ¯å¯è½å¯¼è´æ失çé£é©ãå¦æä½ ä¸å®³æè¿è¡åæ´ï¼å°±å¯ä»¥æ´å¥½å°å åæ¼åä¸ä¸ªåºç¨ï¼ä½¿å ¶æ»¡è¶³ä¸æååçéæ±ã #### ç¨äºå¯å®¡è®¡æ°æ®ç³»ç»çå·¥å · ç®åï¼å°å¯å®¡è®¡æ§ä½ä¸ºé¡¶å±å ³æ³¨ç¹çæ°æ®ç³»ç»å¹¶ä¸å¤ãä¸äºåºç¨å®ç°äºèªå·±ç审计æºå¶ï¼ä¾å¦å°ææåæ´è®°å½å°åç¬ç审计表ä¸ï¼ä½æ¯ç¡®ä¿å®¡è®¡æ¥å¿ä¸æ°æ®åºç¶æçå®æ´æ§ä»ç¶æ¯å¾å°é¾çãå¯ä»¥å®æ使ç¨ç¡¬ä»¶å®å ¨æ¨¡å对äºå¡æ¥å¿è¿è¡ç¾åæ¥é²æ¢ç¯¡æ¹ï¼ä½è¿æ æ³ä¿è¯æ£ç¡®çäºå¡ä¸å¼å§å°±è½è¿å ¥å°æ¥å¿ä¸ã 使ç¨å¯ç å¦å·¥å ·æ¥è¯æç³»ç»çå®æ´æ§æ¯ååæ趣çï¼è¿ç§æ¹å¼å¯¹äºå®½æ³ç硬件ä¸è½¯ä»¶é®é¢ï¼çè³æ¯æ½å¨çæ¶æè¡ä¸ºé½å¾ç¨³å¥ææãå å¯è´§å¸ãåºåé¾ã以å诸å¦æ¯ç¹å¸ã以太åãRippleãStellar çåå¸å¼è´¦æ¬ææ¯å·²ç»è¿ éåºç°å¨è¿ä¸é¢åã71,72,73ãã æ没æèµæ ¼è¯è®ºè¿äºææ¯ç¨äºè´§å¸ï¼æè åååå®æºå¶çä»·å¼ãä½ä»æ°æ®ç³»ç»çè§åº¦æ¥çï¼å®ä»¬å å«äºä¸äºæ趣çæ³æ³ãå®è´¨ä¸ï¼å®ä»¬æ¯åå¸å¼æ°æ®åºï¼å ·ææ°æ®æ¨¡åä¸äºå¡æºå¶ï¼èä¸åå¯æ¬å¯ä»¥ç±äºä¸ä¿¡ä»»çç»ç»æ管ãå¯æ¬ä¸ææ£æ¥å ¶ä»å¯æ¬çå®æ´æ§ï¼å¹¶ä½¿ç¨å ±è¯å议对åºå½æ§è¡çäºå¡è¾¾æä¸è´ã æ对è¿äºææ¯çæå åºå®¹éæ¹é¢æäºæçï¼è¯·åé â[æå åºæ é](ch8.md#æå åºæ é)âï¼ï¼èä¸æåç° **å·¥ä½è¯æï¼proof of workï¼** ææ¯é常浪费ï¼æ¯å¦ï¼æ¯ç¹å¸æç¿ï¼ãæ¯ç¹å¸ç交æååéç¸å½ä½ï¼å°½ç®¡æ´å¤æ¯åºäºæ¿æ²»ä¸ç»æµåå èéææ¯ä¸çåå ãä¸è¿ï¼å®æ´æ§æ£æ¥çæ¹é¢æ¯å¾æ趣çã å¯ç å¦å®¡è®¡ä¸å®æ´æ§æ£æ¥é常ä¾èµ **é»å å°æ ï¼Merkle treeï¼**ã74ãï¼è¿æ¯ä¸é¢æ£åå¼çæ ï¼è½å¤ç¨äºé«æå°è¯æä¸æ¡è®°å½åºç°å¨ä¸ä¸ªæ°æ®éä¸ï¼ä»¥åå ¶ä»ä¸äºç¹æ§ï¼ãé¤äºçä½ç沸沸æ¬æ¬çå å¯è´§å¸ä¹å¤ï¼**è¯ä¹¦éææ§ï¼certificate transparencyï¼** ä¹æ¯ä¸ç§ä¾èµ Merkle æ çå®å ¨ææ¯ï¼ç¨æ¥æ£æ¥ TLS/SSL è¯ä¹¦çæææ§ã75,76ãã æå¯ä»¥æ³è±¡ï¼é£äºå¨è¯ä¹¦éæ度ä¸åå¸å¼è´¦æ¬ä¸ä½¿ç¨çå®æ´æ§æ£æ¥å审计ç®æ³ï¼å°ä¼å¨éç¨æ°æ®ç³»ç»ä¸å¾å°è¶æ¥è¶å¹¿æ³çåºç¨ãè¦ä½¿å¾è¿äºç®æ³å¯¹äºæ²¡æå¯ç å¦å®¡è®¡çç³»ç»åæ ·å¯ä¼¸ç¼©ï¼å¹¶å°½å¯è½éä½æ§è½æ失è¿éè¦ä¸äºå·¥ä½ã ä½æ认为è¿æ¯ä¸ä¸ªå¼å¾å ³æ³¨çæ趣é¢åã ## åæ£ç¡®çäºæ å¨æ¬ä¹¦çæåé¨åï¼ææ³éåä¸æ¥ãå¨æ¬ä¹¦ä¸ï¼æ们èå¯äºåç§ä¸åçæ°æ®ç³»ç»æ¶æï¼è¯ä»·äºå®ä»¬çä¼ç¹ä¸ç¼ºç¹ï¼å¹¶æ¢è®¨äºæ建å¯é ï¼å¯ä¼¸ç¼©ï¼å¯ç»´æ¤åºç¨çææ¯ãä½æ¯ï¼æ们忽ç¥äºè®¨è®ºä¸ä¸ä¸ªéè¦èåºç¡çé¨åï¼ç°å¨ææ³è¡¥å ä¸ä¸ã æ¯ä¸ªç³»ç»é½æå¡äºä¸ä¸ªç®çï¼æ们éåçæ¯ä¸ªä¸¾æªé½ä¼åæ¶äº§çææçåæä¸æå¤çåæãè¿ä¸ªç®çå¯è½åªæ¯ç®åå°èµé±ï¼ä½å ¶å¯¹ä¸ççå½±åï¼å¯è½ä¼è¿è¿è¶ åºæåçç®çãæ们ï¼å»ºç«è¿äºç³»ç»çå·¥ç¨å¸ï¼æ责任å»ä»ç»èèè¿äºåæï¼å¹¶ææè¯å°å³å®ï¼æ们å¸æçæ´»å¨ææ ·çä¸çä¸ã æ们å°æ°æ®å½æä¸ç§æ½è±¡çä¸è¥¿æ¥è®¨è®ºï¼ä½è¯·è®°ä½ï¼è®¸å¤æ°æ®éé½æ¯å ³äºäººçï¼ä»ä»¬çè¡ä¸ºï¼ä»ä»¬çå ´è¶£ï¼ä»ä»¬ç身份ãå¯¹å¾ è¿äºæ°æ®ï¼æä»¬å¿ é¡»æç人æ§ä¸å°éãç¨æ·ä¹æ¯äººç±»ï¼äººç±»çå°ä¸¥æ¯è³å ³éè¦çã 软件å¼åè¶æ¥è¶å¤å°æ¶åéè¦çéå¾·ææ©ãæä¸äºæ导ååå¯ä»¥å¸®å©è½¯ä»¶å·¥ç¨å¸è§£å³è¿äºé®é¢ï¼ä¾å¦ ACM ç软件工ç¨éå¾·è§èä¸ä¸ä¸å®è·µã77ãï¼ä½å®è·µä¸å¾å°ä¼è®¨è®ºè¿äºï¼æ´ä¸ç¨è¯´åºç¨ä¸å¼ºå¶æ§è¡äºãå æ¤ï¼å·¥ç¨å¸å产åç»çææ¶ä¼å¯¹éç§ä¸äº§åæ½å¨çè´é¢åææ±æé常å²æ ¢çæ度ã78,79,80ãã ææ¯æ¬èº«å¹¶æ 好åä¹å ââ å ³é®å¨äºå®è¢«å¦ä½ä½¿ç¨ï¼ä»¥åå®å¦ä½å½±å人们ãè¿å¯¹æªæ¢°è¿æ ·çæ¦å¨æ¯æç«çï¼èæç´¢å¼æè¿æ ·ç软件系ç»ä¸ä¹ç±»ä¼¼ãæ认为ï¼è½¯ä»¶å·¥ç¨å¸ä» ä» ä¸æ³¨äºææ¯è忽è§å ¶åææ¯ä¸å¤çï¼é德责任ä¹æ¯æ们ç责任ã对éå¾·æ¨çå¾å°é¾ï¼ä½å®å¤ªéè¦äºï¼æ们æ æ³å¿½è§ã ### é¢æµæ§åæ 举个ä¾åï¼é¢æµæ§åææ¯ â大æ°æ®â çä½ç主è¦å 容ä¹ä¸ã使ç¨æ°æ®åæé¢æµå¤©æ°æç¾ç ä¼ ææ¯ä¸ç äºã81ãï¼èé¢æµä¸ä¸ªç½ªç¯æ¯å¦å¯è½åç¯ï¼ä¸ä¸ªè´·æ¬¾ç³è¯·äººæ¯å¦æå¯è½è¿çº¦ï¼æè ä¸ä¸ªä¿é©å®¢æ·æ¯å¦å¯è½è¿è¡æè´µçç´¢èµï¼åæ¯å¦å¤ä¸ç äºãåè ä¼ç´æ¥å½±åå°ä¸ªäººççæ´»ã å½ç¶ï¼æ¯ä»ç½ç»å¸æé²æ¢æ¬ºè¯äº¤æï¼é¶è¡å¸æé¿å ä¸è¯è´·æ¬¾ï¼èªç©ºå ¬å¸å¸æé¿å å«æºï¼å ¬å¸å¸æé¿å éä½£æçä½ä¸æä¸å¼å¾ä¿¡ä»»ç人ãä»å®ä»¬çè§åº¦æ¥çï¼å¤±å»åæºçææ¬å¾ä½ï¼èä¸è¯è´·æ¬¾æé®é¢åå·¥çææ¬åè¦é«å¾å¤ï¼å èç»ç»å¸æä¿æè°¨æ ä¹æ¯èªç¶èç¶çäºæ ãæ以å¦æåçï¼å®ä»¬éå¸¸ä¼ Say Noã ç¶èï¼éçç®æ³å³çåå¾è¶æ¥è¶æ®éï¼è¢«æç§ç®æ³ï¼åç¡®å°æé误å°ï¼æ 记为æé£é©çæ人å¯è½ä¼éå大éè¿ç§ âNoâ çå³å®ãç³»ç»æ§å°è¢«æé¤å¨å·¥ä½ï¼èªæ ï¼ä¿é©ï¼ç§èµï¼éèæå¡ï¼ä»¥åå ¶ä»ç¤¾ä¼å ³é®é¢åä¹å¤ãè¿æ¯ä¸ç§å¯¹ä¸ªä½èªç±çæ大约æï¼å æ¤è¢«ç§°ä¸º âç®æ³çç±âã82ããå¨å°é人æçå½å®¶ï¼åäºå¸æ³ç³»ç»ä¼åæ 罪æ¨å®ï¼é»è®¤æ¸ ç½ï¼ç´å°è¢«è¯ææ罪ï¼ãå¦ä¸æ¹é¢ï¼èªå¨åç³»ç»å¯ä»¥ç³»ç»å°ï¼ä»»æå°å°ä¸ä¸ªäººæé¤å¨ç¤¾ä¼åä¸ä¹å¤ï¼ä¸éè¦ä»»ä½æ罪çè¯æï¼èä¸å ä¹æ²¡æç³è¯çæºä¼ã #### åè§ä¸æ§è§ ç®æ³ååºçå³å®ä¸ä¸å®æ¯äººç±»æ´å¥½ææ´å·®ãæ¯ä¸ªäººé½å¯è½æåè§ï¼å³ä½¿ä»ä»¬ä¸»å¨ææè¿ä¸ç¹ï¼èæ§è§æ§åæ³ä¹å¯è½å·²ç»å¨æåä¸è¢«å¶åº¦åäºã人们å¸ææ ¹æ®æ°æ®ååºå³å®ï¼èä¸æ¯éè¿äººç主è§è¯ä»·ä¸ç´è§ï¼å¸æè¿æ ·è½æ´å å ¬å¹³ï¼å¹¶ç»äºä¼ ç»ä½å¶ä¸ç»å¸¸è¢«å¿½è§ç人æ´å¥½çæºä¼ã83ãã å½æ们å¼åé¢æµæ§åæç³»ç»æ¶ï¼ä¸æ¯ä» ä» ç¨è½¯ä»¶éè¿ä¸ç³»å IF ELSE è§åå°äººç±»çå³çè¿ç¨èªå¨åï¼é£äºè§åæ¬èº«çè³é½æ¯ä»æ°æ®ä¸æ¨æåºæ¥çãä½è¿äºç³»ç»å¦å°ç模å¼æ¯ä¸ªé»çï¼å³ä½¿æ°æ®ä¸åå¨ä¸äºç¸å ³æ§ï¼æ们å¯è½ä¹åæ ¹ä¸ç¥é为ä»ä¹ãå¦æç®æ³çè¾å ¥ä¸åå¨ç³»ç»æ§çåè§ï¼åç³»ç»å¾æå¯è½ä¼å¨è¾åºä¸å¦ä¹ 并æ¾å¤§è¿ç§åè§ã84ãã å¨è®¸å¤å½å®¶ï¼åæ§è§æ³å¾ç¦æ¢æç§æãå¹´é¾ãæ§å«ãæ§ååãæ®ç¾æä¿¡ä»°çåä¿æ¤çç¹å¾åºåå¯¹å¾ ä¸åç人ãå ¶ä»ç个人ç¹å¾å¯è½æ¯å 许ç¨äºåæçï¼ä½æ¯å¦æè¿äºç¹å¾ä¸åä¿æ¤çç¹å¾åå¨å ³èï¼åä¼åçä»ä¹ï¼ä¾å¦å¨ç§æé离å°åºä¸ï¼ä¸ä¸ªäººçé®æ¿ç¼ç ï¼çè³æ¯ä»ä»¬ç IP å°åï¼é½æ¯å¾å¼ºçç§ææ示ç©ãè¿æ ·çè¯ï¼ç¸ä¿¡ä¸ç§ç®æ³å¯ä»¥ä»¥æç§æ¹å¼å°æåè§çæ°æ®ä½ä¸ºè¾å ¥ï¼å¹¶äº§çå ¬å¹³åå ¬æ£çè¾åºã85ãä¼¼ä¹æ¯å¾èè°¬çãç¶èè¿ç§è§ç¹ä¼¼ä¹å¸¸å¸¸æ½ä¼å¨æ°æ®é©±å¨åå³ççæ¯æè ä¸ï¼è¿ç§æ度被讽åºä¸º âå¨å¤çåå·®ä¸ï¼æºå¨å¦ä¹ ä¸æ´é±ç±»ä¼¼âï¼machine learning is like money laundering for biasï¼ã86ãã é¢æµæ§åæç³»ç»åªæ¯åºäºè¿å»è¿è¡æ¨æï¼å¦æè¿å»æ¯æ§è§æ§çï¼å®ä»¬å°±ä¼å°è¿ç§æ§è§å½çº³ä¸ºè§å¾ãå¦ææ们å¸ææªæ¥æ¯è¿å»æ´å¥½ï¼é£ä¹å°±éè¦éå¾·æ³è±¡åï¼èè¿æ¯åªæ人类æè½æä¾çä¸è¥¿ã87ããæ°æ®ä¸æ¨¡ååºè¯¥æ¯æ们çå·¥å ·ï¼èä¸æ¯æ们ç主人ã #### 责任ä¸é®è´£ èªå¨å³çå¼åäºå ³äºè´£ä»»ä¸é®è´£çé®é¢ã87ããå¦æä¸ä¸ªäººç¯äºé误ï¼ä»å¯ä»¥è¢«è¿½è´£ï¼åå³å®å½±åç人å¯ä»¥ç³è¯ãç®æ³ä¹ä¼ç¯é误ï¼ä½æ¯å¦æå®ä»¬åºéï¼è°æ¥è´è´£ã88ãï¼å½ä¸è¾èªå¨é©¾é©¶æ±½è½¦å¼åäºæ æ¶ï¼è°æ¥è´è´£ï¼å¦æèªå¨ä¿¡ç¨è¯åç®æ³ç³»ç»æ§å°æ§è§ç¹å®ç§ææå®æç人ï¼è¿äºäººæ¯å¦æä»»ä½è¿½ç´¢æï¼å¦ææºå¨å¦ä¹ ç³»ç»çå³å®è¦åå°å¸æ³å®¡æ¥ï¼ä½ è½åæ³å®è§£éç®æ³æ¯å¦ä½ååºå³å®çåï¼ æ¶éå ³äºäººçæ°æ®å¹¶è¿è¡å³çï¼ä¿¡ç¨è¯çº§æºææ¯ä¸ä¸ªå¾ç»å ¸çä¾åãä¸è¯çä¿¡ç¨è¯åä¼ä½¿çæ´»åå¾æ´è°é¾ï¼ä½è³å°ä¿¡ç¨åé常æ¯åºäºä¸ªäºº **å®é ç** å款åå²è®°å½ï¼èè®°å½ä¸çä»»ä½é误é½è½è¢«çº æ£ï¼å°½ç®¡æºæé常ä¼è®¾ç½®é¨æ§ï¼ãç¶èï¼åºäºæºå¨å¦ä¹ çè¯åç®æ³é常ä¼ä½¿ç¨æ´å®½æ³çè¾å ¥ï¼å¹¶ä¸æ´ä¸éæï¼å èå¾é¾ç解ç¹å®å³çæ¯ææ ·ä½åºçï¼ä»¥åæ¯å¦æ人被ä¸å ¬æ£å°ï¼æ§è§æ§å°å¯¹å¾ ã89ãã ä¿¡ç¨åæ»ç»äº âä½ è¿å»ç表ç°å¦ä½ï¼âï¼èé¢æµæ§åæé常æ¯åºäº âè°ä¸ä½ 类似ï¼ä»¥åä¸ä½ 类似ç人è¿å»è¡¨ç°çå¦ä½ï¼âãä¸ä»äººçè¡ä¸ºç»ä¸çå·æå³çå»æ¿å°è±¡ï¼ä¾å¦ï¼æ ¹æ®ä»ä»¬å± ä½çå°æ¹ï¼ä¸ç§æåé¶çº§å ³ç³»å¯åçç¹å¾ï¼ãé£ä¹é£äºæ¾éä½ç½®ç人æä¹åï¼èä¸ï¼å¦ææ¯å 为é误æ°æ®å¯¼è´çé误å³å®ï¼è¿½ç´¢å ä¹æ¯ä¸å¯è½çã87ãã å¾å¤æ°æ®æ¬è´¨ä¸æ¯ç»è®¡æ§çï¼è¿æå³çå³ä½¿æ¦çåå¸å¨æ»ä½ä¸æ¯æ£ç¡®çï¼å¯¹äºä¸ªä¾ä¹å¯è½æ¯é误çãä¾å¦ï¼å¦æè´µå½çå¹³å寿å½æ¯ 80 å²ï¼è¿å¹¶ä¸æå³çä½ å¨ 80 å²çæ¥æ¶å°±ä¼æ»æãå¾é¾ä»å¹³åå¼ä¸æ¦çåå¸ä¸å¯¹æ个ç¹å®ä¸ªä½ç寿å½ä½åºä»ä¹å¤æï¼åæ ·ï¼é¢æµç³»ç»çè¾åºæ¯æ¦çæ§çï¼å¯¹äºä¸ªä¾å¯è½æ¯é误çã ç²ç®ç¸ä¿¡æ°æ®å³çè³é«æ ä¸ï¼è¿ä¸ä» ä» æ¯ä¸ç§å¦æ³ï¼èæ¯æåå®å±é©çãéçæ°æ®é©±å¨çå³çåå¾è¶æ¥è¶æ®éï¼æ们éè¦å¼æ¸ æ¥ï¼å¦ä½ä½¿ç®æ³æ´è´è´£ä»»ä¸æ´å éæï¼å¦ä½é¿å å 强ç°æçåè§ï¼ä»¥åå¦ä½å¨å®ä»¬ä¸å¯é¿å å°åºéæ¶å 以修å¤ã æ们è¿éè¦æ³æ¸ æ¥ï¼å¦ä½é¿å æ°æ®è¢«ç¨äºå®³äººï¼å¦ä½è®¤è¯æ°æ®ç积ææ½åãä¾å¦ï¼åæå¯ä»¥æ示人们çæ´»çè´¢å¡ç¹ç¹ä¸ç¤¾ä¼ç¹ç¹ãä¸æ¹é¢ï¼è¿ç§æåå¯ä»¥ç¨æ¥å°æ´å©ä¸æ¯æéä¸å¨å¸®å©é£äºæéè¦æ´å©ç人身ä¸ãå¦ä¸æ¹é¢ï¼å®ææ¶ä¼è¢«æ 夺æ§ä¼ä¸ç¨äºè¯å«å¼±å¿ç¾¤ä½ï¼å¹¶åå ¶å å®é«é£é©äº§åï¼æ¯å¦é«å©è´·å没æä»·å¼ç大å¦æåã87,90ãã #### åé¦å¾ªç¯ å³ä½¿æ¯é£äºå¯¹äººç´æ¥å½±åæ¯è¾å°çé¢æµæ§åºç¨ï¼æ¯å¦æ¨èç³»ç»ï¼ä¹æä¸äºå¿ é¡»æ£è§çé¾é¢ãå½æå¡åå¾åäºé¢æµç¨æ·æ³è¦çå°ä»ä¹å 容æ¶ï¼å®æç»å¯è½åªä¼å人们å±ç¤ºä»ä»¬å·²ç»åæçè§ç¹ï¼å°äººä»¬å¸¦å ¥æ»çå»æ¿å°è±¡ï¼è¯¯å¯¼ä¿¡æ¯ï¼ä¸æ端ææ³ç **åé³å®¤**ãæ们已ç»çå°è¿ç¤¾äº¤åªä½åé³å®¤å¯¹ç«éçå½±åäºã91ãã å½é¢æµæ§åæå½±å人们ççæ´»æ¶ï¼èªæ强åçåé¦å¾ªç¯ä¼å¯¼è´é常æ害çé®é¢ãä¾å¦ï¼èèé主使ç¨ä¿¡ç¨åæ¥è¯ä¼°åé人çä¾åãä½ å¯è½æ¯ä¸ä¸ªä¿¡ç¨åä¸éç好åå·¥ï¼ä½å ä¸å¯æåçæå¤èé·å ¥è´¢å¡å°å¢ãç±äºä¸è½ææä»è´¦åï¼ä½ çä¿¡ç¨åä¼åå°å½±åï¼è¿è导è´æ¾å°å·¥ä½æ´ä¸ºå°é¾ã失ä¸ä½¿ä½ é·å ¥è´«å°ï¼è¿è¿ä¸æ¥æ¶åäºä½ çåæ°ï¼ä½¿ä½ æ´é¾æ¾å°å·¥ä½ã87ããå¨æ°æ®ä¸æ°å¦ä¸¥è°¨æ§çä¼ªè£ èåï¼éèçæ¯ç±æ¶æ¯å设导è´çæ¶æ§å¾ªç¯ã æ们æ æ³é¢æµè¿ç§åé¦å¾ªç¯ä½æ¶åçãç¶èéè¿å¯¹æ´ä¸ªç³»ç»ï¼ä¸ä» ä» æ¯è®¡ç®æºåçé¨åï¼èä¸è¿æä¸ä¹äºå¨ç人ï¼è¿è¡æ´ä½æèï¼è®¸å¤åææ¯å¯ä»¥å¤é¢æµç ââ ä¸ç§ç§°ä¸º **ç³»ç»æç»´ï¼systems thinkingï¼** çæ¹æ³ã92ããæ们å¯ä»¥å°è¯ç解æ°æ®åæç³»ç»å¦ä½ååºä¸åçè¡ä¸ºï¼ç»ææç¹æ§ã该系ç»æ¯å¦å 强åå¢å¤§äºäººä»¬ä¹é´ç°æçå·®å¼ï¼ä¾å¦ï¼æä¸è¶³ä»¥å¥æä½ï¼å¯è æå¯ï¼è´«è æè´«ï¼ï¼è¿æ¯è¯å¾ä¸ä¸å ¬ä½æäºï¼èä¸å³ä½¿æçæ好çå¨æºï¼æ们ä¹å¿ é¡»å½å¿ææ³ä¸å°çåæã ### éç§å追踪 é¤äºé¢æµæ§åæ ââ 使ç¨æ°æ®æ¥ååºå ³äºäººçèªå¨å³ç ââ æ°æ®æ¶éæ¬èº«ä¹åå¨éå¾·é®é¢ãæ¶éæ°æ®çç»ç»ï¼ä¸è¢«æ¶éæ°æ®ç人ä¹é´ï¼å°åºå±äºä»ä¹å ³ç³»ï¼ å½ç³»ç»åªåå¨ç¨æ·æç¡®è¾å ¥çæ°æ®æ¶ï¼æ¯å 为ç¨æ·å¸æç³»ç»ä»¥ç¹å®æ¹å¼åå¨åå¤çè¿äºæ°æ®ï¼**ç³»ç»æ¯å¨ä¸ºç¨æ·æä¾æå¡**ï¼ç¨æ·å°±æ¯å®¢æ·ãä½æ¯ï¼å½ç¨æ·çæ´»å¨è¢«è·è¸ªå¹¶è®°å½ï¼ä½ä¸ºä»ä»¬æ£å¨åçå ¶ä»äºæ çå¯ä½ç¨æ¶ï¼è¿ç§å ³ç³»å°±æ²¡æé£ä¹æ¸ æ°äºã该æå¡ä¸åä» ä» å®æç¨æ·æ³è¦å®è¦åçäºæ ï¼èæ¯æå¡äºå®èªå·±çå©çï¼èè¿å¯è½ä¸ç¨æ·çå©çç¸å²çªã 追踪ç¨æ·è¡ä¸ºæ°æ®å¯¹äºè®¸å¤é¢åç¨æ·çå¨çº¿æå¡èè¨ï¼åå¾è¶æ¥è¶éè¦ï¼è¿½è¸ªç¨æ·ç¹å»äºåªäºæç´¢ç»ææå©äºæ¹åæç´¢ç»æçæåï¼æ¨è âå欢 X ç人ä¹å欢 Yâï¼å¯ä»¥å¸®å©ç¨æ·åç°å®ç¨æ趣çä¸è¥¿ï¼ A/B æµè¯åç¨æ·æµéåææå©äºæ¹åç¨æ·çé¢ãè¿äºåè½éè¦ä¸å®éçç¨æ·è¡ä¸ºè·è¸ªï¼èç¨æ·ä¹å¯ä»¥ä»ä¸åçã ä½ä¸åå ¬å¸æçä¸åçåä¸æ¨¡å¼ï¼è¿½è¸ªå¹¶æªæ¢æ¥äºæ¤ãå¦ææå¡æ¯éè¿å¹¿åçå©çï¼é£ä¹å¹¿å主ææ¯çæ£ç客æ·ï¼èç¨æ·çå©çåå±å± å ¶æ¬¡ãè·è¸ªçæ°æ®ä¼åå¾æ´è¯¦ç»ï¼åæåå¾æ´æ·±å ¥ï¼æ°æ®ä¼ä¿çå¾é¿æ¶é´ï¼ä»¥ä¾¿ä¸ºæ¯ä¸ªäººå»ºç«è¯¦ç»ç»åï¼ç¨äºè¥éã ç°å¨ï¼å ¬å¸ä¸è¢«æ¶éæ°æ®çç¨æ·ä¹é´çå ³ç³»ï¼çä¸å»å°±ä¸å¤ªä¸æ ·äºãå ¬å¸ä¼å è´¹æå¡ç¨æ·ï¼å¹¶å¼è¯±ç¨æ·å°½å¯è½å¤å°ä½¿ç¨æå¡ã对ç¨æ·ç追踪ï¼ä¸»è¦ä¸æ¯æå¡äºè¯¥ç¨æ·ä¸ªä½ï¼èæ¯æå¡äºæé±èµå©è¯¥æå¡ç广ååãæ认为è¿ç§å ³ç³»å¯ä»¥ç¨ä¸ä¸ªæ´å ·ç½ªç¯å 涵çè¯æ¥æ°å½å°æè¿°ï¼**çè§ï¼surveilanceï¼**ã #### çè§ è®©æ们åä¸ä¸ªææ³å®éªï¼å°è¯ç¨ **çè§ï¼surveillanceï¼** ä¸è¯æ¿æ¢ **æ°æ®ï¼dataï¼**ï¼åçç常è§ççè¯æ¯ä¸æ¯å¬èµ·æ¥è¿é£ä¹æ¼äº®ã93ããæ¯å¦ï¼âå¨æ们ççè§é©±å¨çç»ç»ä¸ï¼æ们æ¶éå®æ¶çè§æµå¹¶å°å®ä»¬åå¨å¨æ们ççè§ä»åºä¸ãæ们ççè§ç§å¦å®¶ä½¿ç¨é«çº§åæåçè§å¤çæ¥è·å¾æ°çè§è§£ãâ 对äºæ¬ä¹¦ã设计çæ§å¯éååºç¨ãèè¨ï¼è¿ä¸ªææ³å®éªæ¯ç½è§çäºè®®æ§å 容ï¼ä½æ认为éè¦æ¿ççè¨è¾æ¥å¼ºè°è¿ä¸ç¹ãå¨æ们å°è¯å¶é 软件 âåå¬ä¸çâ çè¿ç¨ä¸ã94ãï¼æ们已ç»å»ºç«äºä¸çä¸è¿ä»ä¸ºæ¢æè§è¿çæä¼å¤§ç大è§æ¨¡çè§åºç¡è®¾æ½ãæ们æ£æçä¸ç©äºèè¿è¿ï¼æ们æ£å¨è¿ éèµ°è¿è¿æ ·ä¸ä¸ªä¸çï¼æ¯ä¸ªæäººå± ä½ç空é´è³å°å å«ä¸ä¸ªå¸¦äºèç½è¿æ¥ç麦å é£ï¼ä»¥æºè½ææºãæºè½çµè§ãè¯é³æ§å¶å©ç设å¤ãå©´å¿çè§å¨çè³å¿ç«¥ç©å ·çå½¢å¼åå¨ï¼å¹¶ä½¿ç¨åºäºäºçè¯é³è¯å«ãè¿äºè®¾å¤ä¸çå¾å¤é½æçå¯æçå®å ¨è®°å½ã95ãã å³ä½¿æ¯æ为ææä¸ä¸å¶çæ¿æï¼å¯è½ä¹åªä¼æ³çå¨æ¯ä¸ªæ¿é´è£ ä¸ä¸ªéº¦å é£ï¼å¹¶å¼ºè¿«æ¯ä¸ªäººå§ç»æºå¸¦è½å¤è¿½è¸ªå ¶ä½ç½®ä¸å¨åç设å¤ãç¶èï¼æ们æ¾ç¶æ¯èªæ¿å°ï¼çè³çæ å°æ身äºè¿ä¸ªå ¨åçè§çä¸çãä¸åä¹å¤å¨äºï¼æ°æ®æ¯ç±å ¬å¸ï¼èä¸æ¯ç±æ¿åºæºææ¶éçã96ãã 并ä¸æ¯ææçæ°æ®æ¶éé½ç§°å¾ä¸çè§ï¼ä½æ£è§è¿ä¸ç¹æå©äºç解æ们ä¸æ°æ®æ¶éè ä¹é´çå ³ç³»ã为ä»ä¹æ们似ä¹å¾ä¹ææ¥åä¼ä¸ççè§å¢ï¼ä¹è®¸ä½ è§å¾èªå·±æ²¡æä»ä¹å¥½éçç ââ æ¢å¥è¯è¯´ï¼ä½ ä¸å½æé¶çº§ç©¿ä¸æ¡è£¤åï¼ä½ ä¸æ¯è¢«è¾¹ç¼åçå°æ°æ´¾ï¼ä¹ä¸å¿ 害æåå°è¿«å®³ã97ããä¸æ¯æ¯ä¸ªäººé½å¦æ¤å¹¸è¿ãæè ï¼ä¹è®¸è¿æ¯å 为ç®çä¼¼ä¹æ¯æ¸©åç ââ è¿ä¸æ¯å ¬ç¶èè¿«ï¼ä¹ä¸æ¯å¼ºå¶æ§çï¼èåªæ¯æ´å¥½çæ¨èä¸æ´ä¸ªæ§åçè¥éãä½æ¯ï¼ç»åä¸ä¸èä¸å¯¹é¢æµæ§åæç讨论ï¼è¿ç§åºå«ä¼¼ä¹å¹¶ä¸æ¯å¾æ¸ æ°ã æ们已ç»çå°ä¸æ±½è½¦è¿½è¸ªè®¾å¤æé©ç汽车ä¿é©è´¹ï¼ä»¥ååå³äºéè¦äººä½©æ´å¥èº«è¿½è¸ªè®¾å¤æ¥ç¡®å®çå¥åº·ä¿é©èå´ãå½çè§è¢«ç¨äºå³å®çæ´»çéè¦æ¹é¢æ¶ï¼ä¾å¦ä¿é©æå°±ä¸ï¼å®å°±å¼å§åå¾ä¸é£ä¹æ¸©åäºãæ¤å¤ï¼æ°æ®åæå¯ä»¥æ示åºä»¤äººæ讶çç§å¯äºç©ï¼ä¾å¦ï¼æºè½æ表æå¥èº«è¿½è¸ªå¨ä¸çè¿å¨ä¼ æå¨è½ä»¥ç¸å½å¥½ç精度计ç®åºä½ æ£å¨è¾å ¥çå 容ï¼æ¯å¦å¯ç ï¼ã98ããèåæç®æ³åªä¼åå¾è¶æ¥è¶ç²¾ç¡®ã #### åæä¸éæ©çèªç± æ们å¯è½ä¼æè¨ç¨æ·æ¯èªæ¿éæ©ä½¿ç¨äºä¼è·è¸ªå ¶æ´»å¨çæå¡ï¼èä¸ä»ä»¬å·²ç»åæäºæå¡æ¡æ¬¾ä¸éç§æ¿çï¼å æ¤ä»ä»¬åææ°æ®æ¶éãæ们çè³å¯ä»¥å£°ç§°ï¼ç¨æ·å¨ç¨ææä¾çæ°æ®æ¥ **æ¢å** æä»·å¼çæå¡ï¼å¹¶ä¸ä¸ºäºæä¾æå¡ï¼è¿½è¸ªæ¯å¿ è¦çã毫æ çé®ï¼ç¤¾äº¤ç½ç»ãæç´¢å¼æ以ååç§å ¶ä»å è´¹çå¨çº¿æå¡å¯¹äºç¨æ·æ¥è¯´é½æ¯æä»·å¼çï¼ä½æ¯è¿ä¸ªè¯´æ³å´åå¨é®é¢ã ç¨æ·å ä¹ä¸ç¥éä»ä»¬æä¾ç»æ们çæ¯ä»ä¹æ°æ®ï¼åªäºæ°æ®è¢«æ¾è¿äºæ°æ®åºï¼æ°æ®åæ¯ææ ·è¢«ä¿çä¸å¤çç ââ 大å¤æ°éç§æ¿çé½æ¯æ¨¡æ£±ä¸¤å¯çï¼å¿½æ ç¨æ·èä¸æ¢æå¼å¤©çªè¯´äº®è¯ãå¦æç¨æ·ä¸äºè§£ä»ä»¬çæ°æ®ä¼åçä»ä¹ï¼å°±æ æ³ç»åºä»»ä½ææä¹çåæãææ¶æ¥èªä¸ä¸ªç¨æ·çæ°æ®è¿ä¼æå°ä¸äºå ³äºå ¶ä»äººçäºï¼èå ¶ä»é£äºäººæ¢ä¸æ¯è¯¥æå¡çç¨æ·ï¼ä¹æ²¡æåæä»»ä½æ¡æ¬¾ãæ们å¨æ¬ä¹¦è¿ä¸é¨åä¸è®¨è®ºçè¡çæ°æ®é ââ æ¥èªæ´ä¸ªç¨æ·ç¾¤çæ°æ®ï¼å ä¸è¡ä¸ºè¿½è¸ªä¸å¤é¨æ°æ®æº ââ å°±æ°å¥½æ¯ç¨æ·æ æ³ï¼å¨çæ£æä¹ä¸ï¼ç解çæ°æ®ç±»åã èä¸ä»ç¨æ·èº«ä¸æææ°æ®æ¯ä¸ä¸ªååè¿ç¨ï¼èä¸æ¯çæ£çäºæ å ³ç³»ï¼ä¹ä¸æ¯å ¬å¹³çä»·å¼äº¤æ¢ãç¨æ·å¯¹è½ç¨å¤å°æ°æ®æ¢æ¥ä»ä¹æ ·çæå¡ï¼æ¢æ²¡æ没æåè¨æä¹æ²¡æéæ©æï¼æå¡ä¸ç¨æ·ä¹é´çå ³ç³»æ¯é常ä¸å¯¹ç§°ä¸åè¾¹çãè¿äºæ¡æ¬¾æ¯ç±æå¡æåºçï¼èä¸æ¯ç±ç¨æ·æåºçã99ãã 对äºä¸åæçè§çç¨æ·ï¼å¯ä¸çæ£ç®¡ç¨çå¤é项ï¼å°±æ¯ç®åå°ä¸ä½¿ç¨æå¡ãä½è¿ä¸ªéæ©ä¹ä¸æ¯çæ£èªç±çï¼å¦æä¸é¡¹æå¡å¦æ¤å欢è¿ï¼ä»¥è³äº â被大å¤æ°äººè®¤ä¸ºæ¯åºæ¬ç¤¾ä¼åä¸çå¿ è¦æ¡ä»¶âã99ãï¼é£ä¹ææ人们éæ©éåºè¿é¡¹æå¡æ¯ä¸åçç ââ 使ç¨å® **äºå®ä¸ï¼de factoï¼** æ¯å¼ºå¶æ§çãä¾å¦ï¼å¨å¤§å¤æ°è¥¿æ¹ç¤¾ä¼ç¾¤ä½ä¸ï¼æºå¸¦æºè½ææºï¼ä½¿ç¨ Facebook è¿è¡ç¤¾äº¤ï¼ä»¥åä½¿ç¨ Google æ¥æ¾ä¿¡æ¯å·²æ为常æãç¹å«æ¯å½ä¸é¡¹æå¡å ·æç½ç»æåºæ¶ï¼äººä»¬éæ© **ä¸** 使ç¨ä¼äº§ç社ä¼ææ¬ã å 为ä¸ä¸ªæå¡ä¼è·è¸ªç¨æ·èæç»ä½¿ç¨å®ï¼è¿åªæ¯å°æ°äººææ¥æçæåï¼ä»ä»¬æ足å¤çæ¶é´ä¸ç¥è¯æ¥äºè§£éç§æ¿çï¼å¹¶æ¿åå¾èµ·ä»£ä»·ï¼éè¿ç¤¾ä¼åä¸ï¼ä»¥å使ç¨æå¡å¯è½å¸¦æ¥çä¸ä¸æºä¼ã对äºé£äºå¤å¢ä¸å¤ªå¥½ç人èè¨ï¼å¹¶æ²¡æçæ£æä¹ä¸çéæ©ï¼çæ§æ¯ä¸å¯é¿å çã #### éç§ä¸æ°æ®ä½¿ç¨ ææ¶åï¼äººä»¬å£°ç§° âéç§å·²æ»âï¼çç±æ¯æäºç¨æ·æ¿ææåç§å ³äºä»ä»¬çæ´»çäºæ åå¸å°ç¤¾äº¤åªä½ä¸ï¼ææ¶æ¯å¹³å¡ä¿å¥ï¼ä½ææ¶æ¯é«åº¦ç§å¯çãä½è¿ç§è¯´æ³æ¯é误çï¼èä¸æ¯å¯¹ **éç§ï¼privacyï¼** ä¸è¯ç误解ã æ¥æéç§å¹¶ä¸æå³çä¿å¯ä¸åä¸è¥¿ï¼å®æå³çæ¥æéæ©åè°å±ç¤ºåªäºä¸è¥¿çèªç±ï¼è¦å ¬å¼ä»ä¹ï¼ä»¥åè¦ä¿å¯ä»ä¹ã**éç§ææ¯ä¸é¡¹å³å®æ**ï¼å¨ä»ä¿å¯å°éæçå è°±ä¸ï¼éç§ä½¿å¾æ¯ä¸ªäººé½è½å³å®èªå·±æ³è¦å¨ä»ä¹å°æ¹ä½äºå è°±ä¸çåªä¸ªä½ç½®ã99ããè¿æ¯ä¸ä¸ªäººèªç±ä¸èªä¸»çéè¦æ¹é¢ã å½éè¿çæ§åºç¡è®¾æ½ä»äººèº«ä¸æåæ°æ®æ¶ï¼éç§æä¸ä¸å®åå°æ害ï¼èæ¯è½¬ç§»å°äºæ°æ®æ¶éè æä¸ãè·åæ°æ®çå ¬å¸å®é ä¸æ¯è¯´ âç¸ä¿¡æ们ä¼ç¨ä½ çæ°æ®åæ£ç¡®çäºæ âï¼è¿æå³çï¼å³å®è¦éé²ä»ä¹åä¿å¯ä»ä¹çæå©ä»ä¸ªä½æä¸è½¬ç§»å°äºå ¬å¸æä¸ã è¿äºå ¬å¸åè¿æ¥éæ©ä¿å¯è¿äºçè§ç»æï¼å 为æé²è¿äºä¼ä»¤äººæ¯éª¨æç¶ï¼å¹¶æ害å®ä»¬çåä¸æ¨¡å¼ï¼æ¯å ¶ä»å ¬å¸æ´äºè§£äººï¼ãç¨æ·çç§å¯ä¿¡æ¯åªä¼é´æ¥å°æ«é²ï¼ä¾å¦é对ç¹å®äººç¾¤å®åææ¾å¹¿åçå·¥å ·ï¼æ¯å¦é£äºæ£æç¹å®ç¾ç ç人群ï¼ã å³ä½¿ç¹å®ç¨æ·æ æ³ä»ç¹å®å¹¿åå®åç人群ä¸ä»¥ä¸ªä½çå½¢å¼åºååºæ¥ï¼ä½ä»ä»¬å·²ç»å¤±å»äºæ«é²ä¸äºç§å¯ä¿¡æ¯çè½å¨æ§ï¼ä¾å¦ä»ä»¬æ¯å¦æ£ææç§ç¾ç ãå³å®åè°éé²ä»ä¹å¹¶ä¸æ¯ç±ä¸ªä½æç §èªå·±çå好å³å®çï¼èæ¯ç± **å ¬å¸**ï¼ä»¥å©æ¶¦æ大å为ç®æ æ¥è¡ä½¿éç§æçã 许å¤å ¬å¸é½æä¸ä¸ªç®æ ï¼ä¸è¦è®©äºº **æè§å°** æ¯éª¨æç¶ ââ å ä¸è¯´å®ä»¬æ¶éæ°æ®å®é ä¸æ¯å¤ä¹å ·æä¾µç¯æ§ï¼è®©æ们å å ³æ³¨å¯¹ç¨æ·æåç管çãè¿äºç¨æ·æåç»å¸¸è¢«ç®¡çå¾å¾ç³ç³ï¼ä¾å¦ï¼å¨äºå®ä¸å¯è½æ£ç¡®çä¸äºä¸è¥¿ï¼å¦æä¼è§¦åçè¦çåå¿ï¼ç¨æ·å¯è½å¹¶ä¸å¸æ被æéã100ãã对äºä»»ä½ç±»åçæ°æ®ï¼æ们é½åºå½èèå®åºéãä¸å¯åãä¸åæ¶å®çå¯è½æ§ï¼å¹¶ä¸éè¦å»ºç«å¤çè¿äºå¤±æçæºå¶ãæ è®ºæ¯ âä¸å¯åâ è¿æ¯ âä¸åæ¶å®âï¼å½ç¶é½æ¯ç±äººçå¤æå³å®çï¼é¤éæ们æç¡®å°å°ç®æ³ç¼ç 设计为å°é人类çéæ±ï¼å¦åç®æ³ä¼æ è§è¿äºæ¦å¿µãä½ä¸ºè¿äºç³»ç»çå·¥ç¨å¸ï¼æä»¬å¿ é¡»ä¿æè°¦åï¼å åè§åï¼æ¥åè¿äºå¤±æã å 许å¨çº¿æå¡çç¨æ·æ§å¶å ¶éç§è®¾ç½®ï¼ä¾å¦æ§å¶å ¶ä»ç¨æ·å¯ä»¥çå°åªäºä¸è¥¿ï¼æ¯å°ä¸äºæ§å¶äº¤è¿ç»ç¨æ·ç第ä¸æ¥ãä½æ 论æä¹è®¾ç½®ï¼æå¡æ¬èº«ä»ç¶å¯ä»¥ä¸åéå¶å°è®¿é®æ°æ®ï¼å¹¶è½ä»¥éç§çç¥å 许çä»»ä½æ¹å¼èªç±ä½¿ç¨å®ãå³ä½¿æå¡æ¿è¯ºä¸ä¼å°æ°æ®åºå®ç»ç¬¬ä¸æ¹ï¼å®é常ä¼æäºèªå·±ä¸åéå¶çæå©ï¼ä»¥ä¾¿å¨å é¨å¤çä¸åææ°æ®ï¼èä¸å¾å¾æ¯ç¨æ·å ¬å¼å¯è§çé¨åè¦æ·±å ¥çå¤ã è¿ç§ä»ä¸ªä½å°å ¬å¸ç大è§æ¨¡éç§æ转移å¨åå²ä¸æ¯å²æ åä¾çã99ããçæ§ä¸ç´åå¨ï¼ä½å®è¿å»æ¯æè´µçãæå¨çï¼ä¸æ¯å¯ä¼¸ç¼©çãèªå¨åçãä¿¡ä»»å ³ç³»ä¸ç´åå¨ï¼ä¾å¦æ£è ä¸å ¶å»çä¹é´ï¼æ被åä¸å ¶å¾å¸ä¹é´ ââ ä½å¨è¿äºæ åµä¸ï¼æ°æ®ç使ç¨ä¸¥æ ¼åå°éå¾·ï¼æ³å¾åç管éå¶ç约æãäºèç½æå¡ä½¿å¾å¨æªç»ææä¹çåæä¸æ¶é大éææä¿¡æ¯åå¾å®¹æå¾å¤ï¼èä¸æ éç¨æ·ç解ä»ä»¬çç§äººæ°æ®å°åºåçäºä»ä¹ã #### æ°æ®èµäº§ä¸æå ç±äºè¡ä¸ºæ°æ®æ¯ç¨æ·ä¸æå¡äº¤äºçå¯äº§åï¼å æ¤ææ¶è¢«ç§°ä¸º âæ°æ®åºæ°â ââ æ示æ°æ®æ¯æ¯«æ ä»·å¼çåºæãä»è¿ä¸ªè§åº¦æ¥çï¼è¡ä¸ºåé¢æµæ§åæå¯ä»¥è¢«çä½æ¯ä¸ç§ä»æ°æ®ä¸æåä»·å¼çåæ¶å½¢å¼ï¼å¦åè¿äºæ°æ®å°±ä¼è¢«æµªè´¹ã æ´åç¡®ççæ³æ°æ°ç¸åï¼ä»ç»æµçè§åº¦æ¥çï¼å¦æå®å广åæ¯æå¡çé主ï¼é£ä¹å ³äºäººçè¡ä¸ºæ°æ®å°±æ¯æå¡çæ ¸å¿èµäº§ãå¨è¿ç§æ åµä¸ï¼ç¨æ·ä¸ä¹äº¤äºçåºç¨ä» ä» æ¯ä¸ç§è¯±éªç¨æ·å°æ´å¤ç个人信æ¯æä¾ç»çæ§åºç¡è®¾æ½çæ段ã99ããå¨çº¿æå¡ä¸ç»å¸¸è¡¨ç°åºç令人ææ¦ç人类åé åä¸ç¤¾ä¼å ³ç³»ï¼åå讽åºå°è¢«æ°æ®æåæºå¨æ滥ç¨ã 个人æ°æ®æ¯çè´µèµäº§ç说æ³å 为æ°æ®ä¸ä»çåå¨å¾å°æ¯æï¼è¿æ¯é´å½±ä¸çç§å¯è¡ä¸ï¼è´ä¹°ãèåãåæãæ¨æ以å转å®ç§å¯ä¸ªäººæ°æ®ï¼ä¸»è¦ç¨äºå¸åºè¥éã90ããååå ¬å¸æç §å®ä»¬çç¨æ·æ°éï¼âç¼çæ°âï¼ââ å³å®ä»¬ççè§è½åæ¥ä¼°å¼ã å 为æ°æ®å¾æä»·å¼ï¼æ以å¾å¤äººé½æ³è¦å®ãå½ç¶ï¼å ¬å¸ä¹æ³è¦å® ââ è¿å°±æ¯ä¸ºä»ä¹å®ä»¬ä¸å¼å§å°±æ¶éæ°æ®çåå ãä½æ¿åºä¹æ³è·å¾å®ï¼éè¿ç§å¯äº¤æãèè¿«ãæ³å¾å¼ºå¶æè åªæ¯çªåã101ããå½å ¬å¸ç ´äº§æ¶ï¼æ¶éå°ç个人æ°æ®å°±æ¯è¢«åºå®çèµäº§ä¹ä¸ãèä¸æ°æ®å®å ¨å¾é¾ä¿æ¤ï¼å æ¤ç»å¸¸åç令人é¾å ªçæ³æ¼äºä»¶ã102ãã è¿äºè§å¯å·²ç»å¯¼è´æ¹è¯è 声称ï¼æ°æ®ä¸ä» ä» æ¯ä¸ç§èµäº§ï¼èä¸æ¯ä¸ç§ âææ¯èµäº§âã101ãï¼æè è³å°æ¯ âæ害ç©è´¨âã103ããå³ä½¿æ们认为èªå·±æè½åé»æ¢æ°æ®æ»¥ç¨ï¼ä½æ¯å½æ们æ¶éæ°æ®æ¶ï¼æ们é½éè¦å¹³è¡¡æ¶ç以åè¿äºæ°æ®è½å ¥æ¶äººæä¸çé£é©ï¼è®¡ç®æºç³»ç»å¯è½ä¼è¢«ç¯ç½ªååææå½ç¹å¡æ¸éï¼æ°æ®å¯è½ä¼è¢«å 鬼æ³é²ï¼å ¬å¸å¯è½ä¼è½å ¥ä¸æ©æ段ç管çå±æä¸ï¼èè¿äºç®¡çè æçè¿¥ç¶ä¸åçä»·å¼è§ï¼æè å½å®¶å¯è½è¢«è½æ¯«æ æ§è²è¿«ä½¿æ们交åºæ°æ®çæ¿æææ¥ç®¡ã ä¿è¯è¯´ï¼âç¥è¯å°±æ¯åéâãæ´è¿ä¸æ¥ï¼âå¨é¿å èªå·±è¢«å®¡è§çåæ¶å®¡è§ä»äººï¼æ¯æåæéè¦çå½¢å¼ä¹ä¸âã105ããè¿å°±æ¯æææ¿åºæ³è¦çæ§çåå ï¼è¿è®©å®ä»¬æè½åæ§å¶å ¨ä½å± æ°ã尽管ä»å¤©çç§æå ¬å¸å¹¶æ²¡æå ¬å¼å°å¯»æ±æ¿æ²»æåï¼ä½æ¯å®ä»¬ç§¯ç´¯çæ°æ®ä¸ç¥è¯å´ç»å®ä»¬å¸¦æ¥äºå¾å¤æåï¼å ¶ä¸å¤§é¨åæ¯å¨å ¬å ±çç£ä¹å¤å·å·è¿è¡çã106ãã #### å顾工ä¸é©å½ æ°æ®æ¯ä¿¡æ¯æ¶ä»£çå³å®æ§ç¹å¾ãäºèç½ï¼æ°æ®åå¨ï¼å¤çå软件驱å¨çèªå¨åæ£å¨å¯¹å ¨çç»æµå人类社ä¼äº§çé大影åãæ们çæ¥å¸¸çæ´»ä¸ç¤¾ä¼ç»ç»å¨è¿å»åå¹´ä¸åçäºååï¼èä¸å¨æªæ¥çåå¹´ä¸å¯è½ä¼ç»§ç»åçæ ¹æ¬æ§çååï¼æ以æ们ä¼æ³å°ä¸å·¥ä¸é©å½å¯¹æ¯ã87,96ãã å·¥ä¸é©å½æ¯éè¿é大çææ¯ä¸åä¸è¿æ¥å®ç°çï¼å®å¸¦æ¥äºæç»çç»æµå¢é¿ï¼é¿æçç活水平æ¾èæé«ãç¶èå®ä¹å¸¦æ¥äºä¸äºä¸¥éçé®é¢ï¼ç©ºæ°æ±¡æï¼ç±äºçé¾ååå¦è¿ç¨ï¼å水污æï¼å·¥ä¸åå¾å人类åå¾ï¼æ¯å¯æçãå·¥åèæ¿çæ´»å¨çº·å¥¢ä¹ä¸ï¼èåå¸å·¥äººç»å¸¸å± ä½å¨é常ç³ç³çä½æ¿ä¸ï¼å¹¶ä¸å¨æ¶å£çæ¡ä»¶ä¸é¿æ¶é´å·¥ä½ã童工å¾å¸¸è§ï¼çè³å æ¬ç¿äºä¸å±é©èä½èªçå·¥ä½ã å¶å®ä¿æ¤æªæ½è±è´¹äºå¾é¿çæ¶é´ï¼ä¾å¦ç¯å¢ä¿æ¤æ¡ä¾ãå·¥ä½åºæå®å ¨æ¡ä¾ã宣å¸ä½¿ç¨ç«¥å·¥éæ³ä»¥åé£åå«çæ£æ¥ã毫æ çé®ï¼ç产ææ¬å¢å äºï¼å 为工ååä¹ä¸è½æåºç©åå ¥æ²³æµãéå®æ±¡æçé£ç©æè å¥å工人ãä½æ¯æ´ä¸ªç¤¾ä¼é½ä»ä¸åçè¯å¤ï¼æ们ä¸å¾å°ä¼æ人æ³åå°è¿äºç®¡å¶æ¡ä¾ä¹åçæ¥åã87ãã å°±åå·¥ä¸é©å½æçé»æé¢éè¦åºå¯¹ä¸æ ·ï¼æ们转åä¿¡æ¯æ¶ä»£çè¿ç¨ä¸ï¼ä¹æéè¦åºå¯¹ä¸è§£å³çé大é®é¢ãæç¸ä¿¡æ°æ®çæ¶éä¸ä½¿ç¨å°±æ¯å ¶ä¸ä¸ä¸ªé®é¢ãç¨ Bruce Schneier çè¯æ¥è¯´ã96ãï¼ > æ°æ®æ¯ä¿¡æ¯æ¶ä»£ç污æé®é¢ï¼ä¿æ¤éç§æ¯ç¯å¢ææãå ä¹ææççµèé½è½ç产信æ¯ãå®å 积å¨å¨å´ï¼å¼å§æºçãæ们å¦ä½å¤çå® ââ æ们å¦ä½æ§å¶å®ï¼ä»¥åå¦ä½æè±å® ââ æ¯ä¿¡æ¯ç»æµå¥åº·åå±çæ ¸å¿è®®é¢ãæ£å¦æ们ä»å¤©å顾工ä¸æ¶ä»£çæ©æ年代ï¼å¹¶æ³ç¥éæ们çç¥å å¨å¿äºå»ºè®¾å·¥ä¸ä¸ççè¿ç¨æ¶æä¹è½å¿½ç¥æ±¡æé®é¢ï¼æ们çåè¾å¨åæä¿¡æ¯æ¶ä»£çæ©æ年代æ¶ï¼å°ä¼å°±æ们å¦ä½åºå¯¹æ°æ®æ¶éå滥ç¨çæææ¥è¯ææ们ã > > æ们åºè¯¥è®¾æ³è®©ä»ä»¬æå°éªå²ã #### ç«æ³ä¸èªå¾ æ°æ®ä¿æ¤æ³å¯è½æå©äºç»´æ¤ä¸ªäººçæå©ãä¾å¦ï¼1995 å¹´ç â欧洲æ°æ®ä¿æ¤æ示â è§å®ï¼ä¸ªäººæ°æ®å¿ é¡» â为ç¹å®çãæç¡®çååæ³çç®çæ¶éï¼èä¸æ¯ä»¥ä¸è¿äºç®çä¸ç¸ç¬¦çæ¹å¼è¿ä¸æ¥å¤çâï¼å¹¶ä¸æ°æ®å¿ é¡» âå°±æ¶éçç®çèè¨éå½ãç¸å ³ãä¸è¿åãâã107ãã ä½æ¯ï¼è¿ä¸ªç«æ³å¨ä»å¤©çäºèç½ç¯å¢ä¸æ¯å¦ææè¿æ¯æçé®çã108ããè¿äºè§åç´æ¥å¦å®äºå¤§æ°æ®çå²å¦ï¼å³æ大é度å°æ¶éæ°æ®ï¼å°å ¶ä¸å ¶ä»æ°æ®éç»åèµ·æ¥è¿è¡è¯éªåæ¢ç´¢ï¼ä»¥ä¾¿äº§çæ°çæ´å¯ãæ¢ç´¢æå³çå°æ°æ®ç¨äºæªæ¾é¢æçç®çï¼è¿ä¸ç¨æ·åæç âç¹å®åæç¡®â ç®çç¸åï¼å¦ææ们å¯ä»¥ææä¹å°è¡¨ç¤ºåæçè¯ï¼ã109ããæ´æ°çè§ç« æ£å¨å¶å®ä¸ã89ãã é£äºæ¶éäºå¤§éæå ³äººçæ°æ®çå ¬å¸å对ç管ï¼è®¤ä¸ºè¿æ¯åæ°çè´æ ä¸é»ç¢ãå¨æç§ç¨åº¦ä¸ï¼è¿ç§å对æ¯æéççãä¾å¦ï¼å享å»çæ°æ®æ¶ï¼åå¨ææ¾çéç§é£é©ï¼ä½ä¹ææ½å¨çæºéï¼å¦ææ°æ®åæè½å¤å¸®å©æ们å®ç°æ´å¥½çè¯æææ¾å°æ´å¥½çæ²»çæ¹æ³ï¼è½å¤é»æ¢å¤å°äººçæ»äº¡ã110ãï¼è¿åº¦ç管å¯è½ä¼é»æ¢è¿ç§çªç ´ãå¨è¿ç§æ½å¨æºä¼ä¸é£é©ä¹é´æ¾åºå¹³è¡¡æ¯å¾å°é¾çã105ãã ä»æ ¹æ¬ä¸è¯´ï¼æ认为æ们éè¦ç§æè¡ä¸å¨ä¸ªäººæ°æ®æ¹é¢çæå转åãæ们åºè¯¥åæ¢å°ç¨æ·è§ä½å¾ ä¼åçææ æ°æ®ï¼å¹¶è®°ä½ä»ä»¬æ¯å¼å¾å°éãæå°ä¸¥åè½å¨æ§ç人ãæ们åºå½å¨æ°æ®æ¶éåå®é å¤çä¸èªæ约æï¼ä»¥å»ºç«åç»´æä¾èµæ们软件ç人们çä¿¡ä»»ã111ããæ们åºå½å°æè²ç»ç«¯ç¨æ·è§ä¸ºå·±ä»»ï¼åè¯ä»ä»¬æ们æ¯å¦ä½ä½¿ç¨ä»ä»¬çæ°æ®çï¼èä¸æ¯å°ä»ä»¬èå¨é¼éã æ们åºè¯¥å 许æ¯ä¸ªäººä¿çèªå·±çéç§ ââ å³ï¼å¯¹èªå·±æ°æ®çæ§å¶ ââ èä¸æ¯éè¿çè§æ¥çªåè¿ç§æ§å¶æãæ们æ§å¶èªå·±æ°æ®ç个ä½æå©å°±åæ¯å½å®¶å ¬åçèªç¶ç¯å¢ï¼å¦ææ们ä¸å»æç¡®å°ä¿æ¤å®ãå ³å¿å®ï¼å®å°±ä¼è¢«ç ´åãè¿å°æ¯å ¬å°çæ²å§ï¼æ们é½ä¼å æ¤èåå¾æ´ç³ãæ æä¸å¨ççè§å¹¶éä¸å¯é¿å ç ââ æ们ç°å¨ä»ç¶è½é»æ¢å®ã æ们究ç«è½åå°åªä¸æ¥ï¼æ¯ä¸ä¸ªå¼æ¾çé®é¢ãé¦å ï¼æ们ä¸åºè¯¥æ°¸ä¹ ä¿çæ°æ®ï¼èæ¯ä¸æ¦ä¸åéè¦å°±ç«å³æ¸ é¤æ°æ®ã111,112ããæ¸ é¤æ°æ®ä¸ä¸åæ§çæ³æ³èéèé©°ï¼è¯·åé â[ä¸åæ§çå±éæ§](ch11.md#ä¸åæ§çå±éæ§)âï¼ï¼ä½è¿æ¯å¯ä»¥è§£å³çé®é¢ãææçå°çä¸ç§å¾æåæ¯çæ¹æ³æ¯éè¿å å¯åè®®æ¥å®æ½è®¿é®æ§å¶ï¼èä¸ä» ä» æ¯éè¿çç¥ã113,114ããæ»çæ¥è¯´ï¼æåä¸æ度çæ¹åæ¯å¿ è¦çã ## æ¬ç« å°ç» å¨æ¬ç« ä¸ï¼æ们讨论äºè®¾è®¡æ°æ®ç³»ç»çæ°æ¹å¼ï¼èä¸ä¹å æ¬äºæç个人è§ç¹ï¼ä»¥å对æªæ¥ççæµãæ们ä»è¿æ ·ä¸ç§è§å¯å¼å§ï¼æ²¡æåç§å·¥å ·è½é«ææå¡ææå¯è½çç¨ä¾ï¼å æ¤åºç¨å¿ é¡»ç»å使ç¨å ç§ä¸åç软件æè½å®ç°å ¶ç®æ ãæ们讨论äºå¦ä½ä½¿ç¨æ¹å¤çä¸äºä»¶æµæ¥è§£å³è¿ä¸ **æ°æ®éæï¼data integrationï¼** é®é¢ï¼ä»¥ä¾¿è®©æ°æ®åæ´å¨ä¸åç³»ç»ä¹é´æµå¨ã å¨è¿ç§æ¹æ³ä¸ï¼æäºç³»ç»è¢«æå®ä¸ºè®°å½ç³»ç»ï¼èå ¶ä»æ°æ®åéè¿è½¬æ¢è¡çèªè®°å½ç³»ç»ãéè¿è¿ç§æ¹å¼ï¼æ们å¯ä»¥ç»´æ¤ç´¢å¼ï¼ç©åè§å¾ï¼æºå¨å¦ä¹ 模åï¼ç»è®¡æè¦ççãéè¿ä½¿è¿äºè¡çå转æ¢æä½å¼æ¥ä¸æ¾æ£è¦åï¼è½å¤é²æ¢ä¸ä¸ªåºåä¸çé®é¢æ©æ£å°ç³»ç»ä¸ä¸ç¸å ³é¨åï¼ä»èå¢å æ´ä¸ªç³»ç»ç稳å¥æ§ä¸å®¹éæ§ã å°æ°æ®æµè¡¨ç¤ºä¸ºä»ä¸ä¸ªæ°æ®éå°å¦ä¸ä¸ªæ°æ®éç转æ¢ä¹æå©äºæ¼ååºç¨ç¨åºï¼å¦æä½ æ³åæ´å ¶ä¸ä¸ä¸ªå¤çæ¥éª¤ï¼ä¾å¦åæ´ç´¢å¼æç¼åçç»æï¼åå¯ä»¥å¨æ´ä¸ªè¾å ¥æ°æ®éä¸éæ°è¿è¡æ°ç转æ¢ä»£ç ï¼ä»¥ä¾¿éæ°è¡çè¾åºãåæ ·ï¼åºç°é®é¢æ¶ï¼ä½ ä¹å¯ä»¥ä¿®å¤ä»£ç 并éæ°å¤çæ°æ®ä»¥ä¾¿æ¢å¤ã è¿äºè¿ç¨ä¸æ°æ®åºå é¨å·²ç»å®æçè¿ç¨é常类似ï¼å æ¤æ们å°æ°æ®æµåºç¨çæ¦å¿µéæ°æ¹å为ï¼**åæï¼unbundlingï¼** æ°æ®åºç»ä»¶ï¼å¹¶éè¿ç»åè¿äºæ¾æ£è¦åçç»ä»¶æ¥æ建åºç¨ç¨åºã è¡çç¶æå¯ä»¥éè¿è§å¯åºå±æ°æ®çåæ´æ¥æ´æ°ãæ¤å¤ï¼è¡çç¶ææ¬èº«å¯ä»¥è¿ä¸æ¥è¢«ä¸æ¸¸æ¶è´¹è è§å¯ãæ们çè³å¯ä»¥å°è¿ç§æ°æ®æµä¸è·¯ä¼ éè³æ¾ç¤ºæ°æ®çç»ç«¯ç¨æ·è®¾å¤ï¼ä»èæ建å¯å¨ææ´æ°ä»¥åæ æ°æ®åæ´ï¼å¹¶å¨ç¦»çº¿æ¶è½ç»§ç»å·¥ä½çç¨æ·çé¢ã æ¥ä¸æ¥ï¼æ们讨论äºå¦ä½ç¡®ä¿ææè¿äºå¤çå¨åºç°æ éæ¶ä¿ææ£ç¡®ãæ们çå°å¯ä¼¸ç¼©ç强å®æ´æ§ä¿è¯å¯ä»¥éè¿å¼æ¥äºä»¶å¤çæ¥å®ç°ï¼éè¿ä½¿ç¨ç«¯å°ç«¯æä½æ è¯ç¬¦ä½¿æä½å¹çï¼ä»¥åéè¿å¼æ¥æ£æ¥çº¦æã客æ·ç«¯å¯ä»¥çå°æ£æ¥éè¿ï¼æè ä¸çå¾ ç»§ç»åè¿ï¼ä½æ¯å¯è½ä¼åæè¿å约æéè¦éæçé£é©ãè¿ç§æ¹æ³æ¯ä½¿ç¨åå¸å¼äºå¡çä¼ ç»æ¹æ³æ´å ·å¯ä¼¸ç¼©æ§ä¸å¯é æ§ï¼å¹¶ä¸å¨å®è·µä¸éç¨äºå¾å¤ä¸å¡æµç¨ã éè¿å´ç»æ°æ®æµæ建åºç¨ï¼å¹¶å¼æ¥æ£æ¥çº¦æï¼æ们å¯ä»¥é¿å ç»å¤§å¤æ°çåè°å·¥ä½ï¼å建ä¿è¯å®æ´æ§ä¸æ§è½ä»ç¶è¡¨ç°è¯å¥½çç³»ç»ï¼å³ä½¿å¨å°çæ£å¸çæ åµä¸ä¸åºç°æ éæ¶äº¦ç¶ãç¶åï¼æ们对使ç¨å®¡è®¡æ¥éªè¯æ°æ®å®æ´æ§ï¼ä»¥åæåæ£æµè¿è¡äºä¸äºè®¨è®ºã æåï¼æ们éåä¸æ¥ï¼å®¡è§äºæ建æ°æ®å¯éååºç¨çä¸äºéå¾·é®é¢ãæ们çå°ï¼è½ç¶æ°æ®å¯ä»¥ç¨æ¥å好äºï¼ä½å®ä¹å¯è½é æå¾å¤§ä¼¤å®³ï¼ä½åºä¸¥éå½±å人们çæ´»çå³å®å´é¾ä»¥ç³è¯ï¼å¯¼è´æ§è§ä¸å¥åãçè§å¸¸æåãæå ç§å¯ä¿¡æ¯ãæ们ä¹åçæ°æ®è¢«æ³é²çé£é©ï¼å¹¶ä¸å¯è½ä¼åç°ï¼å³ä½¿æ¯åæå°ä½¿ç¨æ°æ®ä¹å¯è½ä¼å¯¼è´ææ³ä¸å°çåæã ç±äºè½¯ä»¶åæ°æ®å¯¹ä¸ç产çäºå¦æ¤å·¨å¤§çå½±åï¼æ们工ç¨å¸ä»¬å¿ é¡»ç¢è®°ï¼æ们æ责任为æ们æ³è¦çé£ç§ä¸çèåªåï¼ä¸ä¸ªå°é人们ï¼å°é人æ§çä¸çãæå¸ææ们è½å¤ä¸èµ·ä¸ºå®ç°è¿ä¸ç®æ èåªåã ## åèæç® 1. Rachid Belaid: â[Postgres Full-Text Search is Good Enough!](http://rachbelaid.com/postgres-full-text-search-is-good-enough/),â *rachbelaid.com*, July 13, 2015. 1. Philippe Ajoux, Nathan Bronson, Sanjeev Kumar, et al.: â[Challenges to Adopting Stronger Consistency at Scale](https://www.usenix.org/system/files/conference/hotos15/hotos15-paper-ajoux.pdf),â at *15th USENIX Workshop on Hot Topics in Operating Systems* (HotOS), May 2015. 1. Pat Helland and Dave Campbell: â[Building on Quicksand](https://database.cs.wisc.edu/cidr/cidr2009/Paper_133.pdf),â at *4th Biennial Conference on Innovative Data Systems Research* (CIDR), January 2009. 1. Jessica Kerr: â[Provenance and Causality in Distributed Systems](http://blog.jessitron.com/2016/09/provenance-and-causality-in-distributed.html),â *blog.jessitron.com*, September 25, 2016. 1. Kostas Tzoumas: â[Batch Is a Special Case of Streaming](http://data-artisans.com/batch-is-a-special-case-of-streaming/),â *data-artisans.com*, September 15, 2015. 1. Shinji Kim and Robert Blafford: â[Stream Windowing Performance Analysis: Concord and Spark Streaming](http://concord.io/posts/windowing_performance_analysis_w_spark_streaming),â *concord.io*, July 6, 2016. 1. Jay Kreps: â[The Log: What Every Software Engineer Should Know About Real-Time Data's Unifying Abstraction](http://engineering.linkedin.com/distributed-systems/log-what-every-software-engineer-should-know-about-real-time-datas-unifying),â *engineering.linkedin.com*, December 16, 2013. 1. Pat Helland: â[Life Beyond Distributed Transactions: An Apostateâs Opinion](http://www-db.cs.wisc.edu/cidr/cidr2007/papers/cidr07p15.pdf),â at *3rd Biennial Conference on Innovative Data Systems Research* (CIDR), January 2007. 1. â[Great Western Railway (1835â1948)](https://www.networkrail.co.uk/VirtualArchive/great-western/),â Network Rail Virtual Archive, *networkrail.co.uk*. 1. Jacqueline Xu: â[Online Migrations at Scale](https://stripe.com/blog/online-migrations),â *stripe.com*, February 2, 2017. 1. Molly Bartlett Dishman and Martin Fowler: â[Agile Architecture](http://conferences.oreilly.com/software-architecture/sa2015/public/schedule/detail/40388),â at *O'Reilly Software Architecture Conference*, March 2015. 1. Nathan Marz and James Warren: *Big Data: Principles and Best Practices of Scalable Real-Time Data Systems*. Manning, 2015. ISBN: 978-1-617-29034-3 1. Oscar Boykin, Sam Ritchie, Ian O'Connell, and Jimmy Lin: â[Summingbird: A Framework for Integrating Batch and Online MapReduce Computations](http://www.vldb.org/pvldb/vol7/p1441-boykin.pdf),â at *40th International Conference on Very Large Data Bases* (VLDB), September 2014. 1. Jay Kreps: â[Questioning the Lambda Architecture](https://www.oreilly.com/ideas/questioning-the-lambda-architecture),â *oreilly.com*, July 2, 2014. 1. Raul Castro Fernandez, Peter Pietzuch, Jay Kreps, et al.: â[Liquid: Unifying Nearline and Offline Big Data Integration](http://www.cidrdb.org/cidr2015/Papers/CIDR15_Paper25u.pdf),â at *7th Biennial Conference on Innovative Data Systems Research* (CIDR), January 2015. 1. Dennis M. Ritchie and Ken Thompson: â[The UNIX Time-Sharing System](http://www.cs.virginia.edu/~zaher/classes/CS656/p365-ritchie.pdf),â *Communications of the ACM*, volume 17, number 7, pages 365â375, July 1974. [doi:10.1145/361011.361061](http://dx.doi.org/10.1145/361011.361061) 1. Eric A. Brewer and Joseph M. Hellerstein: â[CS262a: Advanced Topics in Computer Systems](http://people.eecs.berkeley.edu/~brewer/cs262/systemr.html),â lecture notes, University of California, Berkeley, *cs.berkeley.edu*, August 2011. 1. Michael Stonebraker: â[The Case for Polystores](http://wp.sigmod.org/?p=1629),â *wp.sigmod.org*, July 13, 2015. 1. Jennie Duggan, Aaron J. Elmore, Michael Stonebraker, et al.: â[The BigDAWG Polystore System](http://dspace.mit.edu/openaccess-disseminate/1721.1/100936),â *ACM SIGMOD Record*, volume 44, number 2, pages 11â16, June 2015. [doi:10.1145/2814710.2814713](http://dx.doi.org/10.1145/2814710.2814713) 1. Patrycja Dybka: â[Foreign Data Wrappers for PostgreSQL](http://www.vertabelo.com/blog/technical-articles/foreign-data-wrappers-for-postgresql),â *vertabelo.com*, March 24, 2015. 1. David B. Lomet, Alan Fekete, Gerhard Weikum, and Mike Zwilling: â[Unbundling Transaction Services in the Cloud](https://www.microsoft.com/en-us/research/publication/unbundling-transaction-services-in-the-cloud/),â at *4th Biennial Conference on Innovative Data Systems Research* (CIDR), January 2009. 1. Martin Kleppmann and Jay Kreps: â[Kafka, Samza and the Unix Philosophy of Distributed Data](http://martin.kleppmann.com/papers/kafka-debull15.pdf),â *IEEE Data Engineering Bulletin*, volume 38, number 4, pages 4â14, December 2015. 1. John Hugg: â[Winning Now and in the Future: Where VoltDB Shines](https://voltdb.com/blog/winning-now-and-future-where-voltdb-shines),â *voltdb.com*, March 23, 2016. 1. Frank McSherry, Derek G. Murray, Rebecca Isaacs, and Michael Isard: â[Differential Dataflow](http://cidrdb.org/cidr2013/Papers/CIDR13_Paper111.pdf),â at *6th Biennial Conference on Innovative Data Systems Research* (CIDR), January 2013. 1. Derek G Murray, Frank McSherry, Rebecca Isaacs, et al.: â[Naiad: A Timely Dataflow System](http://research.microsoft.com/pubs/201100/naiad_sosp2013.pdf),â at *24th ACM Symposium on Operating Systems Principles* (SOSP), pages 439â455, November 2013. [doi:10.1145/2517349.2522738](http://dx.doi.org/10.1145/2517349.2522738) 1. Gwen Shapira: â[We have a bunch of customers who are implementing âdatabase inside-outâ concept and they all ask âis anyone else doing it? are we crazy?â](https://twitter.com/gwenshap/status/758800071110430720)â *twitter.com*, July 28, 2016. 1. Martin Kleppmann: â[Turning the Database Inside-out with Apache Samza,](http://martin.kleppmann.com/2015/03/04/turning-the-database-inside-out.html)â at *Strange Loop*, September 2014. 1. Peter Van Roy and Seif Haridi: *Concepts, Techniques, and Models of Computer Programming*. MIT Press, 2004. ISBN: 978-0-262-22069-9 1. â[Juttle Documentation](http://juttle.github.io/juttle/),â *juttle.github.io*, 2016. 1. Evan Czaplicki and Stephen Chong: â[Asynchronous Functional Reactive Programming for GUIs](http://people.seas.harvard.edu/~chong/pubs/pldi13-elm.pdf),â at *34th ACM SIGPLAN Conference on Programming Language Design and Implementation* (PLDI), June 2013. [doi:10.1145/2491956.2462161](http://dx.doi.org/10.1145/2491956.2462161) 1. Engineer Bainomugisha, Andoni Lombide Carreton, Tom van Cutsem, Stijn Mostinckx, and Wolfgang de Meuter: â[A Survey on Reactive Programming](http://soft.vub.ac.be/Publications/2012/vub-soft-tr-12-13.pdf),â *ACM Computing Surveys*, volume 45, number 4, pages 1â34, August 2013. [doi:10.1145/2501654.2501666](http://dx.doi.org/10.1145/2501654.2501666) 1. Peter Alvaro, Neil Conway, Joseph M. Hellerstein, and William R. Marczak: â[Consistency Analysis in Bloom: A CALM and Collected Approach](http://www.eecs.berkeley.edu/~palvaro/cidr11.pdf),â at *5th Biennial Conference on Innovative Data Systems Research* (CIDR), January 2011. 1. Felienne Hermans: â[Spreadsheets Are Code](https://vimeo.com/145492419),â at *Code Mesh*, November 2015. 1. Dan Bricklin and Bob Frankston: â[VisiCalc: Information from Its Creators](http://danbricklin.com/visicalc.htm),â *danbricklin.com*. 1. D. Sculley, Gary Holt, Daniel Golovin, et al.: â[Machine Learning: The High-Interest Credit Card of Technical Debt](http://research.google.com/pubs/pub43146.html),â at *NIPS Workshop on Software Engineering for Machine Learning* (SE4ML), December 2014. 1. Peter Bailis, Alan Fekete, Michael J Franklin, et al.: â[Feral Concurrency Control: An Empirical Investigation of Modern Application Integrity](http://www.bailis.org/papers/feral-sigmod2015.pdf),â at *ACM International Conference on Management of Data* (SIGMOD), June 2015. [doi:10.1145/2723372.2737784](http://dx.doi.org/10.1145/2723372.2737784) 1. Guy Steele: â[Re: Need for Macros (Was Re: Icon)](https://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg01134.html),â email to *ll1-discuss* mailing list, *people.csail.mit.edu*, December 24, 2001. 1. David Gelernter: â[Generative Communication in Linda](http://cseweb.ucsd.edu/groups/csag/html/teaching/cse291s03/Readings/p80-gelernter.pdf),â *ACM Transactions on Programming Languages and Systems* (TOPLAS), volume 7, number 1, pages 80â112, January 1985. [doi:10.1145/2363.2433](http://dx.doi.org/10.1145/2363.2433) 1. Patrick Th. Eugster, Pascal A. Felber, Rachid Guerraoui, and Anne-Marie Kermarrec: â[The Many Faces of Publish/Subscribe](http://www.cs.ru.nl/~pieter/oss/manyfaces.pdf),â *ACM Computing Surveys*, volume 35, number 2, pages 114â131, June 2003. [doi:10.1145/857076.857078](http://dx.doi.org/10.1145/857076.857078) 1. Ben Stopford: â[Microservices in a Streaming World](https://www.infoq.com/presentations/microservices-streaming),â at *QCon London*, March 2016. 1. Christian Posta: â[Why Microservices Should Be Event Driven: Autonomy vs Authority](http://blog.christianposta.com/microservices/why-microservices-should-be-event-driven-autonomy-vs-authority/),â *blog.christianposta.com*, May 27, 2016. 1. Alex Feyerke: â[Say Hello to Offline First](http://hood.ie/blog/say-hello-to-offline-first.html),â *hood.ie*, November 5, 2013. 1. Sebastian Burckhardt, Daan Leijen, Jonathan Protzenko, and Manuel Fähndrich: â[Global Sequence Protocol: A Robust Abstraction for Replicated Shared State](http://drops.dagstuhl.de/opus/volltexte/2015/5238/),â at *29th European Conference on Object-Oriented Programming* (ECOOP), July 2015. [doi:10.4230/LIPIcs.ECOOP.2015.568](http://dx.doi.org/10.4230/LIPIcs.ECOOP.2015.568) 1. Mark Soper: â[Clearing Up React Data Management Confusion with Flux, Redux, and Relay](https://medium.com/@marksoper/clearing-up-react-data-management-confusion-with-flux-redux-and-relay-aad504e63cae),â *medium.com*, December 3, 2015. 1. Eno Thereska, Damian Guy, Michael Noll, and Neha Narkhede: â[Unifying Stream Processing and Interactive Queries in Apache Kafka](http://www.confluent.io/blog/unifying-stream-processing-and-interactive-queries-in-apache-kafka/),â *confluent.io*, October 26, 2016. 1. Frank McSherry: â[Dataflow as Database](https://github.com/frankmcsherry/blog/blob/master/posts/2016-07-17.md),â *github.com*, July 17, 2016. 1. Peter Alvaro: â[I See What You Mean](https://www.youtube.com/watch?v=R2Aa4PivG0g),â at *Strange Loop*, September 2015. 1. Nathan Marz: â[Trident: A High-Level Abstraction for Realtime Computation](https://blog.twitter.com/2012/trident-a-high-level-abstraction-for-realtime-computation),â *blog.twitter.com*, August 2, 2012. 1. Edi Bice: â[Low Latency Web Scale Fraud Prevention with Apache Samza, Kafka and Friends](http://www.slideshare.net/edibice/extremely-low-latency-web-scale-fraud-prevention-with-apache-samza-kafka-and-friends),â at *Merchant Risk Council MRC Vegas Conference*, March 2016. 1. Charity Majors: â[The Accidental DBA](https://charity.wtf/2016/10/02/the-accidental-dba/),â *charity.wtf*, October 2, 2016. 1. Arthur J. Bernstein, Philip M. Lewis, and Shiyong Lu: â[Semantic Conditions for Correctness at Different Isolation Levels](http://db.cs.berkeley.edu/cs286/papers/isolation-icde2000.pdf),â at *16th International Conference on Data Engineering* (ICDE), February 2000. [doi:10.1109/ICDE.2000.839387](http://dx.doi.org/10.1109/ICDE.2000.839387) 1. Sudhir Jorwekar, Alan Fekete, Krithi Ramamritham, and S. Sudarshan: â[Automating the Detection of Snapshot Isolation Anomalies](http://www.vldb.org/conf/2007/papers/industrial/p1263-jorwekar.pdf),â at *33rd International Conference on Very Large Data Bases* (VLDB), September 2007. 1. Kyle Kingsbury: [Jepsen blog post series](https://aphyr.com/tags/jepsen), *aphyr.com*, 2013â2016. 1. Michael Jouravlev: â[Redirect After Post](http://www.theserverside.com/news/1365146/Redirect-After-Post),â *theserverside.com*, August 1, 2004. 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. Peter Bailis, Alan Fekete, Michael J. Franklin, et al.: â[Coordination-Avoiding Database Systems](http://arxiv.org/pdf/1402.2237.pdf),â *Proceedings of the VLDB Endowment*, volume 8, number 3, pages 185â196, November 2014. 1. Alex Yarmula: â[Strong Consistency in Manhattan](https://blog.twitter.com/2016/strong-consistency-in-manhattan),â *blog.twitter.com*, March 17, 2016. 1. Douglas B Terry, Marvin M Theimer, Karin Petersen, et al.: â[Managing Update Conflicts in Bayou, a Weakly Connected Replicated Storage System](http://css.csail.mit.edu/6.824/2014/papers/bayou-conflicts.pdf),â at *15th ACM Symposium on Operating Systems Principles* (SOSP), pages 172â182, December 1995. [doi:10.1145/224056.224070](http://dx.doi.org/10.1145/224056.224070) 1. Jim Gray: â[The Transaction Concept: Virtues and Limitations](http://research.microsoft.com/en-us/um/people/gray/papers/theTransactionConcept.pdf),â at *7th International Conference on Very Large Data Bases* (VLDB), September 1981. 1. Hector Garcia-Molina and Kenneth Salem: â[Sagas](http://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf),â at *ACM International Conference on Management of Data* (SIGMOD), May 1987. [doi:10.1145/38713.38742](http://dx.doi.org/10.1145/38713.38742) 1. Pat Helland: â[Memories, Guesses, and Apologies](http://blogs.msdn.com/b/pathelland/archive/2007/05/15/memories-guesses-and-apologies.aspx),â *blogs.msdn.com*, May 15, 2007. 1. Yoongu Kim, Ross Daly, Jeremie Kim, et al.: â[Flipping Bits in Memory Without Accessing Them: An Experimental Study of DRAM Disturbance Errors](https://users.ece.cmu.edu/~yoonguk/papers/kim-isca14.pdf),â at *41st Annual International Symposium on Computer Architecture* (ISCA), June 2014. [doi:10.1145/2678373.2665726](http://dx.doi.org/10.1145/2678373.2665726) 1. Mark Seaborn and Thomas Dullien: â[Exploiting the DRAM Rowhammer Bug to Gain Kernel Privileges](https://googleprojectzero.blogspot.co.uk/2015/03/exploiting-dram-rowhammer-bug-to-gain.html),â *googleprojectzero.blogspot.co.uk*, March 9, 2015. 1. Jim N. Gray and Catharine van Ingen: â[Empirical Measurements of Disk Failure Rates and Error Rates](https://www.microsoft.com/en-us/research/publication/empirical-measurements-of-disk-failure-rates-and-error-rates/),â Microsoft Research, MSR-TR-2005-166, December 2005. 1. Annamalai Gurusami and Daniel Price: â[Bug #73170: Duplicates in Unique Secondary Index Because of Fix of Bug#68021](http://bugs.mysql.com/bug.php?id=73170),â *bugs.mysql.com*, July 2014. 1. Gary Fredericks: â[Postgres Serializability Bug](https://github.com/gfredericks/pg-serializability-bug),â *github.com*, September 2015. 1. Xiao Chen: â[HDFS DataNode Scanners and Disk Checker Explained](http://blog.cloudera.com/blog/2016/12/hdfs-datanode-scanners-and-disk-checker-explained/),â *blog.cloudera.com*, December 20, 2016. 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. Martin Fowler: â[The LMAX Architecture](http://martinfowler.com/articles/lmax.html),â *martinfowler.com*, July 12, 2011. 1. Sam Stokes: â[Move Fast with Confidence](http://blog.samstokes.co.uk/blog/2016/07/11/move-fast-with-confidence/),â *blog.samstokes.co.uk*, July 11, 2016. 1. â[Sawtooth Lake Documentation](http://intelledger.github.io/introduction.html),â Intel Corporation, *intelledger.github.io*, 2016. 1. Richard Gendal Brown: â[Introducing R3 Cordaâ¢: A Distributed Ledger Designed for Financial Services](https://gendal.me/2016/04/05/introducing-r3-corda-a-distributed-ledger-designed-for-financial-services/),â *gendal.me*, April 5, 2016. 1. Trent McConaghy, Rodolphe Marques, Andreas Müller, et al.: â[BigchainDB: A Scalable Blockchain Database](https://www.bigchaindb.com/whitepaper/bigchaindb-whitepaper.pdf),â *bigchaindb.com*, June 8, 2016. 1. Ralph C. Merkle: â[A Digital Signature Based on a Conventional Encryption Function](https://people.eecs.berkeley.edu/~raluca/cs261-f15/readings/merkle.pdf),â at *CRYPTO '87*, August 1987. [doi:10.1007/3-540-48184-2_32](http://dx.doi.org/10.1007/3-540-48184-2_32) 1. Ben Laurie: â[Certificate Transparency](http://queue.acm.org/detail.cfm?id=2668154),â *ACM Queue*, volume 12, number 8, pages 10-19, August 2014. [doi:10.1145/2668152.2668154](http://dx.doi.org/10.1145/2668152.2668154) 1. Mark D. Ryan: â[Enhanced Certificate Transparency and End-to-End Encrypted Mail](http://www.internetsociety.org/doc/enhanced-certificate-transparency-and-end-end-encrypted-mail),â at *Network and Distributed System Security Symposium* (NDSS), February 2014. [doi:10.14722/ndss.2014.23379](http://dx.doi.org/10.14722/ndss.2014.23379) 1. âSoftware Engineering Code of Ethics and Professional Practice,â Association for Computing Machinery, *acm.org*, 1999. 1. François Chollet: â[Software development is starting to involve important ethical choices](https://twitter.com/fchollet/status/792958695722201088),â *twitter.com*, October 30, 2016. 1. Igor Perisic: â[Making Hard Choices: The Quest for Ethics in Machine Learning](https://engineering.linkedin.com/blog/2016/11/making-hard-choices--the-quest-for-ethics-in-machine-learning),â *engineering.linkedin.com*, November 2016. 1. John Naughton: â[Algorithm Writers Need a Code of Conduct](https://www.theguardian.com/commentisfree/2015/dec/06/algorithm-writers-should-have-code-of-conduct),â *theguardian.com*, December 6, 2015. 1. Logan Kugler: â[What Happens When Big Data Blunders?](http://cacm.acm.org/magazines/2016/6/202655-what-happens-when-big-data-blunders/fulltext),â *Communications of the ACM*, volume 59, number 6, pages 15â16, June 2016. [doi:10.1145/2911975](http://dx.doi.org/10.1145/2911975) 1. Bill Davidow: â[Welcome to Algorithmic Prison](http://www.theatlantic.com/technology/archive/2014/02/welcome-to-algorithmic-prison/283985/),â *theatlantic.com*, February 20, 2014. 1. Don Peck: â[They're Watching You at Work](http://www.theatlantic.com/magazine/archive/2013/12/theyre-watching-you-at-work/354681/),â *theatlantic.com*, December 2013. 1. Leigh Alexander: â[Is an Algorithm Any Less Racist Than a Human?](https://www.theguardian.com/technology/2016/aug/03/algorithm-racist-human-employers-work)â *theguardian.com*, August 3, 2016. 1. Jesse Emspak: â[How a Machine Learns Prejudice](https://www.scientificamerican.com/article/how-a-machine-learns-prejudice/),â *scientificamerican.com*, December 29, 2016. 1. Maciej CegÅowski: â[The Moral Economy of Tech](http://idlewords.com/talks/sase_panel.htm),â *idlewords.com*, June 2016. 1. Cathy O'Neil: *Weapons of Math Destruction: How Big Data Increases Inequality and Threatens Democracy*. Crown Publishing, 2016. ISBN: 978-0-553-41881-1 1. Julia Angwin: â[Make Algorithms Accountable](http://www.nytimes.com/2016/08/01/opinion/make-algorithms-accountable.html),â *nytimes.com*, August 1, 2016. 1. Bryce Goodman and Seth Flaxman: â[European Union Regulations on Algorithmic Decision-Making and a âRight to Explanationâ](https://arxiv.org/abs/1606.08813),â *arXiv:1606.08813*, August 31, 2016. 1. â[A Review of the Data Broker Industry: Collection, Use, and Sale of Consumer Data for Marketing Purposes](https://www.commerce.senate.gov/public/index.cfm/reports?ID=57C428EC-8F20-44EE-BFB8-A570E9BE0CCC),â Staff Report, *United States Senate Committee on Commerce, Science, and Transportation*, *commerce.senate.gov*, December 2013. 1. Olivia Solon: â[Facebookâs Failure: Did Fake News and Polarized Politics Get Trump Elected?](https://www.theguardian.com/technology/2016/nov/10/facebook-fake-news-election-conspiracy-theories)â *theguardian.com*, November 10, 2016. 1. Donella H. Meadows and Diana Wright: *Thinking in Systems: A Primer*. Chelsea Green Publishing, 2008. ISBN: 978-1-603-58055-7 1. Daniel J. Bernstein: â[Listening to a âbig dataâ/âdata scienceâ talk](https://twitter.com/hashbreaker/status/598076230437568512),â *twitter.com*, May 12, 2015. 1. Marc Andreessen: â[Why Software Is Eating the World](http://genius.com/Marc-andreessen-why-software-is-eating-the-world-annotated),â *The Wall Street Journal*, 20 August 2011. 1. J. M. Porup: â[âInternet of Thingsâ Security Is Hilariously Broken and Getting Worse](http://arstechnica.com/security/2016/01/how-to-search-the-internet-of-things-for-photos-of-sleeping-babies/),â *arstechnica.com*, January 23, 2016. 1. Bruce Schneier: *Data and Goliath: The Hidden Battles to Collect Your Data and Control Your World*. W. W. Norton, 2015. ISBN: 978-0-393-35217-7 1. The Grugq: â[Nothing to Hide](https://grugq.tumblr.com/post/142799983558/nothing-to-hide),â *grugq.tumblr.com*, April 15, 2016. 1. Tony Beltramelli: â[Deep-Spying: Spying Using Smartwatch and Deep Learning](https://arxiv.org/abs/1512.05616),â Masters Thesis, IT University of Copenhagen, December 2015. Available at *arxiv.org/abs/1512.05616* 1. Shoshana Zuboff: â[Big Other: Surveillance Capitalism and the Prospects of an Information Civilization](http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2594754),â *Journal of Information Technology*, volume 30, number 1, pages 75â89, April 2015.[doi:10.1057/jit.2015.5](http://dx.doi.org/10.1057/jit.2015.5) 1. Carina C. Zona: â[Consequences of an Insightful Algorithm](https://www.youtube.com/watch?v=YRI40A4tyWU),â at *GOTO Berlin*, November 2016. 1. Bruce Schneier: â[Data Is a Toxic Asset, So Why Not Throw It Out?](https://www.schneier.com/essays/archives/2016/03/data_is_a_toxic_asse.html),â *schneier.com*, March 1, 2016. 1. John E. Dunn: â[The UKâs 15 Most Infamous Data Breaches](http://www.techworld.com/security/uks-most-infamous-data-breaches-2016-3604586/),â *techworld.com*, November 18, 2016. 1. Cory Scott: â[Data is not toxic - which implies no benefit - but rather hazardous material, where we must balance need vs. want](https://twitter.com/cory_scott/status/706586399483437056),â *twitter.com*, March 6, 2016. 1. Bruce Schneier: â[Mission Creep: When Everything Is Terrorism](https://www.schneier.com/essays/archives/2013/07/mission_creep_when_e.html),â *schneier.com*, July 16, 2013. 1. Lena Ulbricht and Maximilian von Grafenstein: â[Big Data: Big Power Shifts?](http://policyreview.info/articles/analysis/big-data-big-power-shifts),â *Internet Policy Review*, volume 5, number 1, March 2016. [doi:10.14763/2016.1.406](http://dx.doi.org/10.14763/2016.1.406) 1. Ellen P. Goodman and Julia Powles: â[Facebook and Google: Most Powerful and Secretive Empires We've Ever Known](https://www.theguardian.com/technology/2016/sep/28/google-facebook-powerful-secretive-empire-transparency),â *theguardian.com*, September 28, 2016. 1. [Directive 95/46/EC on the protection of individuals with regard to the processing of personal data and on the free movement of such data](http://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:31995L0046), Official Journal of the European Communities No. L 281/31, *eur-lex.europa.eu*, November 1995. 1. Brendan Van Alsenoy: â[Regulating Data Protection: The Allocation of Responsibility and Risk Among Actors Involved in Personal Data Processing](https://lirias.kuleuven.be/handle/123456789/545027),â Thesis, KU Leuven Centre for IT and IP Law, August 2016. 1. Michiel Rhoen: â[Beyond Consent: Improving Data Protection Through Consumer Protection Law](http://policyreview.info/articles/analysis/beyond-consent-improving-data-protection-through-consumer-protection-law),â *Internet Policy Review*, volume 5, number 1, March 2016. [doi:10.14763/2016.1.404](http://dx.doi.org/10.14763/2016.1.404) 1. Jessica Leber: â[Your Data Footprint Is Affecting Your Life in Ways You Canât Even Imagine](https://www.fastcoexist.com/3057514/your-data-footprint-is-affecting-your-life-in-ways-you-cant-even-imagine),â *fastcoexist.com*, March 15, 2016. 1. Maciej CegÅowski: â[Haunted by Data](http://idlewords.com/talks/haunted_by_data.htm),â *idlewords.com*, October 2015. 1. Sam Thielman: â[You Are Not What You Read: Librarians Purge User Data to Protect Privacy](https://www.theguardian.com/us-news/2016/jan/13/us-library-records-purged-data-privacy),â *theguardian.com*, January 13, 2016. 1. Conor Friedersdorf: â[Edward Snowdenâs Other Motive for Leaking](http://www.theatlantic.com/politics/archive/2014/05/edward-snowdens-other-motive-for-leaking/370068/),â *theatlantic.com*, May 13, 2014. 1. Phillip Rogaway: â[The Moral Character of Cryptographic Work](http://web.cs.ucdavis.edu/~rogaway/papers/moral-fn.pdf),â Cryptology ePrint 2015/1162, December 2015. ------ | ä¸ä¸ç« | ç®å½ | ä¸ä¸ç« | | --------------------------- | ------------------------------- | ------------------- | | [第åä¸ç« ï¼æµå¤ç](ch11.md) | [设计æ°æ®å¯éååºç¨](README.md) | [åè®°](colophon.md) |