# Telemetry ingestion

Telemetry ingestion moves measurements from where they’re made to where they’re stored, as they’re made. This page covers the steps between the two, and how batching trades delay for fewer requests.

[`Download this page as a notebook`](https://dev.nominal.io/learning/_downloads/1ad345a263a1542b3d5a4398aff9d868/telemetry-ingestion.md) to run its code in JupyterLab. [Running the notebooks](https://dev.nominal.io/learning/guides/notebooks/running.md) explains how to set it up.

## From source to store

A telemetry pipeline has four steps:

1. **Read** a value from its source: a bus, an instrument or a DAQ. [Communications](https://dev.nominal.io/learning/guides/communications.md) covers the links.
2. **Timestamp** it, ideally where it was measured. A value timestamped on arrival carries the link’s delay with it.
3. **Batch** it with other values, because sending one request for each value is slow.
4. **Send** the batch over the network to the store.

Each step can fall behind. [Network performance](https://dev.nominal.io/learning/guides/network-performance.md) covers what happens when a step falls behind.

## Batching

The Nominal Python client doesn’t send each value as you write it. It collects values into batches, and sends a batch when it reaches `batch_size` points or when it’s `max_wait` old. The defaults are 250,000 points and 0.25 s.[[1]](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#nominal-client) Batching has two effects: a larger batch means fewer requests for the same data, and a longer wait means a value can arrive later.

This code works out both for two streams, from the batching rule above. A stream of 20 channels at 1 kHz is 20,000 points a second. One of 200 channels at 10 kHz is 2 million points a second:

```ipython3
import pandas as pd

batch_size = 250_000  # points: the client's default

def batching(points_per_s, max_wait):
    """A batch is sent when it fills, or when it's max_wait old: whichever comes first."""
    seconds_to_fill = batch_size / points_per_s
    interval = min(max_wait, seconds_to_fill)  # s between requests
    return {
        "points per second": points_per_s,
        "max_wait (s)": max_wait,
        "requests per second": 1 / interval,
        "points per request": points_per_s * interval,
        "longest wait for a value (s)": interval,
    }

pd.DataFrame(
    [
        batching(rate, wait)
        for rate in (20_000, 2_000_000)
        for wait in (0.05, 0.25, 1.0)
    ]
).round(2)
```

|  | points per second | max_wait (s) | requests per second | points per request | longest wait for a value (s) |
| --- | --- | --- | --- | --- | --- |
| 0 | 20000 | 0.05 | 20.0 | 1000.0 | 0.05 |
| 1 | 20000 | 0.25 | 4.0 | 5000.0 | 0.25 |
| 2 | 20000 | 1.00 | 1.0 | 20000.0 | 1.00 |
| 3 | 2000000 | 0.05 | 20.0 | 100000.0 | 0.05 |
| 4 | 2000000 | 0.25 | 8.0 | 250000.0 | 0.12 |
| 5 | 2000000 | 1.00 | 8.0 | 250000.0 | 0.12 |

For the slower stream, no batch ever fills, so `max_wait` alone sets the request rate and the delay. For the faster stream, batches fill first, so each value waits for the batch to fill, and `max_wait` only matters when the stream slows. To get values sooner, use a smaller `max_wait`, and accept more and smaller requests.

## When the network fails

The Nominal Python client streams through nominal-streaming, a library designed to hold data in memory only for a limited time, to write to disk if the network fails, and to apply backpressure when the network’s throughput is saturated.[[2]](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#nominal-streaming) To keep data through an outage, pass `file_fallback`, the path to an `.avro` file, and the client writes batches that fail to upload to that file.[[1]](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#nominal-client)

## In Nominal

This code streams a source into a dataset, with a shorter `max_wait` and a fallback file:

```python
from datetime import datetime, timedelta, timezone

from nominal.core import NominalClient

client = NominalClient.from_profile("default")
dataset = client.get_dataset("<dataset RID>")

with dataset.get_write_stream(
    max_wait=timedelta(seconds=0.1),  # send each batch within 0.1 s
    file_fallback="unsent.avro",  # keep batches that fail to upload
) as stream:
    for channel, value in read_source():  # your source
        stream.enqueue(channel, datetime.now(timezone.utc), value)
```

Writing a value queues it, and doesn’t upload it. If uploads fall behind, a write can block until there’s room, so a slow network can slow the program that writes the data.[[3]](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#nominal-streaming-api) Keep these writes out of any loop that has to keep time. [Network performance](https://dev.nominal.io/learning/guides/network-performance.md#example-streaming-to-nominal) explains why.

## Further reading

- [Network performance](https://dev.nominal.io/learning/guides/network-performance.md), on bandwidth, latency and backpressure.
- [Time-series data](https://dev.nominal.io/learning/guides/time-series-data.md), on what the stored values look like.
- Nominal, [nominal-streaming](https://pypi.org/project/nominal-streaming/), the library the Nominal Python client streams through.

## References

---

[1]
([1](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#id1),[2](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#id3))

Nominal, `Dataset.get_write_stream` in the [nominal](https://pypi.org/project/nominal/) Python client, version 1.186.0: the `batch_size`, `max_wait` and `file_fallback` parameters. Retrieved 2026-11-30.

[[2](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#id2)]

Nominal, [nominal-streaming](https://pypi.org/project/nominal-streaming/) README, version 0.11.1. Retrieved 2026-11-16.

[[3](https://dev.nominal.io/learning/guides/telemetry-ingestion.md#id4)]

Nominal, `PyNominalStreamOpts` and `PyNominalDatasetStream.enqueue_batch` docstrings in [nominal-streaming](https://pypi.org/project/nominal-streaming/), version 0.11.0. Retrieved 2026-11-16.
