50.1 Why Edge Computing
Problem with cloud-only IoT:
Device → Internet → Cloud → Process → Cloud → Internet → Device
Latency: 50–200ms+ (unacceptable for real-time control)
Bandwidth: Massive data volumes from sensors (cost + feasibility)
Connectivity: Remote locations have poor/no internet
Edge Solution:
Device → Edge Gateway → (Local Processing)
→ Alert actuator immediately (< 1ms)
→ Filter/aggregate → Cloud (batch)
→ Store locally during connectivity loss
50.2 AWS Greengrass (Edge Compute)
AWS Greengrass Features:
- Run Lambda functions locally on edge devices
- Local MQTT messaging between devices
- Stream Manager: buffer and batch data to cloud
- Shadow sync: keep device state in sync with AWS IoT Core
- ML Inference locally (SageMaker Edge)
- OTA (Over-the-Air) updates
Greengrass Deployment:
AWS Console/CLI → Greengrass Group → Edge Device
↓
Lambda functions, configs, ML models pushed to device
Edge processing patterns:
- Filter & Aggregate: send only anomalies/aggregates to cloud (e.g., 1-min average instead of 1-sec raw).
- Local ML inference: TensorFlow Lite/ONNX models running on-device for real-time prediction.
- Store & Forward: buffer locally during connectivity loss, replay on reconnect.
- Local Rules: trigger actuators from sensor readings without a cloud round-trip.
50.3 AWS IoT Core Architecture
Device SDK (C, Java, Python, JavaScript)
│
AWS IoT Core
├── Message Broker (MQTT/HTTPS/WebSocket)
├── Device Shadow (virtual representation of device state)
├── Rules Engine (SQL-like, routes to 20+ AWS services)
├── Device Registry (device metadata, groups)
├── Fleet Indexing (search across devices)
├── IoT Defender (security monitoring, anomaly detection)
└── IoT Events (detect and respond to events)
Device Shadow pattern:
{
"state": {
"reported": { "temperature": 23.5, "humidity": 65, "status": "online" },
"desired": { "setpoint": 22.0, "mode": "cooling" },
"delta": { "setpoint": 22.0 }
},
"metadata": {
"reported": { "temperature": { "timestamp": 1719340800 } }
},
"version": 42,
"timestamp": 1719340800
}
reported = what the device currently reports; desired = what the application wants; delta = the difference the device consumes to reconcile itself.
IoT Rules Engine example:
-- Route high-temperature readings and fan out
SELECT deviceId, temperature, humidity, timestamp
FROM 'factory/+/+/temperature'
WHERE temperature > 80
-- Action: → AWS Timestream (time series DB)
-- Action: → SNS Topic (alert if critical)
-- Action: → Lambda (custom processing)
-- Action: → Kinesis (stream processing)
-- Action: → S3 (raw data lake)
50.4 Azure IoT Hub (Comparable Capabilities)
| Capability | AWS IoT Core | Azure IoT Hub |
|---|---|---|
| Device-to-cloud messaging | MQTT/HTTPS/WebSocket broker | MQTT/AMQP/HTTPS |
| Device state sync | Device Shadow | Device Twin (reported/desired properties) |
| Rules/routing | IoT Rules Engine (SQL) | Message Routing + Stream Analytics |
| Edge runtime | AWS Greengrass | Azure IoT Edge (modules as Docker containers) |
| Security | X.509 certs, IoT Policies | X.509 / SAS tokens, Device Provisioning Service |
| Fleet provisioning | Fleet Provisioning / JITP | Device Provisioning Service (DPS) |
50.5 Q&A
Q1: Design an IoT solution for monitoring 10,000 industrial machines across 50 factories.
- Device Layer: industrial edge gateways (AWS Greengrass) at each factory connected to PLCs/SCADA via OPC-UA; local processing filters noise and aggregates before sending to cloud, reducing bandwidth and enabling sub-millisecond local safety alerting.
- Connectivity: MQTT over TLS to AWS IoT Core; each machine has a unique X.509 certificate; IoT Policies restrict each device to its own topic namespace.
- Platform: IoT Rules Engine routes to (1) Kinesis Streams for real-time ML inference, (2) Timestream for time-series storage, (3) S3 for raw data lake.
- Application: QuickSight dashboards for factory ops; SNS alerts for anomalies; a predictive-maintenance model trained on historical failure data generates maintenance recommendations 2–3 weeks ahead of predicted failure.
- Scale check: 10,000 machines × 10 sensors × 1 msg/sec = 100,000 msg/sec — well within Kinesis Data Streams capacity with appropriate shard count.