我们已经为我们的Web应用程序实现了AppFabric Windows Server Cache.最初,我们能够毫无问题地使用缓存.然后我们将流量增加了大约100倍,并开始出现间歇性异常.例外情况大约每2天发生一次,大约每分钟发生一次.
我们的配置:
错误按顺序发生(在1分钟内,九个Web服务器中的每一个都会发生异常):
System.Net.Sockets.SocketException:远程主机Microsoft.ApplicationServer.Caching.DataCacheException强制关闭现有连接: ErrorCode<ERRCA0016>:SubStatus<ES0001>:The connection was terminated, possibly due to server or network problems or serialized Object size is greater than MaxBufferSize on server. Result of the request is unknown. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or …
根据您的目标是Windows Azure或Windows Server,在发现缓存API严重不同之后,我担心微软不会继续为Windows Server开发AppFabric.有谁知道AppFabric for Windows Server是否仍然受支持/开发?
我在服务器上安装了AppFabric.我创建了一台计算机的集群.我还创建了一个名为"Gagan"的缓存.按顺序使用以下命令
Use-CacheCluster -Provider xml -ConnectionString\NB-GJANJUA\Cache Start-CacheCluster
结果是缓存服务已启动并运行..这么好.
然后我设置我的web.config文件,如下所示
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<!-- cache client -->
<dataCacheClient>
<!-- cache host(s) -->
<hosts>
<host
name="NB-GJANJUA.com"
cachePort="22233"/>
</hosts>
</dataCacheClient>
<system.web>
<compilation debug="true" targetFramework="4.0" >
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<sessionState mode="Custom" customProvider="SessionStore" cookieless="true">
<providers> …
Run Code Online (Sandbox Code Playgroud) 我有一个ASP.Net MVC应用程序,它大量使用session来保存状态(包括大数据集合).目前,它托管在一个Web服务器上.会话设置为InProc的默认值.
出现了一个问题,即当许多用户在线时,应用程序会冻结某些用户.我想这是因为InProc会话不能很好地扩展,并且该进程只有很多可用内存.(如果内存需求超过可用内存会发生什么 - 它是否会换出磁盘?)
我有几个解决方案可以帮助实现可伸缩性.(a)Sql server会话状态; (b)配置会话状态以使用AppFabric缓存.第一个选项看起来是一个很好的解决方案,除了它会影响性能并要求存储的项目可序列化.
如何在单个Web服务器也用作缓存主机的环境中配置会话状态以使用AppFabric缓存(也称为Velocity)?在单一服务器环境中,这与InProc有何不同?这会提供比InProc更多的可扩展性和可用内存,还是基本上会达到相同的约束?
在缓存和读取模式中,在这两种模式中我们都需要编写代码来写入数据库.那么通读,后写方法的真正优势是什么?请澄清我的疑问.
我正在使用PowerShell自动化AppFabric安装,我遇到了一个问题,即脚本调用安装程序,等待它完成,但我无法从相同的上下文导入已安装的模块.即:
Start-Process "C:\provision\WindowsServerAppFabricSetup_x64.exe" -ArgumentList "/i /GAC" -Wait
Import-Module DistributedCacheConfiguration
# ...do configuration things...
Run Code Online (Sandbox Code Playgroud)
哪个错误: The specified module 'DistributedCacheConfiguration' was not loaded because no valid module file was found in any module directory.
如果您关闭并重新打开PowerShell,脚本运行正常.Start-Sleep 60
在安装程序和配置之间添加一个没有帮助,所以我尝试调用它,好像PowerShell正在重新启动:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe C:\provision\appfabric_config.ps1
Run Code Online (Sandbox Code Playgroud)
抛出了同样的错误.如何让PowerShell识别新安装的模块?
除了Secondaries=1
在集群配置中设置启用HighAvailability 之外还有什么内容,特别是在缓存客户端配置上吗?
我们的配置:
使用about配置,我们可以看到在三台主机上创建的主区域和辅助区域,但是当其中一台主机停止时,会发生以下异常:
ErrorCode<ERRCA0018>:SubStatus<ES0001>:The request timed out.
An existing connection was forcibly closed by the remote host
No connection could be made because the target machine actively refused it 192.22.0.34:22233
An existing connection was forcibly closed by the remote host
高可用性是否能够在不中断服务的情况下处理主机停机?我们正在使用一个命名区域 - 这会破坏高可用性吗?我在某处读到命名区域只能存在于一个主机上(我确实验证了另一个主机上存在辅助区域).我觉得我们缺少一些缓存客户端配置可以实现高可用性,任何有关此事的见解都将非常感激.
我们生产的AppFabric Cache几乎每天都会崩溃,而且非常不稳定.记录以下错误:
Microsoft.ApplicationServer.Caching.DataCacheException:ErrorCode:SubStatus:存在临时故障.请稍后重试.(没有足够的辅助人员,或者他们处于受限状态.)
Microsoft.ApplicationServer.Caching.DataCacheException:ErrorCode:SubStatus:存在临时故障.请稍后重试.(请求没有找到主要的.)
AppFabric缓存服务崩溃.{外部商店租约已过期:Microsoft.Fabric.Federation.ExternalRingStateStoreException:Microsoft.Fabric.Federation.SiteNode.PerformExternalRingStateStoreOperations中的Microsoft.Fabric.Data.ExternalStoreAuthority.UpdateNode(NodeInfo nodeInfo,TimeSpan超时)租约已过期(Boolean&canFormRing,Boolean isInsert,Boolean isJoining)}
有人可以请我提供一些意见吗?这是一个启用HA的缓存环境,具有3个缓存主机.所有这些都在Windows Server 2008 Enterprise Edition上运行,SQL Server用于配置.
我试图通过自己缓存视图结果对象来重新创建MVC 4中OutputCache操作过滤器的大部分功能.我不想使用OutputCache动作过滤器的原因是因为我不能将它与AppFabric和部分视图一起使用; 部分视图始终存储在MemoryCache中,我希望在服务器场中使用缓存的对象.
我遇到的第一个问题是
{"Type 'System.Web.Mvc.TempDataDictionary' cannot be serialized.
Consider marking it with the DataContractAttribute attribute, and marking all of
its members you want serialized with the DataMemberAttribute attribute.
If the type is a collection, consider marking it with the
CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for
other supported types."}
Run Code Online (Sandbox Code Playgroud)
这让我想知道是否应该缓存其他内容以返回最终的视图.有没有人知道我应该缓存什么来重新创建视图或不同的方法来缓存服务器场上的部分视图?我不想为此使用第三方插件.
谢谢
更新:我开始缓存部分视图的字符串表示,如下所示:
using (StringWriter sw = new StringWriter())
{
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, "ViewName");
ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
view = sw.GetStringBuilder().ToString(); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个工具(在 Visual Studio 2010,C# 中),它可以读取 Appfabric 缓存中存在的所有项目并将它们存储在表中。我不必使用powershell。
首先我想,如果我能得到缓存中存在的所有区域,我就可以利用DataCache.GetObjectsInRegion
方法来完成我的任务。但是我无法从缓存中获取所有区域名称,因为它不显示用户定义的区域名称,而仅显示默认区域名称,所以现在我放弃了这种方法。
任何人都可以在这里指导我,我的主要目标是读取缓存中存在的所有项目。
appfabric ×10
appfabric-cache ×10
c# ×2
.net ×1
asp.net-mvc ×1
azure ×1
caching ×1
inproc ×1
powershell ×1