Security
- Configure API keys
- Enable TLS/HTTPS
- Use IAM roles for S3 access
- Configure firewall rules
- Implement rate limiting
Deploy Mend Media Processing Engine to production environments.
Clone and Configure
cd /path/to/mendcp config.example.yaml config.yamlcp .env.example .envEdit Configuration
server: port: 8080 mode: release api_keys: - "${API_KEY_1}"
redis: addr: redis:6379 password: "" db: 0
s3: region: us-east-1 access_key_id: "${AWS_ACCESS_KEY_ID}" secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
worker: concurrency: 10
processing: temp_dir: /tmp/mend ffmpeg_path: /usr/bin/ffmpegAWS_ACCESS_KEY_ID=your_keyAWS_SECRET_ACCESS_KEY=your_secretAWS_REGION=us-east-1API_KEY_1=your_secure_api_keyStart Services
docker-compose up -dThis starts:
Verify Deployment
# Check healthcurl http://localhost:8080/health
# View logsdocker-compose logs -f apidocker-compose logs -f workerAdjust worker replicas in docker-compose.yaml:
worker: deploy: replicas: 5 # Increase for more throughputThen scale:
docker-compose up -d --scale worker=5Create Namespace
kubectl create namespace mendCreate Secrets
kubectl create secret generic mend-secrets \ --from-literal=aws-access-key-id=YOUR_KEY \ --from-literal=aws-secret-access-key=YOUR_SECRET \ --from-literal=api-key=$(openssl rand -hex 32) \ -n mendCreate ConfigMap
kubectl create configmap mend-config \ --from-file=config.yaml \ -n mendDeploy Redis
kubectl apply -f deployments/k8s/redis.yaml -n mendDeploy API and Worker
kubectl apply -f deployments/k8s/api.yaml -n mendkubectl apply -f deployments/k8s/worker.yaml -n mendExpose API
kubectl apply -f deployments/k8s/service.yaml -n mendkubectl apply -f deployments/k8s/ingress.yaml -n mendapiVersion: apps/v1kind: Deploymentmetadata: name: mend-apispec: replicas: 2 selector: matchLabels: app: mend-api template: metadata: labels: app: mend-api spec: containers: - name: api image: mend:latest command: ["/app/api"] ports: - containerPort: 8080 name: http - containerPort: 9090 name: metrics env: - name: AWS_ACCESS_KEY_ID valueFrom: secretKeyRef: name: mend-secrets key: aws-access-key-id - name: AWS_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: mend-secrets key: aws-secret-access-key - name: API_KEY_1 valueFrom: secretKeyRef: name: mend-secrets key: api-key volumeMounts: - name: config mountPath: /app/config.yaml subPath: config.yaml livenessProbe: httpGet: path: /health/live port: 8080 initialDelaySeconds: 10 periodSeconds: 30 readinessProbe: httpGet: path: /health/ready port: 8080 initialDelaySeconds: 5 periodSeconds: 10 resources: requests: memory: "256Mi" cpu: "250m" limits: memory: "512Mi" cpu: "500m" volumes: - name: config configMap: name: mend-configapiVersion: apps/v1kind: Deploymentmetadata: name: mend-workerspec: replicas: 3 selector: matchLabels: app: mend-worker template: metadata: labels: app: mend-worker spec: containers: - name: worker image: mend:latest command: ["/app/worker"] env: - name: AWS_ACCESS_KEY_ID valueFrom: secretKeyRef: name: mend-secrets key: aws-access-key-id - name: AWS_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: mend-secrets key: aws-secret-access-key volumeMounts: - name: config mountPath: /app/config.yaml subPath: config.yaml - name: temp mountPath: /tmp/mend resources: requests: memory: "512Mi" cpu: "500m" limits: memory: "2Gi" cpu: "2000m" volumes: - name: config configMap: name: mend-config - name: temp emptyDir: {}apiVersion: v1kind: Servicemetadata: name: mend-apispec: selector: app: mend-api ports: - name: http port: 80 targetPort: 8080 - name: metrics port: 9090 targetPort: 9090 type: ClusterIP---apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: mend-api annotations: cert-manager.io/cluster-issuer: letsencrypt-prodspec: tls: - hosts: - api.yourdomain.com secretName: mend-tls rules: - host: api.yourdomain.com http: paths: - path: / pathType: Prefix backend: service: name: mend-api port: number: 80apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata: name: mend-worker-hpaspec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: mend-worker minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 80For running directly on a Linux server:
Build Binaries
make buildInstall Binaries
sudo cp bin/api /usr/local/bin/mend-apisudo cp bin/worker /usr/local/bin/mend-workersudo chmod +x /usr/local/bin/mend-*Create Service Files
[Unit]Description=Mend API ServerAfter=network.target redis.service
[Service]Type=simpleUser=mendWorkingDirectory=/opt/mendExecStart=/usr/local/bin/mend-apiRestart=alwaysRestartSec=5Environment="AWS_ACCESS_KEY_ID=your_key"Environment="AWS_SECRET_ACCESS_KEY=your_secret"
[Install]WantedBy=multi-user.target[Unit]Description=Mend WorkerAfter=network.target redis.service
[Service]Type=simpleUser=mendWorkingDirectory=/opt/mendExecStart=/usr/local/bin/mend-workerRestart=alwaysRestartSec=5Environment="AWS_ACCESS_KEY_ID=your_key"Environment="AWS_SECRET_ACCESS_KEY=your_secret"
[Install]WantedBy=multi-user.targetEnable and Start
sudo systemctl daemon-reloadsudo systemctl enable mend-api mend-workersudo systemctl start mend-api mend-worker
# Check statussudo systemctl status mend-apisudo systemctl status mend-workerSecurity
Reliability
Monitoring
Scaling
Available at http://localhost:9090/metrics
Key Metrics:
mend_jobs_total - Total jobs processedmend_queue_depth - Current queue depthmend_job_duration_seconds - Job processing timemend_worker_utilization - Worker utilizationImport the provided dashboard for comprehensive monitoring:
Queue Metrics
Performance
System Health
Structured JSON logs to stdout. Use:
worker: concurrency: 20 # Increase for more throughputGuidelines:
worker: queues: image: 5 # Highest priority video: 3 # Medium priority audio: 2 # Low priority default: 1 # Lowest priorityprocessing: ffmpeg_path: /usr/bin/ffmpeg ffmpeg_args: - "-hwaccel" - "cuda" # or vaapi, qsvRequires GPU support in Docker container
# Check logsdocker-compose logs api
# Common issues:# - Redis not accessible# - Invalid config.yaml# - Port already in use# Check worker logsdocker-compose logs worker
# Verify Redis connectionredis-cli -h localhost ping
# Check queue statusredis-cli LLEN asynq:queues:image# Verify FFmpeg is installeddocker-compose exec worker ffmpeg -version
# Check file permissionsdocker-compose exec worker ls -la /tmp/mendMonitor Performance
Set up Metrics & Monitoring
Understand Architecture
Read the Architecture Guide
Configure Webhooks
Set up Webhooks