It is now possible to migrate canisters from one subnet to another. A detailed step-by-step guide on how to do canister migrations can be found here.
What is canister migration?
Canister migration is the process of taking a canister running on one subnet, and moving it to a different subnet, while retaining its code, data, and canister id. A migrated canister behaves seamlessly as before, both via ingress and XNet messages, thanks to the canister id being retained. The only difference is what subnet the canister is running on, which can affect XNet latency as same-subnet messages have lower latency.
Who can migrate canisters?
The feature is open to everybody. In order to trigger a canister migration, you must be a controller of the canister. You also must be able create a new canister on the target subnet. The cost of migrating a canister is currently 10T cycles.
Why would I want to migrate a canister?
There are several possible reasons:
- You would like to move to a different subnet type, e.g. making use of added security of the fiduciary subnet.
- You would like to co-host the canister with other canisters that it communicates with for better message latency.
- You control multiple canisters and would like to spread them across different subnets to spread the load.
- Other canisters on the same subnet are slowing the subnet down, and you would like to move to a less busy subnet.
How does a canister migration work
Please refer to the detailed guide here.
The core steps are to
- Create a new canister on the target subnet
- Stop both canisters
- Migrate the canister state using the new snapshot download/upload feature
- Migrate canister settings and cycles as needed
- Reassign the canister id to the new canister
- Restart your canister
How long does a migration take?
Roughly 6 minutes, plus the time it takes to transfer the canister state (variable).
Can I test it first?
Yes! Canister migrations are fully supported by PocketIC, which is also integrated into dfx. You can test run your canister migration first on your local instance of the Internet Computer using the same dfx commands.