在python中使用运动学流 [英] Consuming a kinesis stream in python

查看:89
本文介绍了在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.

这篇关于在python中使用运动学流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆