前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >storm学习新手遇到问题--ack确认

storm学习新手遇到问题--ack确认

作者头像
程序员小王
发布2018-04-13 10:05:08
6770
发布2018-04-13 10:05:08
举报
文章被收录于专栏:架构说架构说

今天是2017年的第48周 今天是2017年的第331天

问题描述:

strom系统重启之后依然从kafka历史数据读取记录

问题分类: KafkaSpout重复消费问题

解决步骤:

1 检查代码没有发现问题

Strom从Kafka中读取数据

涉及代码:

public class SpoutConfig extends KafkaConfig implements Serializable

public class KafkaSpout extends BaseRichSpout

How KafkaSpout stores offsets of a Kafka topic and recovers in case of failures

As shown in the above KafkaConfig properties, you can control from where in the Kafka topic the spout begins to read by setting KafkaConfig.startOffsetTime as follows:

1. kafka.api.OffsetRequest.EarliestTime(): read from the beginning of the topic (i.e. from the oldest messages onwards)

2. kafka.api.OffsetRequest.LatestTime(): read from the end of the topic (i.e. any new messsages that are being written to the topic)

3. A Unix timestamp aka seconds since the epoch (e.g. via System.currentTimeMillis()): see How do I accurately get offsets of messages for a certain timestamp using OffsetRequest? in the Kafka FAQ

用法:

// 偏移量越界处理

spoutConf.ignoreZkOffsets = false; // false

spoutConf.useStartOffsetTimeIfOffsetOutOfRange = true;

spoutConf.startOffsetTime = kafka.api.OffsetRequest.LatestTime();

2

反复观察 offset 半个小时内没有被修改

最终判断是tuple树跟踪影响了ack性能

代码调整如下:

conf.setNumAckers(0);//tuple树不会被跟踪

strom流程知识回顾:

具体流程图如下:

ACK 解决分布式数据数据保证不会被重复处理或者遗漏处理

缺点:ack 存储这些数据用的LinkedList 顺序遍历还是消耗性能的

ack异步确认方式

这次写的比较混乱 后续计划

参考

  1. https://github.com/apache/storm/tree/master/external/storm-kafka
  2. http://blog.jassassin.com/2014/10/22/storm/storm-ack/#如果有多个spout-task的时候-storm在最终ack-spout-tuple的时候-如何知道对应于哪个spout-task-因为必须在产生tuple的那个spout-task进行ack
  3. http://storm.apache.org/releases/1.1.1/Guaranteeing-message-processing.html
  4. http://www.cnblogs.com/intsmaze/p/5918087.html
  5. http://blog.csdn.net/sheen1991/article/details/52788547
  6. https://www.confluent.io/blog/data-reprocessing-with-kafka-streams-resetting-a-streams-application/
  7. http://jstorm.io/ProgrammingGuide_cn/AdvancedUsage/Theory/Acker.html
  8. http://blog.csdn.net/weiyongle1996/article/details/77206684
  9. http://storm.apache.org/releases/current/FAQ.html
  10. https://zhuanlan.zhihu.com/p/23863915 高性能队列——Disruptor
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-11-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Offer多多 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 2
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档