grpc-lite

Resource limits

Admission limits bound retained work, not total process memory. Configured buffer capacity is permission to retain bytes, not eager allocation. Queue occupancy, allocator storage and RSS are different measurements.

Client admission

Each Channel has independent unary and streaming budgets:

BudgetDefaultReleased when
Retained unary calls4096 calls, 64 MiB logical request bytesOperation storage is released after callback return or blocking result copy
Retained streams1024 streams, 1 GiB configured inbound + outbound capacityBoth application and transport ownership end

Unary charge includes path bytes, the 5-byte message header, uncompressed payload, and raw metadata keys/values. It excludes responses and compression workspace. A separately owned result may survive reservation release.

Default streaming capacities are 8 MiB in each direction, so the byte budget permits 64 default streams. Terminal status, half-close and Channel teardown do not release application-retained stream reservations. The backing allocator must outlive the last stream handle. Failed construction rolls reservations back.

The optional grpc_lite_async streaming adapter also retains one application-side decoded-message slot (at most max_message_size payload bytes) and copied metadata. This is additional to transport capacities and excluded from transport admission and occupancy counters. It pauses delivery until the slot is consumed; returned owned messages are separately managed caller storage. See task-friendly clients.

See Zig admission and C/C++ managed channels for configuration and errors.

Buffers and server limits

LimitDefaultScope
Streaming message size4 MiBUncompressed message
Inbound / outbound stream capacity8 MiB / 8 MiBEach direction of each stream
Unary request / response size4 MiB / 4 MiBIndividual request or response
Server connections1024Across server reactors
Server concurrent streams100Per connection
Cleartext preface timeout10 secondsAbsolute initialization deadline
Idle timeout5 minutesOnly while no inbound RPC streams are active

A full outbound queue returns retryable WouldBlock; wait for writable notification. Receive pause defers flow-control credit. Inbound overflow fails the RPC with RESOURCE_EXHAUSTED. Message limits and buffer capacities must be configured together; each stream capacity must be at least max_message_size + 5.

Native TLS batches ciphertext in its existing 64 KiB output queue. A flush drains the batch when full, when TLS needs I/O, or when no more HTTP/2 output can be admitted; small tails do not wait for a timer. Write high-watermark admission counts both queued socket bytes and buffered ciphertext before taking another HTTP/2 chunk. An already admitted chunk may still overshoot the watermark.

Server connection slots remain occupied through asynchronous closing and final destruction. Transport stream admission ends separately from application-retained ServerCall ownership. Release every retained server call before destroying the Server. Active RPCs are exempt from the idle timeout; use RPC deadlines for stalled work.

The optional task server has a separate grpc_lite_async.ServerOptions.max_calls budget (default 1024) across reactors. It includes calls whose handlers are still unwinding after transport termination; excess calls receive RESOURCE_EXHAUSTED. activeCalls() reports this retained count. Each admitted call adds one decoded inbound message slot, capped at transport.stream_limits.max_message_size, and a request-metadata snapshot outside transport counters. Unary handlers also retain their request until return. Task stacks, returned messages, typed arenas, and application allocations are not covered by this count budget.

Memory and ownership

Admission excludes allocator overhead, spare container capacity, metadata/HPACK, compression and decoder workspace, TLS and dependency allocations, application queues, thread stacks and kernel socket buffers. More Channels multiply independent budgets; server stream limits do not provide a global byte budget.

Destroy C result/metadata/stream handles explicitly; C++ RAII adds its own string, metadata and protobuf storage. Callbacks must not block transport threads. Cross-thread server work retains an owning ServerCall, never a borrowed ServerStream.

Queue drain or allocation release need not immediately reduce RSS. Operational snapshots measure documented logical values, not a deduplicated heap total. See operational snapshots and capacity tuning for diagnosis and sizing.

Edit on GitHub

On this page