Wake-on-Request Configuration
Wake-on-request is a cost-saving feature that allows instances to automatically start when accessed via HTTP or SSH-backed workflows. This includes direct SSH sessions as well as exec calls made through the SDK, CLI, or REST API. This is useful for development environments or applications with intermittent usage patterns.
How Wake-on-Request Works
When wake-on-request is enabled:
- Paused State: Your instance can be paused to save compute costs
- Automatic Wake: When a request comes in through HTTP or an SSH-backed access path, the instance automatically resumes
- Seamless Access: Users experience a brief delay while the instance wakes up
- Cost Savings: You only pay for compute time when actively used
There is no separate wake_on_exec setting. If your workflow uses instance.exec(...), morphcloud instance exec, or POST /api/instance/{instance_id}/exec, enable wake_on_ssh and the platform will resume a paused instance before running the command.
Configure Wake-on-Request Settings
Set up wake-on-request behavior for your instances:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Get the instance and enable both HTTP and SSH wake-on-request
instance = client.instances.get(instance_id)
instance.set_wake_on(
wake_on_http=True,
wake_on_ssh=True
)
print(f"Wake-on-request configured for {instance_id}")
print(f"Wake on HTTP: {instance.wake_on.wake_on_http}")
print(f"Wake on SSH: {instance.wake_on.wake_on_ssh}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function configureWakeOnRequest() {
const instanceId = "morphvm_abc123"; // Replace with your instance ID
// Update wake-on-request settings via the REST API
const updated = await client.POST(`/instance/${instanceId}/wake-on`, {}, {
wake_on_http: true,
wake_on_ssh: true
});
console.log(`Wake-on-request configured for ${instanceId}`);
console.log(`Wake on HTTP: ${updated.wake_on.wake_on_http}`);
console.log(`Wake on SSH: ${updated.wake_on.wake_on_ssh}`);
}
configureWakeOnRequest();
# Configure wake-on-request settings
morphcloud instance wake-on-config morphvm_abc123 --wake-on-http --wake-on-ssh
Enable HTTP Wake-on-Request
Configure your instance to wake up when HTTP requests are made:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Enable wake-on-HTTP only
instance = client.instances.get(instance_id)
instance.set_wake_on(wake_on_http=True, wake_on_ssh=False)
# Expose a service for wake-on-HTTP to work
service = instance.expose_http_service("web", 8080)
print(f"HTTP wake-on-request enabled")
print(f"Service URL: {service.url}")
print("Instance will wake when this URL is accessed")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function enableHttpWakeOn() {
const instanceId = "morphvm_abc123"; // Replace with your instance ID
// Enable wake-on-HTTP only
await client.POST(`/instance/${instanceId}/wake-on`, {}, {
wake_on_http: true,
wake_on_ssh: false
});
// Expose a service for wake-on-HTTP to work
const instance = await client.instances.get({ instanceId });
const service = await instance.exposeHttpService("web", 8080);
console.log("HTTP wake-on-request enabled");
console.log(`Service URL: ${service.url}`);
console.log("Instance will wake when this URL is accessed");
}
enableHttpWakeOn();
# Enable HTTP wake-on-request and expose service
morphcloud instance wake-on-config morphvm_abc123 --wake-on-http
morphcloud instance expose morphvm_abc123 --service-name web --port 8080
Enable SSH Wake-on-Request
Configure your instance to wake up when SSH-backed access is attempted, including direct SSH connections and exec calls from the SDK, CLI, or REST API:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Enable wake-on-SSH only
instance = client.instances.get(instance_id)
instance.set_wake_on(wake_on_http=False, wake_on_ssh=True)
print(f"SSH wake-on-request enabled for {instance_id}")
print("Instance will wake when an SSH connection or exec call is attempted")
print(f"SSH command: ssh ubuntu@{instance.ip_address}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function enableSshWakeOn() {
const instanceId = "morphvm_abc123"; // Replace with your instance ID
// Enable wake-on-SSH only
const updated = await client.POST(`/instance/${instanceId}/wake-on`, {}, {
wake_on_http: false,
wake_on_ssh: true
});
console.log(`SSH wake-on-request enabled for ${instanceId}`);
console.log(`Wake on SSH: ${updated.wake_on.wake_on_ssh}`);
console.log("Instance will wake when an SSH connection or exec call is attempted");
console.log("Use your normal SSH flow or any exec call to trigger the wake-up");
}
enableSshWakeOn();
# Enable SSH wake-on-request for SSH sessions and exec calls
morphcloud instance wake-on-config morphvm_abc123 --wake-on-ssh
Check Wake-on-Request Status
View current wake-on-request configuration:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Get current wake-on-request settings
instance = client.instances.get(instance_id)
wake_config = instance.wake_on
print(f"Wake-on-request status for {instance_id}:")
print(f" Wake on HTTP: {wake_config.wake_on_http}")
print(f" Wake on SSH: {wake_config.wake_on_ssh}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function checkWakeOnStatus() {
const instanceId = "morphvm_abc123"; // Replace with your instance ID
// Get current wake-on-request settings
const instance = await client.GET(`/instance/${instanceId}`);
console.log(`Wake-on-request status for ${instanceId}:`);
console.log(` Wake on HTTP: ${instance.wake_on.wake_on_http}`);
console.log(` Wake on SSH: ${instance.wake_on.wake_on_ssh}`);
}
checkWakeOnStatus();
# Check wake-on-request status
morphcloud instance get morphvm_abc123 --show-wake-on
Best Practices
- Use for development environments where cost optimization is important
- Combine with TTL settings to automatically pause idle instances
- Test wake-up times to understand user experience impact
- Monitor wake-on-request usage to optimize settings
Wake-on-request helps balance cost efficiency with accessibility, making it ideal for intermittent workloads.