apache/beam · critical · ValueError
Buffer size {size} exceeds GRPC limit {_FLUSH_MAX_SIZE}. Thi
Error message
Buffer size {size} exceeds GRPC limit {_FLUSH_MAX_SIZE}. This is likely due to a single element that is too large. To resolve, prefer multiple small elements over single large elements in PCollections. If needed, store large blobs in external storage systems, and use PCollections to pass their metadata, or use a custom coder that reduces the element's size. What it means
The worker's outbound data buffer exceeds _FLUSH_MAX_SIZE (the gRPC message limit, ~2GB by protocol but capped lower here) at flush time, meaning buffered encoded elements cannot be sent as one message. This usually indicates a single enormous element or a huge backlog between flushes, and the worker raises ValueError instead of sending an impossible gRPC message.
Source
Thrown at sdks/python/apache_beam/runners/worker/data_plane.py:162
super().__init__(close_callback)
self._flush_callback = flush_callback
self._size_flush_threshold = size_flush_threshold
self._large_buffer_warn_threshold_bytes = large_buffer_warn_threshold_bytes
# This must be called explicitly to avoid flushing partial elements.
def maybe_flush(self):
# type: () -> None
if self.size() > self._size_flush_threshold:
self.flush()
def flush(self):
# type: () -> None
if self._flush_callback:
size = self.size()
if (self._large_buffer_warn_threshold_bytes and
size > self._large_buffer_warn_threshold_bytes):
if size > _FLUSH_MAX_SIZE:
raise ValueError(
f'Buffer size {size} exceeds GRPC limit {_FLUSH_MAX_SIZE}. '
'This is likely due to a single element that is too large. '
'To resolve, prefer multiple small elements over single large '
'elements in PCollections. If needed, store large blobs in '
'external storage systems, and use PCollections to pass their '
'metadata, or use a custom coder that reduces the element\'s '
'size.')
if self._large_flush_last_observed_timestamp + 600 < time.time():
self._large_flush_last_observed_timestamp = time.time()
_LOGGER.warning(
'Data output stream buffer size %s exceeds %s bytes. '
'This is likely due to a large element in a PCollection. '
'Large elements increase pipeline RAM requirements and '
'can cause runtime errors. '
'Prefer multiple small elements over single large elements '
'in PCollections. If needed, store large blobs in external '
'storage systems, and use PCollections to pass their metadata, 'View on GitHub (pinned to 12126d8942)
Solutions
- Split large elements into multiple smaller elements before writing to PCollections
- Store large blobs in external storage (GCS/S3) and pass only references/metadata through PCollections
- Implement a custom coder that compresses or reduces encoded element size
- Ensure the sink/DoFn doesn't buffer many elements into one output (e.g. giant lists); flush per element
- Increase parallel sharding so fewer elements accumulate per output buffer
Example fix
// before
yield {'id': row_id, 'payload': huge_blob} # single 3GB element
// after
blob_ref = upload_to_gcs(huge_blob)
yield {'id': row_id, 'payload_ref': blob_ref} # small metadata element Defensive patterns
Strategy: validation
Validate before calling
MAX_ENCODED = 64 * 1024 * 1024 # stay well below gRPC/flush limits
def element_too_large(elem):
encoded = sys.getsizeof(repr(elem)) # or use the actual coder to measure
return encoded > MAX_ENCODED
# reject or split before writing to the PCollection Try / catch
try:
out = pcoll | beam.Map(emit)
pipeline.run().wait_until_finish()
except ValueError as e:
if 'exceeds GRPC limit' in str(e):
logging.error('Element(s) too large for gRPC data plane; externalize blobs')
raise
raise Prevention
- Keep encoded elements small (KB-scale); reference external blobs instead of embedding them
- Split giant JSON/rows into multiple elements or chunks
- Use a compact/compressing custom coder for large payloads
- Monitor the 'large buffer' warnings in worker logs as an early signal before the hard limit
When it happens
Trigger: maybe_flush -> flush() computes size() > _FLUSH_MAX_SIZE because one encoded element (or an un-flushed accumulation) exceeds the gRPC message limit in data_plane.py.
Common situations: PCollections carrying very large rows/blobs (large JSON, embedded binaries, huge images); forgetting to flush/checkpoint large outputs; missing externalization of large payloads.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- input is already set.
- Header metadata already has a worker_id.
- Service failed to start up with error %s
- Transform service did not start in %s seconds.
- Could not find coder for URN " + urn
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d4a2cee8a50e01e6.
Report an issue: GitHub.