I am building a data pipeline that reads the MySQL binlogs in realtime using Maxwell Daemon and Maxwell Daemon pushes the data to Redis streams. I've built a client that consumes the data from Redis streams processes it. Currently, I'm polling the XREAD using an infinite loop with a sleep time of few milliseconds to consume the data from the stream, but I find this to be an inefficient solution.
I was searching for a way where I can somehow subscribe to the Redis stream and get notified whenever new entries are added to the stream and came across this GitHub issue where they talk about using the Redis pub/sub along with streams to achieve this functionality.
Is there a more efficient way of architecting this system?
Yes, use the
BLOCK
argument ofXREAD
and you'll have same "efficiency".Documentation: https://redis.io/commands/xread and https://redis.io/topics/streams-intro#listening-for-new-items-with-xread