Your best bet at this point is to read the memcached faq at
http://www.socialtext.net/memcached/index.cgi?faq
Especially the "How does memcached work" section...
http://www.socialtext.net/memcached/index.cgi?faq#how_does_memcached_work
Also if you want to have a more in depth conversation about memcached
itself chat with the whole group at
http://groups.google.com/group/memcached?pli=1
This list is really just for the hibernate-memcached list. I can
gladly answer your questions, but the real experts are over there :)
Memcached is distributed in the sense that the client hashes keys to
decide which memcached node to put an object in. When you are only
running one instance (with a client configured to talk to one
instance) you don't get that effect. The key is to run many instances.
The client will hash and then mod the key by the number of servers to
decide where to get/set from. If one of your memcached instances goes
down, you only lose the data that was stored in that instance.
Hope that helps!
Hibernate-memcached doesn't know anything about your database. When
the memcached client can't get to the server it is going to return
nulls to Hibernate. When Hibernate gets a null back from the cache it
goes to the database.
Hibernate always asks the cache before going to the database, that's
the point of having a cache enabled. Your going to see log messages
about spymemcache trying to connect, and even hibernate-memcached
trying to do lookups when the memcached isntances are down as there's
no reason for it to stop trying.
Be sure that running one instance of memcached in development is fine,
but when you go to production you're defeating the purpose of using
memcached if you're only running one instance.
Sorry, I mean that when you request data from hibernate, it will go
the database when the cache returns null. In the meantime, spymemcahed
will be checking the server to see if it can reconnect.
Well that sucks :P
Out of curiosity are you setting an "operationTimeout" value at all?
The default is like 1 second :)
Would it be possible for you to try the latest batch of code at Github out?
http://github.com/raykrueger/hibernate-memcached/
If added better exception handling that might help here when there are
NO memcached instances available. As I've said before, you definitely
shouldn't be running one instance alone though.
If they're all down it still shouldn't increase your query time.
You can either clone it with git or just download it by clicking the
download link. That will zip or tar the latest code for you. From
there you can just build it with Maven (mvn install).
Unfortunately The pom.xml I pulled over from SVN still has "1.0" as
the version, you should change that to 1.1-SNAPSHOT or something.
Let me know if that changes the behavior at all. Thanks!
Hibernate controls what data goes in and out of the cache and how the
lookups are handled. I have no control over that. All I do is map
those requests into memcached.
You might want to pull down the spymemcached source and see if you can
see something worth fixing in there. Right now though, I haven't seen
this behavior or heard of anyone else having a similar problem. I'll
see if I can dig something up as to what sort of timeout it's using.