2013-04-09 34 views
1

AppFabric 1.1客户端文档讨论了如何将DataCachServer端点列表分配给DataCacheFactoryConfiguration。大多数示例显示了由单个或两个不同的缓存服务器组成的列表。如果群集包含n服务器,客户端是否应注册每台服务器?服务器注册的顺序是否重要?例如,如果我的Web层中有50台服务器,而我的缓存层中有5台服务器,则50台Web服务器中的每台服务器是否都注册了所有5台缓存服务器?以下是示例代码:AppFabric 1.1客户端应连接到多少个DataCacheServerEndpoint?

// Declare array for cache host(s). 
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[5]; 
servers[0] = new DataCacheServerEndpoint("Cache01", 22233); 
servers[1] = new DataCacheServerEndpoint("Cache02", 22233); 
servers[2] = new DataCacheServerEndpoint("Cache03", 22233); 
servers[3] = new DataCacheServerEndpoint("Cache04", 22233); 
servers[4] = new DataCacheServerEndpoint("Cache05", 22233); 

// Setup the DataCacheFactory configuration. 
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration(); 
factoryConfig.Servers = servers; 

// Create a configured DataCacheFactory object. 
DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig); 

// Get a cache client for the cache named "default". 
DataCache myDefaultCache = mycacheFactory.GetCache("default"); 

每个Web服务器是否可以相同地注册,并且负载在缓存层中是否平衡?如果注册服务器变得不可用,那么下一个服务器是按顺序尝试还是随机化的?链接到支持文档将有所帮助。

与负载平衡有关,Jason Roth写了下面的[是否有其他文档可用]?

应用结构客户端是智能客户端,它可以直接联系有史以来服务器有你的数据的服务器。应用程序无需担心负载平衡。这是使用路由客户端完成的。

回答

1

基于一些测试,并让杰森·罗斯的评论下沉,我认为的DataCacheServerEndPoint使用的“智能客户端”来检索缓存集群成员的名单时,GetCache方法被调用的DataCacheFactory 。 DataCache对象是智能的 - 从某种意义上说,它非常聪明,如果DataCacheServerEndpoint实例化中使用的服务器脱机或以其他方式变为不可用,则智能客户端仍可访问其他集群成员。因此,多个DataCacheServerEndpoint列表的目的是在调用GetCache方法时提供冗余。

建议是DataCache对象应该遵循单例模式,并且不要在每个缓存中的数据请求上实例化。这就是为什么不需要为各个DataCacheServerEndpoints进行负载平衡或提供VIP的原因。

根据需要实例化尽可能多的DataCacheServerEndPoints,以确保至少有一个总是处于启动状态 - 无需添加缓存集群的每个成员,除非这是确保至少有一个成功启动的唯一方法。

在缓存集群中管理盒子(例如,每月应用补丁)时,请考虑通过一次管理一个盒子来最小化缓存抖动和重新平衡,而不是尝试在“波浪”中管理一组盒子”。