Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation AJAX Performance and Monitoring Ron Bodkin, Glassbox Leader ron.bodkin@glassbox.com 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 ¾ DWR (Direct Web Remoting) ¾ Google Web Toolkit ¾ ZK ¾ AjaxTags ¾ Ajax4JSF PHP ¾ Symfony ¾ AjaxAC Rod Bodkin — AJAX Performance and Monitoring .NET ¾ Atlas ¾ Ajax.NET ¾ MagicAjax.NET Ruby on Rails Python: Django Perl ¾ Catalyst ¾ CGI::Ajax 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 Reverse AJAX: Automatic Updates Server © Copyright 2006, Glassbox Corporation Browser Event Update Rod Bodkin — AJAX Performance and Monitoring ? Script Page 14 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Reverse AJAX: Polling Server Browser Event Update Rod Bodkin — AJAX Performance and Monitoring Script Page 15 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Reverse AJAX: Comet Server Browser Start Event Update Rod Bodkin — AJAX Performance and Monitoring Script Page 16 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Reverse AJAX: Piggy Back Server Browser Event Request Reply Update Script 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 page Mash-ups… AJAX 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 page AJAX engine Google Maps Credit Agency Aggregation server Rod Bodkin — AJAX Performance and Monitoring Order Service Page 20 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, Glassbox Corporation Proxy Web Service Integration Web page AJAX engine Google Maps Credit Agency Proxy server Rod Bodkin — AJAX Performance and Monitoring Order Service 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 • Update Define • Service level Design • Load test architecture • Create budget Test • Load test often • Multi-platform 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 <http://localhost:8080/glassbox/dwr/util.js> util.js: 750 - 2500 milliseconds Function Name: anonymous (Lines 294 - 375) Total Calls: 6930 (max recurse 0) Total Time: 2093.01 (min/max/avg 0/10.02/0.3) Time (ex. calls): 1011.45 (min/max/avg 0/10.02/0.15) 35 <http://localhost:8080/glassbox/js/troubleshooter.js> troubleshooter.js: 750 - 2500 milliseconds Function Name: loadRowInfo (Lines 78 - 83) Total Calls: 99 (max recurse 0) Total Time: 2293.3 (min/max/avg 20.03/40.06/23.16) Time (ex. calls): 0 (min/max/avg 0/0/0) 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 Request Count: 52 Bytes Sent: 61,069 Bytes Received: 165,677 … US West Coast (DSL 30KB/sec) Round trip cost: 5.20s Elapsed Time: 12.20s Rod Bodkin — AJAX Performance and Monitoring Gmail Request Count: 48 Bytes Sent: 55,443 Bytes Received: 51,044 … US West Coast (DSL 30KB/sec) Round trip cost: 4.80s Elapsed Time: 7.80s 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 Server HTTP Client Machine Java Application Application Agent AOP Java Virtual Machine ¾ AJAX latency, load ¾ Excess queries ¾ Slow/broken Web services Application Server Machine Web Services Rod Bodkin — AJAX Performance and Monitoring Java 1.4+ Discovers and tracks operations as they execute Load-time weaving Low overhead Detects common problems, e.g. Any Database 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