0

I have a golang microservice project in kubernetes environment, that is running several nsqd-0, nsqd-1, ... pods, which are controlled by its statefulSet and grouped under nsqd service.

The problem is when I want to make a producer, i import github.com/nsqio/go-nsq and create it p := nsq.NewProducer('nsqd:4150', nsq.NewConfig())

But the connections are sticky (persistent) so what happens is service provides me ip adress of random pod (say it nsqd-2), and all traffic goes to it. others are unused at all

For now I am using awful workaround, every 5 seconds I p.Stop() current producer and reinitialize so it connects to a different pod. But how to load balance it normally? Is there any cloud-native simple way of doing it?

xakepp35
  • 2,878
  • 7
  • 26
  • 54

1 Answers1

0

Another workaround is we can inititalize n times based on number of nsqd and put round robin logic behind it on client side

mrgrey
  • 1
  • Hi, thanks, but what is the way to know N? Also what if n is changing during runtime? – xakepp35 Feb 17 '22 at 18:39
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '22 at 19:22