Design a Virtual Machine Deployment System for a Fleet of Physical Hosts
Company: Crusoe
Role: Software Engineer
Category: System Design
Difficulty: easy
Interview Round: Onsite
Design a system that deploys virtual machines onto a fleet of physical servers. A user asks for a VM of a given machine type with a given disk image; the system chooses a host with enough free capacity, prepares the disk and the network, boots the VM, and reports when it is ready or why it failed. The report gives only the name of the problem, so the scale, the hardware types and the recovery guarantees are open: settle them with the interviewer before designing.
```hint Record intent before acting
Think about what the system should store when a request arrives, so that a crash halfway through a deployment can be resumed or cleaned up instead of leaving a half-built VM.
```
```hint Two requests, one host
Ask what happens when two deployments are placed on the last free capacity of the same host at the same moment.
```
### Clarifying Questions
- How many hosts and VMs, and how many deployment requests per second at peak? How quickly must a VM be ready?
- Do VMs need special hardware such as GPUs or local disks, and must some VMs be placed together or kept apart?
- How large are the images, where are they stored, and can hosts cache them?
- Are VMs deployed one at a time, or in groups that must all start together?
- When a host fails, should its VMs be restarted elsewhere, or only reported as lost?
- Are host maintenance and live migration in scope?
### What a Strong Answer Covers
- Requirements and scale estimates agreed before the design
- A control plane that stores the desired state of each VM durably and drives the actual state toward it
- Placement: filtering and scoring hosts, reserving capacity without double booking, and packing versus spreading
- Host agents and the VM lifecycle: image fetch and caching, disk and network setup, boot and readiness checks
- Failure handling: idempotent steps, retries, timeouts, host failure detection, and safe rescheduling
- Observability, and how the deployment system itself is scaled and upgraded safely
### Follow-up Questions
- A request asks for a group of VMs that must all start together or not at all. How do you place and boot them?
- Many hosts boot VMs from the same new image at once. How do you keep image distribution from becoming the bottleneck?
- A host stops sending heartbeats but may still be running its VMs. How do you decide whether to restart them elsewhere?
- How would you drain a host for maintenance without interrupting the VMs on it?
Overview: A system design question asking for a service that deploys virtual machines onto a fleet of physical hosts. It tests placement and capacity reservation, the VM lifecycle on host agents, image distribution, failure detection with safe rescheduling, and host maintenance.