Académique Documents
Professionnel Documents
Culture Documents
BuildingHighPerformanceandScalable ApplicationsusingAppFabricCache
Abstract
Mostapplicationsfacechallengesrelatedto robustness,speed,andscalability.Thiswhitepaper focusesonWindowsServerAppFabric,whichprovides adistributedinmemorycacheforapplicationsdata. ThepapertalksaboutAppFabriccachesabilityto helpsorganizationcreatescalable,available,high performanceapplicationsbyexposingaunifiedviewof distributedmemoryforclientapplication consumption.ItfocusesonhowAppFabricallows companiestosignificantlyimproveapplication performancebyavoidingrepetitivecallstothedata sourceandhowitenablesapplicationstoscalewith increasingdemand,byusingacacheclusterthat automaticallyhandlesthecomplexitiesofload balancing.
In ntroduct tion
Intheprogrammingworld,dataisca apturedands storedintothefilesystem, , mes,thecostofstoringan ndretrievingt the databaseandothersources.Sometim dataisexpe ensive.While eadvancedte echnologiesa allowthecapt turingandsto oring ofdataina arelativelyine expensivewa ay,howevero organizingand daccessingdatais abigchalle enge.Technol logiessuchas sAppFabriccachecanhelp porganizations developne extgeneration napplications sthataredat tadriven,wherethedatacan resideinth hememory.
Keychallenges
Normallyaninmemory ycacheisused dtostorefrequentlyusedapplicationd data thathelpsi improvethep performanceoftheapplication.Readin ngandwriting g dataintom memoryisfast terthanread dingfromandwritingtoadatabaseord disk. However,s somechalleng gesexistinth hetraditionalinmemoryc cache. Duetolimitedm memoryavailableforanApplication,th heinmemory y cac chesizeislimited.Onlyalimitedsizeof fdatacanbestoredintothein me emorycache. Dat tastoredina aninmemory ycanbelostiftheApplicat tiongoesdow wn due etoanyfailure. The ereisnosimp pletechnique ethatcanred ducepressure efromthedat ta tier rwithoutcom mplexdatapa artitioningtec chniques. Sto oringbigdatamashupsfro ommultipled datareposito oriesisalsoa cha allenge.
Th hesolut tion
Toovercom metheabovechallenges,t theImpetuse engineeringte eamhas undertaken naresearcho onMicrosoftsAppFabricc cache.AppFabriccachingh has thecapabilitytocombin nemultipleco omputersinto oasingleunif fiedcacheclu uster. ByusingAp ppFabriccach hing,userscan nscaleoutth heir.Netapplicationseasilyand inexpensive ely.Heresho ow: ingServicesu useacachecl lusterthatau utomatically AppFabricCachi anagesthecomplexitiesof floadbalancing.Italsoena ables ma org ganizationsto oachievebett terscalability ybyaddingm morecompute erson dem mand. Use erscanachiev veevenhighe eravailability ybyallowingCachingServi ices tos storecopieso ofthedataac crosstheclus ster.Theycan nrunAppFabr ric Cac chingServiceswithanydis stributedapp plicationonth hesameserve er,or acc cesstheservicesoverane etworkonare emoteserver r. AppFabricCachi ingServicese enablesuserstoimprovea application per rformancesig gnificantlybyavoidingunn necessarycall lstothedata sou urce.
Inaddition, ,thereisseam mlessintegra ationwithASP P.Netforstor ringsessionst tate inthecache.Thiscanpr rovideASP.Ne etsiteswitha acosteffectiv vepathforqu uickly
improvings siteperforma anceandscale.Theperfor rmance,scalability,and availabilityofAppFabric ccachingserv vices,inconju unctionwithA AppFabricrich h es,canfacilitaterichWebandenterpri iseapplicationsdevelopment dataservice anddeploy yment.
Mostdevel lopersarefam miliarwithnt tierapplicatio onarchitecturesinwhicht the applicationisbrokenou utintotiers.T Thesetypically yincludethre eeclassiclaye ers:the userinterfa ace,thebusin nesslogiclaye er,andtheda atalayer.Ofc course,userscanbreak theselayer rsdownfurthertoprovide eforadditiona alscalabilitya andflexibility y.Thefigure belowshow wsthepresen nceofafourthlayer,theC Cachingtier.Inthiscase,w whenusers firstacquire esomeitemofdata,suchasinformatio onfromtheA ASP.Netappli icationor valuesread dfromadatabase,theyca anuseanApp pFabricCachin ngServicestie erto explicitlyst torethisinfor rmationinthe ecachecluste erunderaun niquename.L Later,the
4
Figure1:AppFabricCa acheArchitecture
apabilities Figure2:AppFabricCa
5
Cachingfea aturesofWin ndowsServer rAppFabric Dat taisstoredonmultipleno odes,improvingavailability y. The ereiscaching gofanyserial lizableCLRob bject. The ereisintegrat tionwithASP P.Net,making gitpossibleto ocacheASP.N Net ses ssiondataint thecacheviathecustoms sessionstateprovider.This increasesthepe erformanceandscalability yofASP.Neta applications. Aut tomaticloadbalancingacr rosscacheclu uster,thereby yimproving sca alability. The ereareregion ns,wheredat taissegregat tedintologica alsegments. The ereisanExpirationfeature e,whichallow wstimespanbasedexpira ation ofc cacheddata. The eEvictionsfeatureallowsmemorycons servation. AppFabriccache esupportsen nterprisescale e:thatis,tens,tohundred dsof com mputers.
Figure3:HierarchyofAppFabricCa ache NamedCac che Anamedca acheisaconf figurableunit tofinmemor rystoragetha atallapplicat tionsuseto storedatai inthedistribu utedcache.U Userscanconfigureoneor rmorenamed dcachesfor eachofthe eirapplication ns.Eachcache ecanbeconf figuredindep pendentofthe eothers, whichletsu usersoptimiz zethepolicies sofeachcach hefortheirapplications.A Allphysical configurationsandcachepoliciessuc chasfailover, ,expiration,e eviction,etc.,are specifiedat tthislevel.Alltheapplicat tionsthatnee edtocommunicatetothesame namedcachemustinsta antiatethesa amenamedca acheusingth heDataCache eFactory. Allcachesa aredefinedin ntheclusterc configuration n.TheWindow wsPowerShell administrat tiontoolcanbeusedtocr reateorrecon nfigurecache es.Somesetti ingscan onlybecon nfiguredwhen nthecacheis sfirstcreated d.Othersettin ngscanbech hanged later,butm mayrequireth heentirecach heclustertoberestarted.Thereisalim mitof128 namedcaches. Region Regionsare eanadditiona aldatacontainerthatcanbeplacedinthecache.Re egionsarea cacheconstruct:theyar renotdefined dinthecluste erconfigurati ionsettings.R Regionsare optional;ifrequired,the eymustbeex xplicitlycreatedatruntim mewiththeap pplication codebyusi ingtheCreate eRegionmet thod.
Anapplicat tionisnotreq quiredtouseRegionsandcanusethep put/get/remo oveAPIs withjustth hekeytotheobject.Infac ct,theapplica ationwillscale ebetterwhennotusing Regionsbecausethekey yscanbedist tributedacros ssthenamed dcache.IfnoRegionis specified,thesystemau utomaticallyp partitionsthekeysintomu ultipleimplicit tlycreated Regions. CacheItem m TheCacheItemactually ycontainsthe eobject.TheC CacheItemst torestheobje ectwiththe key,theob bjectpayload, ,tags,andthe etimetolive(TTL),thecre eatedtimesta amp,the version,andotherinternalbookkeepinginformat tion.ARegion ncontainson neormore acheItems. oftheseCa Availability y Thisisoneoftheimport tantfeaturesoftheWindo owsServerAp ppFabricCach he.Ifone node(mach hine)ofthed distributedcachegetsdow wn,userscangetdatafrom mthe secondarynode.Whenusingapartit tionedcache,itispossibletospecifyan numberof nodesasse econdarycach he.Bydoingt this,userscanstorethesa amedataonmultiple computers.Therefore,if fonenodefa ailsthenoneo ofthesecond darynodesbe ecomesa lesapplicationstocontinu ueaccessingthedatathatwasstored primarynodeandenabl onthecom mputer.
LocalCache e TheLocalC CacheinAppF Fabricissimila artoinmemorycache.Lo ocalCacheob bjectsare storedwith hinthesameprocessspace einwhichthe eapplicationisrunning.Theserver storesobje ectsinaserial lizedmannerinthecache. .Whenacach heclientrequ uestsan objectfrom mthecache,t theserversen ndsittothec clientoverthe enetwork.Th hecache clientthendesterilizest theobjectfor rusebytheclientapplication.Tospeed dupthe processofretrievinganobject,users scanenablet theLocalCach he.
Ap ppFabric cCacheAPI
bricCachingS ServicesAPIisfairlysimple e.Usersmust tfirstcreatea an TheAppFab instanceof ftheCacheFa actoryobject, ,whichunder rthehoodre eadsthe configurationsettingsfr romWeb.config/app. .configoft theirASP.Net tor WForWCF Fservice.TheneedthisCachefFacto ory Objectto oretrievea nameddatacacheobjec ct.Thesewillbetheleastr requiredstep psforusers achedobjects s(data)fromtheAppFabri icCaching wantingtoaccesstheca Services.Th hefollowingc codeexcerptshowcasesth histechnique e: //Create instance of Cach e heFactory DataCach heFactory_factory= new Data = aCacheFactory(); //Get a named cache from the facto ory he_cache= _factory y.GetCache e("default"); DataCach Fromhere,userscande eploysimpleG GetandPutc commandstoreadorwrite e datafrom,ortotheApp pFabriccachin ngstorage.Th hissnippetus sesthesetwo o commandstowriteandthenreadcu ustomdatafromtheAppFabricCache: //Put da ata into a cache _cache.P Put("id01", new It tem("Test" "25.00", "...")); ", ... he same or a different client //Get th data from the s Item MyI Item = (Item) _cac che.Get("i id01"); // If no present in the cache ot if (MyIt tem== null) { //Read f from the b backend l layer MyItem= ReadFromDatabase( (); //Popula ate the Cache _cache.P Put("id01", new It tem("Test" "25.00", "...")); ", returnMy yItem; }
Constrai C ints
Thereisno odirectsuppo ortofcachedependencyin nWindowSer rverAppFabric caching.Ifd datagetscha angedinthed database,the esamedoesn notchangeinthe CacheClust ter.
10 0
Summ mary
Theprimar ryadvantageofusingWind dowsServerA AppFabriccac cheisthecre eation ofscalable, ,availableandhighperfor rmanceapplic cations.Applicationsthatuse AppFabricc cacherespon ndfaster,beca ausetheyfetchdatafrom stead thecacheins ofretrievin ngitagainand dagainfromt thedatabase eorothersou urces.Ascache storesthes samedataon nmultiplecom mputers,itpr rovidesapplic cationavailab bility atalltimes.WindowsServerAppFab briccachealsoprovidesintegrationwit th atenablesAS SP.Netsession nobjectstob bestoredinth hedistributed d ASP.Nettha cache,with houthavingto owritetodat tabases.Thisincreasesthe escalabilityand performanc ceofASP.Net tapplications s.
Referen nces
1. 2. 3. tp://msdn.mic crosoft.com/enus/library y/ee677312.aspx htt htt tp://msdn.mic crosoft.com/library/cc645 5013.aspx Ste ephenKaufma an,DannyGar rber:ProWin ndowsServerAppFabric,A Apress
AboutImpet tus
ImpetusTech hnologiesoffersProductEng gineeringandT TechnologyR& &Dservicesforsoftwareprod ductdevelopment. Withongoing ginvestmentsinresearchan ndapplicationo ofemergingte echnologyarea as,innovativeb businessmode els,and anagileappr roach,wepartnerwithourclientbasecom mprisinglarges scaleISVsandt technologyinn novatorstodeliver cuttingedge esoftwareprod ducts.Ourexpertisespansth hedomainsofBigData,SaaS,CloudCompu uting,Mobility Solutions,Te estEngineering g,Performance eEngineering,andSocialMediaamongoth hers. ImpetusTechnologies,Inc. vard,Suite450 0,SanJose,CA95129,USA 5300StevensCreekBoulev @impetus.com Tel:408.213.3310|Email:inquiry@ velopmentCentersINDIA:NewDelhiBangaloreIn ndoreHydera abad RegionalDev Toknowmo orevisit:http:/ //www.impetus.com
Di isclaimers
Theinformationcon ntainedinthisdocumentistheprop prietaryandexclus sivepropertyofIm mpetusTechnologi iesInc.exceptaso otherwiseindicate ed.Nopartof isdocument,inwh holeorinpart,ma aybereproduced, ,stored,transmitted,orusedforde esignpurposeswithoutthepriorwri ittenpermissiono ofImpetus thi 11 1 TechnologiesInc.