Comet and Reverse Ajax - Crane, Dave (Apress, 2012)
At the end of Chapter 3, we discussed a number of performance issues with the naive version of the Magnetic Poetry application that we'd developed. Let's see how your Jetty and Cometd implementation addresses these. On the client side, we had found that most browsers will only run two concurrent HTTP requests to a given server, which resulted in blocking of ordinary Ajax requests. In this chapter, however, you've used a single Cometd connection to establish a collaborative magnetic board and report on the progress of your online bakery, with a satisfactorily low degree of coupling between the two components. All the while, you've left the second HTTP connection allowed by the browser open for fetching images and for your conventional Ajax requests. On the server side, we suspended servlet threads but didn't release the servlet back to the pool. This limited the number of clients that we could support and increased the resource footprint of our application considerably. Here, our CRUD functionality is employing Jetty continuations to release servlets, as discussed in Chapter 5. Because the bakery is not pausing the servlet thread but a secondary thread that references very few resources, you've also reduced the load on your servlet pool considerably.