Download - Download It
Ajax Performance Monitor:A Toolkit for Web 2.0 Application Developers
Brian TooneSamford University
Birmingham, [email protected]
What is Web 2.0?
Mind Map by Markus Angermeier
July 13, 2009 Brian Toone, Samford University Slide 2
Our focus
Mind Map by Markus Angermeier
July 13, 2009 Brian Toone, Samford University Slide 3
Web 2.0 Example
FacebookPopular social networking web applicationWeb 2.0 application
Social software, encourages participation, sharing Convergence, 3rd party applications and most importantly for this talk … usability
July 13, 2009 Brian Toone, Samford University Slide 4
November 21, 2008 Brian Toone, Samford University Slide 5
Usability enhancements
Reduce number of context switchesUser constantly sees context of page updatesNo browser busy icon or screen flickerMinimal change to the updated page
Reduce latency by potentially reducing server loadRetrieve only what is necessary to update the pagePotentially reduces amount of data fetched from serverPotentially reduces overall server load
July 13, 2009 Brian Toone, Samford University Slide 6
Ajax 101
Ajax – Asynchronous Javascript And XMLAjax affects what happens after the initial page loadAjax-enabled page has Javascript code to submit additional HTTP requests asynchronously without refreshing the current page
July 13, 2009 Brian Toone, Samford University Slide 7
Ajax 101 … without Ajax or Ajax-equivalent
Impossible to submit data without page refreshImpossible to update the display with new data from the server without page refreshImpact of a page refresh:
Brian Toone, Samford UniversityJuly 13, 2009 Brian Toone, Samford University Slide 8
So far, so good, so what is the problem?
Facebook data requirements are relatively smallFacebook user interactions are relatively limitedConsider a mapping application…
Without Ajax With Ajax
July 13, 2009 Brian Toone, Samford University Slide 9
The Ajax impact on server load
Without Ajax, user “encouraged” to use appropriate zoom tools to minimize thenumber of requestsWith Ajax, the opposite is true – the Rich Internet Application (RIA) “encourages” the user to prefer pan over zoomingPotential explosive increase in HTTP requestsWeb server must respond to each requestIncrease in bandwidth and processing load
July 13, 2009 Brian Toone, Samford University Slide 10
An Extreme Example
Each Ajax request consumes server resourcesCPU cyclesNetwork bandwidthDisk I/O
Extreme ExampleAn onmousemoveevent initiates an Ajax request to retrieve data from the server.Every time every user moves the mouse, a new request is issued!
July 13, 2009 Brian Toone, Samford University Slide 11
onmousemove Example, cont’d
July 13, 2009 Brian Toone, Samford University Slide 12
Our Ajax Performance Monitoring Toolkit
See the server impact of Ajax calls in real-timeNot meant to be a stress tester, many already existHelp a web developer before the site is deployed
Measurement for the client (individual page)Measurement for the server (all accesses)Easy integrationMinimal overhead
July 13, 2009 Brian Toone, Samford University Slide 13
The toolkit “heads-up display”
The same web page with instrumentation addedMinimal amount of code additionsCustomizable appearance (location, color, popup)
July 13, 2009 Brian Toone, Samford University Slide 14
Client measurements
Requests sent / received / pendingResponse time statisticsRequest size statisticsThroughput statistics (requests issued per second)
July 13, 2009 Brian Toone, Samford University Slide 15
Client measurements
Instrumented counters and timersAjax, arbitrary JavascriptClick to view statistics on a specific measurement
July 13, 2009 Brian Toone, Samford University Slide 16
Server measurements
Requests received / processed / pendingResponse time statisticsResponse size statisticsThroughput statistics (requests processed per second)
July 13, 2009 Brian Toone, Samford University Slide 17
Server measurements
Instrumented counters and timersArbitrary PHP code segmentsClick to view statistics on a specific measurement
July 13, 2009 Brian Toone, Samford University Slide 18
Server measurements
Server load statistics1 minute cpu loadApache and MySQL process informationFree memory, free disk space, uptime
July 13, 2009 Brian Toone, Samford University Slide 19
Integrating toolkit into web appsCLIENT SIDE
Javascript “include” file<div> for outputGlobal variable declarationInit global variable in onload function
SERVER SIDEMake sure each Ajax service script is isolated (cannot be loaded independently from an Ajax request)Include header and make function calls at the beginning and end of an Ajax service scriptDo not die()
July 13, 2009 Brian Toone, Samford University Slide 20
Integrating toolkit - clientside
All-in-one request and response handler
Manual integration to existing code
July 13, 2009 Brian Toone, Samford University Slide 21
Instrumenting client timers and counters
Place at any point in the Javascript codeEach timer and/or counter given a unique name
July 13, 2009 Brian Toone, Samford University Slide 22
Integrating toolkit - serverside
Beginning of Ajax service script:
End of Ajax service script:
Instrumentation code:
July 13, 2009 Brian Toone, Samford University Slide 23
Experimental Validation
Web app for retrieving elevation (Google Maps API)Ajax request issued with every mouse moveThree different Ajax requests compared
Random number generatorLocal database lookupExternal web service
Measure web browser response timeCompare Firefox vs Internet Explorer
November 21, 2008 Brian Toone, Samford University Toone 24
Experimental Results
November 21, 2008 Brian Toone, Samford University Toone 25
The Heisenberg Uncertainty Principle
(aka, measurement overhead)Namespace pollution
Client… AjaxPMServer… AjaxPM, apm_Mutex, apm_patSHMC, apm_server
Bandwidth impactClient-side ajaxpm.js (36kb)Polling mechanism for retrieving server statistics (500 bytes per developer configurable # of seconds)
Memory impactClient… 150 member variables (30 holding integers, 120 referencing DOM display elements)Client… Each instrumented counter/timer added to an integer arrayServer… 100kb of shared memory are allocated for server counters and timers
November 21, 2008 Brian Toone, Samford University Toone 26
Conclusion
Real-time feedback on Ajax impact is possibleOverhead can be minimized but only marginally scalable … in other words, for developers only!
For our example application, Internet Explorer has better response time than FirefoxDownload and try it out!
http://faculty.samford.edu/~brtoone/
July 13, 2009 Brian Toone, Samford University Slide 27
Thank you!
Questions?For more information
[email protected]://faculty.samford.edu/~brtoone
July 13, 2009 Brian Toone, Samford University Slide 28