# Resource Allocation Guide

*CPU, memory, and storage recommendations for homelab services*

---

## Overview

This guide provides resource allocation recommendations for services running in the homelab. Values are based on typical usage and should be adjusted based on actual usage patterns.

---

## Host Capacity

### Current Resources

| Host | CPU | RAM | Storage | Workload |
|------|-----|-----|---------|----------|
| Atlantis | 8 cores | 32GB | 40TB | Media, Vault |
| Calypso | 4 cores | 32GB | 12TB | Infrastructure |
| Concord NUC | 2 cores | 16GB | 256GB | Light services |
| Homelab VM | 4 cores | 28GB | 100GB | Monitoring |
| RPi5 | 4 cores | 16GB | 512GB | Edge |

### Available Headroom

| Host | CPU Available | RAM Available | Notes |
|------|---------------|---------------|-------|
| Atlantis | 2 cores | 8GB | ~25% headroom |
| Calypso | 1 core | 12GB | ~37% headroom |
| Concord NUC | 0.5 core | 4GB | Limited |
| Homelab VM | 1 core | 8GB | ~28% headroom |
| RPi5 | 2 cores | 8GB | ~50% headroom |

---

## Service Resource Guidelines

### Infrastructure Services

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Nginx Proxy Manager | 0.5 | 256MB | 1GB | Minimal |
| Authentik | 1 | 1GB | 10GB | With PostgreSQL |
| Prometheus | 1 | 2GB | 20GB | Adjust for retention |
| Grafana | 0.5 | 512MB | 1GB | Dashboards |
| Alertmanager | 0.25 | 128MB | - | Minimal |

### Database Services

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| PostgreSQL | 1 | 1GB | 10GB+ | Per database |
| Redis | 0.5 | 512MB | - | In-memory |
| MariaDB/MySQL | 1 | 512MB | 5GB | Legacy services |

### Media Services

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Plex | 2+ | 2GB | - | Transcoding |
| Jellyfin | 2+ | 2GB | - | Hardware assist |
| Sonarr | 0.5 | 256MB | - | Low usage |
| Radarr | 0.5 | 256MB | - | Low usage |
| Lidarr | 0.5 | 256MB | - | Low usage |
| Prowlarr | 0.25 | 128MB | - | Minimal |
| Bazarr | 0.5 | 512MB | - | Subtitle processing |
| qBittorrent | 1 | 512MB | - | Upload/download |
| SABnzbd | 0.5 | 256MB | - | Download |

### Photo Services

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Immich | 2 | 2GB | 100GB+ | ML processing |
| PhotoPrism | 2 | 2GB | 100GB+ | Optional |

### Communication Services

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Matrix/Synapse | 2 | 1GB | 10GB | Federation |
| Element | 0.5 | 256MB | - | Web client |
| Mastodon | 2 | 2GB | 20GB | Social |
| Mattermost | 1 | 1GB | 5GB | Team chat |
| Jitsi | 2 | 2GB | - | Video |

### Home Automation

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Home Assistant | 1 | 2GB | 5GB | Core |
| Zigbee2MQTT | 0.5 | 256MB | - | MQTT broker |
| Z-Wave JS | 0.5 | 512MB | - | Z-Wave |

### Development

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Gitea | 1 | 512MB | 5GB | Git hosting |
| Gitea Runner | 1 | 512MB | - | CI/CD |
| Portainer | 0.5 | 256MB | - | Management |
| OpenHands | 2 | 4GB | 10GB | AI dev (on-demand) |

### Productivity

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Paperless-NGX | 1 | 1GB | 50GB | Document OCR |
| Wallabag | 0.5 | 256MB | 5GB | Read later |
| Reactive Resume | 0.5 | 256MB | 1GB | Resume builder |
| Seafile | 2 | 2GB | 100GB+ | File sync |

### Security

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Vaultwarden | 1 | 512MB | 1GB | Passwords |
| Bitwarden | 2 | 1GB | 5GB | (if using official) |

### Privacy

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Invidious | 1 | 1GB | - | YouTube frontend |
| Piped | 1 | 1GB | - | Music frontend |
| Libreddit | 0.5 | 256MB | - | Reddit frontend |

### DNS & Network

| Service | CPU | Memory | Storage | Notes |
|---------|-----|--------|---------|-------|
| Pi-hole | 0.5 | 256MB | 2GB | DNS filtering |
| AdGuard | 1 | 512MB | 2GB | DNS + ads |
| WireGuard | 0.25 | 128MB | - | VPN |
| Headscale | 0.5 | 256MB | - | WireGuard server |

---

## Memory Limits by Host

### Atlantis (32GB)

```
System:                    4GB
Container overhead:       4GB
Vaultwarden:            512MB
Immich:                 2GB
Plex:                   2GB
ARR stack:              1GB
Jitsi:                  2GB
Matrix:                 1GB
Mastodon:               2GB
Misc services:          2GB
---------------------------
Reserved:              ~15GB
```

### Calypso (32GB)

```
System:                    4GB
Docker overhead:           4GB
Authentik:               1GB
NPM:                     256MB
Prometheus:              2GB
Grafana:                 512MB
PostgreSQL:              1GB
ARR stack:              512MB
Other services:          3GB
---------------------------
Reserved:              ~16GB
```

### Concord NUC (16GB)

```
System:                    2GB
Docker:                    2GB
Home Assistant:            2GB
AdGuard:                512MB
Plex:                    2GB
Other services:           2GB
---------------------------
Reserved:               ~5.5GB
```

---

## CPU Limits by Service

### High CPU (2+ cores)
- Plex/Jellyfin (transcoding)
- Immich (ML processing)
- OpenHands
- Ollama
- Video processing

### Medium CPU (1 core)
- Databases (PostgreSQL, MariaDB)
- Matrix/Synapse
- Mastodon
- Seafile
- Paperless-NGX (OCR)

### Low CPU (<1 core)
- Nginx Proxy Manager
- Authentik
- Pi-hole/AdGuard
- Vaultwarden
- Arr suite (Sonarr, Radarr)
- Prometheus (scraping)

---

## Storage Guidelines

### Media Storage
- **Movies/TV**: On Atlantis, shared via NFS/SMB
- **Music**: Dedicated volume
- **Photos**: Immich primary on Atlantis, backup on RPi5

### Application Data
- **Prometheus**: SSD required (fast writes)
- **Databases**: SSD required
- **Cache**: Can be small/fast

### Backup Storage
- Local: Dedicated volume on Calypso
- Remote: Backblaze B2 / cold storage

---

## Docker Compose Examples

### Memory Limits
```yaml
services:
  prometheus:
    image: prom/prometheus
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 1G
```

### CPU Limits
```yaml
services:
  plex:
    image: plexinc/pms-docker
    deploy:
      resources:
        limits:
          cpus: '2.0'
```

---

## Monitoring Resource Usage

### Check Current Usage

```bash
# All containers
docker stats --no-stream

# Specific host
curl http://<host>:9100/metrics | grep node_memory_MemAvailable

# Grafana dashboard
# Infrastructure → Host Resources
```

### Alerts

| Metric | Warning | Critical |
|--------|---------|----------|
| CPU | >70% | >90% |
| Memory | >80% | >95% |
| Disk | >80% | >90% |

---

## Optimization Tips

1. **Use :latest sparingly** - Pin versions for stability
2. **Enable GPU transcoding** - For Plex/Jellyfin
3. **Use SSD for databases** - Prometheus, PostgreSQL
4. **Limit concurrent transcode** - In Plex settings
5. **Enable Prometheus targerhs** - For better monitoring

---

## Capacity Planning

### Growth Projections

| Service | Current | 6 Months | 12 Months |
|---------|---------|----------|-----------|
| Media storage | 20TB | 25TB | 30TB |
| Photo storage | 500GB | 750GB | 1TB |
| Prometheus | 10GB | 15GB | 20GB |
| Database | 5GB | 7GB | 10GB |

### Warning Signs
- Disk usage >80% sustained
- Memory pressure alerts daily
- Container restarts increasing
- CPU throttling visible

---

## Links

- [Grafana Dashboards](../services/individual/grafana.md)
- [Docker Guide](../getting-started/docker-compose-guide.md)
- [Monitoring Architecture](../infrastructure/MONITORING_ARCHITECTURE.md)
