Cost Optimization Tips
1. Use Smaller Resources
Start with minimal resources and scale up if needed:- Python
- JavaScript/TypeScript
2. Delete When Done
Always delete sandboxes after use:- Python
- JavaScript/TypeScript
3. Use Pause Instead of Keeping Running
Pause preserves state but costs less than keeping sandboxes running:- Python
- JavaScript/TypeScript
4. Share Sandboxes
Reuse sandboxes for multiple operations instead of creating new ones:- Python
- JavaScript/TypeScript
Resource Optimization
Monitor Resource Usage
Use metrics to understand your actual resource needs:- Python
- JavaScript/TypeScript
Right-Size Resources
Match resources to your workload:Lightweight Workloads
Lightweight Workloads
For simple scripts and basic operations:
- Python
- JavaScript/TypeScript
Data Analysis Workloads
Data Analysis Workloads
For data analysis with Pandas:
- Python
- JavaScript/TypeScript
ML Training Workloads
ML Training Workloads
For machine learning training:
- Python
- JavaScript/TypeScript
Lifecycle Management
Use Timeout for Automatic Cleanup
Automatically clean up sandboxes usingtimeout_seconds:
- Python
- JavaScript/TypeScript
Batch Operations
Group operations together to minimize sandbox creation:- Python
- JavaScript/TypeScript
Cost Comparison
| Strategy | Cost Impact | Use Case |
|---|---|---|
| Minimal resources | Low | Simple scripts, testing |
| Right-sized resources | Medium | Production workloads |
| Over-provisioned | High | ❌ Avoid unless necessary |
| Reuse sandboxes | Low | Multiple operations |
| Create per operation | High | ❌ Avoid |
| Pause when idle | Low | Intermittent workloads |
| Keep running | High | ❌ Avoid for idle sandboxes |

