iot-edge-computing-designer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Edge Computing Designer

边缘计算设计师

Workflow

工作流程

1. Évaluation des contraintes

1. 约束条件评估

Avant toute architecture, répondre à ces questions :
CritèreEdge obligatoire si…
Latence< 50 ms requis pour l'action locale
Bande passante> 10 MB/s de données brutes en continu
Disponibilité réseauCoupures > 1 h/jour ou sites isolés
ConformitéDonnées ne peuvent pas quitter le site (RGPD, données industrielles)
Coût cloudTraitement brut trop coûteux à envoyer (vidéo HD, capteurs HF)
在进行任何架构设计前,需先回答以下问题:
评估标准需采用边缘计算的场景
延迟本地操作要求延迟<50毫秒
带宽持续产生>10MB/s的原始数据
网络可用性每日断网时长>1小时或处于偏远站点
合规性数据不得离开本地站点(如GDPR、工业数据合规要求)
云端成本原始数据上传至云端处理成本过高(如高清视频、高频传感器数据)

2. Découpage edge / fog / cloud

2. 边缘/雾计算/云端分层设计

[Capteurs] → [Edge node] → [Fog gateway] → [Cloud]
               ↓ inférence       ↓ agrégation    ↓ analytics
               ↓ filtrage        ↓ buffer         ↓ modèles ML
               local < 10 ms     local < 500 ms   batch
  • Edge node : Raspberry Pi 5, NVIDIA Jetson Orin, Coral Dev Board, PLC industriel
  • Fog gateway : x86 mini-PC, routeur industriel (Moxa, Advantech)
  • Cloud : AWS Greengrass hub, Azure IoT Hub, GCP Cloud IoT (ou on-prem)
Règle d'affectation : si la décision doit se prendre en < 100 ms ou si la donnée n'a pas de valeur au-delà du site, elle reste en edge. Tout le reste monte au cloud.
[Capteurs] → [Edge node] → [Fog gateway] → [Cloud]
               ↓ inférence       ↓ agrégation    ↓ analytics
               ↓ filtrage        ↓ buffer         ↓ modèles ML
               local < 10 ms     local < 500 ms   batch
  • Edge node : Raspberry Pi 5, NVIDIA Jetson Orin, Coral Dev Board, PLC industriel
  • Fog gateway : x86 mini-PC, routeur industriel (Moxa, Advantech)
  • Cloud : AWS Greengrass hub, Azure IoT Hub, GCP Cloud IoT (ou on-prem)
分配规则 : 若决策需在<100毫秒内完成,或数据离开本地站点后无价值,则保留在边缘层处理;其余数据上传至云端。

3. Sélection matérielle

3. 硬件选型

Charge de calcul faible  → Raspberry Pi 5 (8 Go) + Coral USB Accelerator
Vision par ordinateur    → NVIDIA Jetson Orin NX (16 Go, 100 TOPS)
Industrie / -40°C/+85°C → Advantech MIC-720AI ou Moxa V2406C
Ultra-faible conso       → ESP32-S3 (inférence ML embarquée, ~240 MHz)
Checklist matérielle :
  • Température opérationnelle compatible avec le site
  • Stockage suffisant pour le buffer offline (min. 24 h de données)
  • Watchdog hardware pour redémarrage automatique
  • Interface réseau redondante (LTE + Ethernet)
Charge de calcul faible  → Raspberry Pi 5 (8 Go) + Coral USB Accelerator
Vision par ordinateur    → NVIDIA Jetson Orin NX (16 Go, 100 TOPS)
Industrie / -40°C/+85°C → Advantech MIC-720AI ou Moxa V2406C
Ultra-faible conso       → ESP32-S3 (inférence ML embarquée, ~240 MHz)
硬件选型Checklist :
  • 工作温度适配部署站点环境
  • 具备足够的离线缓存存储(至少可存储24小时数据)
  • 配备硬件看门狗以实现自动重启
  • 具备冗余网络接口(LTE + 以太网)

4. Architecture offline-first

4. 离线优先架构设计

Toute application edge doit persister localement avant d'envoyer au cloud.
Pattern Store-and-Forward avec SQLite :
python
import sqlite3, time, requests

DB = "/data/edge.db"

def init_db():
    with sqlite3.connect(DB) as cx:
        cx.execute("""
            CREATE TABLE IF NOT EXISTS queue (
                id INTEGER PRIMARY KEY,
                payload TEXT,
                created_at REAL,
                sent INTEGER DEFAULT 0
            )
        """)

def enqueue(payload: str):
    with sqlite3.connect(DB) as cx:
        cx.execute("INSERT INTO queue (payload, created_at) VALUES (?,?)",
                   (payload, time.time()))

def flush_to_cloud(endpoint: str):
    with sqlite3.connect(DB) as cx:
        rows = cx.execute(
            "SELECT id, payload FROM queue WHERE sent=0 ORDER BY id LIMIT 100"
        ).fetchall()
        if not rows:
            return
        ids = [r[0] for r in rows]
        batch = [r[1] for r in rows]
        try:
            requests.post(endpoint, json=batch, timeout=10)
            cx.execute(f"UPDATE queue SET sent=1 WHERE id IN ({','.join('?'*len(ids))})", ids)
        except Exception:
            pass  # retry au prochain cycle
Gestion des conflits : utiliser des timestamps logiques (Lamport clock) ou des CRDTs pour les données métriques. Pour les commandes, FIFO strict + idempotency key.
所有边缘应用必须先将数据本地持久化,再上传至云端。
基于SQLite的存储转发模式:
python
import sqlite3, time, requests

DB = "/data/edge.db"

def init_db():
    with sqlite3.connect(DB) as cx:
        cx.execute("""
            CREATE TABLE IF NOT EXISTS queue (
                id INTEGER PRIMARY KEY,
                payload TEXT,
                created_at REAL,
                sent INTEGER DEFAULT 0
            )
        """)

def enqueue(payload: str):
    with sqlite3.connect(DB) as cx:
        cx.execute("INSERT INTO queue (payload, created_at) VALUES (?,?)",
                   (payload, time.time()))

def flush_to_cloud(endpoint: str):
    with sqlite3.connect(DB) as cx:
        rows = cx.execute(
            "SELECT id, payload FROM queue WHERE sent=0 ORDER BY id LIMIT 100"
        ).fetchall()
        if not rows:
            return
        ids = [r[0] for r in rows]
        batch = [r[1] for r in rows]
        try:
            requests.post(endpoint, json=batch, timeout=10)
            cx.execute(f"UPDATE queue SET sent=1 WHERE id IN ({','.join('?'*len(ids))})", ids)
        except Exception:
            pass  # retry au prochain cycle
冲突处理 : 使用逻辑时间戳(Lamport clock)或CRDT处理指标数据;对于指令类数据,采用严格FIFO + 幂等键。

5. Synchronisation cloud

5. 云端同步

bash
undefined
bash
undefined

MQTT avec rétention locale — Eclipse Mosquitto + store-and-forward

MQTT avec rétention locale — Eclipse Mosquitto + store-and-forward

mosquitto.conf : persistence true persistence_location /var/lib/mosquitto/ queue_qos0_messages true max_queued_messages 10000
mosquitto.conf : persistence true persistence_location /var/lib/mosquitto/ queue_qos0_messages true max_queued_messages 10000

Publier avec QoS 1 (at-least-once) pour garantie de livraison

Publier avec QoS 1 (at-least-once) pour garantie de livraison

mosquitto_pub -h broker -t "site/sensor/temp" -m '{"v":42.1}' -q 1

Delta sync : n'envoyer que les changements significatifs (dead-band filtering).

```python
DEAD_BAND = 0.5  # °C

last_sent = None
def should_send(value):
    global last_sent
    if last_sent is None or abs(value - last_sent) >= DEAD_BAND:
        last_sent = value
        return True
    return False
mosquitto_pub -h broker -t "site/sensor/temp" -m '{"v":42.1}' -q 1

增量同步 : 仅发送显著变化的数据(死区过滤)。

```python
DEAD_BAND = 0.5  # °C

last_sent = None
def should_send(value):
    global last_sent
    if last_sent is None or abs(value - last_sent) >= DEAD_BAND:
        last_sent = value
        return True
    return False

6. Déploiement de modèles ML en edge

6. 边缘ML模型部署

bash
undefined
bash
undefined

Convertir un modèle PyTorch → TFLite optimisé

Convertir un modèle PyTorch → TFLite optimisé

python -c " import torch, torch.onnx model.eval() torch.onnx.export(model, dummy_input, 'model.onnx', opset_version=17) "
python -c " import torch, torch.onnx model.eval() torch.onnx.export(model, dummy_input, 'model.onnx', opset_version=17) "

Quantiser en INT8 pour Coral / Jetson

Quantiser en INT8 pour Coral / Jetson

tflite_convert
--saved_model_dir=./saved_model
--output_file=model_quant.tflite
--optimizations=DEFAULT
--inference_input_type=INT8
--inference_output_type=INT8
tflite_convert
--saved_model_dir=./saved_model
--output_file=model_quant.tflite
--optimizations=DEFAULT
--inference_input_type=INT8
--inference_output_type=INT8

Inférence ONNX Runtime (edge x86/ARM)

Inférence ONNX Runtime (edge x86/ARM)

import onnxruntime as ort sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"]) result = sess.run(None, {"input": data})

Cible : modèle < 5 MB, inférence < 20 ms sur CPU ARM Cortex-A55.
import onnxruntime as ort sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"]) result = sess.run(None, {"input": data})

目标 : 模型体积<5MB,在ARM Cortex-A55 CPU上推理延迟<20毫秒。

7. OTA et orchestration de flotte

7. 空中升级(OTA)与设备集群编排

bash
undefined
bash
undefined

Mender.io — déploiement OTA signé avec rollback automatique

Mender.io — déploiement OTA signé avec rollback automatique

mender-artifact write rootfs-image
--device-type raspberry-pi-5
--artifact-name firmware-2.4.1
--file rootfs.img
--output-path firmware-2.4.1.mender
mender-artifact write rootfs-image
--device-type raspberry-pi-5
--artifact-name firmware-2.4.1
--file rootfs.img
--output-path firmware-2.4.1.mender

Vérification d'intégrité post-déploiement (health check)

Vérification d'intégrité post-déploiement (health check)

mender install firmware-2.4.1.mender && mender commit || mender rollback

Alternatives : Balena Fleet (containers), AWS Greengrass v2, Azure IoT Edge modules.

**Règle OTA** : déployer en canary (5 % de la flotte → 48 h de monitoring → 100 %). Ne jamais mettre à jour bootloader et application en même artefact.
mender install firmware-2.4.1.mender && mender commit || mender rollback

替代方案 : Balena Fleet(容器化部署)、AWS Greengrass v2、Azure IoT Edge模块。

**OTA规则** : 采用金丝雀发布(先部署到5%的设备→监控48小时→全量部署)。切勿将引导加载程序与应用程序打包在同一个升级包中。

8. Sécurité edge

8. 边缘安全

bash
undefined
bash
undefined

Boot sécurisé Raspberry Pi (config.txt)

Boot sécurisé Raspberry Pi (config.txt)

program_usb_boot_mode=0
program_usb_boot_mode=0

+ HAT TPM2.0 pour stockage de clés

+ HAT TPM2.0 pour stockage de clés

Chiffrement partition données

Chiffrement partition données

cryptsetup luksFormat /dev/mmcblk0p3 cryptsetup open /dev/mmcblk0p3 data_enc mkfs.ext4 /dev/mapper/data_enc
cryptsetup luksFormat /dev/mmcblk0p3 cryptsetup open /dev/mmcblk0p3 data_enc mkfs.ext4 /dev/mapper/data_enc

mTLS entre edge et cloud (certificats x.509)

mTLS entre edge et cloud (certificats x.509)

mosquitto_pub --cafile ca.crt --cert edge.crt --key edge.key
-h broker -p 8883 -t "data" -m "payload"

Checklist sécurité :
- [ ] Certificats uniques par appareil (pas de clé partagée)
- [ ] Rotation des certificats automatisée (< 1 an)
- [ ] Firewall local : seuls ports MQTT (8883) et SSH (via bastion) ouverts
- [ ] Logs tamper-evident (append-only, hash chaîné)
mosquitto_pub --cafile ca.crt --cert edge.crt --key edge.key
-h broker -p 8883 -t "data" -m "payload"

安全Checklist :
- [ ] 每个设备使用唯一证书(禁止共享密钥)
- [ ] 自动证书轮换(周期<1年)
- [ ] 本地防火墙:仅开放MQTT(8883)和SSH(通过堡垒机)端口
- [ ] 防篡改日志(仅追加、链式哈希)

9. Monitoring distribué

9. 分布式监控

yaml
undefined
yaml
undefined

Prometheus Node Exporter sur chaque edge node

Prometheus Node Exporter sur chaque edge node

prometheus.yml (scrape depuis fog gateway)

prometheus.yml (scrape depuis fog gateway)

scrape_configs:
  • job_name: 'edge_nodes' static_configs:
    • targets: ['192.168.1.10:9100', '192.168.1.11:9100'] scrape_interval: 30s
scrape_configs:
  • job_name: 'edge_nodes' static_configs:
    • targets: ['192.168.1.10:9100', '192.168.1.11:9100'] scrape_interval: 30s

Alerte Grafana : nœud silencieux depuis > 5 min

Alerte Grafana : nœud silencieux depuis > 5 min

alert: EdgeNodeDown expr: up{job="edge_nodes"} == 0 for: 5m

Métriques indispensables : CPU/mémoire/température, taille de la queue locale, latence d'inférence, dernière synchronisation réussie.

---
alert: EdgeNodeDown expr: up{job="edge_nodes"} == 0 for: 5m

必备监控指标 : CPU/内存/温度、本地队列大小、推理延迟、最后一次成功同步时间。

---

Anti-patterns et pièges

反模式与常见陷阱

Anti-patternConséquenceCorrectif
Tout envoyer au cloud brutSaturation bande passante, coût x10Dead-band filtering + agrégation locale
Pas de buffer offlinePerte de données à la moindre coupureStore-and-forward systématique
Mise à jour sans rollbackFlotte brickée à distanceMender/Balena avec commit/rollback
Certificat partagé entre nodesCompromission = toute la flotteUn certificat x.509 par appareil
Modèle ML non quantiséInférence > 500 ms, impossible temps-réelTFLite INT8 ou ONNX avec optimisations
Logs en mémoire seulePerte au reboot, diagnostic impossibleÉcriture sur stockage persistant
NTP absent sur edgeTimestamps incohérents, conflits de sync
chrony
ou PTP obligatoire sur chaque node
反模式后果修正方案
原始数据全部上传至云端带宽饱和、成本飙升10倍死区过滤 + 本地数据聚合
无离线缓存机制网络中断时丢失数据强制采用存储转发模式
升级无回滚机制远程设备集群变砖使用Mender/Balena等支持提交/回滚的工具
设备共享证书单个设备泄露导致整个集群沦陷为每个设备分配独立X.509证书
ML模型未量化推理延迟>500毫秒,无法满足实时要求使用TFLite INT8或带优化的ONNX模型
日志仅存储在内存中重启后丢失日志,无法排查问题将日志写入持久化存储
边缘节点无NTP服务时间戳不一致,同步冲突每个节点必须部署
chrony
或PTP服务

Bonnes pratiques 2026

2026年最佳实践

  • WebAssembly en edge : WASM + WASI pour déployer du code portable sur n'importe quel runtime edge (Wasmtime, WasmEdge) — isolation sandbox sans conteneur lourd.
  • tinyML : modèles < 256 KB pour microcontrôleurs (TensorFlow Micro, Edge Impulse) — inférence sur ESP32 sans OS.
  • Matter / Thread : protocole standard pour la couche réseau IoT locale (2026) — préférer à Zigbee propriétaire pour l'interopérabilité.
  • Edge AI lifecycle : versionner les modèles edge comme du code (DVC + MLflow) et tracer chaque version déployée par appareil.
  • eBPF sur gateway Linux : filtrage de paquets et observabilité réseau sans overhead kernel pour les passerelles Fog.
  • 边缘WebAssembly:使用WASM + WASI在任意边缘运行时(Wasmtime、WasmEdge)部署可移植代码——无需重型容器即可实现沙箱隔离。
  • tinyML:针对微控制器的<256KB模型(TensorFlow Micro、Edge Impulse)——无需操作系统即可在ESP32上运行推理。
  • Matter / Thread:2026年本地IoT网络层标准协议——优先于私有Zigbee协议以实现互操作性。
  • 边缘AI生命周期管理:像管理代码一样对边缘模型进行版本控制(DVC + MLflow),并追踪每个设备部署的模型版本。
  • 雾网关eBPF:在Linux网关上使用eBPF进行数据包过滤和网络观测,无需内核开销。

Communication Rules — MANDATORY

沟通规则 — 强制执行

  • Ultra-concise. No filler, no preamble, no pleasantries.
  • Never say "happy to help", "sure!", "great question", "let me", or similar.
  • Tool first, talk second. Act before explaining.
  • Result first. Lead with outcome, not process.
  • Stop when done. No summary, no recap, no trailing commentary.
  • No politeness wrappers. Direct and blunt.
  • Minimum words. If one word works, do not use ten.
  • No unsolicited explanations.
  • No emoji unless asked.
  • 极致简洁。无冗余内容、无开场白、无客套话。
  • 禁止使用“很高兴帮忙”、“没问题!”、“好问题”、“让我…”等表述。
  • 工具优先,沟通其次。先行动再解释。
  • 结果优先。先给出结果,而非过程。
  • 完成即停止。无需总结、回顾或额外评论。
  • 无客套修饰。直接、坦率。
  • 用词极简。能用一个词就不用十个词。
  • 不主动解释。
  • 除非要求,否则不使用表情符号。