We pull 5 canisters from the queue and upgrade them on each heartbeat.
As we grow we will potentially have 10s or even 100s of thousands of canisters, so we can’t kick them all off at the same time as that would cause the system to become overloaded and unresponsive, so instead we opted for gradual rolling upgrades.
@alexeychirkov yes exactly, we call the ‘upgrade_user_canister_wasm’ method on our user_index canister. This canister then holds that new wasm in a normal Rust struct. But if the user_index gets upgraded that struct will get serialized to stable memory and then deserialized back into the struct so that it can be used again after the upgrade has completed.
This is our generate_wasm.sh
file -
#!/bin/sh
echo Building package $1
cargo build --target wasm32-unknown-unknown --release --package $1
echo Optimising wasm
wasm-opt target/wasm32-unknown-unknown/release/$1.wasm --strip-debug -Oz -o target/wasm32-unknown-unknown/release/$1-opt.wasm
This creates the wasm, we then have another executable which calls into the user_index passing in that wasm as an arg. You can’t pass in wasm files as arguments using dfx (or at least, you couldn’t in the past when we were trying).