监控AppDomain资源并设置阈值
我的公司托管第三方编写的组件。每个组件都托管在自己的 AppDomain 中,但可能与其他组件共享服务器。最近,我认为一个或多个写得不好的组件行为不当并消耗了太多资源,导致服务器崩溃。我希望能够:
确定哪个组件是有罪的一方,或者换句话说,确定每个组件的应用程序域有多少资源(内存、操作系统句柄、CPU 周期等)。
在appdomains上设置阈值,这样即使某个组件确实发疯了,它可以消耗的资源也是有限的,并且它应该不会影响同一服务器上其他组件的性能。
有人有什么想法吗?
My company hosts components authored by third parties. Each component is hosted in its own AppDomain, but may share a server with other components. Recently, I believe that one or more badly written components have been misbehaving and consuming too many resources, causing server crashes. I would like to be able to:
Ascertain which component is the guilty party or, in other words, to determine how many resources each component's appdomain is comsunimg (memory, OS handles, CPU cycles etc).
Put thresholds on appdomains, so even if a component does go crazy, the resources it can consume are limited, and it should hopefully not affect the performance of other components on the same server.
Anyone got any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然这不是我问题的完整答案,但它确实满足了我的大部分要求。
此后,我发现了 AppDomain 对象的MonitoringIsEnabled、MonitoringSurvivedMemorySize、MonitoringSurvivedProcessMemorySize、MonitoringTotalAlownedMemorySize 和MonitoringTotalProcessorTime 属性(http://msdn.microsoft.com/en-us/library/z9744cf9.aspx),它满足了我上面1中的一些要求。但我仍然想了解操作系统句柄,如果可能的话能够设置阈值。这可行吗?
如果无法设置资源使用阈值,我想我可以使用上述属性持续监视域,并在检测到它超过一定量的内存或 CPU 时间时卸载它。
While this isn't a complete answer to my question, it does satisfy most of my requirements.
I have since discovered the MonitoringIsEnabled, MonitoringSurvivedMemorySize, MonitoringSurvivedProcessMemorySize, MonitoringTotalAllocatedMemorySize and MonitoringTotalProcessorTime properties of the AppDomain object (http://msdn.microsoft.com/en-us/library/z9744cf9.aspx), which satisfy some of my requirements from 1 above. But I would still like to know about OS handles, and if possible be able to set thresholds. Is this doable?
If it is not possible to set thresholds on resource usage, I guess I can instead continually monitor the domain using the properties above and unload it if I detect that it exceeds a certain amount of memory or CPU time.