AJAX – Bridging the Thin-Client Performance Gap

By introducing an AJAX engine between the client and the server, the roundtrip delays are eliminated thereby enhancing and streamlining the user experience.
- Les Cardwell, President of White Box, Inc.

December 20, 2005
Iron Speed Designer V3.2
What is AJAX?
AJAX isn't a technology per se, but really several technologies brought together in significant and powerful new ways to improve the user experience.

Asynchronous JavaScript and XML, or AJAX, is a development technique for creating interactive web applications. Microsoft's "Remote Scripting” was the earliest form which made use of a dedicated Java applet, existed before XMLHttpRequest, and was extended by Netscape DevEdge in 2001 by using an IFrame instead of a Java applet. (AJAX, 2005)

The technologies incorporated by AJAX include:

  • XHTML (HTML) and cascading style sheets (CSS) to achieve a standards-based presentation
  • Document Object Model (DOM) for achieving dynamic display and interaction
  • XML and XSLT for data interchange and manipulation
  • XMLHttpRequest for asynchronous data retrieval with the web server (in some AJAX frameworks, an IFrame object is used instead of the XMLHttpRequest object.)
  • JavaScript to manipulate and bind everything together
In a classic web application, user interface events trigger an HTTP request back to a web server for retrieving data and handling various processing requirements, then returns an HTML page to the browser. While this model works technically, because of this round-trip requirement, the user experience suffers from performance delays and often graceless interface issues, especially as compared to interpreted/smart-client applications.

The inadequacies of this architecture are due in large part to the legacy of web development, its original intended use as a medium of text-based exchange, and the expansion of its application since envisioned. It's only a natural progression in technology to evolve the architecture to accommodate and encompass new requirements as they arise, which is where AJAX has found its momentum.

The difference in the two models can be expressed in the following diagram, with the traditional model for web application architecture on the left, and AJAX architecture on the right...

By introducing an AJAX engine between the client and the server, the roundtrip delays are eliminated thereby enhancing and streamlining the user experience. Ironically, while it would seem that adding another layer to the application would negatively impact performance, the opposite is true. Since the amount of data interchanged between the browser and server is vastly reduced, web server processing time is saved since most of it is done on the client. For most tasks, only small amounts of data must be transported between the client and server, rendering the performance of an AJAX application almost as well as an interpreted/smart-client application since the pages only need to be 'updated' in the browser vs. requiring a complete screen refresh.

How AJAX Works
The synchronous interaction pattern of a traditional web application can be visually compared with the asynchronous pattern of an AJAX application as follows...

Each event that would normally generate an HTTP request is instead rendered as a JavaScript call to the AJAX engine, which handles both non-server required events (simple data validation, data editing, and navigation) as well as events that require information from the server. If server resources are needed to fulfill the request (i.e.- fetching new data, code retrieval, or processing data), then the request is handled asynchronously using SOAP (SOAP, 2005) or other XML web-based services dialect. JavaScript then processes the web-server response; typically modifying the document's content through the document object model (DOM) without delaying the user's interaction with the application.

How AJAX Performance Stacks Up
Since performance at all levels must be taken into consideration, in a recent AJAX test case comparing both methods for a traditional web application, the following performance results were obtained...

  Traditional (Average) AJAX (Average) Performance Increase Performance Increase (%)
Bytes Transferred: 1,737,607 460,799 1,276,809 73%
Time (seconds): 115 78 36 32%
Estimated Transmission time to US West Coast (56k) (seconds) 293.45 94.44 199.01 68%

"As expected, in every test there were significant performance improvements across the board in the AJAX version. The greatest improvements were in bandwidth and network traffic efficiency gains. This resulted in improved responsiveness, allowing the user to move more quickly through the application. Overall, there was a 73% improvement in the number of bytes transferred in the AJAX application over the traditional version. This was due to the fact that that server requests were made only for the data that was needed, not for the entire page. Microsoft Fiddler also predicted that there would be a 68% overall time improvement in transferring that information to a location on the US West Coast given the number of HTTP requests, bytes transferred, the latency of that connection, and the bandwidth afforded by a simple 56k modem."
(White, 2005)

This is significant for a number of reasons, but the from a purist perspective it's the litmus test for a pervasive argument in favor of systems written using AJAX vs. those using legacy methods. Companies such as Google are making significant investments in developing AJAX approaches to various problem domains, including such web applications as Orkut, Gmail, Google Groups, Google Suggest, and Google Maps, and many others are following suit, including Flickr and Amazon's A9.com. These are evidence that AJAX is both technically sound as well as practical for pragmatic and complex applications. The core technologies in AJAX are mature, stable, and well understood, but their use in this combination changes the possibilities of what's possible in designing thin-client web applications.

Considerations
There are considerations the application architect has to recognize and address when implementing AJAX...
  • State-handling (i.e. - the 'Back' button, or 'Bookmark'), which can be addressed using IFrame where necessary

  • JavaScript must be enabled

  • Network latency – resolved through good feedback to the browser and smart preloading of data

  • Multimedia – efficient handling is more complex than in rich-client technologies

...however, these are parallel considerations to many of the same types of issues when developing smart-client applications as well. In other words, there is little or no substantive argument at present for not pursuing AJAX’s implementation as a standard practice in developing web applications aside from working through development considerations. As AJAX has matured, a number of programming libraries have become available to expedite these tasks, including AJAX.net (Swartz, 2005), which is an early implementation of Microsoft's "Atlas" based on the .Net controls, which is Iron Speed Designer's intended implementation as well.
The Future of AJAX with Iron Speed Designer
Iron Speed Designer is in the process of opening up the code generator to be much more template-based than it currently is, and intends to provide AJAX through code templates. Template-based code generation will debut in V3.3 (two releases hence), though much of the underlying groundwork will be in V3.2.

One major benefit of opening up the template-based code generation mechanism is that you can easily add your own templates and let Iron Speed Designer generate them into an application. This means you could add an alternative set of your own AJAX code, mix and match it with code templates included in Iron Speed Designer, and add third-party controls that are particular to your needs that Iron Speed Designer wouldn’t ever support directly.

Templates will, for the most part, manifest themselves in the tool box. The application developer will be able to drag an object from the tool box onto a page and doing so will automatically insert a payload of HTML (ASPX, JavaScript, DHTML and XML) into the page along with any number of code segments into various places in the application (safe classes, constructors, etc.) Once on a page, the developer will be able to use a "Configure Wizard" to select any DLL’s, select any parameter values, etc., required by that particular component / template. If the developer wishes to add their own custom templates, they will be able to put most anything in them they choose; the XML package is designed to include any number of HTML chunks, any number of code segments, any number of RESX strings, and any number of style sheet additions. Iron Speed Designer’s current recommendation is for developers to "componentize" their implementation of third-party controls used in Iron Speed Designer applications. That will allow application developers to more easily convert them into code templates in V3.3 and later.

With Iron Speed Designer, we are on the cutting edge...

References
Wikipedia, (2005). AJAX Programming. Retrieved Dec. 05, 2005, from http://en.wikipedia.org/wiki/AJAX.
Garrett, J. J. (2005). AJAX: a new approach to web applications.
Wikipedia, (2005). SOAP. http://en.wikipedia.org/wiki/SOAP.
White, A. (2005). Measuring the benefits of AJAX. Retrieved Dec. 05, 2005, from Developer.com Web site: http://www.developer.com/java/other/article.php/3554271.
Swartz, M. (2005). Retrieved Dec. 05, 2005, from AJAX.NET Professional Web site: http://www.schwarz-interactive.de/.
About the Author
Les Cardwell
President of White Box, Inc.

Les Cardwell, is the President of White Box, Inc. based in Mt. Hood, OR and an affiliate of AKC Development Corp. Les has been with White Box, Inc. since 2004 and specializes in providing custom software development, system analysis/design and IT project management services to customers in the US, Canada, and Europe. Prior to joining White Box, Les spent 9 years in project management and consulting as the Vice President of PLM Consulting, Inc. Les holds a Masters of Information Technology, and graduated summa cum laude, from American Intercontinental University. Les was recently named an Iron Speed MVP for his continued contribution to the Iron Speed community.

Contact the author.



  Privacy Statement