windows server appfabric caching - what it is & when you should use it?

Post on 10-May-2015

5.727 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

This is from my Tech-Ed Africa 2010 talk. For more information see: http://www.sadev.co.za/content/teched-africa-2010-slides-scripts-and-demos-my-talks This session looks at what AppFabric Caching is from start to deep dive.

TRANSCRIPT

Robert MacLeanTechnology SpecialistBB&D

Windows Server AppFabric Caching: What it is & When you should use it?

3

Who am I?

Robert MacLeanMicrosoft ALM MVPMicrosoft ALM RangerProud Community Lead

Information WorkerS.A. Architect

www.sadev.co.za@rmaclean

4

Overture

Level 300State of playBriefly what is AppFabric?What do we get from AppFabric Caching and how to use it!

5

Advert Time

AppFabric:Wed, 11:15pm - WCF Made Easy with .NET 4 and Windows Server AppFabric

Other:Wed, 8:30pm - Tales From the field – Best practices and guidance on implementing TFS2010

6

State of play

.NET prior to 4ASP.NET CachingEnterprise Library Caching

.NET 4 brings us.NET 4 Caching

All are local in-memory caches!

.NET 4 Caching

Demo

8

What is the issue with these?

Limited to memory of current machineLimited to current process

Imagine if I need 50Gb of cache?What about load balancing?

9

A rose by any other name…

Windows Server AppFabric contains two key componentsHosting

EndPoint, Windows App Server Extensions, DublinCaching

VelocityNot to be confused with Azure AppFabric

10

N.B. AppFabric

Requires .NET 4 on ServerNot all applications need .NET 4, depends on features used

Standalone download or Web Platform InstallerHigh Availability is only in Windows Server 2008 Enterprise & Data Centre

11

What is AppFabric Cache?

An in-memory distributed cache which you can call from any .NET applicationOptimised for the cache-aside pattern

Programming against the cache is explicitChanging the cache doesn’t update the original data store

12

AppFabric Cache Single View

Cache Server

Single view from code

Cache Server

Cache Server

Services

Data 1

Data 2

Data 3

Data 4

Cache Server

13

AppFabric Caching Info

Common Configuration StoreXMLDatabase

Runs as Windows ServiceCommunication Between Nodes

WCF net.tcpSelf Adjusting

14

AppFabric Server Types

Dedicated Cache ServerAll it does is AppFabric caching – good for lots of memory and great performation

Hybrid Cache ServerRuns AppFabric caching & other tools. SQL + AppFabricWeb + AppFabric

Local Cache ServerRuns AppFabric per application locallyUsed in conjunction with hybrid and/or dedicated

15

What can I cache?

Anything that can be serialisedXMLPOCOBinary Data

16

Data Cache Planning

Reference DataCities, provinces, product info, etc…

Activity DataSession, per user etc..

Resource DataData with contention We will look at this more later…

NB: Plan, plan and plan some more

17

Management

All Configuration and Administration is done via PowerShell

From the MVP’s: http://mdcadmintool.codeplex.com/

AppFabric from IT Pro to Developer

Demo

19

Cache Structure ReviewServer Server Server

Named Cache: Default

Named Cache: Products

Named Cache: UsersRegion: Male

Region: Female

Items & Tags

20

Expiration of cache items

Put & AddTimeout

NotificationPolling Default: 300 secs

Expiration timeout defaults can be controlled on a cache level

21

Eviction

@ Low watermarkExpired items removed

@ High watermarkItems, expired or not, can be removed or allocated to another serverItems picked by using LRU Can disable if needed

22

ORM’s

Some ORM’s implement second level cachingIt is possible to change the second level to AppFabricExamples: NHibernate & Entity Framework

23

A Problem with Caching

DBAppFabric

Cache

ATM

ORM UI

ATM

ORM UI

Name : RobertBalance: 15

Name : RobertBalance: 15

Name : RobertBalance: 1500

24

Solution

.GetAndLock

.PutAndUnlock

.Unlock

Supports locking timeoutLocked items can survive expiration

Unlock can prolong expiration

25

Data Cache Planning

Reference DataCities, provinces, product info, etc…

Activity DataSession, per user etc..

Resource DataData with contention

NB: Plan, plan and plan some more

Great with defaults

Region per user

Locking per item

26

Cluster Configuration

First node initialises clusterOther nodes join

During install you must configure projected sizeSmall: 1 – 5 nodes Medium: 6 – 15 nodesLarge: > 15 nodes

Performance based on this setting – adding/removing nodes does not effect this

27

Security

Domain:Authentication in AD, Authorisation in AppFabricOnly authorised servers join clustersOnly authorised clients connect to clusters

WorkgroupAuthentication in network share, Authorisation in AppFabric

Transport Level SecuritySigning and Encryption

28

Typical Web Architecture

DB

Web

Se

rver

sU

sers

StateState State Load Balancer

29

ASP.NET

Out of the box caching InProc (Default)StateServerSQLServerAll can be enabled by via config change

Now AppFabric support also just a config change

30

ASP.NET AppFabric Config<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true" allowDefinition="Everywhere"/>

</configSections>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="DcacheLog/dd-hh-mm" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon“ sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary“ sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

31

ASP.NET AppFabric Config<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true" allowDefinition="Everywhere"/>

</configSections>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="DcacheLog/dd-hh-mm" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon“ sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary“ sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary"

allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true"

allowDefinition="Everywhere"/>

</configSections>

32

ASP.NET AppFabric Config<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true" allowDefinition="Everywhere"/>

</configSections>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="DcacheLog/dd-hh-mm" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon“ sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary“ sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

33

ASP.NET AppFabric Config<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true" allowDefinition="Everywhere"/>

</configSections>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="DcacheLog/dd-hh-mm" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon“ sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary“ sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon"

sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

34

ASP.NET AppFabric Config<configSections>

<section name="dataCacheClient“ type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>

<section name="fabric“ type="System.Data.Fabric.Common.ConfigFile, FabricCommon“ allowLocation="true" allowDefinition="Everywhere"/>

</configSections>

<dataCacheClient deployment="routing">

<localCache isEnabled="false"/>

<hosts>

<host name="localhost" cachePort="22233“ cacheHostName="DistributedCacheService"/>

</hosts>

</dataCacheClient>

<fabric>

<section name="logging" path="">

<collection name="sinks" collectionType="list">

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="DcacheLog/dd-hh-mm" defaultLevel="-1"/>

<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon“ sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary“ sinkParam="" defaultLevel="-1"/>

</collection>

</section>

</fabric>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

<system.web>

<sessionState mode="Custom" customProvider="Velocity">

<providers>

<add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider,

ClientLibrary" cacheName="session"/>

</providers>

</sessionState>

</system.web>

35

Summary

Windows Server AppFabric Cache is a distributed application cacheCaching is important to application scalabilityExplicit caching API available to .NET 3.5 SP1 and .NET 4.0ASP.NET Session provider an implicit way to take advantage of the Cache’s capabilitiesPlan, plan and plan some more

36

Questionsrobert@sadev.co.za @rmaclean

Meet me at the community lounge

37

Resources

www.microsoft.com/teched

Sessions On-Demand & Community Microsoft Certification & Training Resources

Resources for IT Professionals Resources for Developers

www.microsoft.com/learning

http://microsoft.com/technet http://microsoft.com/msdn

Learning

SMS [ Your Name ] and the word “AppServer” to 41491Need more Information?

Complete an evaluation via CommNet and Tag to win amazing prizes!

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED

OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

top related