tongsucn opened a new pull request #6534: [Issue 6000][pulsar-client] C++ 
client ACK grouping feature.
URL: https://github.com/apache/pulsar/pull/6534
 
 
   Fixes #6000 
   
   ### Motivation
   
   In our production environment, we created a sinker: It combines messages 
read from Pulsar, and writes the combined data into ClickHouse, which is not 
good at processing highly concurrent inserting (max. 100 QPS).
   
   In the sinker, we used failover subscription with cumulative ACK. The reason 
for not using shared subscription is that, individual ACK in C++ client 
siginificantly reduces throughput. Our analysis shows that huge amount of 
individual ACK requests results in highly concurrent accessing, which finally 
results in terrible throughput. BTW, the machines, where we deploy brokers and 
bookies, are not equipped with SSD. There could be some configuration for 
brokers or bookies helping improving the situation, but we don't find them.
   
   Therefore, the idea is that combining individual ACK requests within one 
request. After reading the protocol (PulsarApi.proto:CommandAck), we find that 
this feature is supported. According to this issue #6000 , Pulsar C++ client 
SDK does not implement ACK grouping feature, but it's already implemented by 
Java client.
   
   After discussing with @jiazhai and @sijie , we are authorized to implement 
this feature and contribute this feature back to community later. It should 
follow the Java client's behavior and provide similar interfaces that Java 
client provides.
   
   ### Modifications
   
   #### Interfaces
   
   Similar to Java client, C++ client implements three trackers to *cache* ACK 
requests within a configured time window:
   
   1. `AckGroupingTracker`: this is the base class of the other two trackers, 
it defines interfaces and provides empty implementation which does not send ACK 
requests to broker. This tracker is used for non-persistent topic, which 
actually does not require ACK.
   2. `AckGroupingTrackerDisabled`: child class of `AckGroupingTracker`. It 
does not provide ACK grouping ability, and acts just like the previous 
individual ACK.
   3. `AckGroupingTrackerEnabled`: child class of `AckGroupingTracker`. This is 
the real implementation of ACK grouping.
   
   The trackers provides following public interfaces:
   
   1. `isDuplicate`: checking if the given message ID exists in the TO-BE-ACKED 
group.
   2. `addAcknowledge` and `addAcknowledgeCumulative`: unlike Java client, 
which combines these two interfaces into one (`addAcknowledge`), C++ clients 
provides them for individual and cumulative ACK requests. Such design can 
provide slightly better performance than if-else implementation.
   3. `close`: closing the tracker.
   4. `flush` and `flushAndClean`: flushing all pending ACK requests, the later 
one also resets internal status.
   
   #### Consumer's Configuration
   
   Two new configuration options are added:
   
   1. `ackGroupingTimeMs`: time window in milliseconds for grouping ACK 
requests. If setting to positive value, ACK requests are grouped and sent to 
broker every `ackGroupingTimeMs` milliseconds (`AckGroupingTrackerEnabled`). 
For non-positive values, ACK requests are sent one by one to brokers as before 
(`AckGroupingTrackerDisabled`). Default is 100.
   2. `ackGroupingMaxSize`: maximum number of grouped message IDs. Java client 
hard-coded it to 1000 for now. However, 1000 is too small in our scenario. Once 
the grouped message number reaches this limit, the ACK requests will be packed 
into one and sent to broker, even the ACK grouping deadline 
(`ackGroupingTimeMs`) is not reached. Non-positive values remove such limit.
   
   #### Commands for this feature.
   
   A few new command factory interfaces are implemented, just like in Java, 
incl.
   
   * `newMultiMessageAck`: command object for multi-message ACK requests.
   * `peerSupports*`: interfaces for checking versions.
   
   #### Topic Domain
   
   Used to help defining and distinguish non-persistent and persistent topics.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   ### Does this pull request potentially affect one of the following parts:
   
   NO
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
     - The rest endpoints: (no)
     - The admin cli options: (no)
     - Anything that affects deployment: (no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup 
issue for adding the documentation

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to