# Server Optimization Research Findings
## Source: Hermes Agent deep-research pass — June 5, 2026
## debian-ai: Debian 13, Xeon E5-2697A v4 (32c), 64GB RAM, RTX 2080 Ti 11GB, NVMe

### Sources Consulted
1. https://docs.docker.com/engine/containers/resource_constraints/
2. https://docs.docker.com/engine/containers/gpu/
3. https://docs.docker.com/reference/cli/dockerd/
4. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
5. https://www.postgresql.org/docs/current/runtime-config-resource.html
6. https://www.postgresql.org/docs/current/runtime-config-wal.html
7. https://www.postgresql.org/docs/current/runtime-config-query.html
8. https://raw.githubusercontent.com/redis/redis/unstable/redis.conf
9. https://nginx.org/en/docs/ngx_core_module.html
10. https://nginx.org/en/docs/http/ngx_http_core_module.html
11. https://www.kernel.org/doc/html/latest/admin-guide/sysctl/vm.html
12. https://pgtune.leopard.in.ua/ (interactive calculator)

### Key Findings Per Domain

#### Docker
- **`default-shm-size: 256M`**: LLM containers need more shared memory (default 64M)
- **`max-concurrent-downloads: 10`**: Parallelize pulls on NVMe (default 3)
- **`default-ulimits.nofile: 1048576`**: LLM servers open many file descriptors (default 1024)
- Container flags: `--shm-size=256m`, `--ipc=host` for CUDA IPC, `--ulimit memlock=-1:-1` for CUDA pinned memory
- NVIDIA: `nvidia-ctk runtime configure --runtime=docker` for GPU passthrough

#### PostgreSQL 17 (64GB RAM)
- `shared_buffers = 16GB` (25% of RAM per official docs)
- `effective_cache_size = 48GB` (75% of RAM)
- `huge_pages = try` — needs `vm.nr_hugepages=8192` in sysctl
- `work_mem = 256MB`, `hash_mem_multiplier = 2.0`
- `wal_compression = zstd` (PG 15+)
- NVMe-specific: `random_page_cost = 1.1`, `effective_io_concurrency = 200`
- PG 17+: `io_method = io_uring` (needs `--with-liburing` build)

#### Redis
- `maxmemory-samples = 10` for better LRU approximation
- `lazyfree-lazy-eviction yes`, `lazyfree-lazy-expire yes`, `lazyfree-lazy-server-del yes`
- `activerehashing yes`, `jemalloc-bg-thread yes`
- Cache-only workload: `save ""`, `appendonly no`

#### Nginx
- `worker_processes auto` matches 32 cores
- `worker_connections 65535` for high concurrency
- `use epoll`, `multi_accept on`
- `sendfile on`, `tcp_nopush on`, `pcre_jit on`
- `open_file_cache max=100000 inactive=20s`
- Streaming: `proxy_buffering off`, `proxy_read_timeout 3600s`

#### Kernel / Sysctl
- `vm.overcommit_memory = 1` — needed for LLM mmap (large model loads)
- `vm.max_map_count = 1048576` — LLM processes hit default 65530 limit
- `kernel.numa_balancing = 0` — single-socket Xeon, no benefit
- `net.ipv4.tcp_congestion_control = bbr` + `net.core.default_qdisc = fq` — BBR on fast link
- `net.core.rmem_max/wmem_max = 16777216` — 16MB TCP buffer

#### NVIDIA GPU
- `nvidia-smi -pm 1` — persistence mode (faster GPU wake)
- `nvidia-smi -pl 250` — power limit (RTX 2080 Ti default 260W)
- `TORCH_CUDA_ARCH_LIST=7.5` for sm_75 compilation
- `PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512` for fragmentation
