什么是流式处理,为什么重要?

使用 AWS Kinesis 与 Lambda 处理流数据

Maksim Pecherskiy

Data Engineer

批处理 vs 流处理

chapter1_take_ms_dahkX.png

使用 AWS Kinesis 与 Lambda 处理流数据

批处理 vs 流处理

批处理

  • "更好"
  • 更大的数据集
  • 更复杂的分析
  • 数据流动较慢
  • 例:每日销售报告
  • 例:下月销售预测
  • 例:流失预测

流处理

  • "更酷"
  • 更简单的分析:聚合/过滤
  • 单条记录/微批次
  • 数据移动很快
  • 例:欺诈检测
  • 例:风机监控
  • 例:实时告警
使用 AWS Kinesis 与 Lambda 处理流数据

Cody 与车队

Cody

Cody 在自行车旁

车队

车辆拼贴

使用 AWS Kinesis 与 Lambda 处理流数据

车联网流式传输

chapter1_take_ms_IfvAm.png

chapter1_take_ms_tNX4d.png

chapter1_take_ms_frlCB.png

使用 AWS Kinesis 与 Lambda 处理流数据

AWS Kinesis

使用 AWS Kinesis 与 Lambda 处理流数据

Data Firehose

chapter1_take_ms_UPYak.png

使用 AWS Kinesis 与 Lambda 处理流数据

传输流(Delivery streams)

chapter1_take_ms_MDHnC.png

使用 AWS Kinesis 与 Lambda 处理流数据

传输流(Delivery streams)

chapter1_take_ms_ytekB.png

使用 AWS Kinesis 与 Lambda 处理流数据

传输流(Delivery streams)

chapter1_take_ms_gx6D1.png

使用 AWS Kinesis 与 Lambda 处理流数据

创建 Firehose 客户端

import boto3

firehose = boto3.client('firehose',
aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET,
region_name='us-east-1')
使用 AWS Kinesis 与 Lambda 处理流数据

使用传输流

# Show created delivery streams
response = firehose.list_delivery_streams()

print(response['DeliveryStreamNames'])
['old-delivery-stream1', 'a-test-stream']
使用 AWS Kinesis 与 Lambda 处理流数据

删除流

# Show created delivery streams
response = firehose.list_delivery_streams()

# Delete them all! for stream_name in response['DeliveryStreamNames']:
firehose.delete_delivery_stream(DeliveryStreamName=stream_name)
使用 AWS Kinesis 与 Lambda 处理流数据

回顾

  • 批处理 vs 流处理
  • Cody 与车联网采集
  • AWS Kinesis
  • Kinesis Firehose 传输流
  • AWS Kinesis Data Firehose
  • 列出并删除 Firehose 传输流
  • 生产者 -> 数据生成器
  • 目标 -> 数据去向
使用 AWS Kinesis 与 Lambda 处理流数据

Vamos praticar!

使用 AWS Kinesis 与 Lambda 处理流数据

Preparing Video For Download...