hot clone a living Linux service

chen steven asked:

We need to hot clone a linux service when it’s alive, not just because of we can’t reboot or something, it’s just because of our special scenario.
(yeah, I’ve already read this answer, but it’s a little bit different from mine Clone a working Linux server)

We have a calculation node, u can say an NLP calculating Node which is running some models on it. When we start the node (with service of course), the calculation will be horrible slow until we feed it several times, we called it warm-up.

Unfortunately, the warming-up job take a long time for us to wait for (maybe our calculating finished before the node warmed up)

So, the problem comes, is there a stable way to hot clone out linux server to keep the node at the best performance so that we can clone and make it online in a shorter time?

My answer:

Maybe you can’t “hot clone” a whole server, but you can freeze and restore a single process, with criu, Checkpoint/Restore in Userspace.

This allows you to save the program’s internal state to disk and stop the program, and
later, to restore the program to that state from the saved files.

To support your desired operation, you can copy the files representing the saved program to another server, and restore it there.

criu requires a recent kernel with various features compiled in, so older Linux distributions might not work. You can run criu check on a particular machine to determine if the prerequisites for criu are present.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.