{"id":1941,"date":"2010-05-10T14:56:46","date_gmt":"2010-05-10T06:56:46","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=1941"},"modified":"2010-05-10T14:56:46","modified_gmt":"2010-05-10T06:56:46","slug":"all-about-cap-i-learn","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2010\/05\/all-about-cap-i-learn\/","title":{"rendered":"\u5173\u4e8eCAP"},"content":{"rendered":"<p>\u540e\u77e5\u540e\u89c9\u4ecd\u7136\u6bd4\u4e0d\u77e5\u4e0d\u89c9\u597d\u4e00\u70b9\uff0c\u867d\u7136\u6211\u4eec\u52aa\u529b\u6700\u6c42\u7684\u662f\u5148\u77e5\u5148\u89c9\u3002<\/p>\n<p>\u5728\u9605\u8bfb\u4e86Eric A. Brewer\u7684<a href=\"http:\/\/www.cs.berkeley.edu\/~brewer\/cs262b-2004\/PODC-keynote.pdf\">keynote at the PODC<\/a>\u548cGilbert and Lynch\u7684<a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/download?doi=10.1.1.20.1495&#038;rep=rep1&#038;type=pdf\">Brewer&#8217;s Conjecture and the Feasibility of Consistent,Available,Partition-Tolerant Web Service<\/a>\u540e\uff0c\u5bf9CAP\u6709\u4e86\u4e9b\u521d\u6b65\u7684\u8ba4\u8bc6\uff0c\u4e5f\u5c1d\u8bd5\u5f04\u6e05\u695a\u4e00\u4e9b\u57fa\u672c\u7684\u95ee\u9898\u3002<\/p>\n<p><font color=red>1. \u4e3a\u4ec0\u4e48\u6211\u4eec\u9700\u8981\u77e5\u9053CAP<\/font><\/p>\n<p>\u8bb0\u5f97\u5f53\u521d\u5b66\u4e60\u6570\u5b66\u79d1\u5b66\uff08\u4f8b\u5982\u5fae\u5206\u65b9\u7a0b\uff09\u7684\u65f6\u5019\uff0c\u5982\u679c\u6c42\u89e3\u4e00\u4e2a\u95ee\u9898\uff0c\u9996\u5148\u6211\u4eec\u9700\u8981\u8bc1\u660e\u8fd9\u4e2a\u89e3\u7684\u5b58\u5728\u6027\u3002\uff08\u6ca1\u5b66\u8fc7\u5fae\u5206\u65b9\u7a0b\u4e5f\u53ef\u4ee5\u56de\u5fc6\u4e00\u4e0b<a href=\"http:\/\/202.113.29.3\/jpkc\/sxwh\/ziyuan\/4\/4-4.pdf\">\u54e5\u5c3c\u65af\u5821\u4e03\u6865\u95ee\u9898<\/a>\uff09<\/p>\n<p>\u73b0\u5b9e\u751f\u6d3b\u4e2d\uff0c\u6211\u4eec\u5f80\u5f80\u9762\u4e34\u7684\u662f\u975e\u5e38\u5177\u4f53\uff08\u751a\u81f3\u7410\u788e\uff09\u7684\u95ee\u9898\uff0c\u6211\u4eec\u4e5f\u5728\u4e0d\u65ad\u4ed8\u51fa\u5de8\u5927\u7684\u52aa\u529b\u7684\u5c1d\u8bd5\u89e3\u51b3\u5b83\u4eec\u3002\u5982\u679c\u95ee\u9898\u68d8\u624b\uff0c\u53d1\u73b0\u4e00\u65f6\u65e0\u6cd5\u8d70\u51fa\u7684\u56f0\u5883\u540e\uff0c\u5f80\u5f80\u4f1a\u5bfb\u6c42\u65b0\u7684\u8bbe\u8ba1\u65b9\u6848\u6765\u89e3\u51b3\u95ee\u9898\u3002\u6bcf\u4e00\u4e2a\u65b9\u6848\uff08\u7cfb\u7edf\uff09\u8bbe\u8ba1\u4e4b\u521d\uff0c\u53c2\u4e0e\u8bbe\u8ba1\u8005\u5f80\u5f80\u5bf9\u672a\u6765\u8fd9\u4e2a\u65b9\u6848\u5145\u6ee1\u4e86\u61a7\u61ac\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u65b0\u65b9\u6848\u4e5f\u4e00\u822c\u80fd\u89e3\u51b3\u73b0\u6709\u7cfb\u7edf\u7684\u74f6\u9888\u3002\u4f46\u662f\u65b0\u65b9\u6848\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u6211\u4eec\u53c8\u4f1a\u91cd\u65b0\u53d1\u73b0\uff0c\u6211\u4eec\u7ed5\u8fc7\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u9762\u5bf9\u7684\u662f\u4e00\u4e9b\u65b0\u7684\u56f0\u5883\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u5728\u8bbe\u8ba1\u65b0\u65b9\u6848\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u5c1d\u8bd5\u5f04\u6e05\u695a\u6211\u4eec\u73b0\u5728\u7cfb\u7edf\u89e3\u51b3\u4e86\u54ea\u4e9b\u95ee\u9898\uff0c\u6ca1\u6709\u89e3\u51b3\u54ea\u4e9b\u95ee\u9898\uff0c\u65e0\u6cd5\u89e3\u51b3\u54ea\u4e9b\u95ee\u9898\uff1b\u8bbe\u8ba1\u65b0\u7cfb\u7edf\uff0c\u6211\u4eec\u80fd\u591f\u89e3\u51b3\u54ea\u4e9b\uff0c\u65e0\u6cd5\u89e3\u51b3\u54ea\u4e9b\u3002<\/p>\n<p>CAP\u7406\u8bba\uff08\u4e5f\u8bb8\u4e0d\u80fd\u8bf4\u662f\u4e25\u683c\u7406\u8bba\uff0c\u56e0\u4e3a\u6211\u4eec\u5f80\u5f80\u5728C\u3001A\u3001P\u4e4b\u524d\u5bfb\u6c42\u5e73\u8861\uff09\u4fbf\u662f\u57fa\u4e8e\u8fd9\u6837\u7684\u601d\u8003\uff0c\u4ea7\u751f\u7684\u7406\u8bba\u3002<!--more--><\/p>\n<p><font color=\"red\">2. \u4ec0\u4e48\u662fCAP<\/font><\/p>\n<p>\u5373\u4f7f\u662f\u73b0\u5728\uff0c\u6211\u4ecd\u7136\u4e0d\u662f\u5f88\u7406\u89e3CAP\uff0c\u6240\u4ee5\u672c\u6587\u4e5f\u65e0\u6cd5\u6e05\u695a\u7684\u9610\u8ff0&#8221;\u4ec0\u4e48\u662fCAP&#8221;\uff0c\u8fd9\u91cc\u5c06\u5217\u51fa\u6211\u7684\u8ba4\u8bc6\uff0c\u548c\u770b\u5230\u5e76\u89c9\u5f97\u9760\u8c31\u7684\u8ba4\u8bc6\u3002<\/p>\n<p>CAP\u662fEric A. Brewer\u5728<a href=\"http:\/\/www.cs.berkeley.edu\/~brewer\/cs262b-2004\/PODC-keynote.pdf\">PODC\u4e0a\u9996\u6b21\u63d0\u51fa<\/a>\uff0cBrewer\u7684\u4e00\u90e8\u5206\u5de5\u4f5c\u4fbf\u8bbe\u8ba1\u5927\u578b\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\uff0c\u4f8b\u5982Global Search Engines\u3001Distributed Web Caches\u7b49\u3002\u6240\u4ee5<strong>CAP\u7406\u8bba\u4e5f\u662f\u57fa\u4e8e\u5206\u5e03\u5f0f<\/strong>\uff08Distributed Systems\uff09\u7684\u7cfb\u7edf\uff0c\u6240\u4ee5\u4e0b\u9762\u5168\u90e8\u7684\u5185\u5bb9\uff0c\u90fd\u9700\u8981\u653e\u5230\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u4e2d\u53bb\u7406\u89e3\uff0c\u5426\u5219\u4f60\u4f1a\u8ff7\u5931\u3002<\/p>\n<div style=\"float:left;margin-right:15px\"><a href=\"http:\/\/www.flickr.com\/photos\/26825745@N06\/4586513428\/\" title=\"CAP by orczhou, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm5.static.flickr.com\/4011\/4586513428_f1d5a3789b_o.jpg\" width=\"257\" height=\"263\" alt=\"CAP\" \/><\/a><\/div>\n<p>CAP\u662f\u6307Consistency, availability and partition tolerance\u7684\u7f29\u5199\uff0c\u4e0d\u8fc7\u7406\u89e3\u8fd9\u4e09\u4e2a\u6982\u5ff5\u5e76\u4e0d\u5bb9\u6613\u3002CAP\u7406\u8bba\u6307\u51fa\uff0c\u8fd9\u4e09\u8005\u4e0d\u53ef\u517c\u5f97\u3002<\/p>\n<p>Consistency\u662f\u5bb9\u6613\u7406\u89e3\u7684\uff1b\u5173\u4e8eAvailability\u548cPartition tolerance\uff0cJeff Darcy\u5728\u6587\u7ae0<a href=\"http:\/\/pl.atyp.us\/wordpress\/?p=2521\">Availability and Partition Tolerance<\/a>\u505a\u4e86\u5982\u4e0b\u9610\u8ff0<\/p>\n<p>\u201cAvailability is sacrificed if certain nodes are forced to wait for unbounded time because of a failure. This includes the common approach of forcing non-quorum nodes down, which Brewer alludes to.\u201d<\/p>\n<p>\u201cPartition tolerance is sacrificed if certain requests are forced to wait for unbounded time because of a failure. This is most often the case when a node holding a lock cannot be reached, and quorum loss is not used to break the lock.\u201d<\/p>\n<p>\u867d\u7136\u770b\u8d77\u6765\u5f88\u6666\u6da9\uff0c\u4e0d\u8fc7\u8fd9\u5df2\u7ecf\u662f\u80fd\u591f\u770b\u5230\u6700\u6e05\u6670\u7684\u89e3\u91ca\u4e86\u3002\uff08\u5982\u679c\u4f60\u4ed4\u7ec6\u770b<a href=\"http:\/\/pl.atyp.us\/wordpress\/?p=2521\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u540e\u9762\u7684\u8bc4\u8bba\uff0c\u8fd8\u6709\u53d1\u73b0\u5f88\u591a\u6709\u610f\u601d\u7684\u4e1c\u897f\uff09<\/p>\n<p><font color=\"red\">3. Sample of CAP<\/font><\/p>\n<p>\u7b26\u5408CAP\u8bbe\u8ba1\u54f2\u5b66\u4e2d\uff0c\u4e24\u4e2a\u6700\u5178\u578b\u7684\u6848\u4f8b\u4fbf\u662f\uff1aGoogle\u7684<a href=\"http:\/\/labs.google.com\/papers\/bigtable.html\">BigTable<\/a>\u548cAmazon\u7684<a href=\"http:\/\/s3.amazonaws.com\/AllThingsDistributed\/sosp\/amazon-dynamo-sosp2007.pdf\">Dynamo<\/a>\u3002\u524d\u8005\u662f\u4e00\u4e2aCA\u7cfb\u7edf\uff0c\u540e\u8005\u5219\u662f\u4e00\u4e2aAP\u7cfb\u7edf\u3002<\/p>\n<p><font color=\"red\">4. CAP \u548c MySQL<\/font><\/p>\n<p>\u8fd9\u91cc\u4ee5MySQL Replication\uff08Master-Slave\uff09\u65b9\u6848\u4e3a\u4f8b\u3002\u5728MS\u7ed3\u6784\u4e2d\uff0c\u8282\u70b9M\u548c\u8282\u70b9S\uff0c\u90fd\u53ef\u4ee5\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u5f53\u5176\u4e2d\u7684\u4e00\u4e2a\u8282\u70b9\u6545\u969c\uff0c\u53e6\u4e00\u4e2a\u8282\u70b9\u4ecd\u7136\u80fd\u591f\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u6240\u4ee5MS\u65b9\u6848\u8ba4\u4e3a\u662f\u6ee1\u8db3Availability\u7684\uff1b\u76ee\u524dMS\u7ed3\u6784\u4ecd\u7136\u662f\u5f02\u6b65\u7684\u65b9\u5f0f\u8fd0\u884c\uff0c\u5373\u5f53\u4e3b\u5e93\u5199\u5165\u65f6\uff0c\u5907\u5e93\u672a\u5fc5\u4e00\u5b9a\u4e5f\u5199\u5165\u4e86\uff0c\u5907\u5e93\u751a\u81f3\u5141\u8bb8\u77ed\u6682\u548c\u4e3b\u5e93\u65ad\u5f00\u8fde\u63a5\uff0c\u800c\u4e14\u5f53\u4e3b\u5e93\u5904\u7406\u8bf7\u6c42\u65f6\uff0c\u4e5f\u65e0\u9700\u786e\u8ba4\u5907\u5e93\u7684\u72b6\u6001\uff0c\u6240\u4ee5MS\u7ed3\u6784\u662f\u6ee1\u8db3Partition tolerance\u7684\uff1b\u4f46\u662f\u7531\u4e8eMS\u7ed3\u6784\u7684\u5f02\u6b65\u7279\u6027\uff0c\u6211\u4eec\u770b\u5230\u4e3b\u5907\u7684\u6570\u636e\u662f\u53ef\u80fd\u4e0d\u4e00\u81f4\u7684\uff0c\u5373\u4e0d\u6ee1\u8db3Consistency\u3002<\/p>\n<p>Semi-sync Replication\u5219\u662f\u5728Consistency<strong>\u8981\u6c42\u66f4\u4e25\u683c<\/strong>\uff0c\u540c\u65f6\u5728<strong>\u90e8\u5206<\/strong>\u5931\u53bbPartition tolerance\uff1b\u5982\u679cMySQL\u4f7f\u7528DRBD\uff08\u4e25\u683c\u6a21\u5f0f\uff09 \u505aHA\u65b9\u6848\uff0c\u5219\u5b9e\u73b0\u4e86Consistency\uff0c\u5c31\u5931\u53bb\u4e86Partition tolerance\u3002<\/p>\n<p><font color=\"red\">\u53c2\u8003\u6587\u732e\uff1a<\/font><br \/>\n[1]. <a href=\"http:\/\/www.cs.berkeley.edu\/~brewer\/cs262b-2004\/PODC-keynote.pdf\">Towards Robust Distributed Systems<\/a><br \/>\n[2]. <a href=\"http:\/\/pl.atyp.us\/wordpress\/?p=2521\">Availability and Partition Tolerance<\/a><br \/>\n[3]. <a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/download?doi=10.1.1.20.1495&#038;rep=rep1&#038;type=pdf\">Brewer\u2019s Conjecture and the Feasibility of Consistent,Available,Partition-Tolerant Web Service<\/a><br \/>\n[4]. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Quorum_(Distributed_Systems)\">Quorum (Distributed_Systems)<\/a><br \/>\n[5]. <a href=\"http:\/\/www.royans.net\/arch\/brewers-cap-theorem-on-distributed-systems\/\">Brewers CAP Theorem on distributed systems<\/a><br \/>\n[6]. <a href=\"http:\/\/devblog.streamy.com\/2009\/08\/24\/cap-theorem\/\">CAP Theorem<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540e\u77e5\u540e\u89c9\u4ecd\u7136\u6bd4\u4e0d\u77e5\u4e0d\u89c9\u597d\u4e00\u70b9\uff0c\u867d\u7136\u6211\u4eec\u52aa\u529b\u6700\u6c42\u7684\u662f\u5148\u77e5\u5148\u89c9\u3002 \u5728\u9605\u8bfb\u4e86Eric A. Brewer\u7684keynote at the PODC\u548cGilbert and Lynch\u7684Brewer&#8217;s Conjecture and the Feasibility of Consistent,Available,Partition-Tolerant Web Service\u540e\uff0c\u5bf9CAP\u6709\u4e86\u4e9b\u521d\u6b65\u7684\u8ba4\u8bc6\uff0c\u4e5f\u5c1d\u8bd5\u5f04\u6e05\u695a\u4e00\u4e9b\u57fa\u672c\u7684\u95ee\u9898\u3002 1. \u4e3a\u4ec0\u4e48\u6211\u4eec\u9700\u8981\u77e5\u9053CAP \u8bb0\u5f97\u5f53\u521d\u5b66\u4e60\u6570\u5b66\u79d1\u5b66\uff08\u4f8b\u5982\u5fae\u5206\u65b9\u7a0b\uff09\u7684\u65f6\u5019\uff0c\u5982\u679c\u6c42\u89e3\u4e00\u4e2a\u95ee\u9898\uff0c\u9996\u5148\u6211\u4eec\u9700\u8981\u8bc1\u660e\u8fd9\u4e2a\u89e3\u7684\u5b58\u5728\u6027\u3002\uff08\u6ca1\u5b66\u8fc7\u5fae\u5206\u65b9\u7a0b\u4e5f\u53ef\u4ee5\u56de\u5fc6\u4e00\u4e0b\u54e5\u5c3c\u65af\u5821\u4e03\u6865\u95ee\u9898\uff09 \u73b0\u5b9e\u751f\u6d3b\u4e2d\uff0c\u6211\u4eec\u5f80\u5f80\u9762\u4e34\u7684\u662f\u975e\u5e38\u5177\u4f53\uff08\u751a\u81f3\u7410\u788e\uff09\u7684\u95ee\u9898\uff0c\u6211\u4eec\u4e5f\u5728\u4e0d\u65ad\u4ed8\u51fa\u5de8\u5927\u7684\u52aa\u529b\u7684\u5c1d\u8bd5\u89e3\u51b3\u5b83\u4eec\u3002\u5982\u679c\u95ee\u9898\u68d8\u624b\uff0c\u53d1\u73b0\u4e00\u65f6\u65e0\u6cd5\u8d70\u51fa\u7684\u56f0\u5883\u540e\uff0c\u5f80\u5f80\u4f1a\u5bfb\u6c42\u65b0\u7684\u8bbe\u8ba1\u65b9\u6848\u6765\u89e3\u51b3\u95ee\u9898\u3002\u6bcf\u4e00\u4e2a\u65b9\u6848\uff08\u7cfb\u7edf\uff09\u8bbe\u8ba1\u4e4b\u521d\uff0c\u53c2\u4e0e\u8bbe\u8ba1\u8005\u5f80\u5f80\u5bf9\u672a\u6765\u8fd9\u4e2a\u65b9\u6848\u5145\u6ee1\u4e86\u61a7\u61ac\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u65b0\u65b9\u6848\u4e5f\u4e00\u822c\u80fd\u89e3\u51b3\u73b0\u6709\u7cfb\u7edf\u7684\u74f6\u9888\u3002\u4f46\u662f\u65b0\u65b9\u6848\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u6211\u4eec\u53c8\u4f1a\u91cd\u65b0\u53d1\u73b0\uff0c\u6211\u4eec\u7ed5\u8fc7\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u9762\u5bf9\u7684\u662f\u4e00\u4e9b\u65b0\u7684\u56f0\u5883\u3002 \u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u5728\u8bbe\u8ba1\u65b0\u65b9\u6848\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u5c1d\u8bd5\u5f04\u6e05\u695a\u6211\u4eec\u73b0\u5728\u7cfb\u7edf\u89e3\u51b3\u4e86\u54ea\u4e9b\u95ee\u9898\uff0c\u6ca1\u6709\u89e3\u51b3\u54ea\u4e9b\u95ee\u9898\uff0c\u65e0\u6cd5\u89e3\u51b3\u54ea\u4e9b\u95ee\u9898\uff1b\u8bbe\u8ba1\u65b0\u7cfb\u7edf\uff0c\u6211\u4eec\u80fd\u591f\u89e3\u51b3\u54ea\u4e9b\uff0c\u65e0\u6cd5\u89e3\u51b3\u54ea\u4e9b\u3002 CAP\u7406\u8bba\uff08\u4e5f\u8bb8\u4e0d\u80fd\u8bf4\u662f\u4e25\u683c\u7406\u8bba\uff0c\u56e0\u4e3a\u6211\u4eec\u5f80\u5f80\u5728C\u3001A\u3001P\u4e4b\u524d\u5bfb\u6c42\u5e73\u8861\uff09\u4fbf\u662f\u57fa\u4e8e\u8fd9\u6837\u7684\u601d\u8003\uff0c\u4ea7\u751f\u7684\u7406\u8bba\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[7],"tags":[55],"class_list":["post-1941","post","type-post","status-publish","format-standard","hentry","category-human","tag-cap"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=1941"}],"version-history":[{"count":22,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1941\/revisions"}],"predecessor-version":[{"id":1990,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1941\/revisions\/1990"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=1941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=1941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=1941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}