资源描述:
《大众点评网高可用数据架构》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、HAArchitectureinDPMMM&Memcached卢钧轶@DPWhoamIMySQLDBA@Dianping.comWeibo:米雪儿侬好的cenaluluBlog:http://www.cnblogs.com/cenalulu/HAinDPWebWeb1Web2Web3MemcachedmemcachememcachememcacheClusterWriterReaderDBReaderDBDBMMMReaderDBMemcachedmemcachedinDPMemcachedinDPNode1Node3MainR
2、ingBackupRingNode2Node4MemcachedinDPClientsetkey1setkey1Node1Node3MainRingBackupRingNode2Node4MemcachedinDPClientgetkey1Node1Node3MainRingBackupRingNode2Node3MemcachedinDPClientgetkey1getkey1Node1Node3MainRingBackupRingNode2Node3MemcachedProblemsWeMetProblem1CacheMis
3、sStormCacheMissStormHappenswhen:●Memcachedfailed(physical)●Keyexpired(logical)CacheMissStormIdealCacheMissProcedure1.getmemcachedmiss2.queryMySQL3.setvalueintomemcachedCacheMissStormInFact!1.getmemcachedmiss2.massiveconcurrentqueryonMySQL(timeout)3.nothingcanbesetint
4、omemcached4.cachemissforever....CacheMissStorm--Fix1Fixforphysicalcachemiss--DoubleWriteNode1Node3MainRingBackupRingNode2Node4CacheMissStorm--Fix2Fixforlogicalcachemiss--HotKey0.get&&setvalueintoweblocalcache1.getmemcachedmiss2.trytoaddalockkeyintomemcachea.if(succes
5、s)queryMySQL&setmemcacheb.if(failed)returnlocalcache*OnlyonewebcanqueryMySQLformissedkeyatthesametime.Problem2MultiGetHoleMultiGetHoleMultiGet/Gets:getcommandwithmultiplekeysPurpose:Omitthemultiplenetworkround-trips,Problem:Thegetscommandwillbeslowerwhenweaddmorenode
6、sintothecluster.http://highscalability.com/blog/2009/10/26/facebooks-memcached-multiget-hole-more-machines-more-capacit.htmlMultiGetHoleClientgetkey1,key2...key12Node1Node2Node3MultiGetHolegetkey1,key4,key7,key10Clientgetkey2,key5,key8,key11getke
7、y3,key6,key7,key12Node1Node2Node3MultiGetHoleResultClientgetkey2,key5,key8,key11v1,v4,v7,v10getkey3,key6,key9,key12getkey1,key4,key7,key10Node1Node2Node3MultiGetHoleResultv1,v4,v7,v10Clientgetkey3,key6,key9,key12v2,v5,v8,v11getkey2,
8、key5,key8,key11Node1Node2Node3MultiGetHoleResultv1,v4,v7,v10Clientv2,v5,v8,v11v3,v6,v9,v12getkey3,key6,key9,key12Node1Node2N