Windows Azure QueueDec.docx
- 文档编号:28204594
- 上传时间:2023-07-09
- 格式:DOCX
- 页数:19
- 大小:193.03KB
Windows Azure QueueDec.docx
《Windows Azure QueueDec.docx》由会员分享,可在线阅读,更多相关《Windows Azure QueueDec.docx(19页珍藏版)》请在冰豆网上搜索。
WindowsAzureQueueDec
WindowsAzureQueue
December,2008
TableofContents
1Introduction1
2BuildCloudApplicationswithAzureQueue2
3DataModel5
4QueueRESTInterface6
5QueueUsageExample7
5.1AProducer-ConsumerScenario7
5.2RESTRequestExamples8
5.2.1RESTPutMessage8
5.2.2RESTGetMessages9
5.2.3RESTDeleteMessage10
6BestPractices11
6.1RetryTimeoutsand“ConnectionclosedbyHost”errors11
6.2TuneApplicationforRepeatedTimeouterrors11
6.3ErrorHandlingandReporting11
6.4ChoosingtheInvisibilityTimeforGetMessage12
6.5DeletingaMessagefromtheQueue12
6.6AdjustingWorkerRolesBasedonQueueLength13
6.7UsingBinaryFormatforMessages13
1Introduction
WindowsAzureisthefoundationofMicrosoft’sCloudPlatform.Itisan“OperatingSystemfortheCloud”,whichprovidesessentialbuildingblocksforapplicationdeveloperstowritescalableandhighlyavailableservices.WindowsAzureprovides:
∙VirtualizedComputation
∙ScalableStorage
∙AutomatedManagement
∙RichDeveloperSDK
WindowsAzureStorageallowsapplicationdeveloperstostoretheirdatainthecloud,sotheapplicationcanaccessitsdatafromanywhereatanytime,storeanyamountofdataandforanylengthoftime,andbeconfidentthatthedataisdurableandwillnotbelost.WindowsAzureStorageprovidesarichsetofdataabstractions:
∙WindowsAzureBlob–providesstorageforlargedataitems.
∙WindowsAzureTable–providesstructuredstorageformaintainingservicestate.
∙WindowsAzureQueue–providesasynchronousworkdispatchtoenableservicecommunication.
ThisdocumentdescribesWindowsAzureQueue,andhowtouseit.WindowsAzureQueueprovidesareliablemessagedeliverymechanism.Itprovidesasimpleandasynchronousworkdispatchmechanism,whichcanbeusedtoconnectdifferentcomponentsofacloudapplication.TheWindowsAzureQueuesarehighlyavailable,durableandperformanceefficient.Itsprogrammingsemanticsensurethatamessagecanbeprocessedatleastonce.Furthermore,WindowsAzureQueuehasaRESTinterface,sothatapplicationscanbewritteninanylanguageandtheycanaccessthequeueatanytimefromanywhereintheInternetviatheweb.
2BuildCloudApplicationswithAzureQueue
WindowsAzureQueueallowsdecouplingofdifferentpartsofacloudapplication,enablingcloudapplicationstobeeasilybuiltwithdifferenttechnologiesandeasilyscalewithtrafficneeds.
Figure1BuildCloudApplicationswithAzureQueue
Thefigureaboveillustratesasimplebutcommonscenarioforcloudapplications.Thereareasetofwebservershostingthefrontendlogicofhandlingwebrequests.Thereareasetofbackendprocessingserversimplementingthebusinesslogicoftheapplication.Thewebserverfrontendnodescommunicatewiththebackendprocessingnodesviaasetofqueues.PersistentstateoftheapplicationcanbestoredinWindowsAzureBlobstorageandWindowsAzureTablestorage.
Consideranonlinevideohostingserviceapplicationasanexample.Userscanuploadvideostothisapplication;theapplicationcanthenautomaticallyconvertthevideofileintodifferentmediaformatsandstorethem;inaddition,theapplicationwillautomaticallyindexthedescriptioninformationofthevideosothattheycanbeeasilysearchedon(e.g.basedonkeywordsinthedescriptions,actors,directors,title,andsoon).
Suchanapplicationcanusethearchitecturedescribedearlier.Thewebfrontendsimplementthepresentationlayerandhandlewebrequestsfromusers.Usersmayuploadvideosviathewebfrontends.Thevideomediafilescanbestoredasblobsinsidetheblobstore.Theapplicationmayalsomaintainasetoftablestokeeptrackofthevideofilesithasaswellasmaintainingtheindexesusedforsearch.Thebackendprocessingserversareresponsibleforconvertingtheinputvideofilesintodifferentformatsandstorethemintotheblobstorage.Thebackendserversarealsoresponsibleforupdatingthetablesforthisapplicationinthetablestorage.Oncethefrontendserversreceiveauserrequest(e.g.avideouploadrequest),theycangenerateaworkitemandpushitintotherequestqueue.ThebackendserverscanthentaketheseworkitemsoffthequeueandprocessthemaccordinglyOnsuccessfulprocessingofeachworkitem,thebackendservershoulddeleteitfromthequeuesoastoavoidduplicateprocessingbyanotherbackendserver.
ThisarchitecturehasanumberofadvantagesduetotheuseofWindowsAzureQueue:
1.Scalability-Theapplicationcanmoreeasilyscaleaccordingtotrafficneeds.Thebenefitsareofseveral-folds:
Firstofall,thequeuelengthdirectlyreflectshowwellthebackendprocessingnodesarecatchingupwiththeoverallworkload.Agrowingqueuelengthindicatesthatthebackendserverscannotprocesstheworkfastenough.Inthiscase,theapplicationmaywanttoincreasethenumberofbackendnodessothattheworkcanbeconsumedmorequickly.Ifthequeuelengthalwaysstaysnearzero,thismeansthereismoreprocessingpoweratthebackendthanwhatthetrafficneeds.Inthiscase,theapplicationmayreducethenumberofbackendnodestosaveresources.Observingthequeuelengthandtuningthenumberofbackendnodesaccordingly,applicationscaneffectivelyscalesmoothlyaccordinglytotheamountoftraffic.
Second,theuseofqueuesdecouplesdifferentpartsoftheapplication,makingiteasiertoscaledifferentpartsoftheapplicationindependently.Inthisexample,thefrontendsandthebackendserversaredecoupled,andtheycommunicateviathequeues.Thisallowsthenumberofbackendserversandthenumberoffrontendserverstobeadjustedindependentlywithoutaffectingtheapplicationlogic.Thisallowsanapplicationtoeasilyscaleoutthecriticalcomponentsbyaddingmoreresources/machinestothem.
Third,theuseofqueuesallowstheflexibilityofefficientresourceusagewithinanapplication,allowingtheapplicationtoscalemoreefficiently.Thatis,separatequeuescanbeusedforworkitemsofdifferentprioritiesand/ordifferentweights,andseparatepoolsofbackendserverscanprocessthesedifferentqueues.Inthisway,theapplicationcanallocateappropriateresources(e.g.intermofthenumberofservers)ineachpool,therebyefficientlyusetheavailableresourcestomeetthetrafficneedsofdifferentcharacteristics.Forexample,workitemsthataremissioncriticalcanbeputintoaseparatequeue,sothattheycanbeprocessedearlierwithouthavingtowaitforotherworktocomplete.Inaddition,workitemsthatwillconsumealargeamountofresources(suchasvideoconversion)mayusetheirownqueue.Differentpoolsofbackendserverscanbeusedtoprocessworkitemsineachofthesequeues.Theapplicationcanadjustthesizeofeachofthesepoolsindependentlyaccordingtothetrafficitreceives.
2.DecouplingFront-EndRolesfromBack-EndRoles-Differentpartsoftheapplicationaredecoupledduetotheuseofqueues,whichallowssignificantflexibilityandextensibilityofhowtheapplicationcanbebuilt.Themessagesinthequeuecanbeinastandardandextensibleformat,suchasXML,sothatthecomponentscommunicatingatbothendsofthequeuedonothavedependencyoneachotheraslongastheycanunderstandthemessagesinthequeue.
Differenttechnologiesandprogramminglanguagecanbeusedtoimplementdifferentpartsofthesystemwithmaximumflexibility.Forexample,thecomponentononesideofthequeuecanbewrittenin.NETframework,andtheothercomponentcanbewritteninPython.
Furthermore,changeswithinacomponentaretransparenttotherestofthesystem.Forexample,acomponentcanbere-writtenusingatotallydifferenttechnologyorprogramminglanguage,andthesystemstillworksseamlesslywithoutchangingtheothercomponents,sincethecomponentsaredecoupledusingqueues.
Inaddition,thisalsoallowsyourapplicationtosmoothlytransitiontonewertechnologies,sincedifferentimplementationsofthesamecomponentcancoexistinsuchasystemduetotheuseofqueues.Intheexampleabove,onecangraduallyphaseoutthecomponentsbuiltwithlegacytechnologiesandreplacethemwithnewimplementations.Theoldimplementationandthenewimplementcanrunondifferentserversatthesametime,andprocessworkitemsoffthesamequeue.Allthesearetransparenttotheothercomponentsintheapplication.
3.TrafficBursts-Queuesprovidebufferingtoabsorbtrafficburstsandreducetheimpactofindividualcomponentfailures.Intheearlierexample,therecanbeoccasionswhereaburstofrequestsarriveinashortinterval.Thebackendserverscannotquicklyprocessalltherequests.Inthiscase,insteadofdroppingtherequests,therequestsarebufferedinthequeue,andthebackendserverscanprocessthoseattheirownpaceandeventuallycatchup.Thisallowstheapplicationtohandleburstytrafficwithoutlosingavailability.
Furthermore,useofqueuesalsomitigatetheimpactofindividualcomponentfailures.Intheearlierexample,ifafewbackendserverscrashed,insteadoflosingalltheworkitems,thequeuescanbufferalltheworkitemssentwhilethebackendserversaredown.Whenthebackendserverscomebackup,theycancontinueprocessingtheworkitemsoffthequeueandeventuallycatchuptoarrivalrateofthedataintothequeue,andthesefailuresaretransparenttotheothercomponents.RememberthattheworkitemsbeingprocessedbythebackendserverswhentheycrashedarealsonotlostastheyreappearinthequeueaftertheVisibilityTimeoutthusensuringthereisnodatalossduetocomponentfailures.Thisallowstheapplicationtotoleratefailureswithoutlosingav
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Windows Azure Queue Dec