nats.go: message consume too slow

i created a stream in Retention=WorkQueuePolicy, and published 1 million messages. then i start to consume it.

for {
  msgs, err := sub.Fetch(10000, nats.Context(ctx))
 for _, msg := range msgs {
	msg.AckSync()
 }
}

the first batch fetched fast enough, after a few loops, Fetch( ) becomes too slow (> 10 seconds), and the whole batch ack time become too slow also.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

What if you remove the allow [“>”] which are non-sensical? Within an account by default everyone can send and receive from any subject by default.

thanks for your advice, i have removed it. the server runs well.

hi, derekcollison。 if i just run nats-server 2.3.1 with -js flag, and 100% use your code. here are the results: 2021/06/30 12:09:34 Took 5.846983265s to send 500000 messages, ~85514 msgs/sec 2021/06/30 12:09:34 Single batched fetch 2021/06/30 12:09:44 Took 9.899456287s to fetch all 500000 messages, ~50508 msgs/sec 2021/06/30 12:09:44 Multiple go routines of batched fetch 2021/06/30 12:10:03 Took 13.691991873s to fetch all 500000 messages, ~36518 msgs/sec

looks better this time.