Coder Workspace Lifecycle

Understand the complete lifecycle of Coder workspaces from creation to deletion.

Workspace States

Creating

Code
Status: Creating
Duration: 1-2 minutes
What's happening:
- Building container image
- Starting VM
- Initializing environment
- Installing dependencies

⏳ Please wait...

Running

Code
Status: Running
Uptime: 2 hours 15 minutes
Cost: $5.00/hour × 2.25 hours = $11.25 so far

You can:
✓ Edit code
✓ Run commands
✓ Share with team
✓ Auto-stop setting applies

Stopped

Code
Status: Stopped
Last running: 2024-06-12 14:30 UTC
Cost: $0/hour (no charges while stopped)
Data: All saved (can restart anytime)

To restart:
1. Click workspace
2. Click Start
3. Returns to Running state

Deleting

Code
Status: Deleting
Duration: 30 seconds - 1 minute
What's happening:
- Stopping container
- Freeing resources
- Deleting data

⏳ Almost done...

Deleted

Code
Status: Deleted
Effect: Workspace permanently gone
Recovery: Not possible (backup before deleting!)
Charges: Stop immediately

Workspace Lifecycle Flow

Diagram
Creating - 1-2 min
Running - ━━━━━
Running - ━━━━━
Manual Stop
Stopping - 10 sec
Running - ━━━━━
Auto-stop
Stopping - 10 sec
Stopping - 10 sec
Stopped - ━━━━━
Stopped - ━━━━━
Start
Running - ━━━━━
Stopped - ━━━━━
Delete
Delete
Deleting - 30 sec
Deleting - 30 sec
Deleted - Irreversible

Creating Workspaces

Initial Creation

Code
1. Click Create Workspace
2. Choose template
3. Set resources
4. Click Create
5. Status: Creating...
6. ~60-90 seconds later: Running
7. Browser IDE opens
8. Ready to code!

First Start Cost

Code
Workspace: backend-api
Resources: 4 CPU, 8 GB RAM
Cost: $5.00/hour

Created: 14:00
Running: 14:02 (2 min creation time - FREE)
Started coding: 14:03

Setup time (creating) is free. Only pay when running!

Running Workspaces

Monitor Runtime

Code
Workspace Details:
Started: 2024-06-12 14:00 UTC
Running for: 2 hours 30 minutes
Cost so far: $12.50
Auto-stop: 30 minutes after inactivity
Last active: Just now

Staying Productive

Workspace runs while:

  • ✓ Editing files (active)
  • ✓ Terminal command running (active)
  • ✓ Idle but within auto-stop time (running)

Auto-stops after:

  • ✗ 30 minutes of no activity (default)
  • ✗ No terminal commands
  • ✗ No file edits
  • ✗ Not accessed

Auto-Stop Mechanism

How It Works

Code
14:00 - Start coding
14:30 - Stop coding, open browser instead
14:32 - No activity for 2 minutes
...continue until 30 min idle...
15:00 - Auto-stop triggered!
Workspace transitions: Running → Stopping → Stopped

Cost: $5.00/hour × 1 hour = $5.00

Adjust Auto-Stop

Change when workspace stops:

Code
Settings → Auto-stop after inactivity
Options:
- 5 minutes (very aggressive)
- 15 minutes (testing)
- 30 minutes (default)
- 1 hour (development)
- Never (always running)

Example: Set to 1 hour if frequently working.

What Counts as Activity?

Active:

  • Typing in editor
  • Running terminal command
  • Saving file
  • Opening file browser

Not active:

  • Browser tab open, not editing
  • Looking at code (no changes)
  • Running long process you're watching
  • Just terminal output

Stopping Workspaces

Manual Stop

Stop anytime:

Code
1. Click workspace
2. Click Stop
3. Status: Stopping...
4. ~10 seconds later: Stopped
5. All data saved
6. No charges while stopped

What Gets Saved

✓ Saved:

  • All files on disk
  • Git commits
  • Database data
  • Terminal history
  • Workspace settings

✓ NOT Saved:

  • Running processes (stopped)
  • Memory state
  • Temporary files in /tmp

Restart After Stop

Code
1. Click workspace
2. Click Start
3. Status: Starting...
4. ~30 seconds later: Running
5. Files are there
6. Continue where you left off

Deleting Workspaces

Before Deletion

BACKUP YOUR WORK:

Terminal
# Push to GitHub
git push origin main

# Or download files
# Or export data

# THEN delete

Delete Process

Code
1. Click workspace
2. Click Delete
3. Confirm deletion
4. Status: Deleting...
5. ~30 seconds: Completely gone
6. No recovery possible!

After Deletion

Code
Workspace: backend-api
Status: Deleted
Available: No longer in your workspace list
Data: Gone forever
Recovery: Not possible
Charges: Stop immediately

Cost Optimization

Running Costs

Code
Example workspace:
- Resource size: 4 CPU, 8 GB RAM
- Hourly rate: $5.00/hour
- Daily usage: 8 hours
- Daily cost: $40
- Monthly cost (20 working days): $800

Reduce Costs

Strategy 1: Use smaller workspaces

Code
Small: 2 CPU, 4 GB RAM = $2.50/hour (50% savings)
Use for: Testing, lightweight work
Full-size: 4 CPU, 8 GB RAM = $5.00/hour (for heavy work)

Strategy 2: Stop when not working

Code
Before: Left running 24/7 = $120/month
After: Stop after 30 min = $40/month (67% savings!)

Strategy 3: Delete unused workspaces

Code
Old workspaces: 3 workspaces × $40/month = $120/month
After cleanup: 1 workspace × $40/month = $40/month

Strategy 4: Combine with SSH

Code
Use browser IDE only for demos
Use SSH for actual development (feels local, still cloud)
Same cost, better experience

Workspace History

View All Your Workspaces

Code
My Workspaces:

Running:
- backend-api (2 hours) - $10 so far
- frontend-app (30 min) - $2.50 so far
Total running: $12.50

Stopped:
- data-analysis (3 days ago)
- legacy-api (1 week ago)

Total this month: $500

Restart Old Workspaces

Find stopped workspace:

  1. Click workspace
  2. Click Start
  3. Restarts in ~30 seconds
  4. All files still there
  5. Start coding immediately

Best Practices

Minimize Costs

  • ✓ Use appropriate resource size
  • ✓ Set reasonable auto-stop time
  • ✓ Stop manually when done
  • ✓ Delete workspaces you don't use
  • ✗ Don't leave running 24/7
  • ✗ Don't over-provision resources

Maintain Productivity

  • ✓ Keep workspaces organized
  • ✓ Name them clearly
  • ✓ Delete after project ends
  • ✓ Push code to GitHub regularly
  • ✓ Share good templates
  • ✗ Don't hoard workspaces
  • ✗ Don't run outdated workspaces

Track Usage

  1. Review cost weekly
  2. Delete unused workspaces
  3. Optimize resource sizes
  4. Check auto-stop settings