简体   繁体   English

检测 IIS 何时在 Azure 中回收

[英]Detect when IIS is recycling in Azure

I'm developing a WCF sercvice in Azure, in a web-role.我正在 Azure 中以 Web 角色开发 WCF 服务。 I build an index in memmory, and use it to serve wcf request.我在内存中建立了一个索引,并用它来服务 wcf 请求。 My problem is that this index is gone from the memory after iis is recycling.我的问题是这个索引在 iis 回收后从内存中消失了。 Is there any way, to detect the recycling event, and copy the index to the memory again?有什么办法,检测回收事件,并再次将索引复制到内存中?

Thansk for your help.感谢您的帮助。

Yes you can detect it in the Application_End event (in your Global.asax.cs).是的,您可以在Application_End事件(在您的 Global.asax.cs 中)中检测到它。

The better solution would be not to put the index in memory.更好的解决方案是不要将索引放在内存中。 Since you're using a Web Role, you can use Windows Azure Caching (you won't need to pay extra for this).由于您使用的是 Web 角色,因此您可以使用 Windows Azure 缓存(您无需为此支付额外费用)。 By using Windows Azure Caching you can store the index in memory, but not in the process of the application pool.通过使用 Windows Azure 缓存,您可以将索引存储在内存中,但不能存储在应用程序池的进程中。 It's still super-fast and it can survive application pool recycles.它仍然非常快,并且可以在应用程序池回收中存活下来。

Another advantage is that, when you store the index in Windows Azure Caching, all instances and roles in the same deployment will be able to use the same cache.另一个优点是,当您将索引存储在 Windows Azure 缓存中时,同一部署中的所有实例和角色将能够使用相同的缓存。 This means they'll all use the same index you store in it.这意味着它们都将使用您存储在其中的相同索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM