Production Photo & Video Management: Deploying Immich with ML Acceleration on OpenZFS

4 min read

Relying on commercial cloud providers for personal photo and video storage surrenders data privacy, introduces recurring subscription fees, and locks your memories into proprietary ecosystems.

Immich is the premier high-performance self-hosted photo and video backup solution. Featuring automatic mobile background backups, facial recognition, vector CLIP semantic search, and multi-user isolation, Immich delivers an experience that matches or surpasses commercial clouds when backed by a rock-solid OpenZFS storage architecture and hardware-accelerated machine learning.

⚡ Quick Runbook: 60-Second Implementation

TL;DR: Production 4-container Immich stack with Valkey and PostgreSQL:

# compose.yaml
services:
  immich-server:
    image: ghcr.io/immich-app/immich-server:v1.118.0
    container_name: immich-server
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /mnt/fastpool/apps/immich/upload:/usr/src/app/upload
      - /mnt/datapool/photos:/mnt/photos:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - DB_HOSTNAME=immich-database
      - DB_DATABASE_NAME=immich
      - DB_USERNAME=immich
      - DB_PASSWORD_FILE=/run/secrets/db_password
      - REDIS_HOSTNAME=immich-valkey
    secrets:
      - db_password
    depends_on:
      - immich-valkey
      - immich-database
    networks:
      - immich-net
      - proxy-tier

  immich-machine-learning:
    image: ghcr.io/immich-app/immich-machine-learning:v1.118.0
    container_name: immich-machine-learning
    restart: unless-stopped
    volumes:
      - model-cache:/cache
    networks:
      - immich-net

  immich-valkey:
    image: valkey/valkey:8.0-alpine
    container_name: immich-valkey
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - immich-net

  immich-database:
    image: tensorchord/pgvecto-rs:pg16-v0.2.1
    container_name: immich-database
    restart: unless-stopped
    environment:
      - POSTGRES_DB=immich
      - POSTGRES_USER=immich
      - POSTGRES_PASSWORD_FILE=/run/secrets/db_password
      - PGDATA=/var/lib/postgresql/data
    secrets:
      - db_password
    volumes:
      - /mnt/fastpool/apps/immich/pgdata:/var/lib/postgresql/data
    networks:
      - immich-net

volumes:
  model-cache:

secrets:
  db_password:
    file: ./secrets/db_password.txt

networks:
  immich-net:
  proxy-tier:
    external: true

1. Storage Tiering on OpenZFS: Fastpool vs Datapool

Immich performs two distinct I/O workloads: high-frequency transactional queries (PostgreSQL database and image thumbnail metadata) and large streaming reads/writes (raw photos and 4K video clips). Optimal homelab performance requires storage tiering:

  • High-Speed SSD Dataset (fastpool): Store the PostgreSQL database (/var/lib/postgresql/data) and Valkey cache on mirrored NVMe/SSDs with a 16K ZFS recordsize for snappy UI responsiveness.
  • Capacity Storage Pool (datapool): Store the primary media upload directory and existing family archives on large spinning disk ZFS pools with 1M recordsize and Zstandard compression (zstd) enabled.

2. Modern Redis Alternative: Valkey

Following Redis licensing changes, modern open-source homelabs utilize Valkey (the Linux Foundation open-source fork). Immich seamlessly operates with Valkey as an in-memory queue and caching layer with zero configuration overhead and 100% API compatibility.


3. Machine Learning Acceleration

Immich utilizes two neural network models: facial detection/recognition and vector CLIP embeddings (enabling semantic natural language search such as “sunset at the beach”). For low-power CPUs (Intel Core 8th-gen+), hardware acceleration significantly accelerates initial bulk imports:

# Device pass-through for Intel QuickSync / OpenVINO ML inference
  immich-machine-learning:
    image: ghcr.io/immich-app/immich-machine-learning:v1.118.0-openvino
    devices:
      - /dev/dri:/dev/dri

4. Backup and Disaster Recovery Strategy

Never rely solely on containerized storage. Implement a 3-tier backup pipeline for Immich:

  1. Automated Database Dumps: Run nightly pg_dump scripts to export plain SQL dumps into a protected backup directory.
  2. OpenZFS Snapshots: Configure Sanoid to take hourly local snapshots of the photo dataset.
  3. Immutable Offsite Replication: Replicate encrypted snapshots to Backblaze B2 or Wasabi S3 via Restic or Syncoid.

Related Runbooks in This Series

Tags:

← Previous:
Next: →