Pause / Resume
The pause and resume functionality allows you to temporarily suspend an instance while preserving its memory state, and later restart it exactly where it left off. This approach saves on compute costs compared to keeping an instance running while still preserving its state.
When to Use Pause vs Stop
- Pause: Use when you need to preserve the running state of applications, the memory contents, and all processes. You'll only be charged for storage, not compute resources.
- Stop: Use when you're completely done with the instance and want to release all resources. You'll lose the running state, but you can always start a new instance from a snapshot.
Pause an Instance
Pausing an instance suspends its execution while preserving the memory state. It's effectively the same as if you had snapshotted the instance.
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with a valid instance ID
instance = client.instances.get(instance_id=instance_id)
instance.pause()
print(f"Instance '{instance_id}' paused.")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function pauseInstance() {
const instanceId = "morphvm_abc123"; // Replace with a valid instance ID
const instance = await client.instances.get({ instanceId: instanceId });
await instance.pause();
console.log(`Instance '${instanceId}' paused.`);
}
pauseInstance();
# Pause an instance
morphcloud instance pause morphvm_abc123
Resume an Instance
Resuming a paused instance restores it to its exact state at the time of pausing, with all processes and memory state intact.
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with a valid instance ID
instance = client.instances.get(instance_id=instance_id)
instance.resume()
print(f"Instance '{instance_id}' resumed.")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function resumeInstance() {
const instanceId = "morphvm_abc123"; // Replace with a valid instance ID
const instance = await client.instances.get({ instanceId: instanceId });
await instance.resume();
console.log(`Instance '${instanceId}' resumed.`);
}
resumeInstance();
# Resume a paused instance
morphcloud instance resume morphvm_abc123
Cost Implications
When an instance is paused:
- We create a new snapshot and suspend the VM
- The VM stops consuming MCUs
- You only get charged for the snapshot taken
- Running processes/memory state preserved as usual
This makes pausing an economical way to temporarily suspend workloads that you'll need to resume later in the exact same state.