Producer sessions
The append session over gRPC and HTTP, with its messages, flow control, failures, and the HTTP frame format.
A producer session sends many batches through one open request and gets an acknowledgement for each, in order, without waiting for one before sending the next. It is how the SDKs append at high throughput. This page is for writing a producer in a language without an SDK; with an SDK, the producer runs the session for you.
Appends
One-shot appends, sessions, and the session window
Append records with an SDK
The producer in Go and TypeScript
Append records
The one-shot append route and its statuses
| Transport | How to open |
|---|---|
| gRPC | The bidirectional stream DataPlaneService.AppendSession |
| HTTP | POST /v1/streams/{bucket}/{key}/records with Content-Type: application/vnd.nova.session, in frames |
Messages
Both transports carry the same protobuf messages, AppendSessionRequest from
the producer and AppendSessionResponse from the node:
| Message | Direction | Fields |
|---|---|---|
AppendOpen | To the node, first only | bucket, key, fencing_token, and follows_batch_bound, which must be true |
AppendOpened | From the node, first only | tail; max_inflight_bytes, the session window: 48 MiB on Standard and 8 MiB on Express; max_inflight_batches (1,024); max_batch_bytes and max_batch_records, the node's batch bound; max_batch_weight |
AppendBatch | To the node | records, and an optional match_seq_num |
AppendAck | From the node, one per batch, in order | start, end, tail |
AppendRejected | From the node, in the batch's place | tail, when match_seq_num missed |
Flow control
- Send batches while their unacknowledged content fits
max_inflight_bytesand their count fitsmax_inflight_batches. At either limit the node stops reading, and flow control makes your next send wait. Nothing is rejected. - Cut each batch within
max_batch_bytesandmax_batch_records.max_batch_weightalso bounds a batch: its content plus 192 bytes a record, 128 a header, and 4 KiB a batch. - A
match_seq_nummiss rejects only that batch. The session goes on. - To finish, close your side. The node sends the remaining acknowledgements and then ends the session cleanly.
Failures
- An open without
follows_batch_boundfails withInvalidArgument: "this Nova SDK predates the 1 MiB / 1,000-record batch limit; upgrade the SDK". So does a first message that is not an open. - A batch over the bound ends the session with
InvalidArgument, and nothing of that batch is appended. Any other failure also ends the session, and so does an expired token. Open a new session and resend the unacknowledged batches in order. A plain batch can be stored twice this way; a batch withmatch_seq_numcannot. - A node at its session limit answers
ResourceExhausted. A node that does not lead the stream answersFailedPreconditionwithNotOwner: open the session at the address it names.
HTTP frames
Over HTTP, a refusal at the open is an ordinary JSON error: 400, 403,
404, 412, 429, or 503. Once the session opens, the answer is 200 with
the session content type, and both bodies are streams of frames.
Each frame is a 3-byte big-endian length, one flag byte, and a body. The length counts the flag byte and the body. A body is one of the protobuf messages above.
| Flag bits | Meaning |
|---|---|
1xxxxxxx | Terminal: the body is a 2-byte big-endian HTTP status, then the JSON error document. The session is over |
x00xxxxx | Uncompressed. The other compression values, and the five low bits, are reserved: a frame that sets one ends the session with terminal 400 |
- A client frame's body holds at most one batch plus 1 MiB, 2 MiB by default.
A longer frame ends the session with terminal
400before the node reads it. A client never sends a terminal frame. - The node sends an empty frame every 15 seconds as a heartbeat. Ignore it.
- Exactly one terminal frame ends a session.
200with no document is a clean end, after you close the request body and the node has sent every acknowledgement.503means the node is draining,401that the token expired, and400a bad frame or a batch over the limit. Open a new session after you fix the cause. - A response that ends without a terminal frame means the connection broke.
- A client that stops reading for 60 seconds is disconnected.
A session needs both directions of one request open at once: HTTP/2, or
HTTP/1.1 where client and server both allow it. Proxies must forward request
bodies as they arrive. A browser cannot open a session, because fetch waits
for the request body to finish before it returns the response.