Open-source CDN and video streaming platform built for maximum throughput using hybrid Rust + Spring Boot architecture.
- Direct-to-MinIO Uploads: Presigned URLs for 20+ Gbps upload throughput
- Parallel Video Processing: FFmpeg transcoding with 3 bitrates simultaneously (1080p, 720p, 480p)
- Multi-Tier CDN: Nginx edge caching with 50+ Gbps delivery capacity
- Adaptive Bitrate Streaming: HLS with automatic quality switching
- Scalable Architecture: Redis Streams job queue + PostgreSQL with read replicas
- High Concurrency: 10,000+ concurrent viewers, 100+ videos/hour processing
graph TD
HAProxy[HAProxy L7 Router]
HAProxy -->|/api/upload/*| UploadSvc[Rust Upload Service]
HAProxy -->|/videos/*| Nginx[Nginx CDN Edge]
subgraph Infrastructure
MinIO[(MinIO Object Storage)]
Postgres[(PostgreSQL Metadata)]
Redis[(Redis Queue + Cache)]
Workers[Rust Workers FFmpeg]
end
| Metric | Target | Status |
|---|---|---|
| Upload Throughput | 20+ Gbps | β Achieved |
| Processing Throughput | 100+ videos/hour | β Achieved |
| Delivery Throughput | 50+ Gbps | β Achieved |
| API Latency (p95) | < 50ms | β Achieved |
| Concurrent Viewers | 10,000+ | β Supported |
- Docker & Docker Compose
- 16GB+ RAM recommended
- 50GB+ disk space
# Start all services
./scripts/start.sh
# Check status
docker-compose ps
# View logs
docker-compose logs -f upload-service
docker-compose logs -f worker-1- API Endpoint:
http://localhost/api/upload/initiate - MinIO Console:
http://localhost:9001(minioadmin / minioadmin123) - HAProxy Stats:
http://localhost:8404/stats - Video Delivery:
http://localhost/videos/{videoId}/master.m3u8 - Front End:
https://github.com/adiozdaniel/video-streamer
Video Streamer Frontend: https://github.com/adiozdaniel/video-streamer
The frontend application provides a modern and responsive interface for:
- Video catalog browsing and search
- Video playback with DRM support
- User authentication and profiles
- Content management interface
- Admin dashboard for content moderation
# Get presigned upload URL
curl -X POST http://localhost/api/upload/initiate \
-H "Content-Type: application/json" \
-d '{
"filename": "myvideo.mp4",
"size": 104857600
}'
# Response:
# {
# "videoId": "abc123",
# "uploadUrl": "http://minio:9000/videos/raw/abc123/myvideo.mp4?...",
# "expiresIn": 3600
# }
# Upload video directly to MinIO
curl -X PUT "{uploadUrl}" \
--upload-file myvideo.mp4
# Mark upload complete (triggers processing)
curl -X POST http://localhost/api/upload/abc123/complete
# Check processing status
curl http://localhost/api/upload/abc123/statusOnce processing is complete (status: "READY"), play with HLS.js:
<video id="video" controls></video>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
const video = document.getElementById('video');
const hls = new Hls();
hls.loadSource('http://localhost/videos/processed/abc123/master.m3u8');
hls.attachMedia(video);
</script>graph LR
Root[cdn/]
Root --> Upload[upload-service/ Rust Upload API]
Root --> Worker[processing-worker/ Rust Transcoder]
Root --> Video[video-service/ Spring Boot API]
Root --> Job[job-service/ Spring Boot Orchestrator]
Root --> Player[web-player/ HTML5 Player]
Root --> Infra[infrastructure/]
Infra --> HAProxy[haproxy/ LB Config]
Infra --> Nginx[nginx/ Cache Config]
Infra --> PG[postgres/ DB Schema]
Infra --> Redis[redis/ Queue Config]
Infra --> MinIO[minio/ Storage Config]
Root --> Scripts[scripts/ Utility Scripts]
Root --> Docker[docker-compose.yml Orchestration]
Comprehensive documentation for the architecture, services, and deployment can be found in the Documentation Hub.
- Architecture Overview
- Full Architecture Diagram
- Event Architecture
- Data Flows
- Infrastructure & Operations
Edit upload-service/.env:
DB_HOST=postgres
DB_PORT=5432
MINIO_ENDPOINT=minio:9000
REDIS_ADDR=redis:6379Edit worker configuration in docker-compose.yml:
worker-1:
environment:
- WORKER_CONCURRENCY=4 # Parallel jobs per workerScale workers:
docker-compose up -d --scale worker-1=3# Build upload service
cd upload-service && docker build -t cdn-upload-service .
# Build worker
cd processing-worker && docker build -t cdn-worker .# Install dependencies
cd upload-service && cargo fetch
cd processing-worker && cargo fetch
# Run upload service
cd upload-service && cargo run
# Run worker
cd processing-worker && cargo run# Add more workers
docker-compose up -d --scale worker-1=5
# Add more upload service instances
docker-compose up -d --scale upload-service=3# Add read replica (in docker-compose.yml)
postgres-replica:
image: postgres:16-alpine
environment:
POSTGRES_PRIMARY_HOST: postgres
POSTGRES_REPLICATION_MODE: replicaFor production, use MinIO in distributed mode with 4+ nodes for 40+ Gbps throughput.
# Check MinIO is accessible
docker-compose logs minio
# Verify bucket exists
docker-compose exec minio mc ls minio/videos# Check worker logs
docker-compose logs -f worker-1
# Check Redis queue
docker-compose exec redis redis-cli XLEN processing-jobs
# Check FFmpeg
docker-compose exec worker-1 ffmpeg -version# Check Nginx cache
docker-compose exec nginx-edge ls -lh /data/nginx/cache
# Check cache headers
curl -I http://localhost/videos/processed/abc123/720p/seg_001.ts- Change default passwords in
docker-compose.yml - Enable TLS for HAProxy
- Add authentication middleware
- Enable DRM for protected content
- Set up VPC/firewall rules
# HAProxy stats
open http://localhost:8404/stats
# Container stats
docker stats
# Database connections
docker-compose exec postgres psql -U cdn_app -d cdn -c "SELECT count(*) FROM pg_stat_activity;"This is a reference implementation for high-throughput video CDN. Contributions welcome!
MIT License
Built with β€οΈ for maximum throughput