在python中使用运动学流

问题描述:

我似乎找不到合适的示例来说明如何通过Python使用AWS Kinesis流.有人可以给我提供一些我可以研究的例子吗?

I cant seem to find a decent example that shows how can I consume an AWS Kinesis stream via Python. Can someone please provide me with some examples I could look into?

最佳

虽然已经回答了这个问题,但对于以后的读者来说,考虑使用 Kinesis Client Library(KCL)for Python ,而不是直接使用 boto .当您有多个使用者实例时和/或更改分片配置时,它可以简化流中的使用者操作.

While this question has already been answered, it might be a good idea for future readers to consider using the Kinesis Client Library (KCL) for Python instead of using boto directly. It simplifies consuming from the stream when you have multiple consumer instances, and/or changing shard configurations.

https://aws.amazon.com/blogs/aws/speak-to-kinesis-in-python/

更多完整枚举KCL提供的内容

  • 连接到流
  • 枚举分片
  • 与其他工作人员(如果有)协调分片关联
  • 为它管理的每个分片实例化一个记录处理器
  • 从流中提取数据记录
  • 将记录推送到相应的记录处理器
  • 检查点处理的记录 (它使用DynamoDB,因此您的代码不必手动保留检查点值)
  • 当工作人员实例计数发生变化时,使shard-worker关联保持平衡
  • 在拆分或合并碎片时平衡shard-worker关联

我认为粗体字是KCL真正为boto提供不小的价值的地方.但是根据您的用例,boto可能要简单得多.

The items in bold are the ones that I think are where the KCL really provides non-trivial value over boto. But depending on your usecase boto may be much much much simpler.