MemCacheStore如何真正与多台服务器一起使用? [英] How does the MemCacheStore really work with multiple servers?

查看:113
本文介绍了MemCacheStore如何真正与多台服务器一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在任何地方都找不到有关ActiveSupport :: Cache :: MemCacheStore行为的文档,我希望这里的人能有所作为. 研究人员说:

I can't find documentation on the behavior of ActiveSupport::Cache::MemCacheStore anywhere, and I'm hoping someone here can shed some light. The rdoc says:

"集群和负载平衡.一个可以指定多个memcached服务器,MemCacheStore将在所有可用服务器之间进行负载平衡.如果一台服务器出现故障,则MemCacheStore将忽略它,直到它恢复正常. "

好的.我想要最后一个功能,因此,如果内存缓存服务器出现故障,整个堆栈都不会失败.但是我需要了解负载平衡功能.我认为这不只是循环请求,因为那样会导致不必要的缓存未命中.另外,我正在使用memcache进行会话,所以我不希望登录的用户突然没有会话,因为memcache客户端会将请求负载均衡"到没有该会话的服务器...

Ok. I want the last feature, so if a memcache server goes down the whole stack doesn't fail. But I need to understand the load balancing feature. I assume it doesn't just round robin requests, as that would result in unnecessary cache misses, it seems. Also, I'm using memcache for sessions, so I wouldn't want someone logged in to suddenly not have a session because memcache client "load balanced" that request to a server that doesn't have that session...

有人可以帮助我了解负载平衡"功能的工作原理吗?

Can someone help me understand how the "load balancing" feature works?

推荐答案

据我了解,它使用哈希机制来确定将请求发送到哪个内存缓存服务器.如果存储了密钥值对,则哈希机制使用密钥,因此,当密钥请求该值时,相同的哈希方法将告知Rails正确的Memcache服务器从中获取数据.

As I understand it it uses a hashing mechanism to determine which memcache server to send requests to. The hashing mechanism uses the key if the key value pair being stored thus when the value is requested by key the same hashing method will tell rails the correct memcache server to fetch the data from.

这意味着如果内存缓存服务器死机,您将丢失缓存在其上的数据的比例(即,如果3个服务器配置中有1台服务器死机,则将丢失33%的缓存)

This means that if a memcache server dies you will loose the proportion of data that is cached on it (ie in a 3 server config if 1 server dies you will loose 33% of your cache)

请参见 http://www.ruby-forum.com/topic/100104比我刚才给出的更好的解释.

See http://www.ruby-forum.com/topic/100104 for a much better explanation of that than I've just given.

这篇关于MemCacheStore如何真正与多台服务器一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆