performance counters tips for server - asp.net-mvc

I have an mvc4 application that communicates to my sql server database via a wcf layer. Each layer is co located on the same server with the database located on a different server.
I am seeing CPU issues on my server which holds the applications, in particular with my mvc4 application. The server is windows server 2008 R2¬ running IIS7.5.
I would like to put some performance counters on my server to analyze where the problem on the server may be and is causing the high cpu problems.
I am new to setting up such and looking for pointers as to what counters to set up that may assist me, how I should analyze and best plan in gaining more knowledge on such.

Performance counters are generally good for production monitoring. On dev environnement (and I suppose you are at this stage), there are many profiling tools & apis.
On Sql Server
The best tool is Sql Server Profiler. You can find and diagnose slow-running queries by capturing all Transact-SQL statements and/or Sql Server Events.
On Asp.net MVC
I highly suggest you install a profiler like asp.net mini-profiler or Glimpse. When browsing you website, this will tell you which controller/action/partial/ajax is slow and sometimes why.
Visual Studio includes a Profiler. This let you measure, evaluate, and target performance-related issues in your code. It's fully integrated into the IDE. Once you have ran a performance session, several reports are available to help visualize and detect performance issues from the data gathered.
If you can't find why, you could run a load test using Visual Studio Web & Load Tests. You will rarely have performance issues for a single user, but for many concurrent users it's not generally the case.

Related

How to stress memory on web server?

I have created web cluster with several web sites and I would like to perform stress test of a memory but I have no clue how to.... I have used Jmeter but I always get CPU load not memory (cant used more then 1GB). Is there anyway to stress test it by Jmeter?
p.s. I would like to avoid custom scripts because I want my test to be repeatable by anyone. For websites I am using generic WP installations.

How to Debug the asp.net web application without disturbing the release build?

I'm working asp.net web based application, I have deployed this application on server, Its getting response on port 80 from a outside client.
I want the to fix the bugs so I want to run this application in Debug mode so that I can attach the worker process with the application and this is making the Performance down and its disturbing the QA team.
So can I have two application one can run in release mode so that QA activity does not get disturbed and parallelly I can debug the build and fix the bugs or can do further development.
I'm facing the same problem during the development activity, If multiple developers are working paralley , only one is able to debug the application other one has to wait.
So please suggest me, If I can get rid of this situation.
I have only one server on which I can test this application.
This is a way too long discussion, but I will try to offer you a few ideas:
Each developer should develop on his own machine (sources and database should be local).
In order to sync your work you should use:
a. a source control solution like TFS or SVN (this is free) for your sources.
b. database changes can easily be synced by generating update scripts using SQL Schema Compare directly from Visual Studio (you will need SQL Server Data Tools for this), Redgate SQL Compare or another application that can compare the database strucure (there are many available online, some of them free).
You should have a separate server (DB and app) to testing.
You should have a separate server (DB anb app) for production.
You say you have one server to test the application. But I suppose each developer has his own computer, right? In this case you need to skip #3 and use the same server for testing and production, but with different databases and applications.
I suggest you check this website for similar answers (see Best practice for test and production environments for example) to find the best solution that applies in your case.

Evaluating AppFabric and have some newbie questions like why does setting up AppFabric require a database or xml?

I'm new to AppFabric and I'm evaluating a distributed cache solution for a production environment and I'm in a Microsoft shop using Asp.net MVC and WebApi, and we are not using Windows Azure.
In setting up AppFabric on my local computer, there was a step to create a database or use xml, I'd like to understand the concept here. Is AppFabri depending on a datasource (db or xml files) to persist? If so, wouldn't this be a potential bottleneck?
Also, could anyone who is using AppFabric right now on their production servers comment on their experience using it? Any pitfalls or gotchas?
Thanks, really appreciate it!
I can give you my experience from a little over a year ago after deploying AppFabric in a production environment. I haven't kept up with it since because my experience wasn't great. Maybe they've fixed some of the issues we had.
The step to create a database or XML is just to store configuration information for the cluster.
My notes (remember this was current a year ago, so maybe things have changed):
When caching an object from C#, the object was turned into XML and stored. It was a verbose format and made storing/getting a little slower than it should have been. I would have rather had the object serialized to a binary format - or compressed - or just anything other than uncompressed XML. We actually modified our objects to have shorter property names when cached since they turned into XML. This caused some objects to go from 1MB down to a couple hundred kilobytes.
AppFabric was communicating over the NetTcp protocol in Windows and this caused us some grief. We had some servers without the Windows service installed (NetTcp) and that caused headaches. We couldn't figure out why AppFabric worked on one machine and not another.
It did seem to do well with distributing the load across multiple machines in the cluster. It also seemed to retrieve stuff fast and the expiration logic always worked fine.
At the time it was just a fairly immature product. We couldn't find any support anywhere for it. I remember being on the phone with Microsoft trying to track down some issues we had and every time the person would say, "AppFabric? What is that?" The community around it at the time was non-existent. (This was really painful for us.)
If I had to do an application for Windows that needed a distributed cache I would have to re-evaluate AppFabric. My first experience wasn't the greatest. Now I'd think of Redis, Couchbase, Memcached - in that order.

High CPU on IIS sites

I have a webserver with 10 mvc sites that I have created. All sites "link" to the same code in a folder. So all 10 sites run on same code. This is done have different languages on the site.
My problem is that 1 site goes up to use 40-60% of the CPU for a few minutes. Then it drops down and another sites rises in CPU. Normally the sites use 300mb in w3wp process, but sometimes rises to 8-900mb!
There's 20GB of memory, 18,9 is constantly used. There is also a SQL server running that takes 13GB.
The site is a MVC 3 site. Uses caching on the SQL data.
Every site has its own pool.
I know its a very vague question. But can anyone see any obvious problems with this setup?
Why does the CPU rise periodically?
There are about constantly 100-150 users on the sites.
Any ideas or thought would be very appreciated.
CPU utilization is result of web application so application developers would know best where is the problem. If application developers aren't "in-house" you as administrator will have to find is there problem in setup (less likely) or in application (more likely in my opinion).
Since IIS NEED tool from Microsoft like IIS Tracer, debugging high CPU utilization with "DebugDiag & friends" require lots of knowledge and effort.
Here is one nice article how to troubleshoot high CPU usage
Do your web apps use caching ?
OutputCache duration="180" varybyparam="*"
Sorry if this isn't helpful, but I'm administrator and when IIS server have high CPU usage in 95% problem is in poor SQL queries or bad programming which we fix after analyzing source code.

ASP.Net MVC Poor Production Performance

We have a MVC 3 application which has been deployed onto a newly built Windows 2008 R2 Web Edition server which is performing badly.
This application has been through development, quality assurance and user acceptance testing cycles on the same operating system (different boxes) with no performance issues.
The only difference we can see with the server is that it sits in the DMZ and as such has two network adapters configured, one for the internet, and one to punch through the firewall.
We have put all sorts of logging into the application and confirmed that up until the 'return ActionResult' everything is working correctly (ie ~500ms). It then takes 15 seconds to render the page.
We have tried turning on debug=false in the config file, i'm not sure what else to look for here, it seems like an environment issue.
Any suggestions please ? I am about to investigate if the thread pool size could be causing problems.
Also, if it helps the page is using multiple partial views, i have read others having problems with them.
Thanks,
Matt
Since the application performs ok in other environments I would suggest you investigate following:
Database - are you running against different database? How long the queries execute? If you have non-optimized database with million records on production, and only few records in test you want find performance problems soon enough.
Network - what is the latency between web box and database? If you loose 100ms for each database query just because of network than if your page triggers 50 queries you've lost 5secs. I've seen poorly configured routers / load balancers that were doing just that.
Try profiling each component of your system (db, network, web box) in order to find out where you're wasting all that time. Try http://code.google.com/p/mvc-mini-profiler/.
PS. You MUST have debug=false in your prod env.

Resources