FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

200 sensors, 17 million rows a day and one key that must be right

Settle the event schema, the edge protocol and the row key before writing code on a client's factory floor, because every wrong choice repeats tens of millions of times.

Neha Narkhede, co-founder of Confluent, gives the talk "The Many Faces of Apache Kafka: Leveraging Real-time Data at Scale" to an audience, with the title shown on two projection screens.
Photo: graysky. / CC BY 2.0
ShareLinkedInFacebookX

In brief

  • Kafka's documentation names collecting sensor data in factories as a use case. According to Kai Waehner, Kafka complements MQTT and OPC UA rather than competing with them.
  • Cassandra and Bigtable can both handle large volumes. The deciding factor is the row key, because Bigtable sorts every row by it.
  • IoT devices are easy to attack because they are always connected, so access to the plant network must be agreed before any work begins.
Horizontal bar chart: to answer the question of how a machine has fared over the past three weeks, a time-first key forces the system to scan 120,960,000 rows, while a device-first key needs to read only 604,800 rows.
With one week of data from 200 sensors reporting every second, a device-first key reads about 1/200 of the rows that a time-first key does. Source: the article's own calculation for a hypothetical factory with 200 sensors.

Take a production line with 200 sensors, each sending one reading per second. Multiply by the 86,400 seconds in a day and you have 17,280,000 records. At that volume, a wrong choice of storage key stops being a minor bug, because it repeats tens of millions of times a day.

Apache Kafka’s introductory documentation names this use case outright: continuously capturing and analyzing sensor data from IoT devices, in places such as factories or wind farms. An FDE working for manufacturing clients will sooner or later have to build a pipeline like this inside their plant.

What follows sketches that pipeline in five steps, from the sensor and the edge protocol through Kafka to the store. The aim is to settle the right design decisions before the first line of code is written on the client’s site; installing each component is a separate job.

What you will build, and what you need

The end result is a five-block diagram, an event schema, pseudocode for writing to Kafka and reading back out, and a row key design with a clear rationale. All code in this article is simplified pseudocode, tied to no particular library’s API.

You need to understand publish/subscribe, be able to read JSON and have a rough grasp of key/value NoSQL. Keep a sheet of scratch paper handy: the load calculation is the part newcomers skip most often.

Step 1: Know which sensors the plant has before writing code

IBM defines a sensor as a device that detects changes in its environment. In manufacturing, industrial IoT is used to monitor machine performance. So the first question on site is “which machines need watching, and which sensors measure them?”, well before anyone asks which Kafka version to run.

Build a sensor inventory with these columns: id, the machine it is attached to, the quantity measured, the unit, the send frequency and the protocol. This is the first thing to go through with the client’s operations engineers.

Check: every row in the table must have a send frequency. Without that column, you cannot calculate the load in step 5.

Step 2: Fix the shape of an event

Kafka defines event streaming as capturing data in real time from sources such as databases and sensors. Every reading will become an event, so normalize events from the start:

{
  "plant": "plant-a",
  "line": "line-3",
  "sensor_id": "temp-042",
  "metric": "temperature_c",
  "value": 71.4,
  "ts": "2026-10-09T08:00:01Z"
}

The unit is written into the metric name, and time uses a single consistent format. This is a design choice made for this article, not a mandatory standard. It does, however, prevent a classic mistake: two lines sending temperature in two different units without anyone noticing.

Check: looking at any event, you can tell at once which plant, line and sensor it came from and when it was measured.

Step 3: Let MQTT and OPC UA do the work at the edge

Kai Waehner, who writes widely on data streaming, argues that MQTT suits unreliable networks and limited bandwidth well. In his view, OPC UA suits industrial automation, and Kafka complements both protocols rather than competing with them.

In practice, you keep whatever protocol the client’s equipment already uses and add a bridging layer from MQTT or OPC UA into Kafka. Respecting the existing infrastructure wins the operations team’s trust faster than any architecture slide deck.

Check: the protocol column in the step 1 table now has a value for every sensor.

Step 4: Publish to Kafka, subscribe to write to the store

Kafka lets you publish (write) and subscribe to (read) streams of events. The writing side looks like this in pseudocode:

# Pseudocode, simplified
for message in mqtt_or_opcua_source:
    event = normalize(message)        # matches the schema from step 2
    publish(topic="sensor-readings", value=event)

The reading side subscribes to the same topic and writes to the store:

# Pseudocode, simplified
subscribe(topic="sensor-readings")
for event in stream:
    row_key = make_row_key(event)     # designed in step 5
    write(table="readings", key=row_key, value=event)

The normalize function is where units, time zones and missing fields get handled. Put all the cleaning logic there instead of scattering it across individual consumers.

Step 5: The row key is the most important decision

Bigtable is a distributed NoSQL database. Each table is a sorted key/value map, and each row is indexed by exactly one row key. Bigtable is used for both time-series and IoT data. Because rows are stored in key order, the way you build the row key determines which queries will be fast.

Key starts with time

  • 2026-10-09T08:00:01#temp-042
  • Every new write lands at the end of the key range
  • Suits questions about all sensors at one moment

Key starts with device

  • plant-a#line-3#temp-042#2026-10-09T08:00:01
  • One sensor's history sits in a single contiguous range
  • Suits questions like this machine's temperature over the past 24 hours

The reason lies in the table being sorted by key. If the key begins with time, every new record has a key larger than every existing one, so all writes pile up at the same end of the table.

The consequence follows directly: in a distributed system, that end of the table lives on one part of the cluster, so a single node carries almost all 17,280,000 writes a day while the others sit nearly idle. That is a write hotspot. Adding machines does not fix it, because new writes still converge on the same place.

When the key begins with the device instead, writes from the 200 sensors are spread across 200 separate key ranges. Each sensor’s history is also stored contiguously, and the question “how did machine X do last week?” needs to read just one key range.

The row key analysis above rests on Bigtable’s sorted-key model. If the client runs Cassandra, the project’s documentation says read and write throughput scale linearly as machines are added. Its masterless architecture lets Cassandra survive the loss of an entire data center without losing data, and failed nodes can be replaced with no downtime.

Those properties take care of scale; the key is still yours to design, following the same logic. One option (simplified) is a partition key made of sensor_id and the date, for example temp-042 + 2026-10-09, with rows inside each partition sorted by ts.

Each partition then holds exactly 86,400 readings from one sensor for one day, writes are spread evenly by sensor, and the question “machine 3 yesterday” touches only one partition.

Check: write down the three queries the client cares about most, then show exactly how your row key serves each one.

Mistakes that break the pipeline in the first week

The most common mistake is choosing the key by arrival order. Go back to the hypothetical plant from the start: a week produces 7 × 17,280,000 = 120,960,000 records, of which the sensor on machine 3 accounts for 604,800. The plant manager asks how machine 3 did over the past week.

With a time-first key, those 604,800 records are interleaved with data from the other 199 sensors. The system has to scan the whole range of 120,960,000 rows to filter out what it needs. With a device-first key, it is a single contiguous range.

The next mistake is skipping the load calculation. Multiply the number of sensors by the send frequency and the seconds in a day before sizing the cluster, rather than waiting until the system is already slow.

Nor should security be left for later. Because they are always connected to one another, IoT devices are vulnerable to intrusion and raise privacy concerns. Each time data is pulled out of the plant network, another way in is opened.

So before the first day on site, ask the client’s IT/OT team: which networks you may access, in which direction data is allowed to flow, and who approves changes. Your architecture has to follow those answers, and not the other way round.

How this skill shows up on client sites and in a CV

Clients ask why machine 3 keeps stopping and want to see its history. A good FDE turns that question into a row key, a topic and a sensor inventory, then takes those back to the operations engineers for discussion.

When reading job descriptions, look for the keywords IIoT, OPC UA, MQTT, time-series and streaming when they appear alongside “customer-facing”. In a CV, do not just write “used Kafka”. Describe the problem: how many sensors, how often they sent data, which row key you chose and why.

Without a real project, build one with simulated sensor data, complete with the load calculation and the reasoning behind the key design, and bring it to the interview. By the second week in the plant, the client needs someone who understands the machine producing the data, and has no use for another person who can only install software.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
6 sources
Read next on the roadmap · Stage 5: DeploymentA good model is useless if its predictions never reach the dashboardBI tools were built to describe the past, so model scores need their own output table, a Streamlit demo first and labels that keep them apart from actual figures.