Situation
Outsourced browser cloud providers introduced high latency, network timeouts, and annual licensing costs exceeding $120,000. Additionally, parallel execution nodes on shared VMs frequently crashed due to unmonitored Chrome memory leaks consuming system Swap space.
Task
Architect an in-house bare-metal browser grid infrastructure capable of managing 10,000 concurrent browser sessions with strict hardware process isolation and zero cross-session session state leakage.
Action
- HAProxy Dynamic Routing Layer: Configured HAProxy as an ingress load balancer that analyzed Incoming WebDriver HTTP commands and routed session IDs (
/session/{id}) dynamically to healthy downstream Linux worker nodes. - Kernel Resource Fencing: Implemented Linux
cgroupsto restrict each headless browser process to 512MB RAM and 1 CPU core, forcibly terminating rogue processes before they starved neighboring execution threads. - Ephemeral Xvfb Instance Recycling: Wrote a background daemon in Python that killed and re-spawned virtual framebuffer displays (
Xvfb :display_id) every 50 sessions to reclaim leaked memory buffers.
Result
- Saved $120,000/year in third-party vendor licensing costs.
- Achieved 99.8% session initiation reliability across 10,000 parallel test runs.