halfgaar / FlashMQ

FlashMQ is a fast light-weight MQTT broker/server, designed to take good advantage of multi-CPU environments
https://www.flashmq.org/
Open Software License 3.0
173 stars 24 forks source link

Shared subscription load balancing strategies? #28

Closed 414owen closed 1 year ago

414owen commented 1 year ago

Hi, FlashMQ seems like a fantastic broker :) I was wondering if load balancing strategies have been considered for FlashMQ. Specifically, I'm interested in emqx's 'hash' strategy, which effectively pairs publishers with subscribers.

halfgaar commented 1 year ago

Absolutely. It's on the list. I'll keep you updated with this issue.

halfgaar commented 1 year ago

I pushed a branch with a beta version of shared subscriptions: https://github.com/halfgaar/FlashMQ/tree/shared-subscriptions-beta

I can provide a build for you if you want, if it's an Ubuntu / Debian version on x64, or the x64 AppImage.

I would like to know more about how you see the hash strategy working. Currently, the man page says:

sender_hash. Selects a receiver deterministically based on the hash of the client ID of the sender. The selected subscriber will depend on how many subscribers there are, so if some disconnect, the distribution will change. Moreover, the selection may also change when FlashMQ cleans up empty spaces in the list of shared subscribers.

Pairing subscribers to publishers predictably/consistently is hard this way, because a receiver has to be selected, and if subscribers disappear, this changes result.

halfgaar commented 1 year ago

Included in FlashMQ 1.2.0.