国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Redis和Memcache的區(qū)別分析 [轉(zhuǎn)]

2019-11-15 01:34:32
字體:
供稿:網(wǎng)友
Redis和Memcache的區(qū)別分析 [轉(zhuǎn)]

1. Redis中,并不是所有的數(shù)據(jù)都一直存儲在內(nèi)存中的,這是和Memcached相比一個最大的區(qū)別。

2. Redis不僅僅支持簡單的k/v類型的數(shù)據(jù),同時還提供list,set,hash等數(shù)據(jù)結(jié)構(gòu)的存儲。

3. Redis支持?jǐn)?shù)據(jù)的備份,即master-slave模式的數(shù)據(jù)備份。

4. Redis支持?jǐn)?shù)據(jù)的持久化,可以將內(nèi)存中的數(shù)據(jù)保持在磁盤中,重啟的時候可以再次加載進(jìn)行使用。

Redis在很多方面具備數(shù)據(jù)庫的特征,或者說就是一個數(shù)據(jù)庫系統(tǒng),而Memcached只是簡單的K/V緩存

來看下Redis作者對比redis和memcache

來源:《Is memcached a dinosaur in comparison to Redis?》(相比Redis,Memcached真的過時了嗎?)

You should not care too much about performances. Redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. Also memcached is faster with big values in the order of 100k. Redis recently imPRoved a lot about big values (unstable branch) but still memcached is faster in this use case. The point here is: nor one or the other will likely going to be your bottleneck for the query-per-second they can deliver.

沒 有必要過多的關(guān)心性能,因為二者的性能都已經(jīng)足夠高了。由于Redis只使用單核,而Memcached可以使用多核,所以在比較上,平均每一個核上 Redis在存儲小數(shù)據(jù)時Memcached性能更高。而在100k以上的數(shù)據(jù)中,Memcached性能要高于Redis,雖然Redis最近也在存儲 大數(shù)據(jù)的性能上進(jìn)行優(yōu)化,但是比起Memcached,還是稍有遜色。說了這么多,結(jié)論是,無論你使用哪一個,每秒處理請求的次數(shù)都不會成為瓶頸。(比如 瓶頸可能會在網(wǎng)卡)

You should care about memory usage. For simple key-value pairs memcached is more memory efficient. If you use Redis hashes, Redis is more memory efficient. Depends on the use case.

如果要說內(nèi)存使用效率,使用簡單的key-value存儲的話,Memcached的內(nèi)存利用率更高,而如果Redis采用hash結(jié)構(gòu)來做key-value存儲,由于其組合式的壓縮,其內(nèi)存利用率會高于Memcached。當(dāng)然,這和你的應(yīng)用場景和數(shù)據(jù)特性有關(guān)。

You should care about persistence and replication, two features only available in Redis. Even if your goal is to build a cache it helps that after an upgrade or a reboot your data are still there.

如果你對數(shù)據(jù)持久化和數(shù)據(jù)同步有所要求,那么推薦你選擇Redis,因為這兩個特性Memcached都不具備。即使你只是希望在升級或者重啟系統(tǒng)后緩存數(shù)據(jù)不會丟失,選擇Redis也是明智的。

You should care about the kind of Operations you need. In Redis there are a lot of complex operations, even just considering the caching use case, you often can do a lot more in a single operation, without requiring data to be processed client side (a lot of I/O is sometimes needed). This operations are often as fast as plain GET and SET. So if you don't need just GET/SET but more complex things Redis can help a lot (think at timeline caching).

當(dāng) 然,最后還得說到你的具體應(yīng)用需求。Redis相比Memcached來說,擁有更多的數(shù)據(jù)結(jié)構(gòu)和并支持更豐富的數(shù)據(jù)操作,通常在Memcached里, 你需要將數(shù)據(jù)拿到客戶端來進(jìn)行類似的修改再set回去。這大大增加了網(wǎng)絡(luò)IO的次數(shù)和數(shù)據(jù)體積。在Redis中,這些復(fù)雜的操作通常和一般的 GET/SET一樣高效。所以,如果你需要緩存能夠支持更復(fù)雜的結(jié)構(gòu)和操作,那么Redis會是不錯的選擇。

1、 Redis和Memcache都是將數(shù)據(jù)存放在內(nèi)存中,都是內(nèi)存數(shù)據(jù)庫。不過memcache還可用于緩存其他東西,例如圖片、視頻等等。2、Redis不僅僅支持簡單的k/v類型的數(shù)據(jù),同時還提供list,set,hash等數(shù)據(jù)結(jié)構(gòu)的存儲。3、虛擬內(nèi)存--Redis當(dāng)物理內(nèi)存用完時,可以將一些很久沒用到的value 交換到磁盤4、過期策略--memcache在set時就指定,例如set key1 0 0 8,即永不過期。Redis可以通過例如expire 設(shè)定,例如expire name 105、分布式--設(shè)定memcache集群,利用magent做一主多從;redis可以做一主多從。都可以一主一從6、存儲數(shù)據(jù)安全--memcache掛掉后,數(shù)據(jù)沒了;redis可以定期保存到磁盤(持久化)7、災(zāi)難恢復(fù)--memcache掛掉后,數(shù)據(jù)不可恢復(fù); redis數(shù)據(jù)丟失后可以通過aof恢復(fù)8、Redis支持?jǐn)?shù)據(jù)的備份,即master-slave模式的數(shù)據(jù)備份。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 利川市| 东兰县| 开阳县| 云浮市| 扶余县| 繁昌县| 阿鲁科尔沁旗| 庆阳市| 东乡县| 黎平县| 嘉义市| 军事| 股票| 武冈市| 乐平市| 铁力市| 江源县| 信阳市| 苍山县| 呼伦贝尔市| 聂拉木县| 沙湾县| 嘉兴市| 白水县| 石林| 普兰店市| 嘉黎县| 青冈县| 阳高县| 滨州市| 凤山县| 江山市| 邢台市| 运城市| 荃湾区| 信阳市| 叙永县| 太保市| 珲春市| 宜君县| 油尖旺区|