Appends

Appends

An append adds a batch of records to the end of a stream and says where Nova stored them.

An append adds records to the end of a stream, its tail. Nova replies only after object storage has stored every record. This reply, the acknowledgement, says where the records went:

The acknowledgement of a two-record append
{
  "start": {
    "seq_num": 0,
    "timestamp_ms": 1795359116774
  },
  "end": {
    "seq_num": 2,
    "timestamp_ms": 1795359116774
  },
  "tail": {
    "seq_num": 2,
    "timestamp_ms": 1795359116774
  }
}

start is the position of the first record, and end is one past the last, so this append stored records 0 and 1. tail is the end of the stream when Nova replied. It is past end when another writer appended right after you.

Batches

You append records in batches. A batch holds at most 1,000 records and 1 MiB of bodies and headers. Nova stores all of a batch or none of it. Its records get consecutive sequence numbers, with no other writer's records between them.

The SDK keeps the records of one call together in one batch and never splits them. A call with more than a batch can hold fails before anything is sent. A single record holds at most 1 MiB, so put a larger payload in object storage and append a pointer to it. When several batches must appear together, append them, then append one record that marks them complete. Readers use the parts only once they see that record.

An operator can change these bounds; see node limits.

Two ways to append

WayHow it worksUse when
Producer sessionKeeps a connection open and sends batches without waiting for each acknowledgement. Nova stores them in the order you sent them.You write often. This is the default.
One-shot appendSends one batch in one request, and waits for its acknowledgementYou write now and then, as in a request handler, or from a browser, which cannot keep a session open

A one-shot append moves one batch per round trip, so a steady flow of them is slow. Parallel one-shot appends are faster, but they are separate requests, so Nova can store them in any order. A producer session has many batches in flight and keeps their order.

If Nova refuses a batch on a session, it ends the session and stores none of the batches sent after it. A batch refused for its match sequence number is the exception: the session goes on.

A stream's producer policy decides who can write at the same time. With any, the default, any number of producers and one-shot appends write at once, and their batches interleave. With fenced, one producer writes at a time. See writer coordination.

The session window

The session window is the most data a producer session can send before Nova acknowledges it. It is 48 MiB on a Standard stream and 8 MiB on an Express stream, in at most 1,024 batches.

When the window is full, the SDK groups new records into one batch, up to the batch bounds. Once that batch is full too, the next append call waits for Nova to acknowledge earlier batches. So a writer faster than the stream slows down, and memory stays bounded. Each call still gets back the positions of its own records. On a stream with a throughput limit, appends above the limit wait too.

An idle producer sends each append at once. For many small records, a linger makes it wait a few milliseconds to fill a batch. A longer linger fills batches better and sends them later.

Latency

Most of an append's latency is the object storage write. The storage class sets how long Nova waits before it, and what it writes:

ClassNova waits up toThen it writesTypical acknowledgement
Standard200 ms, to put the batches of many streams into one object; less once 8 MiB is waitingOne object to standard storageA few hundred milliseconds
Express25 msOne copy to the Express bucket of each zone, and replies once two copies are storedTens of milliseconds

These numbers assume default node settings, in the same region as the object storage. With light traffic, a batch waits the full time.

Once Nova acknowledges an append, every read, tail check, and subscription sees it, on any node. See guarantees.

When the connection breaks

A connection can break after you send a batch and before its acknowledgement arrives. The batch may or may not be stored. This also happens when the stream's leader, the node that serves its writes, changes.

  • A producer reconnects, to the new leader if there is one, and sends every unacknowledged batch again, in order. A batch that was stored before the break is then stored twice, unless it carries a match sequence number.
  • A one-shot append is sent again only when it cannot have been stored. Otherwise the SDK reports the outcome as unknown.

Both keep trying for the SDK's retry budget, 30 seconds by default, and then fail.

To store a batch at most once, append it with a match sequence number. If the first copy was stored, the second one fails its match instead of being stored again. Or check the tail and read from your last known position, to look for your records before you send them again.

How it works: How a write becomes durable.

See also

On this page