Edge computing is a technology that significantly reduces latency and enables real-time processing by performing data processing close to users and devices. In 2025, with the spread of 5G/6G and the evolution of AI, edge computing has entered a new phase.
Basic Concepts of Edge Computing
Architecture Comparison
flowchart TB
subgraph Traditional["Traditional Cloud Architecture"]
Cloud1["Central Cloud<br/>(100ms+ latency)"]
D1["Device"]
D2["Device"]
D3["Device"]
D1 --> |Internet| Cloud1
D2 --> |Internet| Cloud1
D3 --> |Internet| Cloud1
end
flowchart TB
subgraph EdgeArch["Edge Computing Architecture"]
Cloud2["Central Cloud<br/>(Data aggregation & analysis)"]
E1["Edge Node<br/>(10-50ms)"]
E2["Edge Node<br/>(10-50ms)"]
E3["Edge Node<br/>(10-50ms)"]
ED1["Device (<5ms)"]
ED2["Device (<5ms)"]
ED3["Device (<5ms)"]
ED1 --> E1
ED2 --> E2
ED3 --> E3
E1 --> Cloud2
E2 --> Cloud2
E3 --> Cloud2
end
Latency Comparison
| Processing Location | Typical Latency | Use Cases |
|---|---|---|
| On-device | < 1ms | Real-time control |
| Edge node | 5-50ms | AR/VR, gaming |
| Regional DC | 50-100ms | Video streaming, API |
| Central cloud | 100-300ms | Batch processing, analysis |
Key Trends in 2025
1. 5G/6G Convergence
With the full deployment of 5G, MEC (Multi-access Edge Computing) has entered practical use.
# 5G MEC Configuration Example
network:
5g_core:
upf: # User Plane Function
deployment: edge
latency_target: 10ms
mec_platform:
location: base_station
capabilities:
- video_analytics
- ar_rendering
- game_streaming
applications:
- name: autonomous_driving
latency_requirement: 1ms
bandwidth: 1Gbps
- name: industrial_iot
latency_requirement: 5ms
reliability: 99.9999%
2. Proliferation of Edge AI Inference
# Edge AI inference example (ONNX Runtime)
import onnxruntime as ort
import numpy as np
class EdgeAIInference:
def __init__(self, model_path: str):
# Edge optimization options
sess_options = ort.SessionOptions()
sess_options.graph_optimization_level = (
ort.GraphOptimizationLevel.ORT_ENABLE_ALL
)
sess_options.intra_op_num_threads = 4
# Select available providers
providers = ['TensorrtExecutionProvider', # NVIDIA GPU
'CUDAExecutionProvider',
'CoreMLExecutionProvider', # Apple Silicon
'CPUExecutionProvider']
self.session = ort.InferenceSession(
model_path,
sess_options=sess_options,
providers=providers
)
def predict(self, input_data: np.ndarray) -> np.ndarray:
"""Low-latency inference"""
input_name = self.session.get_inputs()[0].name
return self.session.run(None, {input_name: input_data})[0]
# Usage: Image classification (< 10ms)
edge_model = EdgeAIInference("mobilenet_v3.onnx")
result = edge_model.predict(preprocessed_image)
3. WebAssembly Edge Runtime
// Wasm edge function example (Cloudflare Workers compatible)
use worker::*;
#[event(fetch)]
async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
// Get request geo information
let cf = req.cf();
let country = cf.country().unwrap_or("Unknown");
let colo = cf.colo(); // Edge location
// Data processing at edge
let body = req.text().await?;
let processed = process_at_edge(&body);
// Access to KV store (edge cache)
let kv = env.kv("CACHE")?;
kv.put(&cache_key, &processed)?
.expiration_ttl(3600)
.execute()
.await?;
Response::ok(format!(
"Processed at {} ({})",
colo, country
))
}
fn process_at_edge(data: &str) -> String {
// Execute lightweight processing at edge
data.to_uppercase()
}
Major Platform Comparison
Cloud Vendor Edge Services
| Vendor | Service Name | Features |
|---|---|---|
| AWS | Lambda@Edge, Outposts | CloudFront integration, on-prem support |
| Azure | IoT Edge, Stack Edge | AI integration, hybrid |
| Google Cloud | Distributed Cloud Edge | Anthos-based, 5G integration |
| Cloudflare | Workers | WebAssembly, global |
| Fastly | Compute@Edge | VCL compatible, low latency |
AWS Lambda@Edge Implementation Example
// Lambda@Edge function (CloudFront integration)
import {
CloudFrontRequestEvent,
CloudFrontResponseEvent,
Context
} from 'aws-lambda';
// Processing on origin request
export const originRequest = async (
event: CloudFrontRequestEvent,
context: Context
) => {
const request = event.Records[0].cf.request;
// A/B test routing
const experimentGroup = getExperimentGroup(request);
if (experimentGroup === 'B') {
request.origin = {
custom: {
domainName: 'experiment-b.example.com',
port: 443,
protocol: 'https',
path: '',
sslProtocols: ['TLSv1.2'],
readTimeout: 30,
keepaliveTimeout: 5,
customHeaders: {}
}
};
}
return request;
};
// Processing on origin response
export const originResponse = async (
event: CloudFrontResponseEvent
) => {
const response = event.Records[0].cf.response;
// Add security headers
response.headers['strict-transport-security'] = [{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubdomains; preload'
}];
response.headers['content-security-policy'] = [{
key: 'Content-Security-Policy',
value: "default-src 'self'"
}];
return response;
};
function getExperimentGroup(request: any): string {
const cookies = request.headers.cookie || [];
// Cookie parsing logic
return Math.random() < 0.5 ? 'A' : 'B';
}
Cloudflare Workers D1 Database
// Edge SQL (D1) usage example
export interface Env {
DB: D1Database;
}
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url);
if (url.pathname === '/api/products') {
// SQL execution at edge
const { results } = await env.DB.prepare(`
SELECT id, name, price, stock
FROM products
WHERE category = ?
ORDER BY popularity DESC
LIMIT 20
`).bind(url.searchParams.get('category'))
.all();
return Response.json(results, {
headers: {
'Cache-Control': 'public, max-age=60',
},
});
}
if (url.pathname === '/api/analytics') {
// Aggregation processing at edge
const stmt = env.DB.prepare(`
INSERT INTO page_views (path, timestamp, country)
VALUES (?, datetime('now'), ?)
`);
const cf = request.cf as { country?: string };
await stmt.bind(url.pathname, cf?.country || 'Unknown').run();
return new Response('OK');
}
return new Response('Not Found', { status: 404 });
},
};
Edge Computing Use Cases
1. Autonomous Vehicles
flowchart TB
subgraph Vehicle["In-Vehicle Edge"]
Sensors["Camera / LiDAR / Radar"]
AI["AI Module<br/>(<10ms)"]
Control["Control Module"]
Output["Steering / Accel / Brake"]
Sensors --> AI --> Control --> Output
end
subgraph Roadside["Roadside Edge Node"]
R1["Traffic signal optimization"]
R2["Nearby vehicle information aggregation"]
R3["Danger prediction & warning distribution"]
end
subgraph Cloud["Cloud"]
CL1["Map data updates"]
CL2["Machine learning model training"]
CL3["Large-scale traffic analysis"]
end
Vehicle --> |V2X Communication| Roadside --> Cloud
2. Industrial IoT (IIoT)
# Industrial edge gateway implementation example
import asyncio
from dataclasses import dataclass
from typing import List, Optional
import json
@dataclass
class SensorReading:
sensor_id: str
value: float
timestamp: float
unit: str
class IndustrialEdgeGateway:
def __init__(self):
self.alert_thresholds = {
'temperature': {'min': -10, 'max': 85},
'vibration': {'max': 10.0},
'pressure': {'min': 0.5, 'max': 10.0}
}
self.local_buffer: List[SensorReading] = []
async def process_sensor_data(
self,
reading: SensorReading
) -> Optional[dict]:
"""Real-time processing at edge"""
# 1. Anomaly detection (immediate judgment)
alert = self._check_anomaly(reading)
if alert:
# Send emergency alert immediately
await self._send_alert(alert)
return alert
# 2. Data aggregation (buffering)
self.local_buffer.append(reading)
# 3. Periodic cloud sync
if len(self.local_buffer) >= 100:
await self._sync_to_cloud()
return None
def _check_anomaly(self, reading: SensorReading) -> Optional[dict]:
"""Local anomaly detection"""
sensor_type = reading.sensor_id.split('_')[0]
threshold = self.alert_thresholds.get(sensor_type)
if not threshold:
return None
if 'max' in threshold and reading.value > threshold['max']:
return {
'type': 'HIGH_ALERT',
'sensor': reading.sensor_id,
'value': reading.value,
'threshold': threshold['max']
}
if 'min' in threshold and reading.value < threshold['min']:
return {
'type': 'LOW_ALERT',
'sensor': reading.sensor_id,
'value': reading.value,
'threshold': threshold['min']
}
return None
async def _send_alert(self, alert: dict):
"""Immediate alert sending"""
print(f"ALERT: {json.dumps(alert)}")
# Actually send via MQTT/WebSocket
async def _sync_to_cloud(self):
"""Cloud sync of buffered data"""
data = self.local_buffer.copy()
self.local_buffer.clear()
# Compress and send to cloud
print(f"Syncing {len(data)} readings to cloud")
3. AR/VR Streaming
// Distributed AR rendering processing at edge
interface ARRenderRequest {
devicePose: {
position: [number, number, number];
rotation: [number, number, number, number];
};
fov: number;
resolution: [number, number];
}
interface ARRenderResponse {
frame: ArrayBuffer;
timestamp: number;
latency: number;
}
class EdgeARRenderer {
private edgeNodes: Map<string, EdgeNode> = new Map();
async selectOptimalNode(
userLocation: GeolocationPosition
): Promise<EdgeNode> {
// Latency-based node selection
const nodes = Array.from(this.edgeNodes.values());
const latencies = await Promise.all(
nodes.map(async (node) => ({
node,
latency: await this.measureLatency(node)
}))
);
return latencies.reduce((best, current) =>
current.latency < best.latency ? current : best
).node;
}
async renderFrame(
node: EdgeNode,
request: ARRenderRequest
): Promise<ARRenderResponse> {
const start = performance.now();
// Render on edge node
const response = await fetch(`${node.url}/render`, {
method: 'POST',
body: JSON.stringify(request),
headers: {
'Content-Type': 'application/json',
},
});
const frame = await response.arrayBuffer();
const latency = performance.now() - start;
// Maintain under 20ms (threshold for comfortable AR experience)
if (latency > 20) {
console.warn(`High latency: ${latency}ms`);
}
return {
frame,
timestamp: Date.now(),
latency,
};
}
private async measureLatency(node: EdgeNode): Promise<number> {
const start = performance.now();
await fetch(`${node.url}/ping`);
return performance.now() - start;
}
}
interface EdgeNode {
id: string;
url: string;
region: string;
capabilities: string[];
}
Edge Security
Zero Trust Edge
# Edge Security Policy
security:
authentication:
method: mTLS
certificate_rotation: 24h
authorization:
model: ABAC # Attribute-Based Access Control
policies:
- name: sensor_data_access
subjects:
- type: device
attributes:
device_type: sensor
firmware_version: ">=2.0"
resources:
- type: api
path: /data/*
actions: [POST]
conditions:
- time_range: "00:00-23:59"
- rate_limit: 1000/hour
encryption:
at_rest: AES-256-GCM
in_transit: TLS 1.3
monitoring:
anomaly_detection: enabled
log_retention: 7d
alert_channels:
- slack
- pagerduty
Edge Firewall
// Edge WAF implementation example
interface WAFRule {
id: string;
pattern: RegExp;
action: 'block' | 'log' | 'challenge';
category: string;
}
const wafRules: WAFRule[] = [
{
id: 'sqli-001',
pattern: /(\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION)\b.*\b(FROM|INTO|WHERE)\b)/i,
action: 'block',
category: 'SQL Injection'
},
{
id: 'xss-001',
pattern: /<script[^>]*>[\s\S]*?<\/script>/i,
action: 'block',
category: 'XSS'
},
{
id: 'path-001',
pattern: /\.\.[\/\\]/,
action: 'block',
category: 'Path Traversal'
}
];
async function edgeWAF(request: Request): Promise<Response | null> {
const url = new URL(request.url);
const body = await request.text();
const checkTargets = [
url.pathname,
url.search,
body,
...Array.from(request.headers.values())
];
for (const rule of wafRules) {
for (const target of checkTargets) {
if (rule.pattern.test(target)) {
console.log(`WAF blocked: ${rule.category} (${rule.id})`);
if (rule.action === 'block') {
return new Response('Forbidden', { status: 403 });
}
}
}
}
return null; // Pass request through
}
Implementation Best Practices
1. Proper Workload Placement
flowchart TB
Start["Latency requirement < 50ms?"]
RealTime["Real-time processing needed?"]
LargeData["Large data volume?"]
DeviceEdge["Process on device/edge"]
EdgeCache["Utilize edge cache"]
EdgeCloud["Pre-process at edge → Analyze in cloud"]
CloudOnly["Process entirely in cloud"]
Start -->|YES| RealTime
Start -->|NO| LargeData
RealTime -->|YES| DeviceEdge
RealTime -->|NO| EdgeCache
LargeData -->|YES| EdgeCloud
LargeData -->|NO| CloudOnly
Recommended Placement:
| Processing Location | Suitable Workloads |
|---|---|
| Device | Sensor control, immediate response |
| Edge node | AI inference, data aggregation, cache |
| Cloud | Training, long-term storage, analysis |
2. Failure Handling and Fallback
// Edge fault tolerance implementation
class ResilientEdgeClient {
private primaryEdge: string;
private fallbackEdges: string[];
private cloudEndpoint: string;
constructor(config: EdgeConfig) {
this.primaryEdge = config.primaryEdge;
this.fallbackEdges = config.fallbackEdges;
this.cloudEndpoint = config.cloudEndpoint;
}
async request<T>(path: string, options: RequestInit): Promise<T> {
// 1. Try primary edge
try {
return await this.fetchWithTimeout(
`${this.primaryEdge}${path}`,
options,
5000 // 5 second timeout
);
} catch (e) {
console.warn('Primary edge failed, trying fallback');
}
// 2. Try fallback edges
for (const edge of this.fallbackEdges) {
try {
return await this.fetchWithTimeout(
`${edge}${path}`,
options,
5000
);
} catch (e) {
continue;
}
}
// 3. Fallback to cloud as last resort
console.warn('All edges failed, falling back to cloud');
return await this.fetchWithTimeout(
`${this.cloudEndpoint}${path}`,
options,
30000 // Longer timeout for cloud
);
}
private async fetchWithTimeout<T>(
url: string,
options: RequestInit,
timeout: number
): Promise<T> {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);
try {
const response = await fetch(url, {
...options,
signal: controller.signal,
});
return await response.json();
} finally {
clearTimeout(timeoutId);
}
}
}
Summary
Edge computing is rapidly developing in the following areas in 2025:
- 5G/6G Integration: Achieving ultra-low latency through MEC
- Edge AI: Proliferation of on-device inference processing
- WebAssembly: Cross-platform edge runtime
- Security: Application of zero trust architecture
Points to Consider for Implementation
- Clarify latency requirements
- Consider data confidentiality and regulatory requirements
- Design appropriate role division with cloud
- Prepare fallback strategy for failures
Edge computing has become an essential architecture for applications requiring real-time processing and distributed computing.