Solving Container Termination Issues at Scale
Key point
Replit fixed a slow container termination problem occurring in its preemptible VM environment, lowering session connection error rates and shortening boot times.
Details
Replit uses preemptible VMs for cost efficiency, which means it operates in an environment where instances are frequently terminated. Recently, users experienced long delays when connecting to sessions, and analysis revealed that container termination speed was very slow.
Replit's architecture works by having the browser connect via WebSocket to a Docker container inside a VM. Each VM runs conman (container manager), which manages the containers. When a VM is terminated, all containers must be completely destroyed before a new container can be started on another machine.
The investigation found that the docker kill command took far longer than expected during VM termination. A task that should normally complete in milliseconds took over 20 seconds when 100 to 200 containers were being terminated simultaneously at shutdown.
By solving this issue, Replit achieved the following results:
- Session connection error rate: reduced from 3% to under 0.5%
- 99th percentile (p99) session boot time: shortened from 2 minutes to 15 seconds
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.