风暴redis spout元组无一例外地丢失
storm redis spout tuples lost with no exception
我已经设置了 storm 拓扑(1 名工作人员),其中 spout(在 java 中)从 redis 中出列(使用 blpop)事件并传输到螺栓。但是一个观察结果是,当队列超过 200 万并且在风暴 nimbus/supervisor/zookeeper/worker 日志中没有发现 warning/exceptions 时,一些事件没有被接收到螺栓(在 clojure 中,6-spout 线程,50-bolt 线程)。
在本地,此场景未使用虚拟数据进行复制。集群中没有网络 lag/packet 丢失。平均处理延迟为 100 毫秒。
如何找到在生产中修复它的原因。
(ns event-processor
(:import [backtype.storm StormSubmitter LocalCluster]
java.util.UUID
storm_jedis.RedisQueueSpout
)
(:use [backtype.storm clojure config])
(:require [clojure.tools.logging :as log])
(:require [clj-redis.client :as redis])
(:import (redis.clients.jedis Jedis JedisPool JedisPoolConfig))
(:gen-class))
(defmacro process-event [tuple]
(log/info "processing event")
)
(defbolt execute-ls-closure ["word"] {:prepare true}
[conf context collector]
(let [counts (atom {})]
(bolt
(execute [tuple]
(let [
timestart (. System currentTimeMillis)
tuple-message (.get (get tuple "message") 0)
string-to-emit (process-event tuple)
]
(emit-bolt! collector [string-to-emit] :anchor tuple)
(ack! collector tuple)
)))))
(defn mk-topology []
(topology
;{"1" (spout-spec sentence-spout)
{"1" (spout-spec redis-spout :p 6)
}
{"3" (bolt-spec {"1" :shuffle }
execute-ls-closure
:p 50)
}))
(defn run-local! []
(let [cluster (LocalCluster.)]
(.submitTopology cluster "word-count" {TOPOLOGY-DEBUG true} (mk-topology))
(Thread/sleep 10000)
(.shutdown cluster)
))
(defn submit-topology! [name]
(StormSubmitter/submitTopology
name
{TOPOLOGY-DEBUG true
TOPOLOGY-WORKERS 1}
(mk-topology)))
(defn -main
([]
(run-local!))
([name]
(submit-topology! name)))
如果它不会使您的拓扑变慢太多,您可以使用 Config.setDebug(true)
https://github.com/apache/storm/blob/f2ced23fa4e3f699558663baef4ee582ee148fa2/storm-client/src/jvm/org/apache/storm/Config.java#L1763.
启用调试日志记录
否则,我会尝试向您的螺栓添加一些调试日志记录,并为您的 Redis spout 启用日志记录,以确定元组是否被 Storm 或 Redis 集成丢失。
我还注意到您使用的是旧版 Storm。你可以尝试升级。
我已经设置了 storm 拓扑(1 名工作人员),其中 spout(在 java 中)从 redis 中出列(使用 blpop)事件并传输到螺栓。但是一个观察结果是,当队列超过 200 万并且在风暴 nimbus/supervisor/zookeeper/worker 日志中没有发现 warning/exceptions 时,一些事件没有被接收到螺栓(在 clojure 中,6-spout 线程,50-bolt 线程)。
在本地,此场景未使用虚拟数据进行复制。集群中没有网络 lag/packet 丢失。平均处理延迟为 100 毫秒。 如何找到在生产中修复它的原因。
(ns event-processor
(:import [backtype.storm StormSubmitter LocalCluster]
java.util.UUID
storm_jedis.RedisQueueSpout
)
(:use [backtype.storm clojure config])
(:require [clojure.tools.logging :as log])
(:require [clj-redis.client :as redis])
(:import (redis.clients.jedis Jedis JedisPool JedisPoolConfig))
(:gen-class))
(defmacro process-event [tuple]
(log/info "processing event")
)
(defbolt execute-ls-closure ["word"] {:prepare true}
[conf context collector]
(let [counts (atom {})]
(bolt
(execute [tuple]
(let [
timestart (. System currentTimeMillis)
tuple-message (.get (get tuple "message") 0)
string-to-emit (process-event tuple)
]
(emit-bolt! collector [string-to-emit] :anchor tuple)
(ack! collector tuple)
)))))
(defn mk-topology []
(topology
;{"1" (spout-spec sentence-spout)
{"1" (spout-spec redis-spout :p 6)
}
{"3" (bolt-spec {"1" :shuffle }
execute-ls-closure
:p 50)
}))
(defn run-local! []
(let [cluster (LocalCluster.)]
(.submitTopology cluster "word-count" {TOPOLOGY-DEBUG true} (mk-topology))
(Thread/sleep 10000)
(.shutdown cluster)
))
(defn submit-topology! [name]
(StormSubmitter/submitTopology
name
{TOPOLOGY-DEBUG true
TOPOLOGY-WORKERS 1}
(mk-topology)))
(defn -main
([]
(run-local!))
([name]
(submit-topology! name)))
如果它不会使您的拓扑变慢太多,您可以使用 Config.setDebug(true)
https://github.com/apache/storm/blob/f2ced23fa4e3f699558663baef4ee582ee148fa2/storm-client/src/jvm/org/apache/storm/Config.java#L1763.
否则,我会尝试向您的螺栓添加一些调试日志记录,并为您的 Redis spout 启用日志记录,以确定元组是否被 Storm 或 Redis 集成丢失。
我还注意到您使用的是旧版 Storm。你可以尝试升级。