# VM Providers Comparison: LXD vs Multipass
This document provides a detailed comparison between LXD containers and Multipass VMs for the Torrust tracker deployment infrastructure, explaining why LXD was chosen as the official provider.
## ๐ Overview
For the Torrust tracker deployment infrastructure, we evaluated two main approaches for creating virtual environments that support cloud-init:
1. **LXD Containers** - System containers with cloud-init support
2. **Multipass VMs** - Full virtual machines with nested virtualization
## ๐ Detailed Comparison
| **Technology Type** | System containers (shared kernel) | Full virtual machines (separate kernel) |
| **GitHub Actions Support** | โ
Official provider support | โ ๏ธ Undocumented support |
| **Nested Virtualization** | โ Not required | โ
Required |
| **Resource Usage** | โ
Lower (containers) | โ Higher (full VMs) |
| **Boot Time** | โ
Faster (~5-10s) | โ Slower (~30-60s) |
| **Isolation Level** | ๐ถ Process-level | โ
Complete hardware-level |
| **Cloud-init Support** | โ
Container initialization | โ
Full VM boot process |
| **Docker Support** | โ
Full support | โ
Full support |
| **Setup Complexity** | ๐ถ Requires LXD daemon setup | โ
Simple installation |
| **Network Configuration** | โ
Flexible bridge/overlay | โ
Standard VM networking |
| **Storage Management** | โ
Efficient with snapshots | ๐ถ Standard VM disk images |
| **Multi-architecture** | โ
ARM64, x86_64 support | โ
Limited by hypervisor |
## ๐ฏ Why LXD is Our Official Choice
### โ
**Official GitHub Actions Support**
LXD has **official support** from the GitHub Actions team:
- Documented and guaranteed compatibility
- Long-term stability assurance
- Official troubleshooting support
**Multipass support is undocumented:**
- Works currently but no official guarantees
- Could break without notice in future GitHub runner updates
- No official support channel for issues
### โก **Performance Benefits**
**LXD containers provide superior performance:**
- **Boot time**: 5-10 seconds vs 30-60 seconds for Multipass
- **Resource usage**: Shared kernel means lower memory and CPU overhead
- **Storage efficiency**: Container filesystems are more efficient than VM disk images
### ๐ง **CI/CD Optimization**
**LXD is better suited for automated testing:**
- Faster spin-up times reduce CI job duration
- Lower resource requirements allow more parallel jobs
- Predictable performance characteristics
### ๐๏ธ **Infrastructure Consistency**
**LXD provides better DevOps alignment:**
- Container-based approach aligns with modern cloud practices
- Easier to version and distribute container images
- Better integration with container orchestration if needed
## ๐งช When to Use Each Approach
### Use LXD Containers When:
- โ
**CI/CD environments** (GitHub Actions, GitLab CI, etc.)
- โ
**Development environments** requiring fast iteration
- โ
**Testing scenarios** where performance matters
- โ
**Container-based workflows**
- โ
**Resource-constrained environments**
### Use Multipass VMs When:
- ๐ฌ **Complete isolation** is required
- ๐ฌ **Kernel-level testing** (different kernels, kernel modules)
- ๐ฌ **Legacy application testing** requiring specific kernel features
- ๐ฌ **Security testing** requiring hardware-level isolation
- ๐ฌ **Experimental development** where official support isn't critical
## ๐ Getting Started with Each
### LXD Quick Start
```bash
# Install LXD
sudo snap install lxd
sudo lxd init --auto
sudo usermod -a -G lxd $USER
newgrp lxd
# Deploy with OpenTofu
cd templates/tofu/lxd
tofu init && tofu apply
```
### ~~Multipass Quick Start~~ (Deprecated)
> **Note**: Multipass support has been removed from this project as of the LXD over Multipass decision.
> For Multipass-related documentation and examples, see: https://github.com/torrust/torrust-tracker-deployer
```bash
# Multipass is no longer supported in this repository
# See the link above for Multipass examples and documentation
```
## ๐ Technical Deep Dive
### LXD Architecture
**System Containers:**
- Shared kernel with host system
- Isolated userspace processes
- Native performance for most operations
- Container-specific init system (systemd)
**Cloud-init Integration:**
- Cloud-init runs during container initialization
- Supports full cloud-init functionality
- Network configuration, user setup, package installation
### Multipass Architecture
**Full Virtualization:**
- Complete virtual machine with separate kernel
- Hardware-level isolation
- Full Ubuntu VM experience
- Standard VM boot process
**Cloud-init Integration:**
- Cloud-init runs during VM boot
- Complete VM initialization process
- Full hardware simulation
## ๐ ๏ธ Setup Requirements
### LXD Requirements
**Local Development:**
```bash
# System requirements
- Linux host (any distribution)
- 1GB+ RAM available
- 10GB+ disk space
- No special kernel features required
# Installation
sudo snap install lxd
sudo lxd init --auto
```
**GitHub Actions:**
```yaml
# In GitHub Actions workflow
- name: Setup LXD
uses: canonical/setup-lxd@v0.1.1
```
### Multipass Requirements
**Local Development:**
```bash
# System requirements
- Linux/macOS/Windows host
- 2GB+ RAM available
- 20GB+ disk space
- Nested virtualization support (KVM/HyperV)
# Installation
sudo snap install multipass
```
**GitHub Actions:**
```yaml
# Nested virtualization required (may not be available)
- name: Enable nested virtualization
run: |
# Various approaches depending on runner type
# Not officially documented
```
## ๐ Performance Benchmarks
### Boot Time Comparison
| Operation | LXD Container | Multipass VM |
| ---------- | -------------- | -------------- |
| Cold start | 5-8 seconds | 35-45 seconds |
| Warm start | 2-3 seconds | 25-30 seconds |
| Cloud-init | +10-15 seconds | +20-30 seconds |
### Resource Usage
| Metric | LXD Container | Multipass VM |
| -------------- | ------------- | ---------------- |
| Base RAM | ~50MB | ~512MB |
| Boot RAM spike | ~200MB | ~1GB |
| Disk overhead | ~100MB | ~1-2GB |
| CPU overhead | Minimal | Hypervisor layer |
## ๐ Security Considerations
### LXD Security
**Isolation Level:**
- Process-level isolation
- Shared kernel space
- Container escape possible but rare
- Good for development/testing environments
**Security Features:**
- AppArmor/SELinux profiles
- User namespace isolation
- Capability restrictions
- Resource limits
### Multipass Security
**Isolation Level:**
- Hardware-level isolation
- Separate kernel space
- VM escape extremely difficult
- Suitable for security-sensitive testing
**Security Features:**
- Complete VM isolation
- Hardware virtualization boundaries
- Separate network stacks
- Independent file systems
## ๐ง Limitations and Considerations
### LXD Limitations
- **Kernel sharing**: Cannot test different kernel versions
- **Hardware simulation**: Limited hardware device simulation
- **Container-specific**: Some VM-specific features unavailable
- **Setup complexity**: Requires LXD daemon configuration
### Multipass Limitations
- **Nested virtualization**: Requires special hardware/software support
- **Resource overhead**: Higher memory and CPU usage
- **Boot time**: Slower startup affects CI performance
- **GitHub Actions**: Unofficial support may break
## ๐ฎ Future Considerations
### LXD Evolution
- Enhanced cloud-init support
- Better integration with container orchestration
- Improved security isolation features
- GPU and special device passthrough
### Multipass Evolution
- Potential official GitHub Actions support
- Performance improvements
- Better integration with cloud providers
- Enhanced local development features
## ๐ Decision Matrix
Use this matrix to decide which approach fits your specific needs:
| Requirement | Weight | LXD Score | Multipass Score |
| ------------------- | ------ | --------- | --------------- |
| CI/CD Support | High | 10 | 6 |
| Performance | High | 9 | 6 |
| Complete Isolation | Medium | 5 | 10 |
| Setup Simplicity | Medium | 7 | 9 |
| Resource Efficiency | High | 10 | 5 |
| Official Support | High | 10 | 3 |
| **Total** | | **51** | **39** |
**Scoring**: 1-10 scale (10 = excellent, 1 = poor)
## ๐ Additional Resources
### LXD Resources
- [LXD Official Documentation](https://linuxcontainers.org/lxd/)
- [GitHub Actions LXD Setup](https://github.com/canonical/setup-lxd)
- [LXD Cloud-init Guide](https://linuxcontainers.org/lxd/docs/master/cloud-init/)
### Multipass Resources
- [Multipass Official Documentation](https://multipass.run/)
- [Multipass GitHub Repository](https://github.com/canonical/multipass)
- [Ubuntu Cloud Images](https://cloud-images.ubuntu.com/)
### Virtualization Resources
- [Nested Virtualization Guide](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization)
- [KVM Nested Virtualization](https://www.linux-kvm.org/page/Nested_Guests)
- [GitHub Actions Runner Specifications](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners)