High-Performance Edge Architecture

IoT Telemetry
at the Edge

Combining Cloudflare Durable Objects with Cap'n Proto for sub-millisecond serialization at global scale

IoT Devices 10K+ endpoints Cap'n Proto Zero-Copy Serialize 0.8μs latency No parsing needed Durable Objects Stateful Edge Compute shard-01 4.2K msg/s shard-02 3.8K msg/s shard-03 5.1K msg/s shard-04 4.0K msg/s Storage Durable + SQLite
0
msgs/second
0
μs serialization
0
active shards
0
% smaller than JSON

Serialization Performance

JSON 12.4ms
Protocol Buffers 3.2ms
Cap'n Proto 0.8μs
Zero-copy: data is read directly without parsing

Live Telemetry Stream

telemetry-stream.capnp

Cap'n Proto Schema

@0xdbb9ad1f14bf495a;

struct TelemetryReading {
  deviceId @0 :Text;
  timestamp @1 :Int64;
  sensorType @2 :SensorType;
  value @3 :Float32;
  unit @4 :Text;
  location @5 :GeoPoint;
}

struct GeoPoint {
  lat @0 :Float64;
  lng @1 :Float64;
}

enum SensorType {
  temperature @0;
  humidity @1;
  pressure @2;
  motion @3;
}

Durable Object Class

export class TelemetryShard {
  private state: DurableObjectState;
  private storage: DurableObjectStorage;

  constructor(state: DurableObjectState) {
    this.state = state;
    this.storage = state.storage;
  }

  async fetch(request: Request) {
    const data = new CapnpReader(
      await request.arrayBuffer()
    );

    await this.storage.put({
      key: data.deviceId,
      value: data.serialize()
    });

    return new Response('OK');
  }
}

Why This Stack

Sub-millisecond Latency

Cap'n Proto requires no parsing step. Data is memory-mapped and read directly, enabling microsecond-level serialization.

Global Distribution

Durable Objects run at 300+ edge locations worldwide. Your telemetry data stays close to its source with automatic failover.

Stateful Coordination

Each Durable Object maintains its own state with strong consistency. Perfect for device aggregation and time-series windowing.

Cost Efficiency

Binary serialization is 60-80% smaller than JSON. Less bandwidth, lower egress costs, faster cold starts.

Type Safety

Schema-first design ensures all services agree on data structure. Breaking changes are caught at compile time.

Backward Compatible

Add new fields without breaking old clients. Cap'n Proto's evolutionary schema supports seamless versioning.