O'Reilly logo

Adding Ajax by Shelley Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performance and Two-Phase Commits

The resources that need the most protection in a web application are Input/Output (I/O)-specific: file writes and database connections. Both typically have a limited number of "threads"—parallel paths of execution—and if you're adding hundreds of new Ajax requests that result in either of these I/O activities, you could be running into blocking problems; Ajax requests waiting for a response from the server, which is blocking on the request because a resource is not available. In particular, a database update frequently results in both types of action—a database connection and a file write. Based on this, you're going to want to evaluate each use of Ajax against the number of concurrent users who might be using the Ajax service at a time, and how many concurrent database connections your system supports.

Ajax That Plays Well with Others

In-page deletion, discussed previously in this chapter, can add to the burden of a web application. Using the traditional approach where each item to be deleted is checked, one database connection is made for all of the deletions, and it is managed as one transaction that establishes a connection, begins the delete transaction, deletes all the items, ends the transaction, then ends the connection.

The Ajax deletion method does require a separate connection for each deletion. The burden of having to open a connection for each Ajax delete request is offset by how simple and fast the request is, and how quickly the database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required