Hi,
I use the .net clients and 2 servers at 2 different machines.
When one of the memcached servers is down, I try to set an item to the
cache (According the hashing algoritem of the client, this item should
stored the inactive server!) and this item get stored at the active
server.
After I set the item, the second server get back to work. Now if I'll
try to get this item I won't succeed, because the client will searche
the item at the second server (According the hashing algoritem).
What can i do to solve this problem???
(To set the item again at the second server isn't a solution, because
I don't want to store any item at 2 servers)
The memcache changelog for 3.0.5 has the comment:
"Added method MemcachePool::findServer(key) which returns the server a
key hashes to"
I bring this up because knowing (storing elsewhere) the server storing
your key allows to handle the case when your key may no longer exist
there and reload it from the database or file.
Your client and or your server memcache/d versions may not provide
these features.
Also read the other thread `Replication ?`
On 3/3/11 1:53 PM, Evil Boy 4 Life wrote:
> Hi,
> I use the .net clients and 2 servers at 2 different machines.
> When one of the memcached servers is down, I try to set an item to the
> cache (According the hashing algoritem of the client, this item should
> stored the inactive server!) and this item get stored at the active
> server.
> After I set the item, the second server get back to work. Now if I'll
> try to get this item I won't succeed, because the client will searche
> the item at the second server (According the hashing algoritem).
Are you referring to the Enyim client? I believe there's a separate
mailing list for that client, but I am not sure.
> What can i do to solve this problem???
> (To set the item again at the second server isn't a solution, because
> I don't want to store any item at 2 servers)
This seems like something more fundamental is wrong, or I miss the
question.
Keep in mind, having two servers isn't a situation where they are
active/inactive, it's a collection of two servers. Each adds to the
"pool" of cache available. It's normal for a given key to hash to one
server or another, depending on the key.
Are you saying that in a normal, no failures kind of situation, you
cannot get and then set the same key?
Matt
Memcache isn't supposed to do replication - it's a cache that you should
be able to replenish from the real data source. What happens when one
server fails depends on the client hash mechanism. Some people want the
load to be rebalanced evenly over the remaining servers, some don't.
Either way, the next attempt to use a failed server should detect it is
down and retrieve the data from the backing DB.
--
Les Mikesell
lesmi...@gmail.com
it is, however, possible to support "replication" at the client level, if a bit out of band for memcached. we (Fotolog), for example, at one point wrote our own client that would set data in multiple servers and then get from only one of them. it was a read-heavy environment with a small dataset that easily fit completely into RAM on each server, so it actually worked. not saying that it is a good idea, just that as possible.
anyway, it has since been replaced in our system with TokyoTyrant, which solved the problem much better for us... and it (or something similar) very well might in this case as well.
awl