Thoughtful engineering.

How cloud providers can swap the server under your running VM

It may sound like magic but yeah cloud providers can move virtual machines between physical servers for maintenance and hardware upgrades.

One way to do this is to copy the VM memory etc. to the new machine while the virtual machine continues to run, and when most of the memory is across, the system stops the virtual machine for a few milliseconds, sends the remaining stuff, and starts it on the new server.

But this can be problematic when the virtual machine writes to memory faster than the system can copy it, ie. a page gets copied, then the virtual machine changes it, so the system must copy it again, this can repeat ad infinitum.

So another approach is, instead of waiting for all memory to arrive, the system starts the virtual machine on the new server immediately and marks every page that has not arrived yet as "missing", an unmapped page basically, and using a linux syscall called userfaultfd, it basically tells the kernel that if a page fault happens in this memory region, pause the faulting thread and tell me about it, I'll provide the page contents myself.

Now the virtual machine runs normally until it tries to read a missing page, when that happens, the kernel stops that operation, the VM asks the old server to send the page through the network, puts it in memory, and lets the operation continue.

The guest OS does not know that the data came from another machine, at the same time, the old server continues to send the remaining pages in the background. When all pages arrive, the migration is complete.


© 2026 Cirqwit  |  contact@cirqwit.com