文档详情

分布式系统缓存设计.pdf

发布:2017-05-08约3.45千字共24页下载文档
文本预览下载声明
分布式系统 缓存设计浅析 朋春 pengchun@ 为什么要做这个分享? 缓存系统(2011.6) 前端产品 glider ⼀级缓存 二级缓存 缓存系统(2011.6) URL请求,nocache? 前端产品 nocache? glider ⼀级缓存 nocache? 二级缓存 缓存系统(2011.6) URL请求,nocache? data 前端产品 nocache? glider ⼀级缓存 nocache? 二级缓存 缓存系统(2011.6) URL请求,nocache? data etag, http header 前端产品 nocache? ttl, http header glider ⼀级缓存 nocache? min (ttl) 二级缓存 时代变了 • 容灾考虑,缓存多实例,多写单读 • 实时的数据更新 • 更多更复杂的底层系统 缓存系统的三个问题 • 数据⼀致性问题 • 缓存雪崩问题 • 缓存穿透问题 数据⼀致性 • 缓存与底层数据的⼀致性 • 有继承关系的缓存之间的⼀致性 • 多个缓存副本之间的⼀致性 缓存数据的淘汰 • “预估”失效时间 • 单调递增的数据版本号 • 提供清理接口 精细化管理 • 只淘汰该淘汰的 itier的设计(通用) • 根据tag进行缓存管理 • 时间戳做数据版本号 • 提供清理API • 版本号共享协作 var me = Cache.create (...); me.set (key, value, ttl, tags); me.get (key); me.tagrm (tag, offset, flush); 缓存的数据结构 var data = { ‘i’:now, /** 数据写入时间戳 */ ‘e’:now + ttl,/** 预期过期时间 */ ‘k’:key, /** 原始key */ ‘v’:value, /** 原始值 */ ‘t’:tags /** tag列表 */ }; tagrm (cleanByTag) /** * @定时同步 */ var __taginfo = {}; tagrm (tag, offset, flu
显示全部
相似文档