日期:2014-05-16  浏览次数:20376 次

銆愯浆杞姐€慚ongodb VS Hbase
杞浇鑷猦ttp://hi.baidu.com/i1see1you/item/783a701f39a87549e75e06ea

1.Mongodb bson鏂囨。鍨嬫暟鎹簱锛屾暣涓暟鎹兘瀛樺湪纾佺洏涓紝hbase鏄垪寮忔暟鎹簱锛岄泦缇ら儴缃叉椂姣忎釜familycolumn淇濆瓨鍦ㄥ崟鐙殑hdfs鏂囦欢涓€?
2.Mongodb 涓婚敭鏄€淿id鈥?涓婚敭涓婇潰鍙互涓嶅缓绱㈠紩,璁板綍鎻掑叆鐨勯『搴忓拰瀛樻斁鐨勯『搴忎竴鏍凤紝hbase鐨勪富閿氨鏄痳ow key锛屽彲浠ユ槸浠绘剰瀛楃涓?鏈€澶ч暱搴︽槸 64KB锛屽疄闄呭簲鐢ㄤ腑闀垮害涓€鑸负 10-100bytes)锛屽湪hbase鍐呴儴锛宺ow key淇濆瓨涓哄瓧鑺傛暟缁勩€傚瓨鍌ㄦ椂锛屾暟鎹寜鐓ow key鐨勫瓧鍏稿簭(byte order)鎺掑簭瀛樺偍銆傝璁ey鏃讹紝瑕佸厖鍒嗘帓搴忓瓨鍌ㄨ繖涓壒鎬э紝灏嗙粡甯镐竴璧疯鍙栫殑琛屽瓨鍌ㄦ斁鍒颁竴璧枫€?
瀛楀吀搴忓int鎺掑簭鐨勭粨鏋滄槸1,10,100,11,12,13,14,15,16,17,18,19,2,20,21,鈥?9,91,92,93,94,95,96,97,98,99銆傝淇濇寔鏁村舰鐨勮嚜鐒跺簭锛岃閿繀椤荤敤0浣滃乏濉厖銆?
3.Mongodb鏀寔浜岀骇绱㈠紩锛岃€宧base鏈韩涓嶆敮鎸佷簩绾х储寮?
4.Mongodb鏀寔闆嗗悎鏌ユ壘锛屾鍒欐煡鎵撅紝鑼冨洿鏌ユ壘锛屾敮鎸乻kip鍜宭imit绛夌瓑锛屾槸鏈€鍍弇ysql鐨刵osql鏁版嵁搴擄紝鑰宧base鍙敮鎸佷笁绉嶆煡鎵撅細閫氳繃鍗曚釜row key璁块棶锛岄€氳繃row key鐨剅ange锛屽叏琛ㄦ壂鎻?
5.mongodb鐨剈pdate鏄痷pdate-in-place锛屼篃灏辨槸鍘熷湴鏇存柊锛岄櫎闈炲師鍦板绾充笉涓嬫洿鏂板悗鐨勬暟鎹褰曘€傝€宧base鐨勪慨鏀瑰拰娣诲姞閮芥槸鍚屼竴涓懡浠わ細put锛屽鏋減ut浼犲叆鐨剅ow key宸茬粡瀛樺湪灏辨洿鏂板師璁板綍,瀹為檯涓奾base鍐呴儴涔熶笉鏄洿鏂帮紝瀹冨彧鏄皢杩欎竴浠芥暟鎹凡涓嶅悓鐨勭増鏈繚瀛樹笅鏉ヨ€屽凡锛宧base榛樿鐨勪繚瀛樼増鏈殑鍘嗗彶鏁伴噺鏄?銆?
6.mongodb鐨刣elete浼氬皢璇ヨ鐨勬暟鎹爣绀轰负宸插垹闄わ紝鍥犱负mongodb鍦ㄥ垹闄よ褰曟椂骞朵笉鏄湡鎶婅褰曚粠鍐呭瓨鎴栨枃浠朵腑remove锛岃€屾槸灏嗚鍒犻櫎璁板綍鏁版嵁缃┖锛堝啓0鎴栫壒娈婃暟瀛楀姞浠ユ爣璇嗭級鍚屾椂灏嗚璁板綍鎵€鍦ㄥ湴鍧€鏀惧埌涓€涓猯ist鍒楄〃鈥滈噴鏀惧垪琛ㄢ€濅腑锛岃繖鏍峰仛鐨勫ソ灏辨槸灏辨槸濡傛灉鏈夌敤鎴疯鎵ц鎻掑叆璁板綍鎿嶄綔鏃讹紝mongodb浼氶鍏堜粠璇モ€滈噴鏀惧垪琛ㄢ€濅腑鑾峰彇size鍚堥€傜殑鈥滃凡鍒犻櫎璁板綍鈥濆湴鍧€杩斿洖锛岃繖绉嶆柟娉曚細鎻愬崌鎬ц兘锛堥伩鍏嶄簡malloc鍐呭瓨鎿嶄綔锛夛紝鍚屾椂mongodb涔熶娇鐢ㄤ簡bucket size鏁扮粍鏉ュ畾涔夊涓ぇ灏弒ize涓嶅悓鐨勫垪琛紝鐢ㄤ簬灏嗚鍒犻櫎鐨勮褰曟牴鎹叾size澶у皬鏀惧埌鍚堥€傜殑鈥滈噴鏀惧垪琛ㄢ€濅腑銆侶base鐨刣elete鏄厛鏂板缓涓€涓猼ombstonemarkers锛岀劧鍚庤鐨勬椂鍊欎細鍜宼ombstonemarkers鍋歮erge锛屽湪 鍙戠敓major compaction鏃禿elete鐨勬暟鎹褰曟墠浼氱湡鐪熷垹闄ゃ€?
7.mongodb鍜宧base閮芥敮鎸乵apreduce锛屼笉杩噈ongodb鐨刴apreduce鏀寔涓嶅寮哄ぇ锛屽鏋滄病鏈変娇鐢╩ongodb鍒嗙墖锛宮apreduce瀹為檯涓婁笉鏄苟琛屾墽琛岀殑
8.mongodb鏀寔shard鍒嗙墖锛宧base鏍规嵁row key鑷姩璐熻浇鍧囪 锛岃繖閲宻hard key鍜宺ow key鐨勯€夊彇灏介噺鐢ㄩ潪閫掑鐨勫瓧娈碉紝灏介噺鐢ㄥ垎甯冨潎琛$殑瀛楁锛屽洜涓哄垎鐗囬兘鏄牴鎹寖鍥存潵閫夋嫨瀵瑰簲鐨勫瓨鍙杝erver鐨勶紝濡傛灉鐢ㄩ€掑瀛楁寰堝鏄撶儹鐐箂erver鐨勪骇鐢燂紝鐢变簬鏄牴鎹甼ey鐨勮寖鍥存潵鑷姩鍒嗙墖鐨勶紝濡傛灉key鍒嗗竷涓嶅潎琛″氨浼氬鑷存湁浜沰ey鏍规湰灏辨病娉曞垏鍒嗭紝浠庤€屼骇鐢熻礋杞戒笉鍧囪 銆?
9.mongodb鐨勮鏁堢巼姣斿啓楂橈紝hbase榛樿閫傚悎鍐欏璇诲皯鐨勬儏鍐碉紝鍙互閫氳繃hfile.block.cache.size閰嶇疆锛岃閰嶇疆storefile鐨勮缂撳瓨鍗犵敤Heap鐨勫ぇ灏忕櫨鍒嗘瘮锛?.2琛ㄧず20%銆傝鍊肩洿鎺ュ奖鍝嶆暟鎹鐨勬€ц兘銆傚鏋滃啓姣旇灏戝緢澶氾紝寮€鍒?.4-0.5涔熸病闂銆傚鏋滆鍐欒緝鍧囪 锛?.3宸﹀彸銆傚鏋滃啓姣旇澶氾紝鏋滄柇榛樿0.2鍚с€傝缃繖涓€肩殑鏃跺€欙紝浣犲悓鏃惰鍙傝€僪base.regionserver.global.memstore.upperLimit锛岃鍊兼槸memstore鍗爃eap鐨勬渶澶х櫨鍒嗘瘮锛屼袱涓弬鏁颁竴涓奖鍝嶈锛屼竴涓奖鍝嶅啓銆傚鏋滀袱鍊煎姞璧锋潵瓒呰繃80-90%锛屼細鏈塐OM鐨勯闄╋紝璋ㄦ厧璁剧疆銆?
10.hbase閲囩敤鐨凩SM鎬濇兂(Log-Structured Merge-Tree)锛屽氨鏄皢瀵规暟鎹殑鏇存敼hold鍦ㄥ唴瀛樹腑锛岃揪鍒版寚瀹氱殑threadhold鍚庡皢璇ユ壒鏇存敼merge鍚庢壒閲忓啓鍏ュ埌纾佺洏锛岃繖鏍峰皢鍗曚釜鍐欏彉鎴愪簡鎵归噺鍐欙紝澶уぇ鎻愰珮浜嗗啓鍏ラ€熷害锛屼笉杩囪繖鏍风殑璇濊鐨勬椂鍊欏氨璐瑰姴浜嗭紝闇€瑕乵erge disk涓婄殑鏁版嵁鍜宮emory涓殑淇敼鏁版嵁锛岃繖鏄剧劧闄嶄綆浜嗚鐨勬€ц兘銆俶ongodb閲囩敤鐨勬槸mapfile+Journal鎬濇兂锛屽鏋滆褰曚笉鍦ㄥ唴瀛橈紝鍏堝姞杞藉埌鍐呭瓨锛岀劧鍚庡湪鍐呭瓨涓洿鏀瑰悗璁板綍鏃ュ織锛岀劧鍚庨殧涓€娈垫椂闂存壒閲忕殑鍐欏叆data鏂囦欢锛岃繖鏍峰鍐呭瓨鐨勮姹傝緝楂橈紝鑷冲皯闇€瑕佸绾充笅鐑偣鏁版嵁鍜岀储寮曘€?