Skip to content

Commit

Permalink
Decrease max ACK batch size to 2500
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
plamut committed Nov 4, 2019
1 parent 0c61849 commit 86f1d7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"""The maximum amount of time in seconds to wait for additional request items
before processing the next batch of requests."""

_ACK_IDS_BATCH_SIZE = 3000
_ACK_IDS_BATCH_SIZE = 2500
"""The maximum number of ACK IDs to send in a single StreamingPullRequest.
The backend imposes a maximum request size limit of 524288 bytes (512 KiB) per
acknowledge / modifyAckDeadline request. ACK IDs have a maximum size of 164
bytes, thus we cannot send more than o 524288/164 ~= 3197 ACK IDs in a single
bytes, thus we cannot send more than o 524288/176 ~= 2979 ACK IDs in a single
StreamingPullRequest message.
Accounting for some overhead, we should thus only send a maximum of 3000 ACK
Accounting for some overhead, we should thus only send a maximum of 2500 ACK
IDs at a time.
"""

Expand Down
12 changes: 6 additions & 6 deletions pubsub/tests/unit/pubsub_v1/subscriber/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def test_ack_splitting_large_payload():
dispatcher_ = dispatcher.Dispatcher(manager, mock.sentinel.queue)

items = [
# use realistic lengths for ACK IDs (max 164 bytes)
requests.AckRequest(ack_id=str(i).zfill(164), byte_size=0, time_to_ack=20)
for i in range(6001)
# use realistic lengths for ACK IDs (max 176 bytes)
requests.AckRequest(ack_id=str(i).zfill(176), byte_size=0, time_to_ack=20)
for i in range(5001)
]
dispatcher_.ack(items)

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

items = [
# use realistic lengths for ACK IDs (max 164 bytes)
requests.ModAckRequest(ack_id=str(i).zfill(164), seconds=60)
for i in range(6001)
# use realistic lengths for ACK IDs (max 176 bytes)
requests.ModAckRequest(ack_id=str(i).zfill(176), seconds=60)
for i in range(5001)
]
dispatcher_.modify_ack_deadline(items)

Expand Down

0 comments on commit 86f1d7f

Please sign in to comment.