Skip to main content
The two biggest levers for performance are sessions (persistent connections with pipelining) and batching (sending more records per request). The SDKs’ Producer API combines both and is the recommended starting point for most workloads.

Sessions

For sustained throughput, use sessions instead of individual unary calls. Sessions maintain a persistent connection and enable pipelining — multiple batches in flight simultaneously, with an ordering guarantee.
  • Append sessions pipeline batches with strict ordering. If any batch fails, subsequent batches won’t become durable. See SDK: Append Session.
  • Read sessions stream records continuously and handle reconnection on transient failures. See SDK: Read Session.
Contrast sessions with concurrent unary append() calls: while concurrent calls can also achieve high throughput, the ordering in which they become durable is not guaranteed.

Batching

Streams support up to 200 batches per second, so throughput is maximized by sending larger batches (up to 1000 records or 1 MiB per batch). The SDKs offer auto-batching utilities. Key parameters:
OptionDefaultDescription
linger5msHow long to wait for more records before flushing a partial batch
maxBatchRecords1000Flush when the batch hits this many records
maxBatchBytes1 MiBFlush when the batch hits this size
The producer flushes whenever any threshold is hit. Shorter linger for lower latency, longer linger for more efficient batching.

Producer API

The Producer API wraps sessions and auto-batching into a record-oriented interface. You submit individual records and get back per-record tickets — the producer handles batching, pipelining, backpressure, and ordering transparently. Use the Producer API when:
  • Records arrive one at a time (from HTTP requests, message queues, etc.)
  • You want per-record durability confirmation
  • You don’t want to manage batch boundaries yourself

Backpressure

Append sessions track how much data is in flight (submitted but not yet acknowledged). When you hit the configured limits, submit() blocks until capacity frees up.
OptionDefaultDescription
maxInflightBytes5 MiBMaximum unacknowledged bytes before blocking
maxInflightBatchesNoneOptional limit on unacknowledged batches