Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
AJAX Performance and Monitoring Ron Bodkin, Glassbox Leader [email protected]
Rod Bodkin — AJAX Performance and Monitoring Page 1 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Agenda AJAX Overview AJAX Technology Challenges Solutions
Rod Bodkin — AJAX Performance and Monitoring Page 2 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
AJAX…
Rod Bodkin — AJAX Performance and Monitoring Page 3 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
AJAX Defined Asynchronous JavaScript And XML A group of technologies: HTML, JavaScript and XML Still HTML-based, but with JavaScript packages that make web pages feel more responsive Parts of a page fetch data and update without the major re-load everyone is used to Used correctly, Ajax brings the interactivity of good desktop apps to the Web, such as a spell checker that checks on the fly like Outlook. Ajax can be chatty, so it needs a good network and thoughtful design
Rod Bodkin — AJAX Performance and Monitoring Page 4 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Other Options Fat Client ¾ Most interactive ¾ Hard to distribute, maintain HTML ¾ Easy to write, most portable ¾ Less interactive especially on WAN Flash ¾ Wide deployment (>95%)… still mostly used for animation ¾ Harder to develop, integrate Java ¾ applets had early promise, limited to a niche Microsoft XAML/Avalon ¾ Windows Vista only… ask me in 2009
Rod Bodkin — AJAX Performance and Monitoring Page 5 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Why AJAX? Rich interactivity ¾Responsiveness like a desktop app ¾Lively site ¾Ease of use Browser-based ¾Standards ¾Ubiquitous ¾Easy update Productive, usable, networked applications
Rod Bodkin — AJAX Performance and Monitoring Page 6 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Why Now? Technology matured Successful large-scale applications Emergence of tools and frameworks Even as IE went from 95% to 85% share
Rod Bodkin — AJAX Performance and Monitoring Page 7 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
New Interaction Patterns
Source: Adaptive Path
Rod Bodkin — AJAX Performance and Monitoring Page 8 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Agenda AJAX Overview AJAX Technology Challenges Solutions
Rod Bodkin — AJAX Performance and Monitoring Page 9 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Enabling Technologies XMLHttpRequest ¾ Allows asynchronous communication with server ¾ Generates events as data is received JavaScript ¾ Better portability across major browsers ¾ Still a lot of conditional logic required Dynamic updates to page ¾ DOM gives full object access ¾ innerHTML attribute for modifying HTML inside a tag
Rod Bodkin — AJAX Performance and Monitoring Page 10 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Javascript (Browser) Libraries dojo (widgets, packaging, utilities, persistence) Prototype (framework) script.aculo.us (effects, widgets) AjaxTK/Apache Kabuki - Zimbra (widgets) Yahoo! User Interface Library (widgets) TIBCO General Interface (framework & tools)
Rod Bodkin — AJAX Performance and Monitoring Page 11 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Browser + Server Frameworks Java .NET ¾ DWR (Direct Web ¾ Atlas Remoting) ¾ Ajax.NET ¾ Google Web Toolkit ¾ MagicAjax.NET ¾ ZK Ruby on Rails ¾ AjaxTags Python: Django ¾ Ajax4JSF Perl PHP ¾ Catalyst ¾ Symfony ¾ CGI::Ajax ¾ AjaxAC
Rod Bodkin — AJAX Performance and Monitoring Page 12 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Example: DWR 1.0 AJAX
Source: Getahead
Rod Bodkin — AJAX Performance and Monitoring Page 13 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Reverse AJAX: Automatic Updates
Server Browser
Event
Update ? Script
Rod Bodkin — AJAX Performance and Monitoring Page 14 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Reverse AJAX: Polling
Server Browser
Event
Update Script
Rod Bodkin — AJAX Performance and Monitoring Page 15 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Reverse AJAX: Comet
Server Browser Start
Event
Update Script
Rod Bodkin — AJAX Performance and Monitoring Page 16 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Reverse AJAX: Piggy Back
Server Browser
Event
Request
Reply Script Update
Often discussed, but who is implementing it?
Rod Bodkin — AJAX Performance and Monitoring Page 17 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Widgets, e.g., Google Web Toolkit
Rod Bodkin — AJAX Performance and Monitoring Page 18 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Direct Service Integration
Web AJAX Mash-ups… page engine
Google Maps
Credit Agency
Order Service
Rod Bodkin — AJAX Performance and Monitoring Page 19 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Indirect Service Integration
Web AJAX page engine
Google Maps
Credit Agency
Aggregation Order server Service
Rod Bodkin — AJAX Performance and Monitoring Page 20 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Proxy Web Service Integration
Web AJAX page engine
Google Maps
Credit Agency
Proxy Order server Service
Rod Bodkin — AJAX Performance and Monitoring Page 21 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Agenda AJAX Overview AJAX Technology Challenges Solutions
Rod Bodkin — AJAX Performance and Monitoring Page 22 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
AJAX Problem Areas Excess server requests JavaScript problems Server load Service fragility Integration server problems
Rod Bodkin — AJAX Performance and Monitoring Page 23 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Excess Server Requests Adds complexity ¾ One single action can generate a flood of requests ¾ Or a handful of slower ones ¾ What happens if some are unreliable? ¾ One missing timeout can produce a huge backlog Hard to Monitor End User Performance ¾ Initial page load time isn’t the issue… ¾ Can’t determine cause of requests without page analysis Hard to correlate Requests with Pages let alone User Actions
Rod Bodkin — AJAX Performance and Monitoring Page 24 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
JavaScript Problems Not as fast as compiled languages! Processing large data sets is hard Engines can do a lot of work Browser portability is still an issue ¾ May require digging into framework code Stateful UI’s: what interactions led to errors? ¾ Debugging nested DOM/CSS/JS… Accessibility HTTP limit of 2 simultaneous connections per server by default (configurable)
Rod Bodkin — AJAX Performance and Monitoring Page 25 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Server Load: Pre-AJAX Short spikes of activity Long pauses of inactivity “think time” Efficient for use of server sockets and threads Can tax CPU Dynamic pages integrate big static chunks
Rod Bodkin — AJAX Performance and Monitoring Page 26 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Server Load: AJAX Initial download of engine (static content) Bursts of activity (change of context) With more frequent updates Typically shorter less intensive interactions Frequent requests and polling use network, CPU, sockets, and threads Comet instead uses much more sockets and typically threads and buffers More demanding of client too More static content
Rod Bodkin — AJAX Performance and Monitoring Page 27 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Service Fragility Each service is a possible point of failure ¾Outages ¾Configuration problems ¾Changes to service Cascading slowness possible ¾Not meeting SLA ¾Tests robustness/race conditions in browser
Rod Bodkin — AJAX Performance and Monitoring Page 28 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Integration Server Problems Slow database query Too many queries Bottlenecks from aggregating many services ¾memory, sockets, … Contention for locks in server… ¾lots of threads for one session Outages/misconfiguration … Traditional problems in a new context
Rod Bodkin — AJAX Performance and Monitoring Page 29 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Typical Application Problems
Rod Bodkin — AJAX Performance and Monitoring Page 30 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Agenda AJAX Overview AJAX Technology Challenges Solutions
Rod Bodkin — AJAX Performance and Monitoring Page 31 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
The Performance Lifecycle
Operate • Monitor Define • Service level • Update
Design Test • Load test • Load test often architecture • Multi-platform • Create budget
Develop • Code & debug • Unit tests
Troubleshoot
Rod Bodkin — AJAX Performance and Monitoring Page 32 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Architecture Is Key AJAX shuffles the deck ¾ Changed workloads ¾ Emerging, immature technologies Allocate work sensibly ¾ Informs basic goals and SLA’s Budgets for both latency and scalability ¾ Interactive events (heavy & light) ¾ Update callbacks Prototype basic elements ¾ Many new technologies at play Extrapolate to model performance
Rod Bodkin — AJAX Performance and Monitoring Page 33 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Server Options The usual suspects… ¾ Java EE (Tomcat, JBoss, Jetty, GlassFish, WebSphere*, WebLogic*…) ¾ .NET for Windows* ¾ LAMP Emerging networking options ¾ Grizzly event-based HTTP Connector (in GlassFish) ¾ COMETd (Perl) ¾ Twisted (Python) ¾ Scala, Erlang/OTP (Concurrency Oriented Languages) ¾ Apache 2 Event MPM ¾ Continuation support…
* Indicates cost to use.
Rod Bodkin — AJAX Performance and Monitoring Page 34 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Emerging Standards? The Jetty open source Java Web container: Uses NIO to only use threads when processing I/O Server requests set up a continuation ¾ If waiting for data, they suspend by throwing ¾ When data is available, they are resumed ¾ The server replays the processing, but the next time they will continue Continuations allow using one thread per active request Also uses NIO split buffers to limit buffers for many requests DWR 2’s Reverse AJAX ¾ works with Jetty continuations ¾ Supports polling & COMET
Rod Bodkin — AJAX Performance and Monitoring Page 35 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Continuations Object to represent the state of program execution ¾ Native support in dynamic languages like Ruby, Smalltalk ¾ Java options rely on specialized state Jetty implementation supports AJAX scalability ¾ Requires no side effects in code ¾ Replays state based on request state & session state ¾ Doesn’t checkpoint session state… Other frameworks use to simplify conversations ¾ RIFE framework for Java ¾ Seaside framework for Smalltalk
Rod Bodkin — AJAX Performance and Monitoring Page 36 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
IDE Support Eclipse ¾ATF (editor, debugger) ¾MyEclipse * (editor, code assist, debugger) ¾Aptana * (code completion) IntelliJ IDEA* (refactoring editor)
* Indicates cost to use.
Rod Bodkin — AJAX Performance and Monitoring Page 37 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Browser Development Tools Debugging ¾ Mozilla Venkman debugger & profiler ¾ Microsoft Script Debugger for IE Inspectors ¾ WebDeveloper toolbar for Firefox: CSS, inspector ¾ FireBug console viewer, inspector, debugger ¾ Mouseover DOM Inspector Request monitoring ¾ FireBug ¾ GreaseMonkey: XMLHttpRequest Tracing/Debugging ¾ Eclipse ATF Logging: MochiKit, dojo… server-side?
* Indicates cost to use.
Rod Bodkin — AJAX Performance and Monitoring Page 38 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Venkman Profiling Output 33
35
Rod Bodkin — AJAX Performance and Monitoring Page 39 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Unit Test
Baseline test for functionality AND performance In browser ¾ Script.aculo.us, JsUnit, ASTUce JavaScript unit tests ¾ Rhino, MS Windows Script Host ¾ JavaScript Coverage Validator (beta)* On server ¾ JUnit, NUnit ¾ Java Coverage: Emma, Cobertura, Clover*
* Indicates cost to try or use.
Rod Bodkin — AJAX Performance and Monitoring Page 40 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
System Test Functional system tests (in browser) ¾Script recording and playback validation • Selenium, Squish/Web* ¾Script code objects (e.g., for JUnit) • Waitij/Waitir (Win/IE scripting for Java/Ruby) Load and Stress tests: simulate traffic ¾OpenSTA (http/s only… confused by gmail) ¾JMeter (http/s only) ¾LoadRunner (http/s, script objects too)* * Indicates cost to try or use.
Rod Bodkin — AJAX Performance and Monitoring Page 41 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Configuration Tune based on Load Test Network ¾ Load balancers, firewalls, routers OS level ¾ Maximum sockets ¾ Maximum threads Web server ¾ Timeouts Application server ¾ Threads ¾ Timeouts VM ¾ Memory settings (e.g., -Xss thread stack size)
Rod Bodkin — AJAX Performance and Monitoring Page 42 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Systems Monitoring Network-level ¾Router, sniffer metrics: throughput, latency ¾End-user response time (not just http pings!) ¾Customer Experience Management complicated: Keynote*, TeaLeaf* OS-level : sockets, IO, processes, CPU… ¾netstat, top, Nagios, Hyperic, HP Openview*, Tivoli*
* Indicates cost to try or use.
Rod Bodkin — AJAX Performance and Monitoring Page 43 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Using Fiddler: Mail Login & View Yahoo Mail Beta Gmail Request Count: 52 Request Count: 48 Bytes Sent: 61,069 Bytes Sent: 55,443 Bytes Received: 165,677 Bytes Received: 51,044 … … US West Coast (DSL - US West Coast (DSL - 30KB/sec) 30KB/sec) Round trip cost: 5.20s Round trip cost: 4.80s Elapsed Time: 12.20s Elapsed Time: 7.80s
Rod Bodkin — AJAX Performance and Monitoring Page 44 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
App Server Monitoring Container ¾Server JMX: request queue, pools, throughput Java VM with Java 5 JMX Data ¾All threads, memory Key elements ¾threads, memory, request queues, throughput, etc.
* Indicates cost to try or use.
Rod Bodkin — AJAX Performance and Monitoring Page 45 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
App Monitoring with Aspects Aspects run automatically at well-defined points at runtime No need to instrument code Allows low overhead tracking Easy to update monitoring policies ¾ Enable and disable, even sampling Standardized support ¾ AspectJ load-time weaving avoids changes to build process ¾ Popular extensible language for Java 5 javaagents ¾ Spring AOP allows proxy-based option for coarse-grained components Flexibility ¾ Reuse open source monitors for common APIs ¾ Easy to extend for custom monitoring
Rod Bodkin — AJAX Performance and Monitoring Page 46 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Glassbox Open Source
Browser Web Java 1.4+ Server HTTP Discovers and tracks operations as they execute Client Machine Load-time Java Application Application weaving Low overhead
Java Virtual AOP Detectsproblems common Agent Machine , e.g. Application Server Machine ¾ AJAX latency, load ¾ Excess queries ¾ Slow/broken Web services Web Any Database Services
Rod Bodkin — AJAX Performance and Monitoring Page 47 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Troubleshooting Tools Provide
1. Aggressive data filtering can reduce the data haystack early
2. Troubleshooting intelligence means users need not be experts in the tool or have written the system
3. Cleaner data and more accurate diagnoses streamline communication Benefits Fix problems faster and cheaper by streamlining communication. Fix more problems by enabling non-experts to track them down.
Rod Bodkin — AJAX Performance and Monitoring Page 48 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Bringing It Together
DEMO
Rod Bodkin — AJAX Performance and Monitoring Page 49 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Conclusions AJAX is now ready for prime time ¾ Emphasize high-value interactivity Supporting technologies becoming mainstream ¾ But test carefully and watch for shifts Focus on architecture up front ¾ Benchmark latency and throughput Integrate monitoring and troubleshooting up front We’re looking for collaborators to build better AJAX monitoring & troubleshooting Please leave your business card to get updates These slides will be updated on the post-conference CD
Rod Bodkin — AJAX Performance and Monitoring Page 50 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation
Resources Ajaxian for News: www.ajaxian.com Ajax Patterns for Technologies: ajaxpatterns.org Ajax: A New Approach to Web Applications: http://adaptivepath.com/publications/essays/archives/000385.php Ajax Impact on Server Scaling: www.zimbra.com/blog/archives/2006/04/ajax_impact_on.html Scaling Connections for AJAX with Jetty 6: www.mortbay.com/MB/log/gregw/?permalink=ScalingConnections.html Not There Yet: COMET with Apache and Jetty: http://blogs.pathf.com/agileajax/2006/05/not_there_yet_c.html What I Didn’t Know About XHR: http://www.oreillynet.com/xml/blog/2006/10/what_i_didnt_know_about_xhr.html Glassbox: www.glassbox.com
Rod Bodkin — AJAX Performance and Monitoring Page 51