DEV Community

Cover image for Why Cloud-First Event Check-ins Fail at 10k Scale And How We Built an Edge-First Alternative
stampiq
stampiq

Posted on

Why Cloud-First Event Check-ins Fail at 10k Scale And How We Built an Edge-First Alternative

If you have ever built an event registration or ticketing app, the default architecture usually looks clean on paper:

  1. Attendee shows a QR code on their phone.
  2. A scanner app hits a cloud REST API (POST /api/v1/checkin).
  3. An auth token is verified, PostgreSQL flips checked_in = true, and a 200 OK returns.
  4. Total round-trip time: ~180ms.

In staging, this works flawlessly. Even with synthetic loads of 500 req/sec across a few load balancers, everything stays green.

Then production happens at an enterprise expo center in Riyadh.

Within 40 minutes, 8,000 attendees arrive at once. Local cellular towers saturate instantly. The venue’s commercial fiber drops from 300 Mbps down to intermittent 2 Mbps bursts. Latency shoots from 180ms to 9 seconds, gateways start returning 504 Gateway Timeout, turnstiles stop opening, and the physical line stretches out the entrance.

Here is an architectural post-mortem on why cloud-first check-in fails under burst concurrency, and how we redesigned the physical gate stack around local edge nodes, SQLite WAL journaling, and passive UHF radio telemetry.


1. The Core Failure Mode: Synchronous Cloud Dependency

When physical gate hardware waits on a network handshake before actuating a barrier or firing a thermal print head, network latency dictates your physical throughput.

Consider the math:

  • At 200ms per scan, a single lane processes ~5 delegates per minute (ignoring human movement).
  • At 3,000ms latency (common when 4G/5G degrades under crowd density), that lane drops to fewer than 1.5 delegates per minute.
  • With 20 lanes and 6,000 delegates arriving between 8:15 AM and 8:45 AM, a queue of 2,000+ people forms within 12 minutes.

To guarantee zero wait time, the gate controller must never make a blocking remote network call during the transaction. The admission decision must happen strictly on local hardware in under 10 milliseconds.


2. The Edge Node: SQLite with Write-Ahead Logging (WAL)

Instead of thin clients polling a central DB, each gate lane runs a hardened Linux edge controller (e.g., an industrial SBC or embedded mini-PC) connected directly via RS-232/Ethernet to the thermal printer and RFID reader.

The local datastore is SQLite, configured specifically for concurrent high-throughput append operations.

Why SQLite WAL Mode?

By default, standard SQLite locks the database file on write transactions. When multiple processes (the QR scanner thread, the RFID reader daemon, and the background cloud sync worker) hit the database concurrently, rollback journals create thread locks.

Switching to WAL (Write-Ahead Logging) decouples reads from writes entirely:


sql
-- Edge node database initialization
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA busy_timeout = 5000;
PRAGMA cache_size = -32000; -- 32MB in-memory page cache
PRAGMA temp_store = MEMORY;

CREATE TABLE IF NOT EXISTS gate_transactions (
    id TEXT PRIMARY KEY,
    delegate_uuid TEXT NOT NULL,
    portal_id TEXT NOT NULL,
    credential_uid TEXT NOT NULL,
    scanned_at INTEGER NOT NULL,
    synced INTEGER DEFAULT 0
);

CREATE INDEX IF NOT EXISTS idx_sync_state ON gate_transactions(synced);
In WAL mode, writes append sequentially to the -wal companion file. 

Scans commit in less than 4ms, readers don't block writers, and writes don't block readers. 

Even if the venue power plug is pulled mid-write, SQLite recovery leaves the database fully consistent without corruption.   

3. Sub-3-Second Physical Credentials: EPC Gen 2 EncodingFor high-profile conferences, pre-printing thousands of badges beforehand creates logistical chaos: lost passes, last-minute VIP title edits, and human sorting delays.   

The fix is on-demand thermal issuance with concurrent RFID encoding:   [ Delegate Scans QR Pass ]
           │
           ▼
[ Local Edge SQLite Check (3ms) ] ──► Authorized
           │
     ┌─────┴─────────────────────────────────────┐
     ▼                                           ▼
[ Direct Thermal Print Head ]        [ Near-Field UHF Antenna ]
Renders badge canvas (300 DPI)       Encodes 96-bit EPC Gen 2 memory
           │                                     │
           └──────────────────┬──────────────────┘
                              ▼
           Badge ejected in < 2.8 seconds
As the thermal print engine feeds badge stock, a near-field UHF antenna programs the chip's EPC memory bank with an encrypted, cryptographically signed token. The chip’s factory TID (Tag Identifier) is married to the attendee record locally.   

This guarantees: No two delegates can share or duplicate physical passes.   The entire physical credential is created, written, and validated in under 3 seconds.   

4. Passive Telemetry: Replacing Manual Door Scans with UHF PortalsManual barcode scans at interior session doors create secondary queues outside keynote halls. If a session has 1,200 attendees, scanning each badge manually takes at least 15 minutes.   

To eliminate this, we deploy passive Ultra-High Frequency (UHF) overhead portals operating between 865–868 MHz (GCC band standards)[cite: 7, 12].                     ┌──────────────────────────────┐
                     │  Overhead UHF Portal Array   │
                     └──────────────┬───────────────┘
                                    │
               ┌────────────────────┴────────────────────┐
               ▼                                         ▼
      [ Polarized Beam: Zone A ]                [ Polarized Beam: Zone B ]
               │                                         │
    ┌──────────┴──────────┐                   ┌──────────┴──────────┐
    ▼                     ▼                   ▼                     ▼
[ Delegate 1 ]      [ Delegate 2 ]      [ Delegate 3 ]      [ Delegate 4 ]
(UHF Smart Badge)   (UHF Smart Badge)   (UHF Smart Badge)   (UHF Smart Badge)

Passive RF Backscatter: High-gain directional antennas broadcast an RF field across portal openings. As attendees walk naturally through the archway, passive inlays inside their badges harvest the RF energy, wake up, and backscatter their unique UID up to 8 meters away.   

Anti-Collision Framing: Using standard dynamic Q-algorithm arbitration (ISO 18000-6C), the portal interrogator resolves up to 400 distinct tag IDs per second simultaneously[cite: 12].

Automated Dwell Time Extraction: By recording exact entry and exit timestamps, we calculate genuine session attendance and sponsor booth dwell times without requiring attendees to stop[cite: 7, 12].

5. Event Telemetry & Conflict-Free Cloud SynchronizationWhen network connectivity drops, gates must keep working[cite: 12]. 

When connectivity restores, thousands of offline transactions must merge cleanly without primary key collisions or state overwrites[cite: 12].

We handle synchronization using a lightweight daemon running an exponential backoff loop:JavaScript// edge_sync_daemon.js
import Database from 'better-sqlite3';
import axios from 'axios';

const db = new Database('/var/data/gate_edge.db');

async function syncPendingRecords() {
  // Extract unsynced logs in small batches
  const unsynced = db.prepare(`
    SELECT id, delegate_uuid, portal_id, credential_uid, scanned_at 
    FROM gate_transactions 
    WHERE synced = 0 
    ORDER BY scanned_at ASC 
    LIMIT 200
  `).all();

  if (unsynced.length === 0) return;

  try {
    const res = await axios.post('[https://api.stampiq.sa/v1/telemetry/ingest](https://api.stampiq.sa/v1/telemetry/ingest)', {
      batch: unsynced,
      node_id: process.env.EDGE_NODE_ID
    }, { timeout: 4000 });

    if (res.status === 200) {
      const ids = unsynced.map(r => `'${r.id}'`).join(',');
      db.prepare(`UPDATE gate_transactions SET synced = 1 WHERE id IN (${ids})`).run();
    }
  } catch (err) {
    // Graceful silent fail: edge node keeps scanning locally
    console.warn(`[Sync] Uplink degraded (${err.code || err.message}). Buffering locally.`);
  }
}

// Polling interval decoupled from hardware scan threads
setInterval(syncPendingRecords, 3000);

Deterministic State MergingIdempotent Ingestion: The cloud ingestion endpoint enforces unique constraints on (delegate_uuid, portal_id, scanned_at). 

Duplicate delivery from retry timeouts is safely discarded.Timestamp Priority: Every transaction uses monotonic POSIX millisecond timestamps generated at the hardware read layer, eliminating server-side clock skew ambiguities.

Key TakeawaysPhysical hardware must never wait on cloud round-trips. Network degradation during high-density crowd ingress is a certainty, not an edge case[cite: 12].

Local edge persistence is essential. SQLite with WAL journaling provides ACID safety, microscopic write latency, and zero thread contention[cite: 12].

Passive radio protocols eliminate human choke points. Replacing barcode scans with passive UHF portals increases gate throughput by an order of magnitude[cite: 7, 12].

If you are designing high-concurrency event hardware or looking at field implementations in the GCC, you can check out how we architected this for the Humain Leap deployment at StampIQ.   
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
williamsj04 profile image
Jessica Williams •

Good post-mortem. Making the admission decision local in under 10 ms is the right rule, and the WAL settings are a useful reference. One thing I wondered about: if a pass is revoked in the cloud while a gate node is offline, how do you keep the node from admitting it? Do you push a small deny-list to the nodes ahead of the event?