您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 咨询培训 > strata_spark_streaming
SparkStreamingLarge-scalenear-real-timestreamprocessingTathagataDas(TD)UCBerkeleyUCBERKELEYWhatisSparkStreaming?Frameworkforlargescalestreamprocessing-Scalesto100sofnodes-Canachievesecondscalelatencies-IntegrateswithSpark’sbatchandinteractiveprocessing-Providesasimplebatch-likeAPIforimplementingcomplexalgorithm-CanabsorblivedatastreamsfromKafka,Flume,ZeroMQ,etc.MotivationManyimportantapplicationsmustprocesslargestreamsoflivedataandprovideresultsinnear-real-time-Socialnetworktrends-Websitestatistics-Intrustiondetectionsystems-etc.RequirelargeclusterstohandleworkloadsRequirelatenciesoffewsecondsNeedforaframework……forbuildingsuchcomplexstreamprocessingapplicationsButwhataretherequirementsfromsuchaframework?RequirementsScalabletolargeclustersSecond-scalelatenciesSimpleprogrammingmodelCasestudy:Conviva,Inc.Real-timemonitoringofonlinevideometadata-HBO,ESPN,ABC,SyFy,…TwoprocessingstacksCustom-builtdistributedstreamprocessingsystem•1000scomplexmetricsonmillionsofvideosessions•RequiresmanydozensofnodesforprocessingHadoopbackendforofflineanalysis•Generatingdailyandmonthlyreports•SimilarcomputationasthestreamingsystemCustom-builtdistributedstreamprocessingsystem•1000scomplexmetricsonmillionsofvideossessions•RequiresmanydozensofnodesforprocessingHadoopbackendforofflineanalysis•Generatingdailyandmonthlyreports•SimilarcomputationasthestreamingsystemCasestudy:XYZ,Inc.AnycompanywhowantstoprocesslivestreamingdatahasthisproblemTwicetheefforttoimplementanynewfunctionTwicethenumberofbugstosolveTwicetheheadacheTwoprocessingstacksRequirementsScalabletolargeclustersSecond-scalelatenciesSimpleprogrammingmodelIntegratedwithbatch&interactiveprocessingStatefulStreamProcessingTraditionalstreamingsystemshaveaevent-drivenrecord-at-a-timeprocessingmodel-Eachnodehasmutablestate-Foreachrecord,updatestate&sendnewrecordsStateislostifnodedies!Makingstatefulstreamprocessingbefault-tolerantischallengingmutablestatenode1node3inputrecordsnode2inputrecords9ExistingStreamingSystemsStorm-Replaysrecordifnotprocessedbyanode-Processeseachrecordatleastonce-Mayupdatemutablestatetwice!-Mutablestatecanbelostduetofailure!Trident–Usetransactionstoupdatestate-Processeseachrecordexactlyonce-Perstatetransactionupdatesslow10RequirementsScalabletolargeclustersSecond-scalelatenciesSimpleprogrammingmodelIntegratedwithbatch&interactiveprocessingEfficientfault-toleranceinstatefulcomputationsSparkStreaming12DiscretizedStreamProcessingRunastreamingcomputationasaseriesofverysmall,deterministicbatchjobs13SparkSparkStreamingbatchesofXsecondslivedatastreamprocessedresultsChopupthelivestreamintobatchesofXsecondsSparktreatseachbatchofdataasRDDsandprocessesthemusingRDDoperationsFinally,theprocessedresultsoftheRDDoperationsarereturnedinbatchesDiscretizedStreamProcessingRunastreamingcomputationasaseriesofverysmall,deterministicbatchjobs14SparkSparkStreamingbatchesofXsecondslivedatastreamprocessedresultsBatchsizesaslowas½second,latency~1secondPotentialforcombiningbatchprocessingandstreamingprocessinginthesamesystemExample1–GethashtagsfromTwittervaltweets=ssc.twitterStream(Twitterusername,Twitterpassword)DStream:asequenceofRDDrepresentingastreamofdatabatch@t+1batch@tbatch@t+2tweetsDStreamstoredinmemoryasanRDD(immutable,distributed)TwitterStreamingAPIExample1–GethashtagsfromTwittervaltweets=ssc.twitterStream(Twitterusername,Twitterpassword)valhashTags=tweets.flatMap(status=getTags(status))flatMapflatMapflatMap…transformation:modifydatainoneDstreamtocreateanotherDStreamnewDStreamnewRDDscreatedforeverybatchbatch@t+1batch@tbatch@t+2tweetsDStreamhashTagsDstream[#cat,#dog,…]Example1–GethashtagsfromTwittervaltweets=ssc.twitterStream(Twitterusername,Twitterpassword)valhashTags=tweets.flatMap(status=getTags(status))hashTags.saveAsHadoopFiles(hdfs://...)outputoperation:topushdatatoexternalstorageflatMapflatMapflatMapsavesavesavebatch@t+1batch@tbatch@t+2tweetsDStreamhashTagsDStreameverybatchsavedtoHDFSJavaExampleScalavaltweets=ssc.twitterStream(Twitterusername,Twitterpassword)valhashTags=tweets.flatMap(status=getTags(status))hashTags.saveAsHadoopFiles(hdfs://...)JavaJavaDStreamStatustweets=ssc.twitterStream(Twitterusername,Twitterpassword)JavaDstreamStringhashTags=tweets.flatMap(newFunction...{})hashTags.saveAsHadoopFiles(hdfs://...)FunctionobjecttodefinethetransformationFault-toleranceRDDsarerememberthesequenceofoperationsthatcreateditfromtheoriginalfault-tolerantinputdataBatchesofinputdataarereplicatedinmemoryofmultipleworkernodes,thereforefault-tolerantDatalostduetoworkerfailure,canberecomputedfrominputdatainputdatareplicatedinmemoryflatMaplostpartitionsrecomputedonotherworkerstweetsRDDhashTagsRDDKeyconceptsDStream–sequenceofRDDsrepresentingastreamofdata-Twitter,HDFS,Kafka,Flume,ZeroMQ,AkkaActor,TCPsocketsTransformations–modifydatafromonDStreamtoanother-StandardRDDoperations–map,countByValue,reduce,join,…-Statefuloperations–window,countByValueAndWindow,…OutputOperations–senddatatoexternalentity-saveAsHadoopFiles–savestoH
本文标题:strata_spark_streaming
链接地址:https://www.777doc.com/doc-5239148 .html