Kafka - Spark 直接流故障转移

Kafka - Spark direct stream fail over

我们有一个简单的 spark 流应用程序,通过 spark 从 kafka 流式传输事件并将其保存到 redis 中。

最初我们在 spark streaming 中使用 Receiver-based Approach, which replicates the batches into HDFS and starts processing afterwards. This approach wasn't as stable as we whished (lot of traffic on our hadoop machines) so we switched to the Direct Approach (No Receivers)

让我感到困惑的是文档中提到的 auto.offset.reset 参数。当作业失败或 sparkmaster 宕机时,我们会看到流作业通过处理大量事件来赶上来,然后稳定超时。

通过第二种方法,我们不再看到这种行为,我们不确定 spark-streaming 是否真的赶上来了,或者只是从 auto.offset.reset latest.

latest 是故障转移的合理默认值吗?流式传输作业是否真的在 restart/master-failure 上正确赶上?

谢谢, 向

What to do when there is no initial offset in Zookeeper or if an offset is out of range:

  • smallest : automatically reset the offset to the smallest offset
  • largest : automatically reset the offset to the largest offset
  • anything else: throw exception to the consumer. If this is set to largest, the consumer may lose some messages when the number of partitions, for the topics it subscribes to, changes on the broker. To prevent data loss during partition addition, set auto.offset.reset to smallest

此选项仅在您 运行 第一次工作时出现 或者当某些消息过期并且您的消费者中最后提交的偏移量不再存在时。

如果您不想丢失数据,那么最好选择最小的。如果您在数据到期时间内重新启动作业,此选项不会影响您的 failover/restart