乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Memcached, Redis, MongoDB區(qū)別

       博雅書屋lhs 2015-04-29

      mongodb和memcached不是一個范疇內的東西。mongodb是文檔型的非關系型數(shù)據(jù)庫,其優(yōu)勢在于查詢功能比較強大,能存儲海量數(shù)據(jù)。mongodb和memcached不存在誰替換誰的問題。

      和memcached更為接近的是redis。它們都是內存型數(shù)據(jù)庫,數(shù)據(jù)保存在內存中,通過tcp直接存取,優(yōu)勢是速度快,并發(fā)高,缺點是數(shù)據(jù)類型有限,查詢功能不強,一般用作緩存。在我們團隊的項目中,一開始用的是memcached,后來用redis替代。

      相比memcached:

      1、redis具有持久化機制,可以定期將內存中的數(shù)據(jù)持久化到硬盤上。

      2、redis具備binlog功能,可以將所有操作寫入日志,當redis出現(xiàn)故障,可依照binlog進行數(shù)據(jù)恢復。

      3、redis支持virtual memory,可以限定內存使用大小,當數(shù)據(jù)超過閾值,則通過類似LRU的算法把內存中的最不常用數(shù)據(jù)保存到硬盤的頁面文件中。

      4、redis原生支持的數(shù)據(jù)類型更多,使用的想象空間更大。

      5、前面有位朋友所提及的一致性哈希,用在redis的sharding中,一般是在負載非常高需要水平擴展時使用。我們還沒有用到這方面的功能,一般的項目,單機足夠支撐并發(fā)了。redis 3.0將推出cluster,功能更加強大。

      6、redis更多優(yōu)點,請移步官方網(wǎng)站查詢。

      7. 性能

      Redis作者的說法是平均到單個核上的性能,在單條數(shù)據(jù)不大的情況下Redis更好。為什么這么說呢,理由就是Redis是單線程運行的。
      因為是單線程運行,所以和Memcached的多線程相比,整體性能肯定會偏低。
      因為是單線程運行,所以IO是串行化的,網(wǎng)絡IO和內存IO,因此當單條數(shù)據(jù)太大時,由于需要等待一個命令的所有IO完成才能進行后續(xù)的命令,所以性能會受影響。

       

      下面內容來自Redis作者在stackoverflow上的一個回答,對應的問題是《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.
      • 沒有必要過多的關心性能,因為二者的性能都已經(jīng)足夠高了。由于Redis只使用單核,而Memcached可以使用多 核,所以在比較上,平均每一個核上Redis在存儲小數(shù)據(jù)時比Memcached性能更高。而在100k以上的數(shù)據(jù)中,Memcached性能要高于 Redis,雖然Redis最近也在存儲大數(shù)據(jù)的性能上進行優(yōu)化,但是比起Memcached,還是稍有遜色。說了這么多,結論是,無論你使用哪一個,每 秒處理請求的次數(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.
      • 如果要說內存使用效率,使用簡單的key-value存儲的話,Memcached的內存利用率更高,而如果Redis采用hash結構來做key-value存儲,由于其組合式的壓縮,其內存利用率會高于Memcached。當然,這和你的應用場景和數(shù)據(jù)特性有關。
      • 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).
      • 當然,最后還得說到你的具體應用需求。Redis相比Memcached來說,擁有更多的數(shù)據(jù) 結構和并支持更豐富的數(shù)據(jù)操作,通常在Memcached里,你需要將數(shù)據(jù)拿到客戶端來進行類似的修改再set回去。這大大增加了網(wǎng)絡IO的次數(shù)和數(shù)據(jù)體 積。在Redis中,這些復雜的操作通常和一般的GET/SET一樣高效。所以,如果你需要緩存能夠支持更復雜的結構和操作,那么Redis會是不錯的選 擇。

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多