diff options
| author | chrislu <chris.lu@gmail.com> | 2023-09-30 13:19:05 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2023-09-30 13:19:05 -0700 |
| commit | 597ab1e4bf5ef1c72dbcfda3c31a4738ee0aa7e7 (patch) | |
| tree | 7b495cca6c63445eddae8eb8e6f43d828e5635d5 /weed/mq/balancer/balancer.go | |
| parent | d7c211fe8c82dd374146f5cc108e3a2173ba917a (diff) | |
| download | seaweedfs-597ab1e4bf5ef1c72dbcfda3c31a4738ee0aa7e7.tar.xz seaweedfs-597ab1e4bf5ef1c72dbcfda3c31a4738ee0aa7e7.zip | |
add design for mq balancer
Diffstat (limited to 'weed/mq/balancer/balancer.go')
| -rw-r--r-- | weed/mq/balancer/balancer.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/weed/mq/balancer/balancer.go b/weed/mq/balancer/balancer.go index bc919d4e3..258b29f2f 100644 --- a/weed/mq/balancer/balancer.go +++ b/weed/mq/balancer/balancer.go @@ -12,6 +12,23 @@ const ( LockBrokerBalancer = "broker_balancer" ) +// Balancer collects stats from all brokers. +// +// When publishers wants to create topics, it picks brokers to assign the topic partitions. +// When consumers wants to subscribe topics, it tells which brokers are serving the topic partitions. +// +// When a partition needs to be split or merged, or a partition needs to be moved to another broker, +// the balancer will let the broker tell the consumer instance to stop processing the partition. +// The existing consumer instance will flush the internal state, and then stop processing. +// Then the balancer will tell the brokers to start sending new messages in the new/moved partition to the consumer instances. +// +// Failover to standby consumer instances: +// +// A consumer group can have min and max number of consumer instances. +// For consumer instances joined after the max number, they will be in standby mode. +// +// When a consumer instance is down, the broker will notice this and inform the balancer. +// The balancer will then tell the broker to send the partition to another standby consumer instance. type Balancer struct { Brokers cmap.ConcurrentMap[string, *BrokerStats] } |
