Need advice about which tool to choose?Ask the StackShare community!
NSQ vs ZeroMQ: What are the differences?
Introduction
NSQ and ZeroMQ are both messaging systems that provide reliable and high-performance communication between applications. However, there are several key differences between these two systems.
Messaging Model: NSQ follows a distributed publish-subscribe model, where messages are sent to a central broker and delivered to consumers based on subscription preferences. On the other hand, ZeroMQ follows a messaging patterns model, allowing various messaging patterns such as publish-subscribe, request-reply, and push-pull.
Protocol: NSQ uses a custom protocol over TCP as its default transport layer protocol. It also supports HTTP for certain operations. In contrast, ZeroMQ uses its own lightweight binary messaging protocol over various transport protocols such as TCP, PGM, IPC, and in-process.
Message Persistence: NSQ provides built-in message persistence by writing messages to disk, ensuring that messages are not lost even in the event of a system failure. ZeroMQ, on the other hand, does not provide built-in message persistence and relies on the application to handle message durability if needed.
Scalability: NSQ is designed with scalability in mind and supports horizontal scaling by allowing the addition of multiple brokers to handle increased message throughput. ZeroMQ is designed for local inter-process communication and may require additional efforts for scaling across multiple machines.
Language Support: NSQ offers client libraries that support multiple programming languages, including Go, Python, Java, and Ruby. ZeroMQ provides bindings for various programming languages, making it more versatile and accessible to developers.
Advanced Features: NSQ offers advanced features such as message filtering based on topic, channel-based message distribution, and distributed message rate limiting. ZeroMQ provides advanced features such as message queuing, load balancing, and support for various messaging patterns.
In summary, NSQ and ZeroMQ differ in their messaging models, protocols, message persistence capabilities, scalability options, language support, and advanced features. These differences make each system suitable for different use cases and requirements.
Hi, we are in a ZMQ set up in a push/pull pattern, and we currently start to have more traffic and cases that the service is unavailable or stuck. We want to: * Not loose messages in services outages * Safely restart service without losing messages (ZeroMQ seems to need to close the socket in the receiver before restart manually)
Do you have experience with this setup with ZeroMQ? Would you suggest RabbitMQ or Amazon SQS (we are in AWS setup) instead? Something else?
Thank you for your time
ZeroMQ is fast but you need to build build reliability yourself. There are a number of patterns described in the zeromq guide. I have used RabbitMQ before which gives lot of functionality out of the box, you can probably use the worker queues
example from the tutorial, it can also persists messages in the queue.
I haven't used Amazon SQS before. Another tool you could use is Kafka.
Both would do the trick, but there are some nuances. We work with both.
From the sound of it, your main focus is "not losing messages". In that case, I would go with RabbitMQ with a high availability policy (ha-mode=all) and a main/retry/error queue pattern.
Push messages to an exchange, which sends them to the main queue. If an error occurs, push the errored out message to the retry exchange, which forwards it to the retry queue. Give the retry queue a x-message-ttl and set the main exchange as a dead-letter-exchange. If your message has been retried several times, push it to the error exchange, where the message can remain until someone has time to look at it.
This is a very useful and resilient pattern that allows you to never lose messages. With the high availability policy, you make sure that if one of your rabbitmq nodes dies, another can take over and messages are already mirrored to it.
This is not really possible with SQS, because SQS is a lot more focused on throughput and scaling. Combined with SNS it can do interesting things like deduplication of messages and such. That said, one thing core to its design is that messages have a maximum retention time. The idea is that a message that has stayed in an SQS queue for a while serves no more purpose after a while, so it gets removed - so as to not block up any listener resources for a long time. You can also set up a DLQ here, but these similarly do not hold onto messages forever. Since you seem to depend on messages surviving at all cost, I would suggest that the scaling/throughput benefit of SQS does not outweigh the difference in approach to messages there.
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 ZeroMQ
- Fast23
- Lightweight20
- Transport agnostic11
- No broker required7
- Low level APIs are in C4
- Low latency4
- Open source1
- Publish-Subscribe1
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 ZeroMQ
- No message durability5
- Not a very reliable system - message delivery wise3
- M x N problem with M producers and N consumers1