arobson / rabbot

Deprecated: Please see https://github.com/Foo-Foo-MQ/foo-foo-mq
MIT License
276 stars 129 forks source link

Should connections start with a randomly chosen host? #109

Closed djMax closed 6 years ago

djMax commented 7 years ago

We noticed in our cluster that the first rabbit host was receiving almost all the traffic. I assume this is because rabbot always connects to the first host first. Should it start at a random point in the list?

arobson commented 6 years ago

@djMax - yeah - I guess ideally it would maybe hash on pid so that even if you ran multiple processes on a single box they'd spread connections? Let me see if I can work something out quickly and add it to the current release I'm trying to get out later this weekend.

arobson commented 6 years ago

@djMax - ok, this was really simple - I just used an approach that modulos pid unless it's 1 or less (docker containers make your process pid 0 or 1 I think) and then if the pid is that low, it hashes the hostname to an int and modulos that instead.