AJAX - The Complete Reference

(avery) #1

528 Part III: Advanced Topics


liveliness versus posting messages is a bit difficult, with the former requiring that you do
replacements of data to keep an up-to-date duplicate-free list of users, while the latter is a
continuous appending of data approach to updates. We’ll let you dig into the code to see
these issues and more; otherwise, you can enjoy chatting as we did in Figure 10-10.

The Comet Impact

Adding Comet-style interaction to your Web site is a potentially dangerous endeavor. The held
connection approach, coupled with how many Web servers and application environments are
built, can lead to significant scalability problems. For example, PHP doesn’t generally let you
keep connections open for extended periods of time. This is by design, and the approach leads
to the environment’s good scalability. Regardless of the application server, you may also see
Web servers choking on Comet, consuming and holding memory and processes for each
connection. In short, scaling Comet apps can be quite troublesome without careful planning.
Even if you did not face server problems, the approach of held or continuous
connections favored by Comet-style applications is quite troubling in light of the browser’s
two-connection limit we saw in Chapter 6. Of course, you could use another domain name
to avoid this, but then you run into the cross-domain concerns. There are ways around this
using an iframe with document.domain loosening, as we saw in Chapter 7, or using Flash

FIGURE 10-10 Chatting Comet style
Free download pdf