performance - Profiling ASP.net applications over the long term? -


what accepted way instrument web-site record execution statistics?

how long takes x

for example, want know how long takes perform operation, e.g. validating user's credentials active directory server:

authenticated = checkcredentials(login1.username, login1.password); 

a lot of people suggest using tracing, of various kinds, output, or log, or record, interesting performance metrics:

var sw = new system.diagnostics.stopwatch(); sw.start(); authenticated = checkcredentials(login1.username, login1.password); sw.stop();  //write number log writetolog("timetocheckcredentials", sw.elapsedticks); 

not x; x

the problem i'm not interested in how long took validate user's credentials against active directory. i'm interested in how long took validate thousands of user's credentials in activedirectory:

var sw = new system.diagnostics.stopwatch(); sw.start(); authenticated = checkcredentials(login1.username, login1.password); sw.stop();  timetocheckcredentialssum = timetocheckcredentialssum + sw.elapsedticks; timetocheckcredentialscount = timetocheckcredentialscount + 1; if ((sw.elapsedticks < timetocheckcredentialmin) || (timetocheckcredentialmin == 0))    timetocheckcredentialmin = sw.elapsedticks; if ((sw.elapsedticks > timetocheckcredentialmax) || (timetocheckcredentialmax == 0))    timetocheckcredentialmax = sw.elapsedticks; oldmean = timetocheckcredentialsaverage; newmean = timetocheckcredentailssum / timetocheckcredentialscount; timetocheckcredentialsaverage = newmean;  if (timetocheckcredentailscount > 2) {    timetocheckcredentailsvariance = (          ((timetocheckcredentialscount -2)*timetocheckcredentailsvariance  + (sw.elapsedticks-oldmean)*(sw.elapsedticks-newmean))          / (timetocheckcredentialscount -1)) } else     timetocheckcredentailsvariance = 0; 

which lot of boilerplate code can abstracted away into:

var sw = new system.diagnostics.stopwatch(); sw.start(); authenticated = checkcredentials(login1.username, login1.password); sw.stop();  //record sample profiler.addsample("timetocheckcredentials", sw.elapsedticks); 

which still lot of boilerplate code, can abstracted into:

profiler.start("timetocheckcredentials"); authenticated = checkcredentials(login1.username, login1.password); profiler.stop("timetocheckcredentials"); 

now have statistics sitting in memory. can let web-site run few months, , @ time can connect server , @ profiling statistics. ability of sql server present it's own running history in various reports:

enter image description here

but asp kills apps without warning

the problem asp.net web-site/application. randomly throughout course of year, web-server decide shut down application, recycling application pool:

  • perhaps has been idle 3 weeks
  • perhaps reached maximum recycle time limit (e.g. 24 hours)
  • perhaps date on file changed, , web-server has recompile application

when web-server decides shut down, statistics lost.

are there any asp.net performance/instrumentation frameworks solve problem?

try persisting sql server

i thought storing statistics in sql server. asp.net session state can stored in sql server after every request complete, store values in sql server every time:

void addsample(string samplename, long elapsedticks) {     using (idbconnection conn = createdatabaseconnection())     {         executeaddsamplestoredprocedure(conn, samplename, elapsedticks);     } } 

except i've introduced huge latency application. profiling code called many thousand times second. when math performed in memory takes few microseconds. takes few dozen milliseconds. (factor of 1,000; noticeable delay). that's not going work.

save on application shutdown

i have considered registering static helper class asp.net hosting environment implementing iregisteredobject:

public class shutdownnotification : iregisteredobject {     public void stop(boolean immediate)     {         profiler.savestatisticstodatabase();     }  } 

but i'm curious right way solve problem is. smarter people me must have added profiling asp.net before.

we use microsoft's application performance monitoring this. captures page load times, db call times, api call times, etc. when page load unexpectedly slow, alerts , provides stack trace along timings of various calls impacted load time. it's rudimentary trick , allowed verify didn't have variations not performing expected.

advance warning: ui works in ie.

http://technet.microsoft.com/en-us/library/hh457578.aspx


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -