Monitoring AppDomain resources and setting thresholds
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 threshol开发者_运维技巧ds 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?
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.
精彩评论