Wake-on-Request Configuration
Wake-on-request is a cost-saving feature that allows instances to automatically start when accessed via HTTP or SSH. 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 (HTTP or SSH), 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
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 instance_id = "morphvm_abc123"; // Replace with your instance ID
// Get the instance and enable wake-on-request
const instance = await client.instances.get({ instance_id: instance_id });
await instance.set_wake_on({
wakeOnHttp: true,
wakeOnSsh: true
});
console.log(`Wake-on-request configured for ${instance_id}`);
console.log(`Wake on HTTP: ${instance.wakeOn.wakeOnHttp}`);
console.log(`Wake on SSH: ${instance.wakeOn.wakeOnSsh}`);
}
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 instance_id = "morphvm_abc123"; // Replace with your instance ID
// Enable wake-on-HTTP only
const instance = await client.instances.get({ instance_id: instance_id });
await instance.set_wake_on({ wakeOnHttp: true, wakeOnSsh: false });
// Expose a service for wake-on-HTTP to work
const service = await instance.expose_http_service("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 connections are attempted:
- 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(f"Instance will wake when SSH connection is attempted")
print(f"SSH command: ssh ubuntu@{instance.ip_address}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function enableSshWakeOn() {
const instance_id = "morphvm_abc123"; // Replace with your instance ID
// Enable wake-on-SSH only
const instance = await client.instances.get({ instance_id: instance_id });
await instance.set_wake_on({ wakeOnHttp: false, wakeOnSsh: true });
console.log(`SSH wake-on-request enabled for ${instance_id}`);
console.log("Instance will wake when SSH connection is attempted");
console.log(`SSH command: ssh ubuntu@${instance.ipAddress}`);
}
enableSshWakeOn();
# Enable SSH wake-on-request
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 instance_id = "morphvm_abc123"; // Replace with your instance ID
// Get current wake-on-request settings
const instance = await client.instances.get({ instance_id: instance_id });
const wakeConfig = instance.wakeOn;
console.log(`Wake-on-request status for ${instance_id}:`);
console.log(` Wake on HTTP: ${wakeConfig.wakeOnHttp}`);
console.log(` Wake on SSH: ${wakeConfig.wakeOnSsh}`);
}
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.