| name | edge-computing |
| description | Edge computing architecture and implementation |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"architect, devops-engineer","category":"devops"} |
What I do
- Design edge computing architectures
- Deploy applications to edge locations
- Optimize for low-latency processing
- Implement edge-cloud hybrid solutions
- Configure content delivery at the edge
- Manage distributed edge infrastructure
When to use me
- When latency is critical for applications
- When processing IoT data streams
- When reducing bandwidth costs
- When operating in disconnected environments
- When implementing CDN with compute
- When building IoT platforms
Key Concepts
Edge Architecture
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ IoT │ │ Edge │ │ Cloud │
│ Devices │────►│ Node │────►│ Backend │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
│ ┌─────▼─────┐ │
│ │ Local │ │
└───────────►│ Storage │ │
└────────────┘ │
┌────────────┐ │
│ Analytics │ │
└────────────┘ │
Cloudflare Workers
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
const bucket = Math.random() < 0.5 ? 'a' : 'b'
const response = await fetch(request)
const headers = new Headers(response.headers)
headers.set('X-Edge-Bucket', bucket)
return new Response(response.body, {
status: response.status,
headers
})
}
export async function onRequest(context) {
const cache = await context.env.CACHE.get('data')
(cache) (cache)
response = ()
text = response.()
context...(, text, { : })
(text)
}
AWS Lambda@Edge
exports.handler = async (event) => {
const request = event.Records[0].cf.request
request.headers['strict-transport-security'] = [{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains'
}]
const country = request.headers['cloudfront-viewer-country'][0].value
if (country === 'EU') {
request.uri = '/eu' + request.uri
}
return request
}
Kubernetes at the Edge
apiVersion: v1
kind: Pod
metadata:
name: edge-node
spec:
nodeSelector:
node-type: edge
tolerations:
- key: "edge"
operator: "Equal"
value: "true"
effect: "NoSchedule"
containers:
- name: edge-app
image: edge-app:latest
resources:
limits:
cpu: "500m"
memory: "512Mi"
Edge Use Cases
- Video Processing: Transcoding, content moderation
- IoT Analytics: Real-time data filtering and aggregation
- AR/VR: Low-latency rendering
- Autonomous Vehicles: Immediate decision making
- Retail: Inventory management, personalized offers
- Healthcare: Remote monitoring, emergency alerts
Hybrid Edge-Cloud
apiVersion: core.kubefed.io/v1beta1
kind: KubeFedConfig
metadata:
name: kubefed
spec:
scope: Namespaced
controllerDuration:
availableDelay: 20s
unavailableDelay: 60s
leaderElect:
leaseDuration: 15s
renewDeadline: 10s
retryPeriod: 5s
resourceLock: configmaps
featureGates:
- name: PushReconciler
configuration: Enabled
- name: SchedulerPreferences
configuration: Enabled
Key Considerations
- Network connectivity and reliability
- Data sovereignty and compliance
- Resource constraints at edge nodes
- Security at edge locations
- Offline operation capability
- Synchronization with cloud