the future of stream processing
TRANSCRIPT
#ctonight
The Future of Stream Processingアマゾンウェブサービスジャパン株式会社半場光晴
Stream processingしてますか?
Stream processingで何しましょう
ニアリアルタイムな何か(Near Realtime)
Stream processing でニアリアルタイムを体験してみましょう
デモClick stream
http://goo.gl/xxxxxx
http://goo.gl/xxxxxx
デモのアーキテクチャ
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
ここが Stream processingData Source > Collection > Process > Store
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon S3Static Website HostingHighly scalableDesigned for 99.99% availability
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon API GatewayFully managed serviceConfigured as an AWS proxy
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon Kinesis StreamsManages the infrastructure, storage, networking, and configuration needed to stream your data at the level of your data throughput.
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon Elastic MapReduceEnables you to instantly provisionas much or as little capacity as you like to perform.
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon DynamoDBFully managed NoSQL database serviceFast and predictable performancewith seamless scalability
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Amazon LambdaLets you run code without provisioning/managing serversTakes care of everything required to runand scale your code with high availability
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
http://spark.apache.org/docs/latest/streaming-programming-guide.html
例 Windowed computations今回のデモの場合、毎秒、クリック回数を算出して、直近 3 秒間の合計を、2 秒ずつスライドしながら計算し続ける
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
これで完成形でしょうか?
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
完成形に向かって、どこを目指すべきでしょうか?
これ系のスゴイ方々の言動から学ぶ
キーワード「 Reactive 」
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Reactive のマニフェスト
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Responsive可能な限り速やかに応答を返し続けるシステムに問題が発生しても、速やかに検知して効率的に対処する早く一定した応答時間を保ち、十分な上限を満たすことで、一定のサービス品質を維持する
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Resilient予期せぬ障害が発生してもResponsive を維持する
ReplicationIsolationDelegation ( 委譲 )
障害の影響範囲をコンポーネントの中に閉じる
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Elastic多様な負荷状況でもResponsive を維持する競合やボトルネックがない
Shard や Replication で負荷を散らすことができる
負荷状況に応じてスケールできる
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Message Driven非同期であるイベントキューではなくメッセージを受け渡すノンブロッキングであるバックプレッシャーの仕組みを持つ
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
Reactive のマニフェスト
Replication
Isolation
Delegation
Asynchronous
Back-pressure Non-blocking
Scalable
Failure-handling
http://www.reactive-streams.org/http://www.reactivemanifesto.org/
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
このアーキテクチャはReactive でしょうか?
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
最大のボトルネックはここ
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Click stream の急伸で、Kinesis への書き込みが失敗すると、
データが失われる
書き込みに失敗したら、別のコンポーネントに書き込みを委譲する
SQS に入れておき、 Lambda で定期的に捌く
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AWSLambda
AmazonS3
AmazonSQS
Amazon CloudWatch
AmazonSNS
AWSLambda
①
Scheduled event
AWSLambda
書き込みに失敗したら、別のコンポーネントに書き込みを委譲する
SQS に入れておき、 SNS からLambda を実行して、再帰的に捌く
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AWSLambda
AWSLambda
AmazonS3
AmazonSQS
Amazon CloudWatch
AmazonSNS
AWSLambda
AmazonSNS
②
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AWSLambda
AWSLambda
AmazonS3
AmazonSQS
Amazon CloudWatch
AmazonSNS
AWSLambda
AmazonSNS
負荷に連動して、適宜 Kinesisの Reshard も実施する
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
他は問題ないでしょうか?
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Spark で Back pressure が働いても、 Kinesis に一定期間保持でき
る また、負荷に連動して、適宜 EMR クラスターの Resize を実施する
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
EMR で適切に処理すれば、 Write の負荷を軽減できる
また、負荷に連動して、適宜 DynamoDB の Write スループットの変更を実施する
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
Lambda でキャッシュすれば、Read の負荷を軽減できる
また、負荷に連動して、適宜 DynamoDB の Read スループットの変更を実施する
おさらい
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AmazonS3
AWS サービスを活用しよう
Reactive
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AWSLambda
AWSLambda
AmazonS3
AmazonSQS
Amazon CloudWatch
AmazonSNS
AWSLambda
AmazonSNS
AmazonS3
Amazon API Gateway
Amazon API Gateway
Amazon Kinesis
Amazon EMR
AmazonDynamoDB
AWSLambda
AWSLambda
AWSLambda
AmazonS3
AmazonSQS
Amazon CloudWatch
AmazonSNS
AWSLambda
AmazonSNS
非同期ノンブロッキングバックプレッシャー
#ctonight