SQS, SWF, and SNS · SQS, SWF, and SNS Chapter 8 References • All informaon in this presentaon...

Post on 30-Jun-2020

3 views 0 download

transcript

7/24/17

1

SQS,SWF,andSNSChapter8

References•  Allinforma6oninthispresenta6onwasobtainedfromthefollowingsourceswithallcreditduetothelistedauthors:

J.Baron,H.Baz,T.Bixler,B.Gaut,K.E.Kelly,S.Senior,andJ.Stamper,AWSCer(fiedSolu(onsArchitectofficialstudyguide:Associateexam.UnitedStates:Sybex,aWileybrand,2017.

“AWSDocumentaHon,”AmazonWebServices,Inc.[Online].Available:hOps://aws.amazon.com/documentaHon/.[Accessed:15-Jul-2017].

AmazonSimpleQueueService(SQS)

•  AmazonSQSQueue-abufferbetweentheapplica6oncomponentsthatreceivedataandthosethatprocessdatawithinyoursystem.

•  Fullymanagedmessagequeuingservice.•  Fast,reliable,scalable,simple,andcosteffec6ve.•  Transmitsanyvolumeofdatawithoutlosingmessagesorrequiringotherservicestobecon6nuouslyavailable.

•  Ensuresmessagedeliveryatleastonceandsupportsmul1plereadersandwritersinterac6ngwiththesamequeue.

•  Serviceisreliableandefficientbutdoesnotguaranteefirstin,firstout(FIFO)delivery.

7/24/17

2

MessageLifecycle

DelayQueues&VisibilityTimeouts•  Delayqueuesallowyoutopostponedeliveryofqueuedmessages,whichcanbesetbetween0-900seconds(Upto15minutes).

•  QueuescanbesetbyusingCreateQueueandseUngtheDelaySecondsaVribute(Defaultedat0seconds).

•  VisibilityTimeoutsaresimilartodelayqueues,however,thedelayqueuehidesthemessagewhenitisaddedtothequeue,andvisibility6meoutshidethemessageaXeritispulledfromthequeue(Upto12hours).

•  Amessageisconsidered“inflight”ifneitheroftheaboveareapplied(120,000inflightmax).

QueueOperations,IDs,IdentiHiers,&Attributes

•  Opera6onsonlyavailabletoaccountowneroriden6tywithgrantedpermissions.

•  SQSassignsnewqueueswithaqueueURL.•  EachmessageisassignedauniqueID(100charmax),whichisreturnedwhenthemessageissent.

•  SQSalsosupportsmessageaVributes,whichallowyoutoaVachmetadatatoyourmessages(10aVributespermessage).Metadatacaninclude6mestamps,signatures,etc.

Opera6ons:•  ListQueues•  DeleteQueue•  SendMessage•  SendMessageBatch•  ReceiveMessage•  DeleteMessage•  DeleteMessageBatch•  PurgeQueue•  ChangeMessageVisibility•  ChangeMessageVisibilityBatch•  SetQueueAVributes•  GetQueueAVributes•  GetQueueUrl•  ListDeadLeVerSourceQueues•  AddPermission•  RemovePermission

7/24/17

3

LongPolling&DeadLetterQueues

•  LongpollingallowsyoutosendaWaitTimeSecondsargumenttoReceiveMessage(Upto20seconds).

•  Reducestheloadontheclientbyreturningamessageimmediatelyorwai6ngthespecified6methenreturningregardlessofmessage’sexistence.

•  DeadleDerqueuesarequeuesthatsourcequeuescantargettosendmessagesthatcouldnotbeprocessedsuccessfully.

•  Allowsyoutosidelineunsuccessfulmessagesforanalysis.

AmazonSimpleWorkHlowService(SWF)

•  AmazonSWFmakesiteasytobuildapplica6onsthatcoordinateandworkacrossdistributedcomponents.

• Workersperformtasks,whichcanrunonacloudinfrastructureoryourownpremises.

•  SWFstorestasks,assignsthemtoworkerswhentheyareready,monitortheirprogress,andmaintainstheirstate.

• WithSWFyoucanimplement,deploy,scale,andmodifytheseapplica6oncomponentsindependently.

WorkHlows,Domains,&History

• Workflowsareasynchronousapplica6onswithinSWFthatcoordinateandmanagetheexecu6onofac6vi6esthatcanberunacrossmul6plecompu6ngdevicesthatfeatureeithersequen6alofparallelprocessing.

• WorkflowdomainshelptoscopeSWFresourceswithinyourAWSaccount.Domainsmustbespecifiedforallthecomponentsofaworkflow.

•  Youcanhavemorethanoneworkflowinadomain,however,workflowsindifferentdomainscannotinteractwithoneanother.

•  Allworkflowshaveahistory,whichisadetailedcompleteandconsistentrecordofeveryeventthatoccurredsincetheexecu6onoftheworkflow.

7/24/17

4

Actors,Tasks,&TaskLists•  SWFconsistsofanumberofprogramma6cfeaturesknownasactors,whichcanbeworkflowstarters,ac6vitystarters,ordeciders.

•  Aworkflowstarterisanyapplica6onthatcanini6ateworkflowexecu6on.EX:Amobileapplica6onwhereacustomerordersfoodortaxiservice.

•  Thelogicthatcoordinatestasksinaworkflow,whichcanberunsequen6ally,inparallel,synchronously,orasynchronously,iscalledadecider.

•  Anac1vityworkerisasinglecomputerprocess(orthread)thatperformstasksinyourworkflow.

•  Tasksareworkassignmentsandcanbeac1vitytasks,AWSLambdatasks,ordecisiontasks

•  Anac6vitytasktellsaworkertoperformit’sfunc6on.AnAWSLambdataskexecutesAWSLambdafunc6onsinsteadofregulartasks.Adecisiontasktellsadeciderthestateoftheworkflowexecu6onhaschangedsothedecidercanevaluatethenextstepstobetaken.

•  Taskscanbeorganizedintotasklists,whichareflexiblemechanismstoroutetaskstoworkers.

MoreonWorkHlows•  Decidersandac6vityworkerscommunicatewithSWFusinglongpolling.•  SWFobjectsareuniquelyiden6fiedbyworkflowtype,ac6vitytype,decision/ac6vitytasks,andworkflowexecu6on.

•  Registeredworkflowandac6vitytypesareiden6fiedbytheirdomain,name,andversion,whichcanbespecifiedusingRegisterWorkflowTypeandRegisterAc1vityType,respeclully.

•  Asingleexecu6onofisiden6fiedbythedomain,workflowID,andrunID.•  AworkflowisopenaXeritisstarted.Anopenworkflowcanbeclosedascompleted,cancelled,failed,or6medout.

LifecycleofaWorkHlowExecution

•  Thereare20stepstoaworkflowexecu6on.

7/24/17

5

AmazonSimpleNotiHicationService(SNS)

•  AmazonSNSisawebserviceformobileandenterprisemessagingthatenablesyoutosetup,operate,andsendno6fica6ons.

•  Followsapublish-subscribe(pub-sub)messagingparadigm.•  No6fica6onsaredeliveredtoclientsusingapushmechanism,whicheliminatestheneedtopollfornewinforma6onandupdates.

•  Cansendno6fica6onstoApple,Android,FireOS,&Windowsdevices.•  Twotypesofclients,publishersandsubscribers(producersandconsumers).Publisherscommunicatetosubscribersasynchronouslybysendingamessagetoatopic.

•  Messagessenttotopicsareautoma6callyforwardedtoeachsubscriber.•  MessagescanbesentusingdifferentmethodssuchasAmazonSQS,HTTP,HTTPS,email,SMS,andAWSLambda.

CommonSNSScenarios•  FanoutscenarioshappenwhenanAmazonSNSmessageissentandreplicatedandpushedtomul6pleSQSqueues,HTTPendpoints,oremailaddresses,whichallowsforparallelasynchronousprocessing.

•  Applica1on/SystemalertsareSMSoremailno6fica6onsthataretriggeredbypredefinedthresholds.Youcanreceiveno6fica6onsifeventshappenwithinanAWSservice.

•  PushEmail&TextMessagingcanhelptransmitindividualorgroupmessagesviaemailorSMS.Usefulforpushingrelevanttopicstosubscribers.

•  MobilePushNo1fica1onsallowyoutosendmessagesdirectlytomobileapplica6ons.Usefulforupda6ng.

Recap•  AmazonSQSisauniqueservicedesignedtohelpyoudecoupleyourinfrastructure.

•  SQSallowsyoutostoremessagesonareliableandscalableinfrastructureastheytravelbetweendistributedcomponentsofyourapplica6onsthatperformdifferenttasks.

•  AmazonSWFallowsyoutocreateapplica6onsthatcoordinateworkacrossdistributedcomponents.

•  SWFisdrivenbytasks,whichcanbemanaged,keepinginmind,inter-taskdependencies,scheduling,andconcurrence.

•  Workflowsallowyoutohavefullcontroloverimplemen6ngtaskswithoutworryingaboutunderlyingcomplexi6es.

•  AmazonSNSallowsyoutopushindividualormul6plemessagestoalargenumberofrecipients.

•  SNSsupportsawidevarietyofneeds,includingmonitoringapplica6ons,workflowsystems,6me-sensi6veupdates,andanyotherapplica6onthatgenerateorconsumesno6fica6ons.