Chrome Cluster on K8s: Memory Config, /dev/shm, and Graceful Shutdown
200-500MB per instance, /dev/shm requirements, WebSocket long connections, graceful shutdown — K8s native resource management breaks for browser instances.
16Yun Engineering TeamApr 28, 20261 min read
Browsers vs Normal Services
Difference 1: Uneven Memory
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "1Gi"
cpu: "1000m"A blank page: 150MB. A complex SPA: 500MB+. Same instance, different tasks — 3x memory variance.
Difference 2: /dev/shm
Chrome needs shared memory for inter-process communication. Default /dev/shm is 64MB. Chrome often needs 256MB-512MB:
volumes:
- name: dshm
emptyDir:
medium: Memory
sizeLimit: "512Mi"Difference 3: Process Cleanup
spec:
terminationGracePeriodSeconds: 60
containers:
- name: chrome
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- |
curl -s -X PUT http://localhost:9222/json/close 2>/dev/null || true
pkill -f "chrome" || trueResource Configuration
| Task Type | Memory Request | Memory Limit | Notes |
|---|---|---|---|
| Simple page | 256Mi | 512Mi | Static pages |
| Medium SPA | 512Mi | 1Gi | React/Vue |
| Complex SPA | 1Gi | 2Gi | Heavy JS |
| Multi-tab | 2Gi | 4Gi | Shared browser |
HPA Configuration
Use queue depth, not CPU:
triggers:
- type: rabbitmq
metadata:
queueName: browser-tasks
queueLength: "5"Node Selection
Use memory-optimized instances (AWS r6i series). Don't mix browser Pods with other services on the same Node.
Summary
Key points for browser clusters on K8s:
- /dev/shm must be explicitly sized
- Memory requests/limits depend on task type
- Graceful shutdown needs extended terminationGracePeriodSeconds + preStop hook
- HPA should use queue depth, not CPU/memory
- Node isolation — separate browser Pods from other services
Need an enterprise proxy plan?
We can tailor architecture to your target domains, concurrency, and reliability goals.