Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Memcached Server 1.0.3

Items randomly evicted.

1 reply [Last post]
  • Login or register to post comments
Tue, 05/25/2010 - 08:41
Lachoneous
Offline
Joined: 05/25/2010
Groups: None

Hello there. We are using Membase in Windows 2008 Server with Enyim and c#.net. We have a bucket with 1 GB allocated that we are using to store website user session information. The total amount of data stored in the bucket is probably no more than 2K at any time so far during our local testing. Here is an IM I received from one of our developers:

"If I let the our web console just sit here on a page, it takes about 15 minutes and then my account data that is in memcached gets evicted for some reason and it needs to be reloaded. How much data have I cram packed into my 1 GB bucket? Whatever the size of 1 account row and 1 group row is (very small). So it does seem odd that it would evict that data, especially since I have placed an infinite time span on it when I stored it."

The problem he is having is with what appear to be random items getting evicted from the bucket when 1) there is plenty of available space in the bucket, and 2) An infinite timespan allocated on the item. It would seem to me that in this case, memcached would keep the item around forever unless the capacity for the bucket was full and it was at the top for the LRU list.

Is there something I'm missing here?

Thanks for your time!

Top
Tue, 05/25/2010 - 23:13
ingenthr
Offline
Joined: 03/16/2010
Groups:

Hi,

First let me address your question, then let's look at your use case.

For high performance and to ensure we do not fragment memory, memcached (and NorthScale's Memcached Server) divide memory up into various sizes (called slabs). Intentionally, the LRU implemented in memcached is not a strict LRU in a number of ways. One way it's not a strict LRU is that items are evicted from within a group of memory locations for a particular size. So, what you may be seeing isn't items randomly evicted, but rather the result of the algorithm choosing to evict one item over another.

To very simply see if it's LRU-on-slabsize which is giving you that behavior, you may want to double or half the bucket size. If that changes the lifetime, then this is likely what you're seeing. This could be verified with some low level statistics and/or scripts with some effort. I can provide more detail here if this would be helpful.

Having said that, let me address the particular use case you have. The contract between a memcached client and the server is that the server may evict any item at any time for any reason. More realistically, the memcached server always tries to keep items with an expiration of 0, but the server does not promise a strict LRU. As a result you may want to reconsider how you use the NorthScale Memcached Server with your user session data. It can definitely be used with user sessions (lots of people use memcached for this), but the pattern we recommend with the NorthScale Memcached Server is one where you send all session modifications to a persistent store (with either the session or an invalidation going to the cache), but read session data from the cache in most cases.

In this case, for instance, if a user goes idle for a long period of time you don't use precious memory resources keeping the session around for hot access, but if the session is still valid it can be recreated as needed from the persistent store.

There may well be some other options available in the future as well. We know the session use case is popular, so we're working to simplify how this can be deployed.

I hope that helps. Please let me know if this helps/you could use more information.

p.s.: Sorry for the delayed reply, I forgot to hit the "post" button when I typed this earlier this morning.

Top
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker