Monitor WCF service memory usage - c#

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.

Related

clr.Dll!MetaDataGetDispenser and higher than expected CPU usage

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.

How to find performance bottleneck in application?

Question is a bit general, but I'll try my best to ask it correctly.
So I started supporting system which is composed of parts:
Client Application (.net/c#)
WebService Server (IIS 6)
DB (Oracle 10g)
In client application, user is making reports requests, which are proceeded by the web service, and the data is taken from DB.
And some of these reports are proceeding VERY SLOW. About 1 hour for proceeding about 100 000 rows from 1 table.
So I want to know, which part of the system is slowing the whole system down.
What are the most common practics to find this out? I understand that the question is very complex and general and recommending particular instrument is quite impossible. But what are common tactics? What is usual way to find out if system is slowing down on DB, web service or client side?
You can use profilers.You can find "Hot spots" based on profiling methods(eg CPU Sampling ,Instrumentation...and etc) .Personally for C# client i use visual studio profiler ,Jabraines DotTrace and ANT Memory profiler .Additionally you can use windows performance monitor as well. I use SQL profiler and RedGate Profiler for Database profiling.But there are more profilers available over the internet.Just have a research on Google and select a suitable one.
You may have answered your own question in the "where", ie have a look at the queries called when running the reports. As for the "How" have a look at the tools/profilers available to profile your application and the database.

How do I log the CPU/Network usage for my console app, alternative a unittest in c#

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

High CPU and Memory usage from .NET MVC app

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

CPU usage extremely high on TS deployment

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.

Categories

Resources