Skip to main content

Welcome to Morph Cloud

Morph Cloud's Infinibranch technology lets you snapshot, branch, and restore entire computational environments in under 250ms. With this technology, you can now parallelize and time travel between VM states, unlocking entirely new patterns for developing, testing, and debugging. The age of linear computing is behind us.

You can create a free account and get started with Morph Cloud at cloud.morph.so.

How are we different?

FeatureTraditional VM InfrastructureInfinibranch
Startup Times2-3 minutes for typical VMs<250ms
CopyingFull clone required, consuming equal resourcesNear-zero overhead branching
BranchingNot natively supportedNative support for unlimited parallel branches
State ManagementManual snapshots and restoresInstant snapshots and restores at any point
Remote DesktopNo built-in supportBuilt-in browser-based access

Quick Start (5 minutes)

This guide will walk you through creating your first Morph environment and experiencing the magic of perfect state preservation.

Prerequisites

First, set up your environment:

# Python developers
pip install morphcloud # For Python

# TypeScript developers
npm install morphcloud # For TypeScript

# Set your API key (get it from cloud.morph.so)
export MORPH_API_KEY='your-api-key-here'

Step 1: Create Your First Snapshot

Start by creating a snapshot from our minimal Linux image:

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()
snapshot = client.snapshots.create(
image_id="morphvm-minimal",
vcpus=1,
memory=128,
disk_size=700
)
print(f"Created snapshot: {snapshot.id}")

Step 2: Start an Instance

Next, start an instance from your snapshot:

instance = client.instances.start(snapshot.id)
print(f"Started instance: {instance.id}")

Step 3: Create a Background Process

Let's create a script that runs in the background and increments a counter every 5 seconds:

# Create counter script
counter_script = """#!/bin/bash
count=1
echo $count > /root/counter.txt
while [ $count -le 100 ]; do
sleep 5
count=$((count + 1))
echo $count > /root/counter.txt
done
"""
instance.exec(f"cat > /root/counter_script.sh << 'EOF'\n{counter_script}\nEOF")
instance.exec("chmod +x /root/counter_script.sh")
instance.exec("nohup /root/counter_script.sh > /dev/null 2>&1 &")

# Check initial counter value
import time
time.sleep(2)
initial_counter = instance.exec("cat /root/counter.txt").stdout
print(f"Initial counter: {initial_counter}")

# Wait for counter to increment
print("Waiting for counter to increment...")
time.sleep(10)
incremented_counter = instance.exec("cat /root/counter.txt").stdout
print(f"Counter after waiting: {incremented_counter}")

Step 4: Create a Snapshot of the Running Instance

Now for the magic part - take a snapshot of the instance with the counter process running:

# Create snapshot of running instance
print("Creating snapshot of running instance...")
new_snapshot = instance.snapshot()
print(f"Created snapshot: {new_snapshot.id}")

Step 5: Start a New Instance from the Snapshot

Start a new instance from the snapshot with the running process:

# Start new instance from snapshot
new_instance = client.instances.start(new_snapshot.id)
print(f"Started new instance: {new_instance.id}")

Step 6: Verify State Preservation

Finally, check if the counter continues from where it left off in the new instance:

# Check counter in new instance
new_counter = new_instance.exec("cat /root/counter.txt").stdout
print(f"Counter in new instance: {new_counter}")

# Wait to verify counter continues incrementing
print("Waiting to verify counter continues in new instance...")
time.sleep(10)
final_counter = new_instance.exec("cat /root/counter.txt").stdout
print(f"Counter after waiting in new instance: {final_counter}")

print("\n✨ Success! The background process continued exactly where it left off.")
print(f"Original instance counter: {incremented_counter} → New instance counter: {final_counter}")

Understanding What Just Happened

You've just experienced the core magic of Morph Cloud:

  1. Perfect Process Preservation: The counter process continued running exactly where it left off, with no restarting or loss of state
  2. Sub-Second Boot Times: The new instance started in milliseconds, not minutes
  3. Complete Environment Capture: The entire system state, including running processes, was preserved

This is what makes Infinibranch technology revolutionary - you can take a snapshot of a running computation at any point, and instantly create multiple copies that all continue from exactly the same point.

Complete Scripts

Here are the complete scripts for each language:

# tutorial.py
from morphcloud.api import MorphCloudClient
import time

# Demonstrate perfect state preservation with Morph Cloud
client = MorphCloudClient()

print("Creating snapshot and starting instance...")
snapshot = client.snapshots.create(image_id="morphvm-minimal", vcpus=1, memory=128, disk_size=700)
instance = client.instances.start(snapshot.id)
print(f"Started instance: {instance.id}")

# Create and start counter script
counter_script = """#!/bin/bash
count=1
echo $count > /root/counter.txt
while [ $count -le 100 ]; do
sleep 5
count=$((count + 1))
echo $count > /root/counter.txt
done
"""
instance.exec(f"cat > /root/counter_script.sh << 'EOF'\n{counter_script}\nEOF")
instance.exec("chmod +x /root/counter_script.sh")
instance.exec("nohup /root/counter_script.sh > /dev/null 2>&1 &")

# Check initial counter value and wait for increment
time.sleep(2)
initial_counter = instance.exec("cat /root/counter.txt").stdout
print(f"Initial counter: {initial_counter}")

print("Waiting for counter to increment...")
time.sleep(10)
incremented_counter = instance.exec("cat /root/counter.txt").stdout
print(f"Counter after waiting: {incremented_counter}")

# Create snapshot and start new instance
print("Creating snapshot of running instance...")
new_snapshot = instance.snapshot()
new_instance = client.instances.start(new_snapshot.id)
print(f"Started new instance: {new_instance.id}")

# Check counter in new instance
new_counter = new_instance.exec("cat /root/counter.txt").stdout
print(f"Counter in new instance: {new_counter}")

# Wait to verify counter continues incrementing
print("Waiting to verify counter continues in new instance...")
time.sleep(10)
final_counter = new_instance.exec("cat /root/counter.txt").stdout
print(f"Counter after waiting in new instance: {final_counter}")

print("\n✨ Success! The background process continued exactly where it left off.")
print(f"Original instance counter: {incremented_counter} → New instance counter: {final_counter}")

Next Steps

See what Morph Cloud can do:

Real-World Applications

  • CI/CD Debugging: Access the exact state of any failure instantly
  • Agent Development: Enable agents to explore thousands of parallel paths with minimal overhead
  • Development Environments: Create staging environments that mirror production perfectly
  • Testing at Scale: Generate and validate thousands of test cases efficiently

Start Building

Check out our API documentation
Explore our SDKs (PythonTypeScript) and repositories
Read our blog
Follow us on Twitter/X to stay up to date with our latest releases