Posted 鐮佸啘寮€鑺?/a> 琚棶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。

鎶€鏈共璐?馃憠 蹇呭畾濂変笂


鏉ユ簮锛?/span>projectfailures.wordpress.com


鑳屾櫙浠嬬粛



涓€銆佷粈涔堟槸鍝堝笇绠楁硶


涓€鑷存€у搱甯岀畻娉曞湪1997骞寸敱楹荤渷鐞嗗伐瀛﹂櫌鎻愬嚭鐨勪竴绉嶅垎甯冨紡鍝堝笇锛圖HT锛夊疄鐜扮畻娉曪紝璁捐鐩爣鏄负浜嗚В鍐冲洜鐗圭綉涓殑鐑偣(Hot spot)闂锛屽垵琛峰拰CARP鍗佸垎绫讳技銆備竴鑷存€у搱甯屼慨姝d簡CARP浣跨敤鐨勭畝 鍗曞搱甯岀畻娉曞甫鏉ョ殑闂锛屼娇寰楀垎甯冨紡鍝堝笇锛圖HT锛夊彲浠ュ湪P2P鐜涓湡姝e緱鍒板簲鐢ㄣ€?span class="mq-17">

涓€鑷存€ash绠楁硶鎻愬嚭浜嗗湪鍔ㄦ€佸彉鍖栫殑Cache鐜涓紝 鍒ゅ畾鍝堝笇绠楁硶濂藉潖鐨勫洓涓畾涔夛細
1銆?span class="mq-24">骞宠 鎬?Balance)锛?/strong>骞宠 鎬ф槸鎸囧搱甯岀殑缁撴灉鑳藉灏藉彲鑳藉垎甯冨埌鎵€鏈夌殑缂撳啿涓幓锛岃繖鏍峰彲浠ヤ娇寰楁墍鏈夌殑缂撳啿绌洪棿閮藉緱鍒板埄鐢ㄣ€傚緢澶氬搱甯岀畻娉曢兘鑳藉婊¤冻杩欎竴鏉′欢銆?/span>
2銆?span class="mq-27">鍗曡皟鎬?Monotonicity)锛?/strong>鍗曡皟鎬ф槸鎸囧鏋滃凡缁忔湁涓€浜涘唴瀹归€氳繃鍝堝笇鍒嗘淳鍒颁簡鐩稿簲鐨勭紦鍐蹭腑锛屽張鏈夋柊鐨勭紦鍐插姞鍏ュ埌绯荤粺涓€傚搱甯岀殑缁撴灉搴旇兘澶熶繚璇佸師鏈夊凡鍒嗛厤鐨勫唴瀹瑰彲浠ヨ鏄犲皠鍒板師鏈夌殑鎴栬€呮柊鐨勭紦鍐蹭腑鍘伙紝鑰屼笉浼氳鏄犲皠鍒版棫鐨勭紦鍐查泦鍚堜腑鐨勫叾浠栫紦鍐插尯銆?/span>
3銆?span class="mq-30">鍒嗘暎鎬?Spread)锛?/strong>鍦ㄥ垎甯冨紡鐜涓紝缁堢鏈夊彲鑳界湅涓嶅埌鎵€鏈夌殑缂撳啿锛岃€屾槸鍙兘鐪嬪埌鍏朵腑鐨勪竴閮ㄥ垎銆傚綋缁堢甯屾湜閫氳繃鍝堝笇杩囩▼灏嗗唴瀹规槧灏勫埌缂撳啿涓婃椂锛岀敱浜庝笉鍚岀粓绔墍瑙佺殑缂撳啿鑼冨洿鏈夊彲鑳戒笉鍚岋紝浠庤€屽鑷村搱甯岀殑缁撴灉涓嶄竴鑷达紝鏈€缁堢殑缁撴灉鏄浉鍚岀殑鍐呭琚笉鍚岀殑缁堢鏄犲皠鍒颁笉鍚岀殑缂撳啿鍖轰腑銆傝繖绉嶆儏鍐垫樉鐒舵槸搴旇閬垮厤鐨勶紝鍥犱负瀹冨鑷寸浉鍚屽唴瀹硅瀛樺偍鍒颁笉鍚岀紦鍐蹭腑鍘伙紝闄嶄綆浜嗙郴缁熷瓨鍌ㄧ殑鏁堢巼銆傚垎鏁f€х殑瀹氫箟灏辨槸涓婅堪鎯呭喌鍙戠敓鐨勪弗閲嶇▼搴︺€傚ソ鐨勫搱甯岀畻娉曞簲鑳藉灏介噺閬垮厤涓嶄竴鑷寸殑鎯呭喌鍙戠敓锛屼篃灏辨槸灏介噺闄嶄綆鍒嗘暎鎬с€?/span>
4銆?span class="mq-33">璐熻浇(Load)锛?/strong>璐熻浇闂瀹為檯涓婃槸浠庡彟涓€涓搴︾湅寰呭垎鏁f€ч棶棰樸€傛棦鐒朵笉鍚岀殑缁堢鍙兘灏嗙浉鍚岀殑鍐呭鏄犲皠鍒颁笉鍚岀殑缂撳啿鍖轰腑锛岄偅涔堝浜庝竴涓壒瀹氱殑缂撳啿鍖鸿€岃█锛屼篃鍙兘琚笉鍚岀殑鐢ㄦ埛鏄犲皠涓轰笉鍚?鐨勫唴瀹广€備笌鍒嗘暎鎬т竴鏍凤紝杩欑鎯呭喌涔熸槸搴斿綋閬垮厤鐨勶紝鍥犳濂界殑鍝堝笇绠楁硶搴旇兘澶熷敖閲忛檷浣庣紦鍐茬殑璐熻嵎銆?/span>
鍦ㄥ垎甯冨紡闆嗙兢涓紝瀵规満鍣ㄧ殑娣诲姞鍒犻櫎锛屾垨鑰呮満鍣ㄦ晠闅滃悗鑷姩鑴辩闆嗙兢杩欎簺鎿嶄綔鏄垎甯冨紡闆嗙兢绠$悊鏈€鍩烘湰鐨勫姛鑳姐€傚鏋滈噰鐢ㄥ父鐢ㄧ殑hash(object)%N绠楁硶锛岄偅涔堝湪鏈夋満鍣ㄦ坊鍔犳垨鑰呭垹闄ゅ悗锛屽緢澶氬師鏈夌殑鏁版嵁灏辨棤娉曟壘鍒颁簡锛岃繖鏍蜂弗閲嶇殑杩濆弽浜嗗崟璋冩€у師鍒欍€傛帴涓嬫潵涓昏璁茶В涓€涓嬩竴鑷存€у搱甯岀畻娉曟槸濡備綍璁捐鐨勶細

鐜舰Hash绌洪棿

鎸夌収甯哥敤鐨刪ash绠楁硶鏉ュ皢瀵瑰簲鐨刱ey鍝堝笇鍒颁竴涓叿鏈?^32娆℃柟涓《鐨勭┖闂翠腑锛屽嵆0~(2^32)-1鐨勬暟瀛楃┖闂翠腑銆傜幇鍦ㄦ垜浠彲浠ュ皢杩欎簺鏁板瓧澶村熬鐩歌繛锛屾兂璞℃垚涓€涓棴鍚堢殑鐜舰銆傚涓嬪浘

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

鎶婃暟鎹€氳繃涓€瀹氱殑hash绠楁硶澶勭悊鍚庢槧灏勫埌鐜笂

鐜板湪鎴戜滑灏唎bject1銆乷bject2銆乷bject3銆乷bject4鍥涗釜瀵硅薄閫氳繃鐗瑰畾鐨凥ash鍑芥暟璁$畻鍑哄搴旂殑key鍊硷紝鐒跺悗鏁e垪鍒癏ash鐜笂銆傚涓嬪浘锛?/span>

Hash(object1) = key1锛?br>Hash(object2) = key2锛?br>Hash(object3) = key3锛?br>Hash(object4) = key4锛?/span>

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

灏嗘満鍣ㄩ€氳繃hash绠楁硶鏄犲皠鍒扮幆涓?/strong>

鍦ㄩ噰鐢ㄤ竴鑷存€у搱甯岀畻娉曠殑鍒嗗竷寮忛泦缇や腑灏嗘柊鐨勬満鍣ㄥ姞鍏ワ紝鍏跺師鐞嗘槸閫氳繃浣跨敤涓庡璞″瓨鍌ㄤ竴鏍风殑Hash绠楁硶灏嗘満鍣ㄤ篃鏄犲皠鍒扮幆涓紙涓€鑸儏鍐典笅瀵规満鍣ㄧ殑hash璁$畻鏄噰鐢ㄦ満鍣ㄧ殑IP鎴栬€呮満鍣ㄥ敮涓€鐨勫埆鍚嶄綔涓鸿緭鍏ュ€硷級锛岀劧鍚庝互椤烘椂閽堢殑鏂瑰悜璁$畻锛屽皢鎵€鏈夊璞″瓨鍌ㄥ埌绂昏嚜宸辨渶杩戠殑鏈哄櫒涓€?/span>
鍋囪鐜板湪鏈塏ODE1锛孨ODE2锛孨ODE3涓夊彴鏈哄櫒锛岄€氳繃Hash绠楁硶寰楀埌瀵瑰簲鐨凨EY鍊硷紝鏄犲皠鍒扮幆涓紝鍏剁ず鎰忓浘濡備笅锛?/span>

Hash(NODE1) = KEY1;
Hash(NODE2) = KEY2;
Hash(NODE3) = KEY3;

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

閫氳繃涓婂浘鍙互鐪嬪嚭瀵硅薄涓庢満鍣ㄥ浜庡悓涓€鍝堝笇绌洪棿涓紝杩欐牱鎸夐『鏃堕拡杞姩object1瀛樺偍鍒颁簡NODE1涓紝object3瀛樺偍鍒颁簡NODE2涓紝object2銆乷bject4瀛樺偍鍒颁簡NODE3涓€傚湪杩欐牱鐨勯儴缃茬幆澧冧腑锛宧ash鐜槸涓嶄細鍙樻洿鐨勶紝鍥犳锛岄€氳繃绠楀嚭瀵硅薄鐨刪ash鍊煎氨鑳藉揩閫熺殑瀹氫綅鍒板搴旂殑鏈哄櫒涓紝杩欐牱灏辫兘鎵惧埌瀵硅薄鐪熸鐨勫瓨鍌ㄤ綅缃簡銆?/span>
鏈哄櫒鐨勫垹闄や笌娣诲姞
鏅€歨ash姹備綑绠楁硶鏈€涓轰笉濡ョ殑鍦版柟灏辨槸鍦ㄦ湁鏈哄櫒鐨勬坊鍔犳垨鑰呭垹闄や箣鍚庝細鐓ф垚澶ч噺鐨勫璞″瓨鍌ㄤ綅缃け鏁堬紝杩欐牱灏卞ぇ澶х殑涓嶆弧瓒冲崟璋冩€т簡銆備笅闈㈡潵鍒嗘瀽涓€涓嬩竴鑷存€у搱甯岀畻娉曟槸濡備綍澶勭悊鐨勩€?/span>
1.鑺傜偣锛堟満鍣級鐨勫垹闄?/span>
浠ヤ笂闈㈢殑鍒嗗竷涓轰緥锛屽鏋淣ODE2鍑虹幇鏁呴殰琚垹闄や簡锛岄偅涔堟寜鐓ч『鏃堕拡杩佺Щ鐨勬柟娉曪紝object3灏嗕細琚縼绉诲埌NODE3涓紝杩欐牱浠呬粎鏄痮bject3鐨勬槧灏勪綅缃彂鐢熶簡鍙樺寲锛屽叾瀹冪殑瀵硅薄娌℃湁浠讳綍鐨勬敼鍔ㄣ€傚涓嬪浘锛?/span>

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

2.鑺傜偣锛堟満鍣級鐨勬坊鍔?/span>

濡傛灉寰€闆嗙兢涓坊鍔犱竴涓柊鐨勮妭鐐筃ODE4锛岄€氳繃瀵瑰簲鐨勫搱甯岀畻娉曞緱鍒癒EY4锛屽苟鏄犲皠鍒扮幆涓紝濡備笅鍥撅細

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

閫氳繃鎸夐『鏃堕拡杩佺Щ鐨勮鍒欙紝閭d箞object2琚縼绉诲埌浜哊ODE4涓紝鍏跺畠瀵硅薄杩樹繚鎸佽繖鍘熸湁鐨勫瓨鍌ㄤ綅缃€傞€氳繃瀵硅妭鐐圭殑娣诲姞鍜屽垹闄ょ殑鍒嗘瀽锛屼竴鑷存€у搱甯岀畻娉曞湪淇濇寔浜嗗崟璋冩€х殑鍚屾椂锛岃繕鏄暟鎹殑杩佺Щ杈惧埌浜嗘渶灏忥紝杩欐牱鐨勭畻娉曞鍒嗗竷寮忛泦缇ゆ潵璇存槸闈炲父鍚堥€傜殑锛岄伩鍏嶄簡澶ч噺鏁版嵁杩佺Щ锛屽噺灏忎簡鏈嶅姟鍣ㄧ殑鐨勫帇鍔涖€?/span>
骞宠 鎬?/strong>
鏍规嵁涓婇潰鐨勫浘瑙e垎鏋愶紝涓€鑷存€у搱甯岀畻娉曟弧瓒充簡鍗曡皟鎬у拰璐熻浇鍧囪 鐨勭壒鎬т互鍙婁竴鑸琱ash绠楁硶鐨勫垎鏁f€э紝浣嗚繖杩樺苟涓嶈兘褰撳仛鍏惰骞挎硾搴旂敤鐨勫師鐢憋紝鍥犱负杩樼己灏戜簡骞宠 鎬с€備笅闈㈠皢鍒嗘瀽涓€鑷存€у搱甯岀畻娉曟槸濡備綍婊¤冻骞宠 鎬х殑銆俬ash绠楁硶鏄笉淇濊瘉骞宠 鐨勶紝濡備笂闈㈠彧閮ㄧ讲浜哊ODE1鍜孨ODE3鐨勬儏鍐碉紙NODE2琚垹闄ょ殑鍥撅級锛宱bject1瀛樺偍鍒颁簡NODE1涓紝鑰宱bject2銆乷bject3銆乷bject4閮藉瓨鍌ㄥ埌浜哊ODE3涓紝杩欐牱灏辩収鎴愪簡闈炲父涓嶅钩琛$殑鐘舵€併€傚湪涓€鑷存€у搱甯岀畻娉曚腑锛屼负浜嗗敖鍙兘鐨勬弧瓒冲钩琛℃€э紝鍏跺紩鍏ヤ簡铏氭嫙鑺傜偣銆?/span>

鈥斺€斺€滆櫄鎷熻妭鐐光€濓紙 virtual node 锛夋槸瀹為檯鑺傜偣锛堟満鍣級鍦?hash 绌洪棿鐨勫鍒跺搧锛?replica 锛夛紝涓€瀹為檯涓妭鐐癸紙鏈哄櫒锛夊搴斾簡鑻ュ共涓€滆櫄鎷熻妭鐐光€濓紝杩欎釜瀵瑰簲涓暟涔熸垚涓衡€滃鍒朵釜鏁扳€濓紝鈥滆櫄鎷熻妭鐐光€濆湪 hash 绌洪棿涓互hash鍊兼帓鍒椼€?/p>

浠ヤ笂闈㈠彧閮ㄧ讲浜哊ODE1鍜孨ODE3鐨勬儏鍐碉紙NODE2琚垹闄ょ殑鍥撅級涓轰緥锛屼箣鍓嶇殑瀵硅薄鍦ㄦ満鍣ㄤ笂鐨勫垎甯冨緢涓嶅潎琛★紝鐜板湪鎴戜滑浠?涓壇鏈紙澶嶅埗涓暟锛変负渚嬶紝杩欐牱鏁翠釜hash鐜腑灏卞瓨鍦ㄤ簡4涓櫄鎷熻妭鐐癸紝鏈€鍚庡璞℃槧灏勭殑鍏崇郴鍥惧涓嬶細
琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=
鏍规嵁涓婂浘鍙煡瀵硅薄鐨勬槧灏勫叧绯伙細object1->NODE1-1锛宱bject2->NODE1-2锛宱bject3->NODE3-2锛宱bject4->NODE3-1銆傞€氳繃铏氭嫙鑺傜偣鐨勫紩鍏ワ紝瀵硅薄鐨勫垎甯冨氨姣旇緝鍧囪 浜嗐€傞偅涔堝湪瀹為檯鎿嶄綔涓紝姝g湡鐨勫璞℃煡璇㈡槸濡備綍宸ヤ綔鐨勫憿锛熷璞′粠hash鍒拌櫄鎷熻妭鐐瑰埌瀹為檯鑺傜偣鐨勮浆鎹㈠涓嬪浘锛?/span>

琚棶鐑傜殑涓€鑷存€у搱甯岀畻娉曪紝浣犵湡鐨勭悊瑙e悧锛? class=

鈥滆櫄鎷熻妭鐐光€濈殑hash璁$畻鍙互閲囩敤瀵瑰簲鑺傜偣鐨処P鍦板潃鍔犳暟瀛楀悗缂€鐨勬柟寮忋€備緥濡傚亣璁綨ODE1鐨処P鍦板潃涓?92.168.1.100銆傚紩鍏モ€滆櫄鎷熻妭鐐光€濆墠锛岃绠?cache A 鐨?hash 鍊硷細

Hash(鈥?92.168.1.100鈥?;

寮曞叆鈥滆櫄鎷熻妭鐐光€濆悗锛岃绠椻€滆櫄鎷熻妭鈥濈偣NODE1-1鍜孨ODE1-2鐨刪ash鍊硷細

Hash(鈥?92.168.1.100#1鈥?; // NODE1-1
Hash(鈥?92.168.1.100#2鈥?; // NODE1-2

鍙傝€冿細

[1] http://blog.huanghao.me/?p=14


end



    鍏虫敞鎴戝摝锛侊紒锛?br class="mq-145">

绋嬪簭鐚縄T绀惧尯

骞茶揣鍒嗕韩


鍥炲銆?01銆戣幏鍙?nbsp; 銆婂叏鏍堟灦鏋勫笀銆嬭绋?nbsp;

鍥炲銆?02銆戣幏鍙?銆婇珮绾у疄鎴樻灦鏋勫笀璇剧▼銆嬭绋?nbsp;

鍥炲銆?03銆戣幏鍙?銆婇珮绾ф灦鏋勫笀鍏ㄥ鏁欑▼銆嬭绋?nbsp;

鍥炲銆?05銆戣幏鍙?nbsp;銆婂ぇ鏁版嵁涔婬ive瑙嗛銆嬭绋?nbsp;

鍥炲銆?08銆戣幏鍙?nbsp;銆妚3 RabbitMQ娑堟伅涓棿浠舵妧鏈簿璁层€嬭绋?nbsp;

鍥炲銆?09銆戣幏鍙?nbsp; 銆婂ぇ鏁版嵁涔媄ookeeper瑙嗛銆嬭绋?nbsp;


鏇村瀛︿範璧勬枡璇疯仈绯绘垜鍝︼紒锛侊紒

 
   
   
 

鏈夌儹闂ㄦ帹鑽?/span>馃憞

1. 

2. 

3. 

4. 

鎶€鏈€丣VM銆丣ava骞跺彂銆丼SM銆佸井鏈嶅姟銆佹暟鎹簱銆佹暟鎹粨鏋勭瓑绛夈€?/span>

鍠滄鐨勭殑璇濓紝鐐逛釜鈥?/strong>鍦ㄧ湅鈥?/strong>榧撳姳涓€涓嬪惂

璋㈣阿 (*^__^*锛?/strong>


以上是关于的主要内容,如果未能解决你的问题,请参考以下文章

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数

VSCode自定义代码片段8——声明函数