tisonkun commented on code in PR #18878:
URL: https://github.com/apache/pulsar/pull/18878#discussion_r1045340003


##########
site2/docs/concepts-messaging.md:
##########
@@ -599,10 +599,137 @@ In the diagram below, **Consumer A**, **Consumer B** and 
**Consumer C** are all
 
 #### Key_Shared
 
-In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. When a consumer connects or disconnects, it causes the 
served consumer to change some message keys.
+In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. 
 
 ![Key_Shared subscriptions](/assets/pulsar-key-shared-subscriptions.svg)
 
+There are three types of mapping algorithms dictating how to select a consumer 
for a given message key (or ordering key): Sticky, Auto-split Hash Range, and 
Auto-split Consistent Hashing. Before using the algorithm, the message key (or 
ordering key) is first passed to a hash function (e.g., Murmur3 32-bit), 
yielding a 32-bit integer hash. That hash number is then fed to the algorithm 
to select a consumer from the existing connected consumers.
+When a new consumer is connected and thus added to the list of connected 
consumers, the algorithm re-adjusts the mapping such that some keys currently 
mapped to existing consumers will be mapped to the newly added consumer. When a 
consumer is disconnected, thus removed from the list of connected consumers, 
keys mapped to it will be mapped to other consumers. The sections below will 
explain how a consumer is selected given the message hash and how the mapping 
is adjusted given a new consumer is connected or an existing consumer 
disconnects for each algorithm.
+
+##### Auto-split Hash Range
+The algorithm assumes there is a range of numbers between 0 to 2^16 (65,536). 
Each consumer is mapped into a single region in this range, so all mapped 
regions cover the entire range, and no regions overlap. A consumer is selected 
for a given key by running a modulo operation on the message hash by the range 
size (65,536). The number received ( 0 <= i < 65,536) is contained within a 
single region. The consumer mapped to that region is the one selected.
+
+Example:
+
+Suppose we have 4 consumers (C1, C2, C3 and C4), then:
+```

Review Comment:
   ditto these cases



##########
site2/docs/concepts-messaging.md:
##########
@@ -599,10 +599,137 @@ In the diagram below, **Consumer A**, **Consumer B** and 
**Consumer C** are all
 
 #### Key_Shared
 
-In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. When a consumer connects or disconnects, it causes the 
served consumer to change some message keys.
+In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. 
 
 ![Key_Shared subscriptions](/assets/pulsar-key-shared-subscriptions.svg)
 
+There are three types of mapping algorithms dictating how to select a consumer 
for a given message key (or ordering key): Sticky, Auto-split Hash Range, and 
Auto-split Consistent Hashing. Before using the algorithm, the message key (or 
ordering key) is first passed to a hash function (e.g., Murmur3 32-bit), 
yielding a 32-bit integer hash. That hash number is then fed to the algorithm 
to select a consumer from the existing connected consumers.
+When a new consumer is connected and thus added to the list of connected 
consumers, the algorithm re-adjusts the mapping such that some keys currently 
mapped to existing consumers will be mapped to the newly added consumer. When a 
consumer is disconnected, thus removed from the list of connected consumers, 
keys mapped to it will be mapped to other consumers. The sections below will 
explain how a consumer is selected given the message hash and how the mapping 
is adjusted given a new consumer is connected or an existing consumer 
disconnects for each algorithm.
+
+##### Auto-split Hash Range
+The algorithm assumes there is a range of numbers between 0 to 2^16 (65,536). 
Each consumer is mapped into a single region in this range, so all mapped 
regions cover the entire range, and no regions overlap. A consumer is selected 
for a given key by running a modulo operation on the message hash by the range 
size (65,536). The number received ( 0 <= i < 65,536) is contained within a 
single region. The consumer mapped to that region is the one selected.

Review Comment:
   ```suggestion
   ##### Auto-split Hash Range
   
   The algorithm assumes there is a range of numbers between 0 to 2^16 
(65,536). Each consumer is mapped into a single region in this range, so all 
mapped regions cover the entire range, and no regions overlap. A consumer is 
selected for a given key by running a modulo operation on the message hash by 
the range size (65,536). The number received (0 <= i < 65,536) is contained 
within a single region. The consumer mapped to that region is the one selected.
   ```



##########
site2/docs/concepts-messaging.md:
##########
@@ -599,10 +599,137 @@ In the diagram below, **Consumer A**, **Consumer B** and 
**Consumer C** are all
 
 #### Key_Shared
 
-In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. When a consumer connects or disconnects, it causes the 
served consumer to change some message keys.
+In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. 
 
 ![Key_Shared subscriptions](/assets/pulsar-key-shared-subscriptions.svg)
 
+There are three types of mapping algorithms dictating how to select a consumer 
for a given message key (or ordering key): Sticky, Auto-split Hash Range, and 
Auto-split Consistent Hashing. Before using the algorithm, the message key (or 
ordering key) is first passed to a hash function (e.g., Murmur3 32-bit), 
yielding a 32-bit integer hash. That hash number is then fed to the algorithm 
to select a consumer from the existing connected consumers.
+When a new consumer is connected and thus added to the list of connected 
consumers, the algorithm re-adjusts the mapping such that some keys currently 
mapped to existing consumers will be mapped to the newly added consumer. When a 
consumer is disconnected, thus removed from the list of connected consumers, 
keys mapped to it will be mapped to other consumers. The sections below will 
explain how a consumer is selected given the message hash and how the mapping 
is adjusted given a new consumer is connected or an existing consumer 
disconnects for each algorithm.

Review Comment:
   If you intend to write these two lines in different paragraphs, insert a 
blank line between them. Otherwise, this paragraph reads too long at first 
glance.



##########
site2/docs/concepts-messaging.md:
##########
@@ -599,10 +599,137 @@ In the diagram below, **Consumer A**, **Consumer B** and 
**Consumer C** are all
 
 #### Key_Shared
 
-In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. When a consumer connects or disconnects, it causes the 
served consumer to change some message keys.
+In the *Key_Shared* type, multiple consumers can attach to the same 
subscription. Messages are delivered in distribution across consumers and 
messages with the same key or same ordering key are delivered to only one 
consumer. No matter how many times the message is re-delivered, it is delivered 
to the same consumer. 
 
 ![Key_Shared subscriptions](/assets/pulsar-key-shared-subscriptions.svg)
 
+There are three types of mapping algorithms dictating how to select a consumer 
for a given message key (or ordering key): Sticky, Auto-split Hash Range, and 
Auto-split Consistent Hashing. Before using the algorithm, the message key (or 
ordering key) is first passed to a hash function (e.g., Murmur3 32-bit), 
yielding a 32-bit integer hash. That hash number is then fed to the algorithm 
to select a consumer from the existing connected consumers.
+When a new consumer is connected and thus added to the list of connected 
consumers, the algorithm re-adjusts the mapping such that some keys currently 
mapped to existing consumers will be mapped to the newly added consumer. When a 
consumer is disconnected, thus removed from the list of connected consumers, 
keys mapped to it will be mapped to other consumers. The sections below will 
explain how a consumer is selected given the message hash and how the mapping 
is adjusted given a new consumer is connected or an existing consumer 
disconnects for each algorithm.
+
+##### Auto-split Hash Range
+The algorithm assumes there is a range of numbers between 0 to 2^16 (65,536). 
Each consumer is mapped into a single region in this range, so all mapped 
regions cover the entire range, and no regions overlap. A consumer is selected 
for a given key by running a modulo operation on the message hash by the range 
size (65,536). The number received ( 0 <= i < 65,536) is contained within a 
single region. The consumer mapped to that region is the one selected.

Review Comment:
   We may try to insert a blank line between elements even when it's not 
required. Perhaps we need to write it explicitly in the documentation writing 
style guide. So it's now not a blocker.
   
   But I read you also insert blank lines between elements below, then let's 
keep the style consistent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to