Lowest Cost Cloud Load Testing Tool

Web Performance Optimization Part 3 - Data Caching

web performance optimization eliminate diskIn the previous installments of our Web performance series, we've examined how developers can employ Web server caching and application caching to speed up their Web applications. In this installment, we'll see how caching entire data sets can increase platform efficiency.

What is Data Caching?

Database caching is a species of application caching that caches the result of one or more database queries in the application server's memory. For our purposes, we use application caching to refer to caching any component in an application server's memory, and data caching to refer to caching a collection of data for future querying and sorting.

There are two main approaches to data caching:

  1. Data set caching. Data returned from a database is stored in a data set, an in-memory representation of data that mimics the column/row structure of a relational database.
  2. In-memory databases. An in-memory database is a relational database that operates completely in a server's RAM, as opposed to storing data to a hard drive. In-memory databases can be used for fast access to data previously retrieved from a traditional, disk-based RDBMS.

Let's dig deeper into each of these.

Data Set Caching

One of the best architectures for data set caching is found in Microsoft's .NET platform. The DataSet class in .NET implements a disconnected data set. Once a DataSet is filled with the data returned from a SQL query, the connection to the underlying database is broken. This makes DataSets ideal for caching in the Application object.

David Burgett discusses using cached DataSets in detail in an article in MSDN Magazine. In Burgett's example, a developer of a credit card authorization Web service for businesses retrieves the list of authorized customers into a DataSet and caches the DataSet in memory for future reference.

web performance optimization DataSetWhat happens when a customer changes part of their customer record? In this case, the developer can maximize the benefits of caching by changing the data directly in the cached DataSet, and then push the change down to the underlying database. Instead of invalidating the entire DataSet and re-querying the database for all customer records (a costly operation for performance), the developer need only commit changes to a single customer record. In his article, Burgett further demonstrates how the application can use Web Service calls to keep all of the DataSet caches in a server farm synchronized.

While .NET contains the best support for data set caching, it can be utilized (or at least emulated) in other platforms. PHP programmers can retrieve the results of their database queries as associative arrays, which can be cached in shared memory using the Alternative PHP Cache (PHP). Java contains more direct support for data caching using Service Data Objects (SDO).

In-Memory Databases and Data Caches

Some database vendors support an even more sophisticated version of caching via in-memory databases. The Oracle In-Memory Database Cache supports caching critical subsets of Oracle relational data tables in the application tier. This cache relies upon Oracle's TimesTen In-Memory Database, which maintains its databases as "embedded databases" entirely within system memory. TimesTen uses checkpointing to persist in-memory data to disk for recoverability, and transactional replication to keep data consistent across multiple servers. Server replication and checkpointing both insure against data loss in the case of server failure.

web performance optimization MySQL Cluster
Other in-memory database systems include SQLite and IBM's solidDB. MySQL Cluster may also be configured as an in-memory database.

Some developers argue that embedded databases are the wave of the future. As writer Greg Linden points out, most highly performant sites like Facebook already cache so much data that up to 75% of their total data retrieval is from RAM anyway!

Temporary Tables and Database Connections

In the past, it was common for client/server developers to utilize temporary tables stored in a database server's memory. The temporary table could hold the output of queries that were the result of complex JOIN operations. However, most temporary tables are associated with a specific database connection. Since nearly all Web-based applications use database connection pooling, using temporary tables isn't feasible.

Some database systems support memory-based database tables. For instance, MySQL can create temporary tables with the MEMORY command. However, these tables are specific to a single instance of the database server and don't support row-level locking.

Conclusion

Web performance optimization is an engineering discipline which can have a tremendous impact on revenue and customer satisfaction. Caching is probably the biggest weapon in the arsenal of performance engineers, and it is usually relatively easy to utilize. Moving data to and from a database is typically one of the bottlenecks of a web application's performance because it involves physical devices actuating mechanical arms that are exponentially slower than electricity flowing through memory chips. Thus, putting data into cache memory has enormous performance gains.

In general, developers will achieve greater speed boosts by storing data sets in the application tier, and using the techniques described above to keep these cached data sets synchronized across application and database servers.



Storm on Demand - Pay Per Test

Storm on Demand Users Cost
1,000 $39.90
5,000 $199.50
10,000 $399.00
25,000 $997.50
50,000 $1,995.00
100,000 $3,990.00
200,000 $7,980.00

performance testing sign upIt's easy. You can be load testing in 15 minutes.

  1. Click the "Free Account" button.
  2. Enter your name & email address.
  3. Click the confirmation link in an email.
  4. Create a test scenario for your site.
  5. Run a load test.
  6. Analyze the test results.
  7. Send us a testimonial because you are amazed!

Customers love our load testing tool

“We needed an easy & cost effective way to load test our Windows Azure solution. Thanks to LoadStorm - highly recommended!” - Jonas Stawski, Microsoft MVP

"LoadStorm is a very useful tool." Alan Cheung, Manager - Technical Services, Dow Jones Publishing Company

"It has been a pleasure to work with LoadStorm." - Mike Compton, V.P. of I.T., Hearst Business Media

"Load-testing in the cloud was a great solution and LoadStorm a dream partner. " - Julie Hansen, COO, Publisher, The Business Insider

"There was no risk because I knew what the tool would provide before spending a dime. LoadStorm is a great tool." - Richard Ertman, QA/Release Manager, PETA

"I am definitely a fan of LoadStorm. I like its ease-of-use and the way in which the solution scales." - Darin Creason, Sr. Software Engineer, TransCore Corp

Want a Live Demo? Have Questions?

Please feel free to contact us:

(970) 389-1899

We are eager to help you with LoadStorm in any way that you need.