-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support grouping ACK requests by time and size #957
Conversation
Fixes apache#949 ### Motivation Currently the Go client does not support grouping ACK requests, so each time `Ack` (or similar APIs) is called, a ACK request will be sent, which could downgrade the performance. We need to support configuring the time and size to cache `MessageID` before sending ACK requests. ### Modifications - Add an `AckGroupingOptions` field to `ConsumerOptions`, when it's nil, use 100ms as the max time and 1000 as the max size. - Add an `ackGroupingTracker` interface to support grouping ACK requests - When `AckWithResponse` is false, adding the `MessageID` instance to the tracker instead of sending the requests to `eventsCh`. ### Verifying this change - [ ] Make sure that the change passes the CI checks. This change added tests and can be verified as follows: - Added `ack_grouping_tracker_test.go` to verify `ackGroupingTracker` in various cases - The consumer side change can be covered by existing tests because the default `AckGroupingOptions` config is `{ MaxSize: 1000, MaxTime: 100*time.Millisecond }`.
b25d861
to
6800045
Compare
Does Community has some Performance Test Data? I used the latest version(v0.9.1-0.20230222003822-7d257b01b121) to test today, still found that which Test Case by EnableBatchIndexAcknowledgment=true consumed messages much more slower than EnableBatchIndexAcknowledgment=false, and could not catch up with the producer‘s production. I think that Support grouping ACK feature is OK, but maybe EnableBatchIndexAcknowledgment feature have much room for improvement. |
Maybe we should set ackIndividualCh and ackCumulativeCh size > 0. /cc @BewareMyPower |
@shibd What's the benefit of setting this channel size greater than 0? I think we don't need to cache these MessageIDs again in the channel. They are already cached in
Currently not. Could you provide more information to diagnosis? For example, the prometheues metrics |
Just guessing. For example, if the channel has buffers while the thread is flushing data, then the add operation will not be blocked. |
There are some prometheues metrics in Grafana Graph: Version label stands for As the metrics shows, receiving and acking messages for enable_batch_master is slower than other two versions, processing time metrics looks like it does't have a very large difference. There are three flamegraph screenshot for enable_batch_master: As above, compare to disable_batch_master, Next I will try to adjust |
@panszobe From the flamegraph, I think the root case is the inefficiency process of sending ACKs. The most time of While I'm looking forward to your test results of other
BTW, the
I didn't see the |
The situations of producer: about 20MB/s, 200k messages/s, batch = 10. Through JAVA pressure test procedure. I adjusted the Looking forward to your local test. @BewareMyPower |
The default MaxSize is 1000, which means every time 1000 messages are acknowledged, the ACK request will be sent. Increasing MaxTime to 1000 won't help because the receiving speed is far more than 1000 messages per second. BTW, I just remembered an important thing that this PR does not support the list ACK. See
I'm going to implement the list ACK soon and see if it works. |
Emmm, I made a mistake while adjusting the options. As your diagnosis, I adjusted the options by increasing the two settings to 10000, which still didn't make a difference. |
Okay. When I open a new PR, I will also perform a simple test in my local env to see if it works. |
@BewareMyPower hi~ According to the flamegraphs as above, SendRequest and MessageReceive took much time. As above, consuming rates and message receving rates also show the test result.The subscription is very simple, just receiving and acking the Message, has no business processing logic, as below: But it still could not catch up with the producer's production while the other one which disables Do you have any other idea? Or there is any optimizations doing now? |
### Motivation apache#957 adds the support for grouping MessageID instances to acknowledge. However, when flushing N cached MessageID instances, N CommandAck requests will be sent. It downgrades the performance. ### Modifications When more than one MessageID instances are acknowledged, use a single CommandAck request to carry all of them.
### Motivation apache#957 adds the support for grouping MessageID instances to acknowledge. However, when flushing N cached MessageID instances, N CommandAck requests will be sent. It downgrades the performance. ### Modifications When more than one MessageID instances are acknowledged, use a single CommandAck request to carry all of them.
### Motivation apache#957 adds the support for grouping MessageID instances to acknowledge. However, when flushing N cached MessageID instances, N CommandAck requests will be sent. It downgrades the performance. ### Modifications - When more than one MessageID instances are acknowledged, use a single CommandAck request to carry all of them. - Reduce number of the stored MessageIDs of the ACK grouping tracker - Support configure AckGroupingOptions - Add test to cover new logic of the ACK grouping tracker
Fixes #949
Motivation
Currently the Go client does not support grouping ACK requests, so each time
Ack
(or similar APIs) is called, a ACK request will be sent, which could downgrade the performance. We need to support configuring the time and size to cacheMessageID
before sending ACK requests.Modifications
AckGroupingOptions
field toConsumerOptions
, when it's nil, use 100ms as the max time and 1000 as the max size.ackGroupingTracker
interface to support grouping ACK requests.AckWithResponse
is false, adding theMessageID
instance to the tracker instead of sending the requests toeventsCh
.Verifying this change
This change added tests and can be verified as follows:
ack_grouping_tracker_test.go
to verifyackGroupingTracker
in various casesAckGroupingOptions
config is{ MaxSize: 1000, MaxTime: 100*time.Millisecond }
.Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation