Need advice about which tool to choose?Ask the StackShare community!
NSQ vs Redis: What are the differences?
Introduction:
NSQ and Redis are both popular tools used for message queuing and storage in distributed systems. While they serve similar purposes, there are significant differences between the two that can impact the design and performance of your system.
Data Persistence: NSQ does not provide built-in data persistence, which means messages are not stored on disk by default. On the other hand, Redis is an in-memory data structure store that can persist data to disk.
Message Ordering: NSQ does not guarantee message ordering, so messages can be processed in a different order than they were received. In contrast, Redis provides options for ordered data structures, allowing you to maintain message ordering if necessary.
Scaling: NSQ is designed for horizontal scaling by running multiple instances and distributing load, making it suitable for high throughput scenarios. While Redis also supports clustering for scaling, it relies on a single-threaded model which may become a bottleneck for some use cases.
Message Retention: NSQ allows you to configure message retention duration, after which messages will be automatically removed from the system. Redis, being a persistent data store, retains messages until explicitly deleted or expired based on set time-to-live (TTL).
Protocols: NSQ uses a custom binary protocol for communication between producers and consumers, providing optimized performance for message passing. Redis, on the other hand, supports various protocols like Redis protocol, Memcached protocol, etc., making it more versatile but potentially less efficient for specific use cases.
Use Cases: NSQ is well-suited for scenarios requiring high message throughput, fault tolerance, and easy horizontal scalability. Redis, with its rich set of data structures and features like transactions, pub/sub, and Lua scripting, is often favored for use cases where complex data manipulation and querying are required alongside message queuing functionality.
In Summary, NSQ and Redis differ in data persistence, message ordering, scalability, message retention, protocols, and ideal use cases.
I am looking into IoT World Solution where we have MQTT Broker. This MQTT Broker Sits in one of the Data Center. We are doing a lot of Alert and Alarm related processing on that Data, Currently, we are looking into Solution which can do distributed persistence of log/alert primarily on remote Disk.
Our primary need is to use lightweight where operational complexity and maintenance costs can be significantly reduced. We want to do it on-premise so we are not considering cloud solutions.
We looked into the following alternatives:
Apache Kafka - Great choice but operation and maintenance wise very complex. Rabbit MQ - High availability is the issue, Apache Pulsar - Operational Complexity. NATS - Absence of persistence. Akka Streams - Big learning curve and operational streams.
So we are looking into a lightweight library that can do distributed persistence preferably with publisher and subscriber model. Preferable on JVM stack.
Kafka is best fit here. Below are the advantages with Kafka ACLs (Security), Schema (protobuf), Scale, Consumer driven and No single point of failure.
Operational complexity is manageable with open source monitoring tools.
Pros of NSQ
- It's in golang29
- Distributed20
- Lightweight20
- Easy setup18
- High throughput17
- Publish-Subscribe11
- Scalable8
- Save data if no subscribers are found8
- Open source6
- Temporarily kept on disk5
- Simple-to use2
- Free1
- Topics and channels concept1
- Load balanced1
- Primarily in-memory1
Pros of Redis
- Performance886
- Super fast542
- Ease of use513
- In-memory cache444
- Advanced key-value cache324
- Open source194
- Easy to deploy182
- Stable164
- Free155
- Fast121
- High-Performance42
- High Availability40
- Data Structures35
- Very Scalable32
- Replication24
- Great community22
- Pub/Sub22
- "NoSQL" key-value data store19
- Hashes16
- Sets13
- Sorted Sets11
- NoSQL10
- Lists10
- Async replication9
- BSD licensed9
- Bitmaps8
- Integrates super easy with Sidekiq for Rails background8
- Keys with a limited time-to-live7
- Open Source7
- Lua scripting6
- Strings6
- Awesomeness for Free5
- Hyperloglogs5
- Transactions4
- Outstanding performance4
- Runs server side LUA4
- LRU eviction of keys4
- Feature Rich4
- Written in ANSI C4
- Networked4
- Data structure server3
- Performance & ease of use3
- Dont save data if no subscribers are found2
- Automatic failover2
- Easy to use2
- Temporarily kept on disk2
- Scalable2
- Existing Laravel Integration2
- Channels concept2
- Object [key/value] size each 500 MB2
- Simple2
Sign up to add or upvote prosMake informed product decisions
Cons of NSQ
- Long term persistence1
- Get NSQ behavior out of Kafka but not inverse1
- HA1
Cons of Redis
- Cannot query objects directly15
- No secondary indexes for non-numeric data types3
- No WAL1