We are seeing a very high amount of CPU and memory usage from one of our .NET MVC apps and can't seem to track down what the cause of it is. Our group does not have access to the web server itself but instead gets notified automatically when certain limits are hit (90+% of CPU or memory). Running locally we can't seem to find the problem. Some items we think might be the culprit
The app has a number of threads running in the background when users take certain actions
We are using memcached (on a different machine than the web server)
We are using web sockets
Other than that the app is pretty standard as far as web applications go. Couple of forms here, login/logout there, some admin capabilities to manage users and data; nothing super fancy.
I'm looking at two different solutions and wondering what would be best.
Create a page inside the app itself (available only to app admins) that shows information about memory and CPU being used. Are there examples of this or is it even possible?
Use some type of 3rd party profiling service or application that gets installed on the web servers and allows us to drive down to find what is causing the high CPU and memory usage in the app.
i recommed the asp.net mvc miniprofiler. http://miniprofiler.com/
it is simple to implement and to extend, can run in production mode, can store its results to SQL Server. i used it many times to find difficult performance issues.
Another possibility is to use http://getglimpse.com/ in combination with the miniprofiler glimpse-plugin https://github.com/mcliment/miniprofiler-glimpse-plugin
both tools are open source and don't require admin access to the server.
You can hook up Preemptive's Runtime Intelligence to it. - http://www.preemptive.com/
Otherwise a profiler, or load test could help find the problem. Do you have anything monitoring the actual machine health? (Processor usage, memory usage, disk queue lengths, etc..).
http://blogs.msdn.com/b/visualstudioalm/archive/2012/06/04/getting-started-with-load-testing-in-visual-studio-2012.aspx
Visual studio has a built-in profiler (depending on version and edition). You may be able to WMI query the web server that has the issues, or write/provide diagnostic recording/monitoring tools to hand them over to someone that does have access.
Do you have any output caching? what version of IIS? Is the 90% processor usage you are getting alerted to showing that your web process is actually the one doing it? ( Perhaps it's not your app if the alert is improperly configured)
I had a similar situation and I created a system monitor to my app admins based on this project
Related
I have a Windows Service written in C# which is running on a customer's server and seems to be working fine without any problems, but the CPU usage for this process is often much higher than I would expect. It is never over 50%, but is still a lot higher than the single figures I see when running in house.
This may simply be due to a higher workload, but I was attempting to determine what exactly the service was doing and process explorer is reporting a lot of threads with a start address of clr.Dll!MetaDataGetDispenser, each with small CPU Usage, but they all add up.
Does anyone know what this and what sort of code would be using it?
The service will be using WCF to connect to various clients (and presumably that will involve some sort of serialisation) and will also be accessing a Microsoft SQL Server, but no explicit reflection.
Good day,
Is there a way to monitor the memory usage of a WCF service?
I Googled and couldn't find any proper answer. Unfortunately I don't have access to 3rd party tools like RedGate ANTS or the JetBrains memory profiler.
I have enabled all performance counters in my service web config in order to see if I can use the Performance Monitor to view the memory usage but I don't know where to look to get the amount of memory being used by the service.
I also created a load test for one of the wcf methods just as a test to see if it can tell me how much memory was used by the service during the test, but also don't think it gives me the info I need.
Does anyone know how I could do this or point me in the right direction?
Thank you in advance.
I you want to watch Performance counters by standart means you should use PerfMon utilite. Launch it from cmd and open System monitor link. There you should add new monitor (CTRL+N). Depending on the CLR version and hosting paramenters of your service you can select two options from the appeared list, which could probably help you:
1) ServiceModelServices (3.0 or 4.0) - monitors the information about your services, number of instances, processor loading, transactions, security, numbers of calls and so on.
2) Memory in CLR. NET - helps you to monitor the memory usage by .NET FrameWork applications. There you should choose your service hosting process (w3wp for IIS for example). After this you can watch the required infromation.
I have profiling and optimizing a set of code. For now I have actually just manual looked at the runtime of a unittest and been looking in Resource Manager in windows.
My unit-test now work and everything is working as it should. I would like to documentate my findings, and need to log the CPU and Network Usage instead of just viewing it myself.
If i can do it directly on my unit-test that would be fine, but there properly are some overhead and therefore i did put the code in a console app instead.
How do i easiest log the CPU / Network usage like the number shown in the Resource Manger in windows 8 (its nicely detailed).
Solution for calculating performance CPU / Memory Address
If you want to do it manually, you can add the "namespace"
"System.Diagnostic" and use the class "StopWath" that allows you to
retrieve time to calculate the performance of your applications and
the time to call your functions.
Look here to use the class "StopWath" by microsoft example with
computing performance.
StopWatch How to use it ?
Or else you can also use a fabulous tool called Microsoft "CLR
Profiler" is an application to calculate the performance of your
application. Net C # or ASP. Application complete with visual speech
on the memory and the time between each call over the management of
"garbage collector"
How use Clr profiler
Download Clr profiler
Solution for calculating performance Network traffic
You can use the network simulation from visual studio
Or this applications :
A network sniffer c#
Network sniffer and connection Analyser
sniff web client
As far as you know, are there any problems in running a C# application from a shared exe file? This is a request from a customer asking their 20 clients to run the same exe file on shared path.
First tests didn't show problems, but don't know on long terms. I personally don't like this, don't think that framework was developed with this in mind, but they do for a quick upgrade of the exe file when needed.
Any point to discourage this?
Thanks
Sav
The first consideration is deployment concerns. Prior to .NET 3.5 SP1, this was not allowed by default because the shipped security policy treated network locations in a less trusted way. .NET 3.5 SP1 and later, this is no longer the case. You could, of course, use caspol to modify this security policy to allow this, if you are working with versions of the framework prior to that. Additionally, some more recent versions of Windows may have additional security policies outside of .NET that can prevent execution from remote locations.
The second consideration is making sure the application is designed in a way that it is aware of its environment, not assuming the environment is relative to the local machine when it is expected to be so (which could affect resolution of external resources and, depending on the situation, could result in resource contention or users overwriting each other's data).
The third is availability. What if the server hosting that executable becomes unavailable (is powered off by accident, crashes, experiences networking issues, is renamed, etc.)? Is that acceptable? How large is the executable? If it is large, that can increase network traffic and at any rate result in the executable being slow to start as it is invoked over the network.
I suppose for trivial applications, these issues may be negligible. However, there are lots of ways of installing applications on client computers in a way that they are installed and updated quickly and easily, such as ClickOnce deployment.
We currently run software designed in house. This runs off a central SQL database. Each computer is set up with a batch program which runs through Windows Start Up and downloads the current program files from the central server. The .exe is therefore run off the individuals computer and not off the server. This has been found, in our case at least, to be the most efficient method.
Our application is written in .NET (framework 3.5). We are experiencing problems with the applications performance when deployed in a terminal services environment. The client is using a TS farm. They have 4GB ram and a decent xeon processor.
When the application is opened in this environment, it sits at 25% CPU usage even when idle. When deployed in a normal client - server environment, it behaves normally, spiking the CPU usage when necessary and drops down to 0 when idle.
Does anyone have any ideas what could be causing this? Or, what I could do to investigate? We have no memory leaks that we can find using performance profiling tools.
This is a WinForms application
We dont have a TS environment avialable to test on
The application is a Business Application.
Basically, capturing and updating of data. Its a massive business application, but there is little multithreading, listeners etc. We do have ANTS profiler (memory / performance) but as mentioned in our environment we dont have the problem - it only occurs on the TS environment
Well, there are a few questions before we can really get you too far.
Is this a Console Application? WinForms Application? or Windows Service?
Do you have a Terminal Services environment available?
What does your application do?
Depending on what the application does, you might check to see if there is unusually high activity on their hardware that you have not accounted for. Examples that I have noticed in the past are items such as having a FileSystemWatcher accidentally listening to a "drop location" for reporting on a client server. Things of that nature, items that while "idle" shouldn't be busy, but are.
Otherwise, if you have the ability to do so, you could also use a tool such as ANTS Profiler from RedGate to see WHAT is using the CPU time on the environment.
Look for sections in your application that constantly repaints the window. Factor those out so that when sitting idle it isn't constantly repainting the window.