Error on large number of subscriptions
See original GitHub issueI am trying to publish messages to 1 million subjects and subscribing to those subjects from another process. I get the following error:
NatsError: Subject must be supplied
at Client.publish (/root/node_modules/nats/lib/nats.js:1022:13)
at Message.ack (/root/node_modules/node-nats-streaming/lib/stan.js:804:24)
at Message.maybeAutoAck (/root/node_modules/node-nats-streaming/lib/stan.js:791:10)
at Object.callback (/root/node_modules/node-nats-streaming/lib/stan.js:690:11)
at Client.processMsg (/root/node_modules/nats/lib/nats.js:957:11)
at Client.processInbound (/root/node_modules/nats/lib/nats.js:885:14)
at Socket.<anonymous> (/root/node_modules/nats/lib/nats.js:468:12)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
Publisher code:
var stan = require('node-nats-streaming').connect('test-cluster', 'test',{maxPubAcksInflight: 1100000});
let total = 1000000;
stan.on('connect', function () {
for(let i=0;i<total;i++)
{
stan.publish('foo'+i, 'Hello node-nats-streaming:' + i);
if(i%1000 == 0)
console.log(i);
}
});
Subscriber code:
var stan = require('node-nats-streaming').connect('test-cluster', 'test3');
let total = 1000000;
let a = [];
let j = 0;
stan.on('connect', function () {
for(let i=0;i<total;i++)
{
var opts = stan.subscriptionOptions();
opts.setDeliverAllAvailable();
opts.setMaxInFlight(1000000);
opts.setDurableName('my-durable' + i);
a.push(stan.subscribe('foo'+i, opts));
// a[i].on('ready',function() {
a[i].on('error', function (err) {
console.log('subscription for ' + this.subject + " raised an error: " + err + '\n' + err.stack);
});
a[i].on('message', function (msg) {
j += 1;
if(j%1000 == 0){
console.log(j);
console.log('Received a message [' + msg.getSequence() + '] ' + msg.getData());
}
// });
});
}
});
Running nats streaming from a docker using:
docker run -p 4222:4222 -ti nats-streaming --max_channels 1000000 --max_subs 1000000
Please help me out figuring the issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Error on large number of subscriptions · Issue #39 · nats-io ...
aricart I am trying to publish messages to 1 million subjects and subscribing to those subjects from another process.
Read more >Maximum 25 Current Subscriptions - Google Groups
I have hit an error on the Stripe API that is causing me a great deal of concern: "Customer [x] already has the...
Read more >IT29738: IBM MQ V9.1: Performance degradation when large ...
In a scenario with a very large number (hundreds) of subscribers on a topic using selectors which rarely match publications, a delay in...
Read more >Subscriptions - Apollo GraphQL Docs
When Apollo Client executes the OnCommentAdded subscription, it establishes a connection to your GraphQL server and listens for response data. Unlike with a ......
Read more >Frequently asked questions about Troubleshooting Power BI ...
Subscriptions may fail on reports or dashboards with extremely large images ... There's a limit to the number of subscribers for one report...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, so here is what would make it “work”:
The publisher code:
I did run this with a separate
gnatsd
to better monitor the memory and cpu usage. I also made use of a feature in nats streaming in master to reduce the number of streaming server’s internal subscriptions to receive application acks. NATS server:NATS Streaming Server:
Still, this is a lot of subscriptions (and I have reduce to 500,000 instead of 1M). You may want to split the load on different servers/processes.
Looked at the fix on the server and looks ok to me. Let’s see if @karteek-gamooga make sure that it connects to master server (and not a running docker version that is still 0.3.8) and see if he can still reproduce.