Skip to main content

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:

  1. Paused State: Your instance can be paused to save compute costs
  2. Automatic Wake: When a request comes in (HTTP or SSH), the instance automatically resumes
  3. Seamless Access: Users experience a brief delay while the instance wakes up
  4. 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:

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}")

Enable HTTP Wake-on-Request

Configure your instance to wake up when HTTP requests are made:

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")

Enable SSH Wake-on-Request

Configure your instance to wake up when SSH connections are attempted:

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}")

Check Wake-on-Request Status

View current wake-on-request configuration:

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}")

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.