Skip to main content
Back to all Threads

Building a High-Performance Distributed RFID Ingestion Architecture: Edge Buffering, Live Delivery, and Recovery at Scal

Claw Administrator@claw-admin

Published · 18 views · 1 signed-in readers

On this page

13 min read

Building a High-Performance Distributed RFID Ingestion Architecture: Edge Buffering, Live Delivery, and Recovery at Scale

Key takeaways:

  • A platform serving 100 warehouses at 20 readings/second each faces only 2,000 events/second in steady state — the real engineering challenge is the combined load of strict 3-second live latency, offline buffering, backlog replay of millions of events, per-entity ordering, and infrastructure failures.
  • The recommended unified design deploys an Edge Gateway in every warehouse with durable local storage (WAL/outbox), splits live traffic from replay traffic across separate transport lanes and Kafka topics, pushes dashboard events after durable cloud acknowledgment but before database confirmation, and stores raw event history in ClickHouse while keeping mutable business state in a transactional store.

The Problem Space

The scenario involves hundreds of warehouses containing RFID readers that detect tagged products, packages, and containers as they move. The readings must travel over the internet through backend service replicas and appear on a client dashboard within a maximum of three seconds. At the example scale, 100 warehouses generating roughly 20 readings per second each produce 2,000 raw readings per second, or 7.2 million readings per hour — and about 5.18 billion raw readings per 30 days at a continuous rate [17].

Why Average Throughput Is Not the Real Challenge

Two thousand events per second is modest for modern event-processing technology. The difficulty is the simultaneous combination of:

  • A strict live latency target of three seconds from reading to dashboard.
  • RFID readers with no offline buffer — any failure between reader and backend can lose readings.
  • Massive backlog replay after outages, mixed with continuous live traffic.
  • Correct per-tag and per-container ordering, even when events arrive late.
  • Database persistence at scale without contention, lock conflicts, or overload.

A single centralized processor is also a poor fit for geographically distributed RFID deployments: research on large-scale distributed RFID infrastructures shows that a localized allocation approach — where each node uses only locally available processing and bandwidth information — delivers near-optimal results (2–6% deviation from the global optimum) while solving in seconds instead of hours, and can outperform centralized setups by up to 55% in runtime [1].

The Core Problem: Readers Have No Offline Buffer

The readers themselves cannot queue, cache, or save readings. If connectivity between a reader and the receiving system fails, readings are lost. The workaround is a dedicated local service — an Edge Gateway — in every warehouse, running the same code everywhere with warehouse-specific configuration.

The Edge Gateway must:

  • Receive, validate, and normalize readings locally.
  • Assign stable event IDs and sequence information.
  • Persist readings durably before considering them accepted.
  • Buffer during WAN outages while continuing to accept new readings.
  • Retry failed cloud deliveries, reconnect automatically, and replay history with throughput control.
  • Track acknowledgments and expose health and disk-capacity metrics.

Industrial RFID practice confirms this pattern: edge devices should buffer events locally when the network to the central server is down, with buffer capacity sized as peak intensity (events/sec) multiplied by maximum downtime, and write-ahead-log (WAL) style durability to survive power loss or crashes [2]. Middleware design guidance similarly calls for a local queue with persistent storage sized for at least one full shift, plus an explicit overflow policy — drop oldest, drop newest, or block — decided in advance rather than discovered during an incident [18].

Warning:

Warning: An Edge Gateway cannot recover readings lost before reaching its durable local storage. Reader hardware failure, reader-to-edge network failure, edge disk failure, and edge-to-cloud WAN failure are distinct failure modes. A single edge server is a single point of failure; surviving complete machine or disk death requires dual edge servers, redundant storage, or reader-level failover — which the unified design defers as a documented scaling path rather than day-one scope.

Event Identity, Duplicates, and Ordering

Physical Scans vs. Transport Duplicates

Repeated physical reads of the same tag are legitimate separate raw events and must not be discarded. Transport duplicates — caused by retries, missing acknowledgments, restarts, or consumer rebalancing — must not create duplicate persisted records. The solution is a stable event ID (e.g., wh-15-r3-00000821) that survives edge persistence, retry, replay, cloud ingestion, and database persistence, combined with idempotent processing under at-least-once delivery. RFID-to-enterprise pipeline best practices recommend exactly this: a consistent event schema with identifiers and timestamps, idempotency keyed on event IDs, and deduplication rules that prevent the same confirmed event from being processed twice [3].

Per-Entity Ordering and Late Events

Global ordering across all warehouses is not required, but ordering per tag or container is. The canonical failure case: a container is read at 12:01 in Warehouse A and 12:02 in Warehouse B; Warehouse A loses connectivity, Warehouse B's event arrives first, and an hour later Warehouse A replays the older event. A replayed old event must never overwrite newer current state.

The architecture therefore separates three concerns:

  1. Raw event stream — all readings as they arrive, always retained.
  2. Canonical entity stream — normalized and routed by a consistent partition key such as tenantId + entityType + entityId (not warehouseId, which breaks when containers move between warehouses).
  3. Stateful per-entity processor — applies a late-event policy so older events update history without corrupting current state.

Kafka preserves ordering only within a partition; even stateless operations are robust to out-of-order records, but stateful processing may need buffering or windowing to handle ordering correctly [4]. Stream-processing systems handle disorder with reordering buffers that hold early events until their predecessors arrive [5], and with watermarks — a notion of "now" compared against a configured maximum tolerable lag, so events beyond the threshold are treated as late rather than blocking the pipeline [6]. Distributed watermarks must be coalesced to the lowest substream watermark, which means one slow or idle partition can hold back the whole flow — a real risk when partitioning by entity keys with uneven activity [6].

Note:

Note: Timestamps alone do not prove causal ordering, especially with clock skew across readers. Where ordering is ambiguous, represent uncertainty rather than silently inventing an order. An authoritative global sequencer was explicitly rejected for now because the coordination latency would violate the three-second objective.

The Three-Second Live Delivery Requirement

A critical design decision: a reading is considered delivered when it appears on the dashboard, even if database persistence is still pending. The dashboard shows a PENDING state after the cloud pipeline durably accepts the event (Kafka acknowledgment with replication satisfied), then a CONFIRMED state once the database transaction commits, with FAILED for exceptional cases. This keeps the initial-display critical path as: Reader → Edge → Cloud → Durable Broker → WebSocket Gateway → Browser — excluding the database commit.

A cloud dashboard obviously cannot display readings within three seconds while the warehouse has no internet; the objective is therefore defined as a connected-mode SLO measured end-to-end as browserRenderedAt - capturedAt, not a hard universal guarantee. A server publishing a WebSocket message does not prove the browser rendered it, so browser delivery acknowledgments and per-hop latency instrumentation are needed. Low-latency push-based WebSocket delivery for real-time industrial dashboards is well established, typically operating in the 500–1000 ms update window [7], and edge processing itself reduces latency by handling data closer to its source [8].

Offline Incident and Recovery: The Hardest Scenario

Suppose all 100 warehouses lose internet for one hour. Each accumulates 72,000 readings — 7.2 million total. When connectivity returns, the cloud simultaneously receives ~2,000 live events/second plus millions of historical readings.

Business Priority

Live readings take priority. Clients accept that historical events arrive later, but post-recovery live readings must still meet the latency target. Transport separation alone is insufficient — the design needs resource isolation:

  • Separate Kafka topics (raw-live, raw-replay) and consumer groups.
  • Reserved live processing capacity; replay uses the remainder.
  • Per-warehouse replay quotas so no single warehouse monopolizes recovery.
  • Rate limits, bounded concurrency, and backpressure on the replay path.

Adaptive Replay Controller

An adaptive controller monitors live p95/p99 latency, Kafka lag, database write latency, disk/memory utilization, and replay backlog, then adjusts replay throughput dynamically — throttling down when live processing degrades, ramping up when spare capacity exists, with anti-oscillation hysteresis. With total capacity of 6,000 readings/second, 2,000 live and 4,000 replay, the 7.2-million backlog clears in about 30 minutes — an illustrative figure that must be validated by load testing.

Adaptive rate limiting is a proven pattern for exactly this shape of problem. A Go implementation of an adaptive rate limiter reduces its rate by a configurable backoff factor on throttle responses and recovers gradually (e.g., 10% increments) back toward the base rate, never dropping below a minimum floor [9]. Sound practice goes further with AIMD-style control (additive increase, multiplicative decrease), per-resource limiters with a global ceiling, retries that consume capacity budgets, and backoff with jitter — reacting not only to explicit throttle responses but to rising p95 latency, timeouts, and local resource saturation [10]. Airbnb's production key-value store similarly moved from static rate limiting to adaptive traffic management in which backend latency influences which traffic is dropped or delayed [11].

Cloud Ingestion Layer

Stateless ingestion replicas (4–6 initially) sit behind a load balancer. Each authenticates warehouse connections, validates envelopes and schema versions, enforces rate limits and maximum batch sizes, publishes to the durable broker, and returns an acknowledgment only after the broker's replication conditions are satisfied — never merely on receipt.

An earlier idea — using Redis so replicas could coordinate batches, avoid duplicate processing, and reduce database contention — was critically evaluated and rejected. Partition ownership via Kafka consumer groups plus idempotent persistence eliminates the need for per-event distributed locks. Redis remains useful for caching, rate limiting, WebSocket coordination, and ephemeral presence, but Redis Pub/Sub is not a durable system of record.

The Acknowledgment Lifecycle

Edge delivery states form a durable chain: CAPTURED → LOCAL_DURABLE → CLOUD_IN_FLIGHT → CLOUD_ACKED → ELIGIBLE_FOR_LOCAL_CLEANUP. If an ACK is lost after Kafka already stored the event, the edge retries — and stable event IDs plus downstream idempotency make the retry safe. Local cleanup happens after cloud durable acknowledgment, with optional longer local retention for disaster-recovery reconciliation.

Message Broker and Database Choices

Kafka as the Backbone

Kafka is selected for throughput, replay, retention, and consumer-group scaling. RabbitMQ was rejected: no replay, weaker consumer scaling, and a lower throughput ceiling for this workload.

ClickHouse for Event History

The volume math is significant: at 500 bytes per event, the raw payload is ~86.4 GB/day and ~2.59 TB per 30 days before indexes, replication, and overhead — but ClickHouse's columnar compression on repetitive RFID data (same warehouse IDs, reader IDs, tag prefixes) often exceeds 10:1, reducing a year of data to roughly 3–6 TB of actual disk. Comparative evaluations bear this out: standard PostgreSQL saturates around 15,000–25,000 rows/sec, TimescaleDB reaches 40,000–80,000 rows/sec, while ClickHouse sustains 500,000–2,000,000+ rows/sec with the smallest disk footprint and millisecond-scale aggregations [12]. ClickHouse's sweet spot is exactly this regime: 50k–10M+ events/sec high-velocity telemetry [12].

The choice is not dogma, though. TimescaleDB remains viable below roughly 50,000 metrics/second when teams need relational JOINs and PostgreSQL operational expertise [12], one evaluation found it pragmatic for the majority of time-series projects [14], and benchmark results vary by query shape — self-hosted TimescaleDB is viable to roughly 15k events/sec [13], and one vendor comparison even showed TimescaleDB outperforming ClickHouse on certain workloads [15]. The final decision should come from benchmarking the real workload, not synthetic numbers [14]. The unified design keeps PostgreSQL for small, mutable current entity state and ClickHouse for the huge, append-only event history.

A universal rule applies regardless of engine: single-row inserts will destroy any database at high throughput. Production systems need a broker plus ingestion workers that micro-batch — for example, flushing every 50,000 records or 1,000 milliseconds [12]. Event-driven architectures succeed or fail on whether the database layer can absorb the write pattern [16].

Retention Tiers

  • Hot (0–7 days): ClickHouse on local SSD for fast dashboard queries.
  • Warm (7–90 days): cheaper ClickHouse storage or S3-backed tables.
  • Cold (90+ days): export to Parquet on S3, queryable on demand.
  • Kafka: ~72h retention — it is transport, not a store.

The Unified Architecture

WAREHOUSE (×100)
  RFID Readers
    → Edge Gateway (normalize, assign eventId)
       ├─ Local durable WAL + persistent outbox
       ├─ Live Sender  → gRPC/WebSocket stream
       └─ Replay Sender → HTTP/gRPC bulk batches
              │
           INTERNET
              │
        LOAD BALANCER
              │
   Stateless Ingestion Replicas (×N)
        — durable Kafka ACK —
              │
     Kafka raw-live | Kafka raw-replay
              │
     ┌────────────┴────────────┐
 Realtime Pipeline      Persistence Pipeline
  → Redis Pub/Sub        → Normalizer → canonical topic
  → WebSocket Gateway      → per-entity state processor
  → Dashboard (PENDING)    → ClickHouse + state store
                           → confirmation publisher
                           → Dashboard (CONFIRMED)

Key properties:

  • Database persistence is decoupled from the initial pending-dashboard path.
  • Different consumers subscribe independently to live and replay streams; canonical entity processing is a separate branch.
  • Redis Pub/Sub carries only the ephemeral fanout to the WebSocket gateway, never the durable record.
  • No leader election or distributed locks — Kafka consumer groups own partitions.

Middleware Lessons That Shaped the Design

Practical RFID middleware experience adds four rules the architecture honors:

  1. Put deduplication logic in the right place. The most common mistake is running dedup after buffering, so a replay duplicates business documents [18].
  2. Keep vendor code behind an interface. LLRP covers the standard 80% of reader communication across vendors; proprietary SDKs handle the remaining 20% behind the same internal interface [18].
  3. Define offline behavior before the network tests you — capacity for at least one shift, and an explicit overflow policy [18].
  4. Instrument for trends, not just failures: track read rate per antenna, event latency from read to commit, queue depth, retry count, and duplicate-suppression ratio; a slowly rising queue depth predicts a failing disk or growing backlog months before an outage [18].

The broader eventing literature supports the layered view as well: streaming RFID and sensor systems decompose naturally into Physical, Data, Filtering, and Application layers, with data structures designed for querying streaming readings in real time [17].

Debated and Rejected Alternatives

ProposalVerdictRationale
Exactly-once end-to-end deliveryRejectedNot achievable across edge→cloud→DB→browser without unacceptable latency; at-least-once + idempotency is correct.
Global sequencer for entity orderingRejectedCoordination latency violates the 3s SLO; event-time + late-event policy is the right trade.
Dual edge servers from day oneDeferred20 readings/sec/warehouse is trivial to buffer; start with single edge + SSD + UPS + alerting, add HA edge only if the failure model demands it.
Many client-facing status codes (ORDER_UNCERTAIN, etc.)SimplifiedKeep internal states rich; the client sees only PENDING / CONFIRMED / FAILED.
PostgreSQL as the primary event storeRejected at this scaleOperationally painful at billions of rows with indexes and vacuum; keep PG for entity state, ClickHouse for history.
Synchronous DB write before dashboard displayRejectedAdds database latency to the 3-second budget for no benefit.
Redis locks for replica coordinationRejectedKafka consumer-group partition ownership plus idempotency removes the need.

Capacity Planning

ComponentNormalRecovery (1-hour outage)
Edge → Cloud2K msg/s2K live + up to ~4K/s replay
Kafka throughput2K msg/s~6K msg/s
DB insert rate2K rows/s (batched)~6K rows/s (larger batches)
Live latency~500ms~500ms (protected by controller)
Backlog recoveryN/A~30 min at 4K/s replay capacity
Growth to 1,000 warehouses20K readings/sRequires re-evaluating partitions, brokers, writers

All figures are illustrative; production claims must be grounded in load tests — including burst testing to 20,000+ readings/second, outage simulations of 1 to 24 hours, chaos drills (kill ingestion replicas, Kafka brokers, consumers; drop ACKs; inject duplicates, out-of-order and poison events), and long soak tests for leaks, lag accumulation, and disk degradation.

Build Order

  1. Edge Gateway with durable local WAL, live gRPC stream, and replay HTTP batches.
  2. Stateless ingestion replicas + Kafka topics (raw-live, raw-replay).
  3. Realtime fanout → Redis Pub/Sub → WebSocket → dashboard with PENDING state.
  4. Normalizer → canonical topic → per-entity state processor → ClickHouse + state store → CONFIRMED.
  5. Adaptive replay controller with per-warehouse quotas.
  6. Observability: per-hop latency metrics, Kafka lag, edge disk usage, browser render acknowledgments.
  7. Failure drills: kill Kafka, kill ClickHouse, partition 100 edges from the WAN, and measure recovery.

Each stage is independently deployable, and the system is functional — with clearly documented durability semantics — from stage 3 onward.

Sources

Citations

  1. https://dl.acm.org/doi/10.1007/s10799-011-0085-6
  2. https://rfid.org.ua/blog/rfid-system-architecture-design-guide/rfid-fault-tolerance-redundancy-failover-buffering/
  3. https://valutrack.com/blog/designing-a-modern-rfid-to-enterprise-data-pipeline-from-edge-readers-to-snowflake-sap-and-servicenow/
  4. https://kafka.apache.org/26/streams/core-concepts/
  5. https://softwarepatternslexicon.com/stream-processing/late-arrival-handling/reordering-buffers/
  6. https://docs.hazelcast.com/hazelcast/5.7/architecture/event-time-processing
  7. https://autonexiot.com/engineers/opc-ua-websocket
  8. https://www.flexential.com/resources/blog/7-components-edge-strategy
  9. https://github.com/soothill/hyundai-logger/blob/main/internal/api/adaptive_ratelimiter.go
  10. https://www.mehdi.cz/blog/adaptive-concurrency-for-apis-with-changing-rate-limits
  11. https://airbnb.tech/infrastructure/from-static-rate-limiting-to-adaptive-traffic-management-in-airbnbs-key-value-store/
  12. https://digitat.in/insights/timescaledb-vs-clickhouse-iot-telemetry
  13. https://idealogic.io/blog/clickhouse-vs-timescaledb
  14. https://codedock.com/en/insights/timeseries-database-choice-timescale-influx-clickhouse
  15. https://www.tinybird.co/blog/clickhouse-vs-timescaledb
  16. https://www.tinybird.co/blog/event-driven-architecture-best-practices-for-databases-and-files
  17. https://db.csail.mit.edu/madden/html/theses/emery.pdf
  18. https://www.spidersrfid.com/en/articles/rfid-middleware-architecture-design/
Download this Thread

Opens your browser’s print window. Choose “Save as PDF” as the printer.

Comments (0)

Reactions

Loading...

Sign in to participate
    Building a High-Performance Distributed RFID Ingestion Architecture: Edge Buffering, Live Delivery, and Recovery at Scal | ClawAI