Resource Optimization
Implement Resource Limits:
# Add to high-resource services
deploy:
resources:
limits:
memory: 2G
cpus: '1.0'
reservations:
memory: 1G
cpus: '0.5'
Database Performance Tuning:
PostgreSQL Optimization:
# Create custom PostgreSQL configuration
# /mnt/swarm-data/postgres/postgresql.conf
shared_buffers = 256MB
effective_cache_size = 1GB
maintenance_work_mem = 64MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
MariaDB Optimization:
# Custom MariaDB configuration
# /mnt/swarm-data/mariadb/my.cnf
[mysqld]
innodb_buffer_pool_size = 512M
innodb_log_file_size = 128M
max_connections = 100
query_cache_size = 64M
Redis Optimization:
# Optimize Redis for authentication workload
auth_authentik_redis:
command: >
--save 60 1000
--maxmemory 256mb
--maxmemory-policy allkeys-lru
--tcp-keepalive 60
Network Performance
Optimize Overlay Networks:
# Monitor network performance
docker network inspect homelab
# Check VXLAN overhead
ip -d link show
# Optimize MTU settings if needed
# /etc/docker/daemon.json
{
"mtu": 1450
}
Traefik Performance Tuning:
# Optimize Traefik for high load
command:
- --entrypoints.web.transport.respondingTimeouts.readTimeout=60s
- --entrypoints.web.transport.respondingTimeouts.writeTimeout=60s
- --providers.swarm.refreshSeconds=30s
- --ping.entryPoint=traefik
- --metrics.prometheus=true
Storage Performance
Optimize Bind Mount Performance:
# Use noatime mount option for performance
# /etc/fstab
/dev/nvme0n1p1 /mnt ext4 defaults,noatime,discard 0 2
# Monitor I/O performance
iostat -x 1
iotop -o
Database Storage Optimization:
# Separate database storage for better performance
# Consider separate mount points:
# /mnt/postgres-data - PostgreSQL
# /mnt/mariadb-data - MariaDB
# /mnt/app-data - Application files
Volume Driver Optimization:
# For high-performance workloads, consider
# local volumes with direct device access
volumes:
high_perf_data:
driver: local
driver_opts:
type: none
o: bind,noatime
device: /mnt/nvme-fast/data