alternative to memcached that can persist to disk

前端 未结 15 2050
猫巷女王i
猫巷女王i 2020-12-02 07:52

I am currently using memcached with my java app, and overall it\'s working great.

The features of memcached that are most important to me are:

  • it\'s fast,
相关标签:
15条回答
  • 2020-12-02 07:58

    EhCache has a "disk persistent" mode which dumps the cache contents to disk on shutdown, and will reinstate the data when started back up again. As for your other requirements, when running in distributed mode it replicates the data across all nodes, rather than storing them on just one. other than that, it should fit your needs nicely. It's also still under active development, which many other java caching frameworks are not.

    0 讨论(0)
  • 2020-12-02 08:00

    Maybe your problem is like mine: I have only a few machines for memcached, but with lots of memory. Even if one of them fails or needs to be rebooted, it seriously affects the performance of the system. According to the original memcached philosophy I should add a lot more machines with less memory for each, but that's not cost-efficient and not exactly "green IT" ;)

    For our solution, we built an interface layer for the Cache system so that the providers to the underlying cache systems can be nested, like you can do with streams, and wrote a cache provider for memcached as well as our own very simple Key-Value-2-disk storage provider. Then we define a weight for cache items that represent how costly it is to rebuild an item if it cannot be retrieved from cache. The nested Disk cache is only used for items with a weight above a certain threshold, maybe around 10% of all items.

    When storing an object in the cache, we won't lose time as saving to one or both caches is queued for asynchronous execution anyway. So writing to the disk cache doesn't need to be fast. Same for reads: First we go for memcached, and only if it's not there and it is a "costly" object, then we check the disk cache (which is by magnitudes slower than memcached, but still so much better then recalculating 30 GB of data after a single machine went down).

    This way we get the best from both worlds, without replacing memcached by anything new.

    0 讨论(0)
  • 2020-12-02 08:00

    In my experience, it is best to write an intermediate layer between the application and the backend storage. This way you can pair up memcached instances and for example sharedanced (basically same key-value store, but disk based). Most basic way to do this is, always read from memcached and fail-back to sharedanced and always write to sharedanced and memcached.

    You can scale writes by sharding between multiple sharedance instances. You can scale reads N-fold by using a solution like repcached (replicated memcached).

    If this is not trivial for you, you can still use sharedanced as a basic replacement for memcached. It is fast, most of the filesystem calls are eventually cached - using memcached in combination with sharedance only avoids reading from sharedanced until some data expires in memcache. A restart of the memcached servers would cause all clients to read from the sharedance instance atleast once - not really a problem, unless you have extremely high concurrency for the same keys and clients contend for the same key.

    There are certain issues if you are dealing with a severely high traffic environment, one is the choice of filesystem (reiserfs performs 5-10x better than ext3 because of some internal caching of the fs tree), it does not have udp support (TCP keepalive is quite an overhead if you use sharedance only, memcached has udp thanks to the facebook team) and scaling is usually done on your aplication (by sharding data across multiple instances of sharedance servers).

    If you can leverage these factors, then this might be a good solution for you. In our current setup, a single sharedanced/memcache server can scale up to about 10 million pageviews a day, but this is aplication dependant. We don't use caching for everything (like facebook), so results may vary when it comes to your aplication.

    And now, a good 2 years later, Membase is a great product for this. Or Redis, if you need additional functionality like Hashes, Lists, etc.

    0 讨论(0)
  • 2020-12-02 08:00

    You can use GigaSpaces XAP which is a mature commercial product which answers your requirements and more. It is the fastest distributed in-memory data grid (cache++), it is fully distributed, and supports multiple styles of persistence methods.

    Guy Nirpaz, GigaSpaces

    0 讨论(0)
  • 2020-12-02 08:01

    Try go-memcached - memcache server written in Go. It persists cached data to disk out of the box. Go-memcached is compatible with memcache clients. It has the following features missing in the original memcached:

    • Cached data survive server crashes and/or restarts.
    • Cache size may exceed available RAM size by multiple orders of magnitude.
    • There is no 250 byte limit on key size.
    • There is no 1Mb limit on value size. Value size is actually limited by 2Gb.
    • It is faster than the original memcached. It also uses less CPU when serving incoming requests.

    Here are performance numbers obtained via go-memcached-bench:

    -----------------------------------------------------
    |            |  go-memcached   | original memcached |
    |            |      v1         |      v1.4.13       |
    | workerMode ----------------------------------------
    |            | Kqps | cpu time |  Kqps  | cpu time  |
    |----------------------------------------------------
    | GetMiss    | 648  |    17    |  468   |   33      |
    | GetHit     | 195  |    16    |  180   |   17      |
    | Set        | 204  |    14    |  182   |   25      |
    | GetSetRand | 164  |    16    |  157   |   20      |
    -----------------------------------------------------
    

    Statically linked binaries for go-memcached and go-memcached-bench are available at downloads page.

    0 讨论(0)
  • 2020-12-02 08:11

    Oracle NoSQL is based on BerkeleyDB (the solution that Bill Karwin pointed to), but adds sharding (partitioning of the data set) and elastic scale-out. See: http://www.oracle.com/technetwork/products/nosqldb/overview/index.html

    I think it meets all of the requirements of the original question.

    For the sake of full disclosure, I work at Oracle (but not on the Oracle NoSQL product). The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.

    0 讨论(0)
提交回复
热议问题