Skip to content

Commit 86f1d7f

Browse files
committed
Decrease max ACK batch size to 2500
The previous limit of 3000 seems to be too optimistic, and the request size limit is still hit. Reducing the batch size to 2500 fixes the problem.
1 parent 0c61849 commit 86f1d7f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pubsub/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
"""The maximum amount of time in seconds to wait for additional request items
3838
before processing the next batch of requests."""
3939

40-
_ACK_IDS_BATCH_SIZE = 3000
40+
_ACK_IDS_BATCH_SIZE = 2500
4141
"""The maximum number of ACK IDs to send in a single StreamingPullRequest.
4242
4343
The backend imposes a maximum request size limit of 524288 bytes (512 KiB) per
4444
acknowledge / modifyAckDeadline request. ACK IDs have a maximum size of 164
45-
bytes, thus we cannot send more than o 524288/164 ~= 3197 ACK IDs in a single
45+
bytes, thus we cannot send more than o 524288/176 ~= 2979 ACK IDs in a single
4646
StreamingPullRequest message.
4747
48-
Accounting for some overhead, we should thus only send a maximum of 3000 ACK
48+
Accounting for some overhead, we should thus only send a maximum of 2500 ACK
4949
IDs at a time.
5050
"""
5151

pubsub/tests/unit/pubsub_v1/subscriber/test_dispatcher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ def test_ack_splitting_large_payload():
102102
dispatcher_ = dispatcher.Dispatcher(manager, mock.sentinel.queue)
103103

104104
items = [
105-
# use realistic lengths for ACK IDs (max 164 bytes)
106-
requests.AckRequest(ack_id=str(i).zfill(164), byte_size=0, time_to_ack=20)
107-
for i in range(6001)
105+
# use realistic lengths for ACK IDs (max 176 bytes)
106+
requests.AckRequest(ack_id=str(i).zfill(176), byte_size=0, time_to_ack=20)
107+
for i in range(5001)
108108
]
109109
dispatcher_.ack(items)
110110

@@ -187,9 +187,9 @@ def test_modify_ack_deadline_splitting_large_payload():
187187
dispatcher_ = dispatcher.Dispatcher(manager, mock.sentinel.queue)
188188

189189
items = [
190-
# use realistic lengths for ACK IDs (max 164 bytes)
191-
requests.ModAckRequest(ack_id=str(i).zfill(164), seconds=60)
192-
for i in range(6001)
190+
# use realistic lengths for ACK IDs (max 176 bytes)
191+
requests.ModAckRequest(ack_id=str(i).zfill(176), seconds=60)
192+
for i in range(5001)
193193
]
194194
dispatcher_.modify_ack_deadline(items)
195195

0 commit comments

Comments
 (0)