Edge Computing Architecture
Design edge computing systems. Covers edge deployment patterns, IoT data processing, edge-cloud synchronization, latency optimization, offline-first architectures, and edge ML inference.
Edge computing processes data near the source — on factory floors, in retail stores, on vehicles, in cell towers — instead of sending everything to a centralized cloud. The motivations are concrete: a self-driving car can’t wait 100ms for a cloud API to decide whether to brake. A factory sensor generating 10GB per hour can’t afford the bandwidth costs of streaming to the cloud. A retail kiosk in a dead zone needs to work without internet.
This guide covers the architecture patterns for building edge computing systems that are reliable, secure, and manageable at scale.
Edge Computing Spectrum
← Lower latency More compute power →
┌──────────┐ ┌──────────┐ ┌────────────┐ ┌──────────────┐
│ Device │ │ Edge │ │ Regional │ │ Cloud │
│ Edge │ │ Gateway │ │ Edge │ │ (Centralized) │
├──────────┤ ├──────────┤ ├────────────┤ ├──────────────┤
│ Sensors, │ │ On-prem │ │ CDN PoPs, │ │ Full compute │
│ cameras, │ │ servers, │ │ 5G MEC, │ │ storage, │
│ actuators │ │ gateways │ │ wavelength │ │ analytics │
├──────────┤ ├──────────┤ ├────────────┤ ├──────────────┤
│ < 1ms │ │ 1-10ms │ │ 10-50ms │ │ 50-200ms │
│ latency │ │ latency │ │ latency │ │ latency │
└──────────┘ └──────────┘ └────────────┘ └──────────────┘
Edge Deployment Patterns
Pattern 1: Edge Filtering (Process Locally, Send Summaries)
# Industrial IoT: Process sensor data at edge, send only anomalies to cloud
import numpy as np
from collections import deque
class EdgeSensorProcessor:
def __init__(self, window_size=100, anomaly_threshold=3.0):
self.readings = deque(maxlen=window_size)
self.anomaly_threshold = anomaly_threshold
def process_reading(self, sensor_id, value, timestamp):
self.readings.append(value)
if len(self.readings) < 10:
return None # Insufficient data
mean = np.mean(self.readings)
std = np.std(self.readings)
z_score = abs(value - mean) / std if std > 0 else 0
if z_score > self.anomaly_threshold:
# Only send anomalies to cloud (reduces bandwidth 90%+)
return {
"type": "anomaly",
"sensor_id": sensor_id,
"value": value,
"z_score": round(z_score, 2),
"mean": round(mean, 2),
"std": round(std, 2),
"timestamp": timestamp,
}
# Periodically send aggregated summaries (every 5 min)
return None # Normal reading, process locally only
Pattern 2: Edge ML Inference
# Deploy lightweight ML model at edge for real-time classification
import onnxruntime as ort
import numpy as np
class EdgeMLInference:
def __init__(self, model_path="model.onnx"):
# Load quantized model (INT8 for edge deployment)
self.session = ort.InferenceSession(
model_path,
providers=["CPUExecutionProvider"],
)
self.input_name = self.session.get_inputs()[0].name
def predict(self, input_data):
"""Run inference locally — no cloud roundtrip needed."""
input_array = np.array(input_data, dtype=np.float32)
result = self.session.run(None, {self.input_name: input_array})
prediction = result[0]
confidence = float(np.max(prediction))
return {
"class": int(np.argmax(prediction)),
"confidence": round(confidence, 4),
"inference_time_ms": self._last_inference_time,
}
Pattern 3: Offline-First with Sync
// Edge application that works offline and syncs when connected
class OfflineFirstStore {
constructor() {
this.localDB = new IndexedDB("edge-store");
this.syncQueue = [];
this.isOnline = navigator.onLine;
window.addEventListener("online", () => this.syncToCloud());
window.addEventListener("offline", () => this.isOnline = false);
}
async write(record) {
// Always write locally first
const timestamped = {
...record,
_localTimestamp: Date.now(),
_synced: false,
_version: crypto.randomUUID(),
};
await this.localDB.put(timestamped);
if (this.isOnline) {
this.syncToCloud();
}
return timestamped;
}
async syncToCloud() {
const unsynced = await this.localDB.query({ _synced: false });
for (const record of unsynced) {
try {
const result = await fetch("/api/sync", {
method: "POST",
body: JSON.stringify(record),
headers: { "Content-Type": "application/json" },
});
if (result.ok) {
record._synced = true;
await this.localDB.put(record);
}
} catch {
break; // Network issue, retry later
}
}
}
}
Cloud Edge Services
| Service | Provider | Best For |
|---|---|---|
| AWS IoT Greengrass | AWS | IoT device management, local Lambda |
| Azure IoT Edge | Azure | Industrial IoT, containerized modules |
| GCP Distributed Cloud | GCP | Edge Kubernetes, retail/telecom |
| AWS Wavelength | AWS | 5G ultra-low latency |
| Azure Stack Edge | Azure | On-premises AI inference |
| CloudFlare Workers | Cloudflare | CDN-edge compute, global distribution |
Edge-Cloud Synchronization
| Pattern | Latency Tolerance | Consistency | Best For |
|---|---|---|---|
| Eventual sync | Minutes to hours | Eventually consistent | IoT telemetry, logs |
| Queue-based | Seconds | Ordered delivery | Transaction processing |
| CRDTs | Variable | Automatically resolved | Collaborative editing, counters |
| Change Data Capture | Seconds | Sequentially consistent | Database replication |
Anti-Patterns
| Anti-Pattern | Problem | Fix |
|---|---|---|
| Cloud-first fallback | Edge device useless without internet | Design offline-first, sync when possible |
| Sending raw data to cloud | Bandwidth costs explode | Filter, aggregate, and compress at edge |
| No remote management | Can’t update edge software remotely | OTA update mechanism from day one |
| Ignoring security | Edge devices are physically accessible | Hardware security modules, encrypted storage |
| Single edge architecture | Not all edges have same constraints | Tiered architecture: device → gateway → regional → cloud |
Checklist
- Edge tier defined: device, gateway, regional, or CDN edge
- Offline-first: application works without cloud connectivity
- Data filtering: only necessary data sent to cloud
- ML models optimized for edge (quantized, ONNX)
- Sync strategy: eventual consistency, conflict resolution defined
- Remote management: OTA updates, remote diagnostics
- Security: device identity, encrypted storage, secure boot
- Monitoring: edge health metrics, sync queue depth
- Bandwidth budget: edge-to-cloud data transfer limits set
- Fallback: graceful degradation when edge fails
:::note[Source] This guide is derived from operational intelligence at Garnet Grid Consulting. For edge computing consulting, visit garnetgrid.com. :::