Enterprise Library Caching Application Block Brian Button Software Design Engineer Ron Jacobs Product Manager Scott Densmore Software Design Engineer.

Slides:



Advertisements
Similar presentations
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Advertisements

CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Copyright 2007, Information Builders. Slide 1 Workload Distribution for the Enterprise Mark Nesson, Vashti Ragoonath June, 2008.
Leveraging Enterprise Library in Your Applications Keith Elder Quicken Loans Manager, Sr. Software Engineer Microsoft MVP Keith a t keithelder dot net.
Chapter 9 Chapter 9: Managing Groups, Folders, Files, and Object Security.
MCDST : Supporting Users and Troubleshooting a Microsoft Windows XP Operating System Chapter 10: Collect and Analyze Performance Data.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 12: Managing and Implementing Backups and Disaster Recovery.
Implementing ISA Server Caching. Caching Overview ISA Server supports caching as a way to improve the speed of retrieving information from the Internet.
Patterns & practices Enterprise Library Brian Button Consultant/Developer patterns & practices.
MCITP Guide to Microsoft Windows Server 2008 Server Administration (Exam #70-646) Chapter 14 Server and Network Monitoring.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 7: Planning a DNS Strategy.
Hands-On Microsoft Windows Server 2008 Chapter 11 Server and Network Monitoring.
CH 13 Server and Network Monitoring. Hands-On Microsoft Windows Server Objectives Understand the importance of server monitoring Monitor server.
Windows Server 2008 Chapter 11 Last Update
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 12: Managing and Implementing Backups and Disaster Recovery.
22-Aug-15 | 1 |1 | Help! I need more servers! What do I do? Scaling a PHP application.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Managing Large RDF Graphs (Infinite Graph) Vaibhav Khadilkar Department of Computer Science, The University of Texas at Dallas FEARLESS engineering.
Smart Client Applications for Developers Davin Mickelson, MCT, MCSD New Horizons of MN.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
A Scalable Application Architecture for composing News Portals on the Internet Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta Famagusta.
CROSS CUTTING CONCERNS SAMANVITHA RAMAYANAM 8 th APRIL 2010 CPE
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 12: Managing and Implementing Backups and Disaster Recovery.
M i SMob i S Mob i Store - Mobile i nternet File Storage Platform Chetna Kaur.
Enterprise Library Building an Application Block Ed Jezierski Solution Architect Scott Densmore Software Engineer Ron Jacobs Product Manager.
Computer Measurement Group, India Optimal Design Principles for better Performance of Next generation Systems Balachandar Gurusamy,
Module 7: Fundamentals of Administering Windows Server 2008.
Meet with the AppEngine Márk Gergely eu.edge. What is AppEngine? It’s a tool, that lets you run your web applications on Google's infrastructure. –Google's.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems CSCI-6140 – Computer Operating Systems David Goldschmidt, Ph.D.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
DEV364 Caching Best Practices in.NET Applications Ron Jacobs Product Manager Microsoft Patterns & Practices.
Step By Step Windows Server 2003 Installation Guide Step By Step Windows Server 2003 Installation Guide.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
DEV325 Deploying Visual Studio.NET Applications Billy Hollis Author / Consultant.
Enterprise Library Cryptography Application Block Tim Shakarian Software Design Engineer Avanade Ron Jacobs Product Manager Microsoft Scott Densmore Software.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice HP Library Encryption - LTO4 Key.
Sage ACT! 2013 SDK Update Brian P. Mowka March 23, 2012 Template date: October 2010.
The Client/Server Database Environment Ployphan Sornsuwit KPRU Ref.
Module 10 Administering and Configuring SharePoint Search.
ASP.NET Caching - Pradeepa Chandramohan. What is Caching? Storing data in memory for quick access. In Web Application environment, data that is cached.
Operating Systems David Goldschmidt, Ph.D. Computer Science The College of Saint Rose CIS 432.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
MCDST : Supporting Users and Troubleshooting a Microsoft Windows XP Operating System Chapter 11: Managing Access to File System Resources.
Construction Planning and Prerequisite
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
CH 13 Server and Network Monitoring. Hands-On Microsoft Windows Server Objectives Understand the importance of server monitoring Monitor server.
20 Copyright © 2008, Oracle. All rights reserved. Cache Management.
Enterprise Library Caching Application Block Peter Provost Software Design Engineer Ron Jacobs Product Manager Scott Densmore Software Design Engineer.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
1 Chapter Overview Monitoring Access to Shared Folders Creating and Sharing Local and Remote Folders Monitoring Network Users Using Offline Folders and.
Module 5: Managing Content. Overview Publishing Content Executing Reports Creating Cached Instances Creating Snapshots and Report History Creating Subscriptions.
Enterprise Library Overview Tom Hollander Product Manager Microsoft Edward Jezierski ArchitectMicrosoft Kyle Huntley Architect Avanade Ron Jacobs Product.
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
IPEmotion License Management PM (V1.2).
1 Copyright © 2008, Oracle. All rights reserved. Repository Basics.
Cofax Scalability Document Version Scaling Cofax in General The scalability of Cofax is directly related to the system software, hardware and network.
Storage Systems CSE 598d, Spring 2007 Lecture 13: File Systems March 8, 2007.
Configuring the User and Computer Environment Using Group Policy Lesson 8.
Hands-On Microsoft Windows Server 2008
Software Design and Architecture
The Client/Server Database Environment
Software Architecture in Practice
Advanced Operating Systems
O.S Lecture 13 Virtual Memory.
Lecture 1: Multi-tier Architecture Overview
CROSS CUTTING CONCERNS
Presentation transcript:

Enterprise Library Caching Application Block Brian Button Software Design Engineer Ron Jacobs Product Manager Scott Densmore Software Design Engineer

Agenda Caching architectural guidance from patterns & practices Describe implementation of caching scenarios and guidance using the Caching Application Block DemonstrationQuestions

Sound familiar? Users are complaining about application performance You have already spent the next year’s IT budget scaling out your database servers to handle the amount of requests for data Your application cannot perform, or is severely degraded, without a live connection to the backend data source

Why Cache? Performance Storing relevant data as close as possible to the data consumer avoids repetitive data creation, processing, and transportation Scalability Avoid wasting resources processing the same data, business functionality, and user interface fragments required by multiple users and processes Reduce database requests, allowing more users to be served Availability Storing that data in another place, your application may be able to survive system failures such as network latency, Web service problems, or hardware failures

Sample Application Caching Scenarios You are creating a smart client application that uses locally cached reference data to create requests and support offline operations You are creating a Windows Service or Console application which needs a cache to improve performance

Caching Application Block Provides a flexible and extensible caching mechanism that can be used at all layers of an application Supports backing stores that persist cache data into a database or isolated storage, so the data can survive app restarts Easy to use Easy to configure, using the Enterprise Library Configuration Tool Thread-safe Ensures that the states of the in-memory cache and the backing store remain synchronized.

Exploring the Caching Application Block Creating the Caching Application Block configuration Selecting a backing store Creating the cache Adding an item to the cache Setting the expiration policy Retrieving an item from the cache Implementing cache loading strategies Removing an item from the cache Flushing the cache Key extensibility points

Add the Caching Application Block to your application configuration Create a cache manager for each set of data to be cached Designate one as the default cache manager Creating Configuration

Cache Storage Guidance Memory resident cache. Memory-based caching is usually used when: An application is frequently using the same data An application often needs to reacquire the data Disk resident cache. Disk based caching is useful when: You are handling large amounts of data Data in the application services (for example, a database) may not always be available for reacquisition (for example, in offline scenarios) Cached data lifetime must survive process recycles and computer reboots Caching Architecture Guide for.NET Framework Applications Caching Architecture Guide for.NET Framework Applications

Caching Application Block Storage Cache always exists in memory Cache always has a backing store Null backing store (in-memory only, not persistent) Persistent storage Persistent backing stores Useful when cached data lifetime must survive process recycles and computer reboots Isolated storage, Data Access Application Block Contents always match in-memory cache In-memory cache is loaded from backing store during cache initialization

Backing Store Configuration Isolated Storage Segregated by user and assembly Caching Application Block provides partition to segregate multiple cache managers within an application

Backing Store Configuration Data Access Application Block Segregated by database instance and named partition Require configuring the Data Access Application Block

Backing Store Configuration Encrypting cache data in the backing store Requires Cryptography Application Block Select Symmetric provider to use

Create the default cache manager Creating the Cache in Code CacheManager myCache = CacheManager.GetCacheManager(); Create the cache manager named “Products” CacheManager productsCache = CacheManager.GetCacheManager(“Products”);

Adding an Item to the Cache Add an item to the cache with defaults productsCache.Add(“ProductID123”, productObject); Defaults Scavenging priority: Normal No expiration Notes Adding a second item with the same key as an existing item replaces the existing item When configured to use a persistent backing store, objects added to the cache must be serializable

Determining an Expiration Policy Time-based expirations Invalidate data based on either relative or absolute time periods For use when volatile cache items—such as those that have regular data refreshes or those that are valid for only a set amount of time—are stored in a cache. Notification-based expirations Validity of a cached item based on the properties of an application resource, such as a file, a folder, or any other type of data source.

Time-Based Expirations Absolute. Allows you to define the lifetime of an item by specifying the absolute time for an item to expire. Simple—You define the lifetime of an item by setting a specific date and time for the item to expire. Extended—You define the lifetime of an item by specifying expressions such as every minute, every Sunday, expire at 5:15 AM on the 15th of every month, and so on. Sliding. Allows you to define the lifetime of an item by specifying the interval between the item being accessed and the policy defining it as expired.

Time-Based Expirations DateTime refreshTime = new DateTime(2005, 3, 21, 2, 0, 0); AbsoluteTime expireTime = new AbsoluteTime(refreshTime); primitivesCache.Add("Key1", "Cache Item1", CacheItemPriority.Normal, null, expireTime); Requires using extended overload of Add method Caching Application Block classes support time- based expirations AbsoluteTimeSlidingTimeExtendedFormatTime Absolute time example: expire at 2:00 AM on 3/21/05

Sliding Time Expirations TimeSpan refreshTime = new TimeSpan(0, 5, 0); SlidingTime expireTime = new SlidingTime(refreshTime); primitivesCache.Add("Key1", "Cache Item1", CacheItemPriority.Normal, null, expireTime); Sliding time example: expire if item has not been accessed for 5 minutes

Extended Time Format Expirations Extended time format “ ” * means run every period Examples “* * * * *” expires every minute “5 * * * *” expire 5th minute of every hour “* 21 * * *” expire every minute of the 21st hour of every day “31 15 * * *” expire 3:31 PM every day “7 4 * * 6” expire Saturday 4:07 AM “ *” expire 9:15 PM on 4 July

Extended Time Format Expirations ExtendedFormatTime expireTime = new ExtendedFormatTime("0 0 * * 6"); primitivesCache.Add("Key1", "Cache Item1", CacheItemPriority.Normal, null, expireTime); Extended format example: expire at midnight every Saturday

Notification-Based Expirations FileDependencyexpireNotice = new FileDependency(“Trigger.txt”); productsCache.Add("Key1", "Cache Item1", CacheItemPriority.Normal, null, expireNotice); File dependency example: expire if the file Trigger.txt is changed You can create custom expirations by creating classes that implement ICacheItemExpiration

Configuring Expiration Poll Frequency Removal of expired items occurs on a background thread You can set the frequency of how often this thread will run looking for expired items

Item Removal Notifications productsCache.Add("Key1", "Cache Item1", CacheItemPriority.Normal, new ProductCacheRefreshAction(), expireNotice); Caching Application Block provides notification when an item is removed from cache Item has expired Item was removed explicitly through code Item was scavenged Provide an object that implements ICacheItemRefreshAction when item is added to cache

Item Removal Notifications [Serializable] public class ProductCacheRefreshAction : ICacheItemRefreshAction { public void Refresh(string key, object expiredValue, CacheItemRemovedReason removalReason) { // Item has been removed from cache. // Perform desired actions here, // based upon the removal reason (e.g. refresh the cache with the // item). } Class implementing ICacheItemRefreshAction must be marked as Serializable (for persistent backing store)

Cast returned object to correct type Check for null (item not found in cache) Retrieving an Item from the Cache public Product ReadProductByID(string productID) { Product product = (Product)cache.GetData(productID); if (product == null) { // Item not in cache }

Proactive loading Cache is preloaded with items on application startup Application response time improves, as all items are in cache Application startup time increases, as all items are loaded May cache items that are never requested, using unnecessary resources Loading typically done on a separate thread, increasing complexity Reactive loading Cache an item after it is retrieved from the data source Only caches items truly needed (uses less resources) Response times slower during application execution if an item is not yet cached Loading the Cache

Create cache manager Loading the Cache Proactively CacheManager productsCache = CacheManager.GetCacheManager(); // Retrieve the data from the source ArrayList list = dataProvider.GetProductList(); // Add all the items to the cache for (int i = 0; i < list.Count; i++) { Product product = (Product) list[i]; productsCache.Add( product.ProductID, product ); } Add items during component initialization

Loading the Cache Reactively Product product = (Product) productsCache.GetData(productID); if (product == null) { // Retrieve it from the data provider // and cache it for more requests. product = dataProvider.GetProductByID(productID); if (product != null) { productsCache.Add(productID, product); } Create cache manager CacheManager productsCache = CacheManager.GetCacheManager(); Add items when retrieved from data source

Proactive caching is recommended in situations that have one or more of the following characteristics: You are using static or semistatic state that has known update periods. If you use it in other scenarios, the state might expire before it is used. You are using state with a known lifetime. You are using state of a known size. If you use proactive cache data loading when you do not know the size of the data, you might exhaust system resources. You must try to not use resources that you do not have. You have problematic resources, such as a slow database, a slow network, or unreliable Web services. You can use this technique to retrieve all the state proactively, cache it, and work against the cache as much as it can. Loading the Cache

Reactive caching is recommended in situations that have one or more of the following characteristics: You are using lots of state and you do not have sufficient resources to cache all state for the entire application. You are using reliable and responsive resources, such as a database, network, or Web service that will not impede application stability and performance. You are interested in caching data that is not available during the initialization of an application. For example, this data might be affected by user input such as common search queries or user-specific data such as a user's profile. Loading the Cache

Remove item with specified key Removing an Item from the Cache productsCache.Remove(“Product101Key”) No error occurs if key is not found

Flushing the Cache Use to manage storage, memory and other resources efficiently Explicit flushing Initiated by application code Removes all items from the cache Scavenging Initiated by application block Based upon priority and last access time Configuration settings control size of cache and number removed productsCache.Flush()

Flushing the Cache with Scavenging Scavenging configuration Maximum elements in cache Number of items removed when scavenging occurs

Flushing the Cache with Scavenging Priority is established when an item is added to the cache productsCache.Add("Key1", "Cache Item1", CacheItemPriority.High, new ProductCacheRefreshAction(), expireNotice) Priority values LowNormalHighNotRemovable The scavenging algorithm is not an extension point

View/Application Share: Demonstration [Live Meeting View/Application Share. Use Live Meeting > Edit Slide Properties... to edit.]

Key Extensibility Points Custom backing store provider Implement IBackingStore (derive from BaseBackingStore) Use Configuration Console to select custom provider Custom expiration policy Implement ICacheItemExpiration Specify object on call to Add method of CacheManager object Plus… Anything and everything – you have the source code! Please post extensions and suggestions to the community

Security Crypto Configuration DataAccessLogging CachingExceptions Enterprise Library v1 Legend Dependency Plug-in ConfigTool

Announcing: Enterprise Library Download it Today!

patterns & practices Live! 3/14 Enterprise Library Logging & Instrumentation Application Block 3/17 Enterprise Library Exception Handling Application Block 3/22 Enterprise Library Cryptography Application Block 3/24 Enterprise Library Security Application Block

Enterprise Library Community