IMD SolutionComputing LibraryShop main store

Explainer

Why high frequency data logging fails at the database write rate

Edge computing and IIoT Published 8 min read

Short answer

Data every 250 µs means capturing the sensor at 4,000 samples per second, not writing the database that often. No general-purpose path — Node-RED point by point or OPC UA subscriptions — sustains that write rate, so capture near the I/O with buffering and commit bulk batches every few seconds. The article shows the arithmetic and how to find the layer dropping samples.

On this page
  1. What the requirement splits into
  2. Why the direct write path breaks first
  3. Working the numbers for one 4-20 mA channel at 250 µs
  4. Capture, buffer, bulk write: the architecture that holds
  5. What the bus cycle decides
  6. Finding which layer drops the samples
  7. Retention is a deletion schedule, not a speed setting
  8. The decision
  9. Questions asked

A request for new data every 250 µs fails when it is read as a database requirement, because that interval is 4,000 samples per second for one value, and no general-purpose write path — a Node-RED flow writing point by point, an OPC UA subscription, an untuned InfluxDB — sustains it. Read it instead as two separate rates. Capture the sensor at the required rate close to the I/O, hold the samples in a buffer, and commit them to the database as bulk arrays every few seconds. This article gives the arithmetic that converts an interval into rates, batch sizes and buffer sizes, shows where the common paths break, and how to tell which layer is dropping the samples when the stored trace looks wrong.

What the requirement splits into #

"Add new data every 250 µs" can mean three different things, and each one lands on different hardware and software:

  • Acquisition — the input card must convert the 4–20 mA signal every 250 µs. This is decided by the card's conversion behavior and the controller's bus cycle, not by anything in the database.
  • Write cadence — every sample must be committed to the database on that interval as an individual write. This is the interpretation that breaks, and the one to push back on.
  • Retention — the customer's one-day window only schedules deletion of old records. It moves neither the capture rate nor the write throughput.

Clarify which one the customer means before selecting anything. In most vibration, burst, or transient-logging projects the requirement is capture and storage, not a live per-sample commit; the database cadence is an implementation detail nobody actually asked for.

Why the direct write path breaks first #

Three stages sit between the sensor and a stored point, and each adds its own pacing.

The database. A long-standing response on the InfluxDB issue tracker puts a reasonably well-tuned server near 10,000 points per second and stresses batching: sending single points costs far more per point than sending arrays. Untuned, or loaded with tags, queries and other buckets writing at the same time, the sustainable rate is lower still. That 10,000 points per second is a reported figure for a tuned server, not a guarantee for your instance — measure it on the target hardware before you design against it.

The flow runtime. A Node-RED path turns every sample into a message, runs it through the flow's function nodes, and issues a write. At the required rate that is thousands of messages and HTTP round trips per second for a single value, before any dashboard or second tenant shares the server.

The subscription. The OPC UA specification defines the sampling interval as the fastest rate at which the server should sample its underlying source — a request, not a promise. The server samples at what its bus and CPU allow, a value-change subscription only conveys changes the server actually sampled, and the publishing interval adds its own pacing on top. Two consecutive samples with the same value coalesce into one notification, so intermediate samples vanish by design. That is correct subscription behavior, and it disqualifies the subscription path for no-loss capture at a fixed interval.

Working the numbers for one 4-20 mA channel at 250 µs #

Inputs. The interval is 250 µs per sample, the customer's stated requirement. The channel count is one 4–20 mA value, the single sensor named for the project. Retention is one day, the customer's storage window. The flush interval is 5 s — an example choice you tune against tolerated latency.

Rule in words. Required sample rate equals one divided by the interval. Batch size equals the sample rate multiplied by the flush interval. Stored volume equals the sample rate multiplied by the retention window in seconds.

Arithmetic.

  • 1 s ÷ 0.000250 s = 4,000 samples per second for the one channel.
  • Batch size: 4,000 × 5 = 20,000 samples per flush.
  • Stored volume: 86,400 s × 4,000 = 345,600,000 samples held at any moment under the one-day window.

Decision. A point-per-write path must sustain 4,000 individual writes per second — roughly 40% of the 10,000 points per second a well-tuned server reportedly manages, before your tags, dashboards and a second channel take their share; a second channel pushes the requirement past that figure outright. The batch path asks for one write of 20,000 samples every 5 s, comfortably inside the same budget. Commit to buffered capture with bulk writes; do not wire the flow point by point. Scale the same three multiplications by channel count as the project grows — the aggregate rate, not the interval, is what sizes the buffer, the batches and the storage.

Capture, buffer, bulk write: the architecture that holds #

The practical chain has four stages, each with its own job:

  1. Capture at the I/O. The input card or the controller's real-time data layer samples at the required interval. Whether this is achievable is a property of the card, the bus cycle and the release — verify it on the exact hardware, not from a product family name.
  2. Buffer. Hold samples between flushes in memory sized as rate × channels × longest outage. Buffer sizing works the same way as sizing an edge PC for oversampled PLC data to InfluxDB: compute the aggregate rate first, then leave headroom.
  3. Bulk write. Push the buffered array to the database in one operation per flush. Each sample keeps its own timestamp from the moment it was captured, so the stored trace preserves the original timing even though the writes arrive seconds later.
  4. Verify. Confirm a known spike appears in the database with the expected timestamp before declaring the chain lossless.

For this class of controller, the path described as lossless runs from Telegraf inside the controller, sampling the real-time data layer and writing to InfluxDB directly — not over OPC UA from an external PC, which inherits the subscription semantics described above. A direct data-layer-to-InfluxDB feature was also announced for a future release; treat every such statement as release-specific and verify the release notes and your exact hardware before designing around it. If the collector must run off the controller anyway — for instance on a hardware-independent HMI machine — put it on a fanless mini PC rated for cabinet mounting and give it the same buffer sizing.

When the project grows to many channels, the aggregate rate becomes the sizing input, and the same reasoning as in how tag count and write rate drive historian database sizing applies: total points per second, not tag count alone, decides what one database instance absorbs.

What the bus cycle decides #

Before any software runs, the controller's fieldbus cycle caps what the acquisition can see. The EtherCAT master documentation for the controller family discussed here lists a minimum bus cycle time of 500 µs, and a 250 µs cycle was described as a target for a later release. On current hardware, then, the fastest the controller observes the 4–20 mA loop is every 500 µs — half the requested rate — and no database, retention or dashboard change removes that ceiling. To hit the requested interval, confirm with the vendor the exact controller, I/O card and release that support it, and test at the expected channel count under the expected application load before quoting the capability to the customer.

Finding which layer drops the samples #

When the stored trace looks wrong, compare timestamps stage by stage. A database timestamp cannot reconstruct a sample the input or transport never delivered.

What you see Layer to suspect Decisive check
Stored points come slower than the source should capture Input card, bus cycle, or controller release Read the card's sampling behavior and the bus-cycle documentation for the exact controller and release
Source timestamps dense, database points sparse Subscription, flow, or write path Count points and compare timestamps after each stage, source to database
Records arrive in bursts, late, or with gaps Buffering or batch transfer Check batch size, flush interval and queue depth during a deliberate network interruption
Fast spikes missing, steady values correct Sampling or change-notification semantics Capture the signal at the source side and compare with the delivered values

Separate a timing fault from an electrical one first: if the value is wrong or unstable at the controller itself, inspect the 4–20 mA loop, wiring and card configuration before tuning any database software.

Retention is a deletion schedule, not a speed setting #

A one-day window answers "how long do we keep it", not "how fast can we take it". Shortening retention does not raise the capture rate or the write throughput, and lengthening it does not slow either down; it only changes when old records are removed. Set retention from the customer's analysis window, size the storage from the sample rate and channel count, and never tune timing by touching retention.

The decision #

  • Values change slowly (single-digit hertz logging of temperatures, levels, states): the direct path — flow to database, point per write — is fine; nothing here applies.
  • Capture at 250 µs is the requirement: capture near the I/O with buffering on the card or in the controller, bulk-write arrays every few seconds, size the buffer as rate × channels × longest outage, and verify the exact controller, card and release can sample at that interval first.
  • A database write every 250 µs is the requirement: redesign it into the capture-plus-batch shape above. No general-purpose write path sustains individual commits at that rate, and the stored data ends up identical anyway — the batch path just arrives in arrays instead of one point at a time.

One safety boundary sits around all of this: keep the logging chain out of the control path. Capture copies of the signal; never let a buffer, a flush interval or a database outage delay or gate the loop that actually runs the machine.

Questions asked

Does setting a one-day retention make the database faster?

No. Retention only schedules deletion of old records. It sets neither how fast the acquisition runs nor how many points per second the database accepts. A short window can even hide a fault: once records expire, a broken write path becomes invisible a day after you stop watching. Fix throughput by batching writes, and keep retention long enough to debug a failure.

How big does the buffer have to be?

Multiply the required sample rate by the channel count and by the longest outage you must survive. For one channel at 4,000 samples per second and a 60 second database outage, the buffer needs 240,000 samples; at 16 channels that is 3,840,000. Keep it in the controller or on-card memory where the vendor supports it, and flag or drop data when the buffer fills rather than overwrite silently.

Is an OPC UA subscription a lossless way to move this data?

Not by itself. The OPC UA specification describes the sampling interval as the fastest rate at which the server should sample its source — a request, bounded by what the server and its bus cycle actually do — and publishing intervals and reconnects add their own gaps. The lossless subscription discussed for this class of controller runs from Telegraf inside the controller straight to InfluxDB, not over OPC UA from an external PC.

What flush interval should the bulk write use?

Balance latency against batch size. At a 5 second flush the worked example writes 20,000 samples per batch; at 1 second the batches are five times smaller and the database handles five times more write operations. Choose the longest interval the application tolerates, keep the buffer able to hold at least two flush intervals of samples, and test the flush during a deliberate network interruption.

Keep reading

  • Comparison

    Historian-like data logging on a restricted edge network

    On a restricted plant network the approved destination decides the architecture: write directly from Node-RED to the database when that connection is approved, publish MQTT and land it in InfluxDB with Telegraf when only a broker is approved, and capture to local files when nothing outbound is allowed. Whatever the path, prove store-and-forward with an outage test sized from your tag count and write period.

    Edge computing and IIoT

  • Explainer

    How tag count and write rate drive historian database sizing

    A historian database size is rows per day times measured bytes per row times retention days. Rows per day come from tags with history enabled and their write interval; a max-age heartbeat sets a floor and pruning sets a cap. In the worked example, 2,000 tags at a 10-second rate with 365-day retention need about 492 GB, while the same tags held only by a 20-minute heartbeat need about 4.1 GB.

    Edge computing and IIoT

  • Selection guide

    Sizing an edge PC for oversampled PLC data to InfluxDB

    Yes — the database side carries it. 50 samples every 2 ms is 25,000 values per second, reaching InfluxDB as 2.5 writes per second at the documented 10,000-line batch, about 0.38 MB each. What decides the project is the controller's 2 ms buffer handshake and line serialization — no vendor rates that path in bytes per second, so each stage is proven on the box with a synthetic signal before a sensor is wired.

    Edge computing and IIoT

Tag historian not logging zero: deadband and max time decide