ATS缓存中间层介绍
生活随笔
收集整理的這篇文章主要介紹了
ATS缓存中间层介绍
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
下面的譯文來自ATS官方交流博客中豪哥的一篇英文介紹,碰巧工作中又要用到,為了大家閱讀方便,我特此翻譯如下,不妥之處請指正:
說明:
慢速磁盤指普通的3.5寸硬盤,快速磁盤指ssd
緩存中間層
當我們考慮ATS的存儲時,最原始的設計是支持具有相同容量的多塊磁盤,(最適合沒有做raid的塊設備),由此構建分區,將每個分區指定某個域名(主機名),我們發現假如我們不對現有緩存設計做大的變動,我們就不能利用簡單的方式來得到多級緩存架構,因此我們得到下面的中間層解決方案:
我們假定你部署混合存儲(方案),快速磁盤在容量或是個數上小于慢速設備的十分之一
我們假設在絕大多數情況下,8塊快速磁盤已經相當多了
我們假設你的慢速設備每塊盤不會超過32TB
慢速設備存放所有的數據,這樣的話,萬一有快速磁盤緩存失敗時數據不會丟失
相較于存儲百分比,快速磁盤在服務器重啟期間可能丟失數據10%的數據
快速磁盤應當對所有的慢速磁盤在容量和IOPS上做均衡,磁盤分區基于慢速磁盤創建,對應的扇區分散在各個磁盤上,負載也應該在各個快速磁盤上做均衡
負載均衡設計
cache的中間層以快速磁盤為主(絕大多數情況下是SSD),重啟服務器進程會丟失數據, 因此只將中間數據(有備份)存放到中間層緩存中
我們最多支持8塊高速磁盤
我們做了一個塊級別(block level)的中間層緩存,(不像慢速磁盤)它不含任何索引信息
我們已經完成的工作
借用Dir結構體中的4bit來區分每個快速磁盤(因而快速磁盤個數不能超過32)
限制磁盤上限是32TB
使用volume.config中的配置來對每塊快速磁盤分區并綁定之
將中間層數據存到慢速磁盤的dir結構體中
將源服務器的數據寫到慢速磁盤
構建一個內部的LRU鏈表,大小限制為1M的bucket,將busy blocks備份到快速磁盤上
調用快速磁盤上的熱點數據,為了使它更高效,我們需要不斷比較LRU鏈表中的blocks
混合緩存設備(快速磁盤)也是呀RRD寫數據
優缺點pros and cons
優點:
我們做了一個可靠的解決方案,它對當前的存儲架構沒有做大的改動
LUR算法有助于我們得到熱的block,它是有效的
block層級的中間層緩存對大小對象都有作用
缺點:
服務器進程崩潰時會丟失數據,已在TS-2275中修正
僅只能有限個塊設備用作中間層緩存設備
中間層緩存設備在空間上不是追加,而僅是慢速磁盤設備上的熱點數據的復制
我們設置存儲系統的最大磁盤大小是0.5PB到32TB
默認配置情況下并不開啟中間層緩存功能
代碼及更改要點
the change of Dir:
@@ -155,15 +157,42 @@ struct FreeDir
? ?unsigned int reserved:8;
? ?unsigned int prev:16; ? ? ? ? // (2)
? ?unsigned int next:16; ? ? ? ? // (3)
+#if TS_USE_INTERIM_CACHE == 1
+ ?unsigned int offset_high:12; ? // 8GB * 4K = 32TB
+ ?unsigned int index:3; ? ? ? ? ?// interim index
+ ?unsigned int ininterim:1; ? ? ? ? ?// in interim or not
+#else
? ?inku16 offset_high; ? ? ? ? ? // 0: empty
+#endif
?#else
? ?uint16_t w[5];
? ?FreeDir() { dir_clear(this); }
we split the stat of read_success into disk, interim and ram:
@@ -2633,6 +2888,11 @@ register_cache_stats(RecRawStatBlock *rsb, const char *prefix)
? ?REG_INT("read.active", cache_read_active_stat);
? ?REG_INT("read.success", cache_read_success_stat);
? ?REG_INT("read.failure", cache_read_failure_stat);
+ ?REG_INT("interim.read.success", cache_interim_read_success_stat);
+ ?REG_INT("disk.read.success", cache_disk_read_success_stat);
+ ?REG_INT("ram.read.success", cache_ram_read_success_stat);
? ?REG_INT("write.active", cache_write_active_stat);
? ?REG_INT("write.success", cache_write_success_stat);
? ?REG_INT("write.failure", cache_write_failure_stat);
如何啟用中間層緩存
添加--enable-interim-cache編譯選項來配置開啟緩存中間層功能
另外在主配置文件records.config中增加兩個配置項
proxy.config.cache.interim.storage:
用于緩存中間層的磁盤設備,只支持全路徑設備,多個磁盤使用空格分隔開
比如:
LOCAL proxy.config.cache.interim.storage STRING /dev/sdb /dev/sdc1
proxy.config.cache.interim.migrate_threshold:
遷移閾值,默認是2次,就是說,當一個url在LRU鏈表中出現2次以后,它才會從慢速硬盤存儲storage轉移到緩存中間interim cache中去。
比如:
LOCAL proxy.config.cache.interim.migrate_threshold 2
測試結果
我們的系統有160G SSD + 3 * 500G SAS, 16G RAM, 4 cores,下面是tsar和iostat -x的執行結果
tsar ======================================================================================
Time ? ? ? ? ? --------------------ts------------------ -------------ts_cache-----------
Time ? ? ? ? ? ? ?qps ? ?cons ? ? Bps ? ? ?rt ? ? rpc ? ? ?hit ?ramhit ? ?band ?ssdhit
24/06/13-10:30 901.83 ? 18.89 ? 22.6M ? 17.36 ? 47.74 ? ?87.30 ? 68.08 ? 88.90 ? 22.49
24/06/13-10:35 934.12 ? 18.88 ? 22.0M ? 14.34 ? 49.47 ? ?87.60 ? 68.53 ? 90.70 ? 22.21
24/06/13-10:40 938.14 ? 18.92 ? 21.7M ? 15.36 ? 49.58 ? ?87.70 ? 68.02 ? 89.50 ? 22.45
iostat -x ==================================================================================
avg-cpu: ?%user ? %nice %system %iowait ?%steal ? %idle
? ? ? ? ? ?5.47 ? ?0.00 ? 15.62 ? 25.09 ? ?0.00 ? 53.82
Device: ? ? ? ? rrqm/s ? wrqm/s ? ? r/s ? ? w/s ? rsec/s ? wsec/s avgrq-sz avgqu-sz ? await ?svctm ?%util
sda ? ? ? ? ? ? ? 0.00 ? ? 7.33 ? 25.67 ? ?3.33 ?1600.00 ?1438.00 ? 104.76 ? ? 0.45 ? 15.46 ?12.17 ?35.30
sdb ? ? ? ? ? ? ? 0.00 ? ? 0.00 ? 28.67 ? 11.33 ?1461.00 ?8723.00 ? 254.60 ? ? 0.74 ? 18.47 ?11.21 ?44.83
sdc ? ? ? ? ? ? ? 0.00 ? ? 0.00 ? 25.67 ? ?2.00 ?2178.00 ?1373.33 ? 128.36 ? ? 0.40 ? 14.05 ?11.04 ?30.53
sdd ? ? ? ? ? ? ? 0.00 ? ? 0.00 ?196.00 ? ?4.00 14790.00 ?2823.00 ? ?88.06 ? ? 0.13 ? ?0.66 ? 0.41 ? 8.30 ? 猜測這塊硬盤是ssd
參考文獻
說明:
慢速磁盤指普通的3.5寸硬盤,快速磁盤指ssd
緩存中間層
當我們考慮ATS的存儲時,最原始的設計是支持具有相同容量的多塊磁盤,(最適合沒有做raid的塊設備),由此構建分區,將每個分區指定某個域名(主機名),我們發現假如我們不對現有緩存設計做大的變動,我們就不能利用簡單的方式來得到多級緩存架構,因此我們得到下面的中間層解決方案:
我們假定你部署混合存儲(方案),快速磁盤在容量或是個數上小于慢速設備的十分之一
我們假設在絕大多數情況下,8塊快速磁盤已經相當多了
我們假設你的慢速設備每塊盤不會超過32TB
慢速設備存放所有的數據,這樣的話,萬一有快速磁盤緩存失敗時數據不會丟失
相較于存儲百分比,快速磁盤在服務器重啟期間可能丟失數據10%的數據
快速磁盤應當對所有的慢速磁盤在容量和IOPS上做均衡,磁盤分區基于慢速磁盤創建,對應的扇區分散在各個磁盤上,負載也應該在各個快速磁盤上做均衡
負載均衡設計
cache的中間層以快速磁盤為主(絕大多數情況下是SSD),重啟服務器進程會丟失數據, 因此只將中間數據(有備份)存放到中間層緩存中
我們最多支持8塊高速磁盤
我們做了一個塊級別(block level)的中間層緩存,(不像慢速磁盤)它不含任何索引信息
我們已經完成的工作
借用Dir結構體中的4bit來區分每個快速磁盤(因而快速磁盤個數不能超過32)
限制磁盤上限是32TB
使用volume.config中的配置來對每塊快速磁盤分區并綁定之
將中間層數據存到慢速磁盤的dir結構體中
將源服務器的數據寫到慢速磁盤
構建一個內部的LRU鏈表,大小限制為1M的bucket,將busy blocks備份到快速磁盤上
調用快速磁盤上的熱點數據,為了使它更高效,我們需要不斷比較LRU鏈表中的blocks
混合緩存設備(快速磁盤)也是呀RRD寫數據
優缺點pros and cons
優點:
我們做了一個可靠的解決方案,它對當前的存儲架構沒有做大的改動
LUR算法有助于我們得到熱的block,它是有效的
block層級的中間層緩存對大小對象都有作用
缺點:
服務器進程崩潰時會丟失數據,已在TS-2275中修正
僅只能有限個塊設備用作中間層緩存設備
中間層緩存設備在空間上不是追加,而僅是慢速磁盤設備上的熱點數據的復制
我們設置存儲系統的最大磁盤大小是0.5PB到32TB
默認配置情況下并不開啟中間層緩存功能
代碼及更改要點
the change of Dir:
@@ -155,15 +157,42 @@ struct FreeDir
? ?unsigned int reserved:8;
? ?unsigned int prev:16; ? ? ? ? // (2)
? ?unsigned int next:16; ? ? ? ? // (3)
+#if TS_USE_INTERIM_CACHE == 1
+ ?unsigned int offset_high:12; ? // 8GB * 4K = 32TB
+ ?unsigned int index:3; ? ? ? ? ?// interim index
+ ?unsigned int ininterim:1; ? ? ? ? ?// in interim or not
+#else
? ?inku16 offset_high; ? ? ? ? ? // 0: empty
+#endif
?#else
? ?uint16_t w[5];
? ?FreeDir() { dir_clear(this); }
we split the stat of read_success into disk, interim and ram:
@@ -2633,6 +2888,11 @@ register_cache_stats(RecRawStatBlock *rsb, const char *prefix)
? ?REG_INT("read.active", cache_read_active_stat);
? ?REG_INT("read.success", cache_read_success_stat);
? ?REG_INT("read.failure", cache_read_failure_stat);
+ ?REG_INT("interim.read.success", cache_interim_read_success_stat);
+ ?REG_INT("disk.read.success", cache_disk_read_success_stat);
+ ?REG_INT("ram.read.success", cache_ram_read_success_stat);
? ?REG_INT("write.active", cache_write_active_stat);
? ?REG_INT("write.success", cache_write_success_stat);
? ?REG_INT("write.failure", cache_write_failure_stat);
如何啟用中間層緩存
添加--enable-interim-cache編譯選項來配置開啟緩存中間層功能
另外在主配置文件records.config中增加兩個配置項
proxy.config.cache.interim.storage:
用于緩存中間層的磁盤設備,只支持全路徑設備,多個磁盤使用空格分隔開
比如:
LOCAL proxy.config.cache.interim.storage STRING /dev/sdb /dev/sdc1
proxy.config.cache.interim.migrate_threshold:
遷移閾值,默認是2次,就是說,當一個url在LRU鏈表中出現2次以后,它才會從慢速硬盤存儲storage轉移到緩存中間interim cache中去。
比如:
LOCAL proxy.config.cache.interim.migrate_threshold 2
測試結果
我們的系統有160G SSD + 3 * 500G SAS, 16G RAM, 4 cores,下面是tsar和iostat -x的執行結果
tsar ======================================================================================
Time ? ? ? ? ? --------------------ts------------------ -------------ts_cache-----------
Time ? ? ? ? ? ? ?qps ? ?cons ? ? Bps ? ? ?rt ? ? rpc ? ? ?hit ?ramhit ? ?band ?ssdhit
24/06/13-10:30 901.83 ? 18.89 ? 22.6M ? 17.36 ? 47.74 ? ?87.30 ? 68.08 ? 88.90 ? 22.49
24/06/13-10:35 934.12 ? 18.88 ? 22.0M ? 14.34 ? 49.47 ? ?87.60 ? 68.53 ? 90.70 ? 22.21
24/06/13-10:40 938.14 ? 18.92 ? 21.7M ? 15.36 ? 49.58 ? ?87.70 ? 68.02 ? 89.50 ? 22.45
iostat -x ==================================================================================
avg-cpu: ?%user ? %nice %system %iowait ?%steal ? %idle
? ? ? ? ? ?5.47 ? ?0.00 ? 15.62 ? 25.09 ? ?0.00 ? 53.82
Device: ? ? ? ? rrqm/s ? wrqm/s ? ? r/s ? ? w/s ? rsec/s ? wsec/s avgrq-sz avgqu-sz ? await ?svctm ?%util
sda ? ? ? ? ? ? ? 0.00 ? ? 7.33 ? 25.67 ? ?3.33 ?1600.00 ?1438.00 ? 104.76 ? ? 0.45 ? 15.46 ?12.17 ?35.30
sdb ? ? ? ? ? ? ? 0.00 ? ? 0.00 ? 28.67 ? 11.33 ?1461.00 ?8723.00 ? 254.60 ? ? 0.74 ? 18.47 ?11.21 ?44.83
sdc ? ? ? ? ? ? ? 0.00 ? ? 0.00 ? 25.67 ? ?2.00 ?2178.00 ?1373.33 ? 128.36 ? ? 0.40 ? 14.05 ?11.04 ?30.53
sdd ? ? ? ? ? ? ? 0.00 ? ? 0.00 ?196.00 ? ?4.00 14790.00 ?2823.00 ? ?88.06 ? ? 0.13 ? ?0.66 ? 0.41 ? 8.30 ? 猜測這塊硬盤是ssd
參考文獻
[1].https://blog.zymlinux.net/index.php/archives/555
[2].https://cwiki.apache.org/confluence/display/TS/SSDSupport
總結
以上是生活随笔為你收集整理的ATS缓存中间层介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用awk,sort和uniq从ATS访
- 下一篇: 在Ubuntu 14.04 64bit上