Distributed Atmospheric Monitoring System – Cloud Architecture, Module Implementation, and Cost Analysis
The paper describes Tencent’s community‑driven distributed atmospheric monitoring platform, detailing its multi‑layer cloud architecture, data ingestion and aggregation modules built with API Gateway, Serverless Functions, MySQL, and Cloud Map, and compares Phase II and Phase III operational costs while outlining future enhancements.
This article introduces a community‑driven, fine‑grained distributed atmospheric monitoring project initiated by Tencent. The goal is to build a system that monitors micro‑environment air quality at the neighborhood level using Tencent Cloud products and volunteer‑operated devices.
Architecture Overview (Phase II)
The system consists of several layers:
Deployment dimension: terminal devices at monitoring points and cloud‑side platform.
Functional dimension: logical separation of monitoring node, local gateway, IoT access layer, middleware layer, logic layer, storage layer, and presentation layer.
Key components include:
Monitoring nodes built on TencentOS tiny firmware, communicating via Tencent IoT Explorer.
Local gateway for protocol conversion.
IoT Explorer access layer that forwards data to API Gateway.
Middleware using API Gateway, authentication, flow control, and Serverless Cloud Functions.
Logic layer (Cloud Functions) for data ingestion, aggregation, and output.
Storage layer using TencentDB for MySQL.
Presentation layer using Tencent Cloud Map for map, list, and chart visualisation.
Data Structures
Data arrives at the cloud as a JSON payload from IoT Explorer. The raw event structure includes non‑body API‑Gateway metadata and a base64‑encoded body field containing the device data.
Example of the raw event JSON (kept intact):
{
"body": "{\"payload\":\"eyJtZXRob2QiOiJyZXBvcnQiLCJjbGllbnRUb2tlbiI6IjIwMjAtMDgtMThUMTE6MTc6NDkuNDAzWiIsInBhcmFtcyI6eyJQTTFfQ0YxIjo1LCJQTTJkNV9DRjEiOjYsIlBNMTBfQ0YxIjo3LCJQTTEiOjUsIlBNMmQ1Ijo2LCJQTTEwIjo3LCJwYXJ0aWNsZXNfMGQzIjo3OTIsInBhcnRpY2xlc18wZDUiOjI1NCwicGFydGljbGVzXzEiOjE1LCJwYXJ0aWNsZXNfMmQ1IjozLCJwYXJ0aWNsZXNfNSI6MywicGFydGljbGVzXzEwIjowLCJ2ZXJzaW9uIjoxNTEsIkVycm9yIjowfX0=\", \"seq\":18639, \"timestamp\":1597749469, \"topic\":\"$thing/up/property/?????/?????\", \"devicename\":\"?????\", \"productid\":\"?????\"}"
,
"headerParameters": {},
"headers": {
"accept-encoding": "gzip",
"content-length": "511",
"content-type": "application/json",
"endpoint-timeout": "15",
"host": "service-???-???.gz.apigw.tencentcs.com",
"user-agent": "Go-http-client/1.1",
"x-anonymous-consumer": "true",
"x-api-requestid": "???03a993936ae191f44651???",
"x-b3-traceid": "???03a993936ae191f44651???",
"x-qualifier": "$LATEST"
},
"httpMethod": "POST",
"path": "/??????",
"pathParameters": {},
"queryString": {},
"queryStringParameters": {},
"requestContext": {
"httpMethod": "POST",
"identity": {},
"path": "/??????",
"serviceId": "service-?????",
"sourceIp": "?.?.?.?",
"stage": "release"
}
}After base64 decoding, the payload contains fields such as PM1, PM2.5, particle counts, error code, and timestamps.
The database schema (see linked SQL file) includes tables for configuration, locations (space), devices (client), raw logs (base_data), aggregated data (aggregate_data), and temporary logs (temp_base_data).
Module Implementations
Data Ingestion: API Gateway + Serverless Cloud Function parses the IoT Explorer payload and writes to MySQL.
Terminal Online Update: Cloud Function triggered every 3 minutes to refresh terminal status for fast queries.
Data Statistics: Hourly and daily aggregation Cloud Functions compute summary metrics.
Data Interfaces: API Gateway + Cloud Functions expose endpoints for terminal summary and detail tables, consumed by Tencent Cloud Map.
Data Presentation: Web front‑end (Tencent Cloud Map) visualises map points, lists, and line charts.
Cost Analysis (Phase II vs Phase III)
Assuming 10 000 nodes reporting once per minute, the annual per‑node cloud cost is calculated as:
Phase II: (Database + Cloud Map / 10 000) + (API Gateway + Cloud Function / 4) ≈ 3.335 CNY per node per year.
Phase III (with message queue, additional storage, logs): ≈ 1.09 CNY per node per year.
Future Plans (Phase III)
Interaction optimisation: enable location table display.
Mobile support: add mini‑program for mobile queries and alert push.
Disaster‑recovery enhancements: object storage for backup, CKafka message queue, and log service for data reconciliation.
References include links to the full series, source code repositories, Tencent Cloud IoT Explorer, TencentOS tiny, API Gateway, Serverless Cloud Functions, TencentDB, and Tencent Cloud Map.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.