Top Related Projects
Mirror of Apache Kafka
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Apache Pulsar - distributed pub-sub messaging system
Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
High-Performance server for NATS.io, the cloud and edge native messaging system.
Confluent's Apache Kafka Golang client
Quick Overview
NSQ is a realtime distributed messaging platform designed to operate at scale, providing high availability and fault tolerance. It facilitates the building of large-scale, distributed consumer applications and is used for various purposes such as data pipelines and task distribution systems.
Pros
- Highly scalable and fault-tolerant architecture
- Low-latency push-based message delivery
- Simple and easy-to-use TCP protocol
- Supports both pub-sub and distributed queue patterns
Cons
- Limited built-in security features
- Lacks some advanced messaging features found in other platforms
- Requires additional components for complete deployment (e.g., nsqlookupd)
- Learning curve for optimal configuration and tuning
Code Examples
- Publishing a message:
producer, err := nsq.NewProducer("localhost:4150", nsq.NewConfig())
if err != nil {
log.Fatal(err)
}
defer producer.Stop()
err = producer.Publish("topic_name", []byte("Hello NSQ!"))
if err != nil {
log.Fatal(err)
}
- Consuming messages:
consumer, err := nsq.NewConsumer("topic_name", "channel_name", nsq.NewConfig())
if err != nil {
log.Fatal(err)
}
consumer.AddHandler(nsq.HandlerFunc(func(message *nsq.Message) error {
fmt.Printf("Received message: %s\n", string(message.Body))
return nil
}))
err = consumer.ConnectToNSQD("localhost:4150")
if err != nil {
log.Fatal(err)
}
// Wait for messages
<-consumer.StopChan
- Using nsqlookupd for discovery:
consumer, err := nsq.NewConsumer("topic_name", "channel_name", nsq.NewConfig())
if err != nil {
log.Fatal(err)
}
err = consumer.ConnectToNSQLookupd("localhost:4161")
if err != nil {
log.Fatal(err)
}
// Wait for messages
<-consumer.StopChan
Getting Started
-
Install NSQ:
brew install nsq # macOS # or download from https://nsq.io/deployment/installing.html
-
Start nsqd:
nsqd
-
Publish a message:
curl -d 'Hello World!' 'http://127.0.0.1:4151/pub?topic=test'
-
Consume messages:
nsq_tail --topic=test --channel=test
For more advanced usage, refer to the NSQ documentation and the code examples provided above.
Competitor Comparisons
Mirror of Apache Kafka
Pros of Kafka
- Higher throughput and scalability for large-scale data streaming
- Strong data replication and fault-tolerance features
- Rich ecosystem with many integrations and tools
Cons of Kafka
- More complex setup and configuration
- Higher resource requirements and operational overhead
- Steeper learning curve for developers and operators
Code Comparison
Kafka producer example:
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
Producer<String, String> producer = new KafkaProducer<>(props);
NSQ producer example:
config := nsq.NewConfig()
producer, err := nsq.NewProducer("localhost:4150", config)
if err != nil {
log.Fatal(err)
}
Both Kafka and NSQ are distributed messaging systems, but they have different design philosophies and use cases. Kafka is better suited for high-volume, large-scale data streaming applications, while NSQ is designed for simplicity and ease of use in distributed systems. Kafka offers stronger guarantees for data consistency and replication, but comes with increased complexity. NSQ, on the other hand, provides a more straightforward setup and operation, making it a good choice for smaller-scale applications or those prioritizing simplicity.
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Pros of RabbitMQ
- More feature-rich with advanced routing capabilities and exchange types
- Supports multiple protocols (AMQP, MQTT, STOMP)
- Offers a management UI for easier monitoring and administration
Cons of RabbitMQ
- More complex to set up and configure compared to NSQ
- Higher resource consumption, especially for large-scale deployments
- Steeper learning curve due to its extensive feature set
Code Comparison
RabbitMQ (Erlang):
basic_publish(Channel, <<"my_exchange">>, <<"routing_key">>, <<"Hello, World!">>),
{#'basic.consume_ok'{}, Tag} = basic_consume(Channel, <<"my_queue">>, no_ack),
receive
{#'basic.deliver'{}, #amqp_msg{payload = Body}} ->
io:format("Received: ~p~n", [Body])
end,
NSQ (Go):
producer, _ := nsq.NewProducer("localhost:4150", nsq.NewConfig())
producer.Publish("topic", []byte("Hello, World!"))
consumer, _ := nsq.NewConsumer("topic", "channel", nsq.NewConfig())
consumer.AddHandler(nsq.HandlerFunc(func(message *nsq.Message) error {
fmt.Printf("Received: %s\n", string(message.Body))
return nil
}))
The code examples show basic publishing and consuming operations for both message brokers. RabbitMQ uses Erlang and offers more granular control over exchanges and routing, while NSQ uses Go and provides a simpler API for publishing and consuming messages.
Apache Pulsar - distributed pub-sub messaging system
Pros of Pulsar
- Supports multiple messaging models (pub-sub, queuing, streaming)
- Offers multi-tenancy and geo-replication features
- Provides strong durability guarantees with tiered storage
Cons of Pulsar
- More complex setup and configuration compared to NSQ
- Higher resource requirements for deployment
- Steeper learning curve for developers and operators
Code Comparison
NSQ:
producer, _ := nsq.NewProducer("localhost:4150", nsq.NewConfig())
producer.Publish("topic", []byte("message"))
Pulsar:
PulsarClient client = PulsarClient.builder().serviceUrl("pulsar://localhost:6650").build();
Producer<byte[]> producer = client.newProducer().topic("topic").create();
producer.send("message".getBytes());
Both NSQ and Pulsar are distributed messaging systems, but they cater to different use cases and scales. NSQ is designed for simplicity and ease of use, making it ideal for smaller to medium-sized deployments. Pulsar, on the other hand, offers a more comprehensive feature set suitable for large-scale, enterprise-grade messaging needs. While NSQ focuses on a single messaging model, Pulsar provides flexibility with multiple models. The code examples demonstrate that NSQ has a slightly simpler API, while Pulsar offers more configuration options out of the box.
Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
Pros of RocketMQ
- More feature-rich, supporting advanced messaging patterns like transactional messages and scheduled messages
- Better scalability, capable of handling higher throughput and larger message sizes
- Stronger durability guarantees with support for persistent storage and replication
Cons of RocketMQ
- More complex to set up and operate compared to NSQ's simplicity
- Heavier resource consumption, requiring more memory and CPU
- Steeper learning curve due to its extensive feature set
Code Comparison
NSQ (Go):
producer, _ := nsq.NewProducer("localhost:4150", nsq.NewConfig())
producer.Publish("topic", []byte("message"))
RocketMQ (Java):
DefaultMQProducer producer = new DefaultMQProducer("ProducerGroup");
producer.setNamesrvAddr("localhost:9876");
producer.start();
producer.send(new Message("topic", "message".getBytes()));
Both examples show basic message publishing, but RocketMQ's code is more verbose and requires more setup. NSQ's simplicity is evident in its concise API, while RocketMQ offers more configuration options at the cost of increased complexity.
High-Performance server for NATS.io, the cloud and edge native messaging system.
Pros of NATS Server
- Higher performance and lower latency, especially for large-scale deployments
- More flexible messaging patterns, including request-reply and pub-sub
- Better support for clustering and high availability
Cons of NATS Server
- Less built-in persistence options compared to NSQ
- Steeper learning curve for advanced features and configurations
- Fewer language-specific client libraries available
Code Comparison
NATS Server (Go):
nc, err := nats.Connect(nats.DefaultURL)
if err != nil {
log.Fatal(err)
}
defer nc.Close()
NSQ (Go):
config := nsq.NewConfig()
producer, err := nsq.NewProducer("localhost:4150", config)
if err != nil {
log.Fatal(err)
}
defer producer.Stop()
Both NATS Server and NSQ are popular messaging systems, but they have different strengths and use cases. NATS Server excels in high-performance, low-latency scenarios and offers more flexible messaging patterns. It's particularly well-suited for microservices architectures and real-time applications. NSQ, on the other hand, provides simpler setup and usage, with better built-in persistence options. It's a good choice for projects that prioritize ease of use and don't require advanced messaging patterns. The code examples demonstrate the slightly different approaches to connecting and setting up producers in each system.
Confluent's Apache Kafka Golang client
Pros of confluent-kafka-go
- Robust Kafka ecosystem support with advanced features
- High-performance C library (librdkafka) underneath
- Extensive documentation and enterprise-level support
Cons of confluent-kafka-go
- More complex setup and configuration
- Steeper learning curve for beginners
- Heavier resource footprint
Code Comparison
NSQ example:
producer, _ := nsq.NewProducer("localhost:4150", nsq.NewConfig())
producer.Publish("topic", []byte("message"))
confluent-kafka-go example:
p, _ := kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": "localhost:9092"})
p.Produce(&kafka.Message{TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny}, Value: []byte("message")}, nil)
Summary
NSQ is simpler and easier to set up, making it ideal for smaller projects or those new to message queues. It's lightweight and focuses on distributed messaging.
confluent-kafka-go, on the other hand, offers a more comprehensive Kafka experience with advanced features and scalability. It's better suited for large-scale, enterprise-level applications that require complex event streaming capabilities.
The choice between the two depends on the specific needs of your project, such as scalability requirements, existing infrastructure, and the level of complexity you're willing to manage.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
- Source: https://github.com/nsqio/nsq
- Issues: https://github.com/nsqio/nsq/issues
- Mailing List: nsq-users@googlegroups.com
- IRC: #nsq on freenode
- Docs: https://nsq.io
- Twitter: @nsqio
NSQ is a realtime distributed messaging platform designed to operate at scale, handling billions of messages per day.
It promotes distributed and decentralized topologies without single points of failure, enabling fault tolerance and high availability coupled with a reliable message delivery guarantee. See features & guarantees.
Operationally, NSQ is easy to configure and deploy (all parameters are specified on the command line and compiled binaries have no runtime dependencies). For maximum flexibility, it is agnostic to data format (messages can be JSON, MsgPack, Protocol Buffers, or anything else). Official Go and Python libraries are available out of the box (as well as many other client libraries), and if you're interested in building your own, there's a protocol spec.
We publish binary releases for Linux, Darwin, FreeBSD and Windows, as well as an official Docker image.
NOTE: master is our development branch and may not be stable at all times.
In Production
Code of Conduct
Help us keep NSQ open and inclusive. Please read and follow our Code of Conduct.
Authors
NSQ was designed and developed by Matt Reiferson (@imsnakes) and Jehiah Czebotar (@jehiah) but wouldn't have been possible without the support of Bitly, maintainers (Pierce Lopez), and all our contributors.
Logo created by Wolasi Konu (@kisalow).
Top Related Projects
Mirror of Apache Kafka
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Apache Pulsar - distributed pub-sub messaging system
Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
High-Performance server for NATS.io, the cloud and edge native messaging system.
Confluent's Apache Kafka Golang client
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot