Scalable streams
A scalable stream spreads one address over many ranges, so its write rate can grow past what one node serves.
A plain stream has one sequence, and one node at a time writes it, so its write rate is what that node can take. A scalable stream removes that limit. Behind its one address it stores records in ranges, each with its own sequence numbers. Each record carries a routing key, and all records with the same key go to the same range, in order. When a range gets busy, Nova splits it in two. This read of a new scalable stream returns records from its two ranges:
{
"records": [
{
"seq_num": 0,
"timestamp_ms": 1795372266741,
"body": "signed in",
"headers": [
{
"name": "nova-routing-key",
"value": "user-7"
}
],
"range": "01a20486-b3dc-71ff-9e0b-5836891c8ad1"
},
{
"seq_num": 0,
"timestamp_ms": 1795372266507,
"body": "signed in",
"headers": [
{
"name": "nova-routing-key",
"value": "user-42"
}
],
"range": "01a20486-b3dc-7203-a7ac-54b558c3ba96"
},
{
"seq_num": 1,
"timestamp_ms": 1795372266507,
"body": "added to cart",
"headers": [
{
"name": "nova-routing-key",
"value": "user-42"
}
],
"range": "01a20486-b3dc-7203-a7ac-54b558c3ba96"
}
],
"bookmark": "CAESKAokMDFhMjA0ODYtYjNkYy03MWZmLTllMGItNTgzNjg5MWM4YWQxEAESKAokMDFhMjA0ODYtYjNkYy03MjAzLWE3YWMtNTRiNTU4YzNiYTk2EAI"
}Each record names its range, and each range numbers its records from 0. user-42's two records are in one range, in the order they were appended. The bookmark holds the reader's place in every range at once.
A queue is a scalable stream too: queues are built on them.
Plain or scalable
You choose a stream's kind when you create it, and it never changes. Create a scalable stream from an SDK, over the API, or with nova stream create.
| Plain | Scalable | |
|---|---|---|
| Order | One order for every record | One order per routing key; none between keys |
| Sequence numbers | One sequence | One per range |
| Write rate | What one node can take | Grows as ranges split |
| A reader's place | A sequence number | A bookmark |
| Conditional appends | Yes | Refused |
| Settings you can change later | All | Retention only |
Use a plain stream when you need one order across all records, or conditional appends. Use a scalable stream when one stream's writes can grow past one node and order per key is enough, such as clicks per user or events per device.
How it grows
You create a scalable stream with one range or more, at most 256. Nova then splits a range that stays busy, by default above 100 MiB/s for a minute, and merges neighbouring ranges that stay idle. You never reconnect for a split or a merge: the SDK sends each append to the right range. Splits and merges gives the exact rules and the limit on ranges.
Fencing
A fencing token works on a scalable stream as on a plain one: one token for the whole stream, installed with a fence and presented by writers. Nova applies it at every range, including the ranges a later split creates, so you install it once. A fence returns a bookmark instead of a tail: each range's position when the token took effect. Read up to it to see everything written before the change.
A producer that the new token shuts out fails on its next append, on every range, and reconnecting does not let it back in. A fence that fails partway has already installed the token. The SDK retries it until every range has it. Over HTTP, the fence answers 503; send it again.
Duplicates after a reconnect
Appends are at least once. When a range moves to another node, a producer sends again the records it has no acknowledgement for. A record that was stored before the move is then stored twice, at a later sequence number.
Detect repeats yourself
A scalable stream refuses match sequence numbers, so Nova cannot drop a repeat for you. If a consumer must not act twice on one record, give each record an ID of your own, such as a counter per key in a header, and skip IDs it has already seen.
How it works: Scalable streams inside.