Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit d136dfd

Browse files
authored
docs: Docs have inconsistent default values for max_latency and max_bytes (#572)
* fix max_latency and max_byte defaults and add to docs * docs: fix max_latency and max_byte defaults
1 parent cdda762 commit d136dfd

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

docs/publisher/index.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The way that this works is that on the first message that you send, a new batch
7272
is created automatically. For every subsequent message, if there is already a
7373
valid batch that is still accepting messages, then that batch is used. When the
7474
batch is created, it begins a countdown that publishes the batch once
75-
sufficient time has elapsed (by default, this is 0.05 seconds).
75+
sufficient time has elapsed (by default, this is 0.01 seconds).
7676

7777
If you need different batching settings, simply provide a
7878
:class:`~.pubsub_v1.types.BatchSettings` object when you instantiate the
@@ -84,11 +84,23 @@ If you need different batching settings, simply provide a
8484
from google.cloud.pubsub import types
8585
8686
client = pubsub.PublisherClient(
87-
batch_settings=types.BatchSettings(max_messages=500),
87+
batch_settings=types.BatchSettings(
88+
max_messages=500, # default 100
89+
max_bytes=1024, # default 1 MB
90+
max_latency=1 # default .01 seconds
91+
),
8892
)
8993
90-
Pub/Sub accepts a maximum of 1,000 messages in a batch, and the size of a
91-
batch can not exceed 10 megabytes.
94+
The `max_bytes` argument is the maximum total size of the messages to collect
95+
before automatically publishing the batch, (in bytes) including any byte size
96+
overhead of the publish request itself. The maximum value is bound by the
97+
server-side limit of 10_000_000 bytes. The default value is 1 MB.
98+
99+
The `max_messages` argument is the maximum number of messages to collect
100+
before automatically publishing the batch, the default value is 100 messages.
101+
102+
The `max_latency` is the maximum number of seconds to wait for additional
103+
messages before automatically publishing the batch, the default is .01 seconds.
92104

93105

94106
Futures

samples/snippets/publisher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def publish_messages_with_batch_settings(project_id: str, topic_id: str) -> None
189189
# or 1 KiB of data, or 1 second has passed.
190190
batch_settings = pubsub_v1.types.BatchSettings(
191191
max_messages=10, # default 100
192-
max_bytes=1024, # default 1 MiB
192+
max_bytes=1024, # default 1 MB
193193
max_latency=1, # default 10 ms
194194
)
195195
publisher = pubsub_v1.PublisherClient(batch_settings)

0 commit comments

Comments
 (0)