Transparent Mid-Tier Database Caching in SQL Server - CiteSeerX

3 downloads 625 Views 17KB Size Report
database caching, that is, running a local database server on each application server that ... It builds on SQL Server's support for materialized views, distributed ...
Transparent Mid-Tier Database Caching in SQL Server Per-Åke Larson Jonathan Goldstein

Jingren Zhou

Microsoft Research {palarson, jongold}@microsoft.com

Columbia University [email protected]

1. INTRODUCTION Many applications today are designed for a multi-tier environment typically consisting of browser-based clients, application servers and a backend database server. Application servers do not maintain persistent state and typically run on fairly inexpensive machines. Hence, bottlenecks in the application server tier can be solved easily and cheaply by increasing the number of servers. All persistent state is maintained by the backend database server. A user request may cause tens or even hundreds of queries against the backend database, potentially overwhelming the backend server. One promising way of addressing this problem is mid-tier database caching, that is, running a local database server on each application server that caches data from the backend database. This allows some queries to be computed locally. The key challenge is retaining application transparency (i.e. not requiring any changes in applications). In particular, applications should not be aware of what is cached and should not be responsible for routing requests to the cache or to the backend server. We have designed and prototyped MTCache, a mid-tier database cache solution for Microsoft SQL Server that achieves these goals. It builds on SQL Server’s support for materialized views, distributed queries and transactional replication. In this sense, it resembles the approach taken by DBCache [1][3] but MTCache allows caching not only of complete tables but also horizontal and vertical subsets of tables and materialized views. DBCache always uses the cached version of a table when it is referenced in a query. In MTCache this is not always the case: the decision is integrated into the optimization process and entirely cost-based. MTCache also includes improved optimization of parameterized queries that results in more efficient use of cached data. TimesTen offers a mid-tier caching solution built on their in-memory database manager [4] [5] but the cache is not transparent to applications.

2. SYSTEM OVERVIEW



Data is added to the cache by creating materialized views on the mid-tier server. These materialized views may be selections and projections of tables or materialized views on the backend server.



The materialized views on the mid-tier server are updated by SQL Server replication. When a view is created, a matching replication subscription is automatically created and the view is populated.



Queries may be computed locally, remotely or part locally and part remotely as decided by the query optimizer. The decisions are cost based and not guided by heuristics.



Parameterized queries are dealt with by generating plans with two branches, one fast (local) branch and one (remote) fallback branch. The appropriate branch is selected at run time depending on actual parameter values.



Stored procedures may be executed locally or on the backend server. If the procedure is found locally, it is evaluated on the mid-tier server; otherwise the call is transparently forwarded to the backend server



All inserts, deletes and updates are transparently forwarded to the backend server.

3. DEMONSTRATION We demonstrated the capabilities of MTCache using the TPC-W benchmark [6]. TPC-W is a web-based store-front application emulating a bookstore. MTCache was set up in a typical three-tier architecture using Microsoft IIS as the application server and SQL Server as the backend database server and as the mid-tier cache server. We showed the improvements in scalability and response time obtained by mid-tier caching and described the key internal mechanisms and techniques used in the prototype implementation. Finally, we demonstrated how easy it is to set up the mid-tier cache and to change the caching strategy without affecting applications.

MTCache is based on the following approach.

4. REFERENCES



[1] M. Altinet, Q. Luo, S. Krishnamurthy, C. Mohan, H. Pirahesh, B. G. Lindsay, H. Woo, L. Brown, DBCache: Database Caching for Web Application Servers, SIGMOD 2002, 612.

A shadow database is created on the mid-tier server that contains the same tables as the backend database, including constraints, indexes, views and permissions, but all tables are empty. However, the statistics maintained on shadow tables, indexes and materialized views reflect the data on the backend server.

Contact information: Per-Åke Larson and Jonathan Goldstein, Microsoft Research, One Microsoft Way, Redmond, WA 98052; Jingren Zhou, Department of Computer Science, Columbia University, 1214 Amsterdam Avenue, New York, NY 10027. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. SIGMOD 2003, June 9-12, 2003, San Diego, CA. Copyright 2003 ACM 1-58113-634-X/03/06…$5.00.

[2] J. Anton, L. Jacobs, X. Liu, J. Parker, Z. Zeng, T. Zhong, Web Caching for Database Applications with Oracle Web Cache, SIGMOD 2002, 593-599. [3] Q. Luo, S. Krishnamurthy, C. Mohan, H. Pirahesh, H. Woo, B. G. Lindsay, J. F. Naughton, Middle-Tier Database Caching for e-Business, SIGMOD 2002, 600-611. [4] The TimesTen Team, High Performance and Scalability through Application-Tier, In-Memory Data Management, VLDB 2000, 677-680. [5] The TimesTen Team, Mid-Tier Caching: The TimesTen Approach, SIGMOD 2002, 588-593. [6] http://www.tpc.org/tpcw/default.asp