A high-performance, production-ready video/audio streaming service built in Go, designed for 100M+ RPS with HLS adaptive bitrate streaming.
This streaming platform provides enterprise-grade video delivery with:
- HLS Adaptive Streaming - Automatic quality adjustment based on viewer bandwidth
- Multi-Bitrate Encoding - 1080p, 720p, 480p, 360p renditions
- Audio Support - Standalone audio streaming and video audio extraction
- AWS Native - S3 storage, DynamoDB metadata, CloudFront CDN
- Kubernetes Ready - Terraform-managed infrastructure for auto-scaling
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Web β β Mobile β β Smart TV β β OTT β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
βββββββββΌββββββββββββββΌββββββββββββββΌββββββββββββββΌββββββββββββββββββββββββββββ
β β β β
βββββββββββββββ΄βββββββ¬βββββββ΄ββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CDN / EDGE LAYER β
β βββββββββββββββββββ β
β β CloudFront β βββ Cached HLS Segments β
β ββββββββββ¬βββββββββ β
βββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API GATEWAY LAYER β
β βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ β
β β Load Balancer ββββ API Server ββββ Auth β β
β βββββββββββββββββ βββββββββ¬ββββββββ βββββββββββββββββ β
β β β
βββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MICROSERVICES LAYER β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Upload β β Transcode β β Stream β β Audio β β
β β Service β β Service β β Service β β Service β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
βββββββββββΌβββββββββββββββββΌβββββββββββββββββΌβββββββββββββββββΌβββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA & PROCESSING LAYER β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β S3 β β FFMPEG β β DynamoDB β β Redis β β
β β (Storage) β β (Encoding) β β (Metadata) β β (Queue) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
streaming-service/
βββ cmd/
β βββ api/ # API server entrypoint
β βββ worker/ # Transcoding worker entrypoint
βββ internal/
β βββ api/ # HTTP handlers & Chi router
β βββ config/ # Viper configuration management
β βββ domain/ # Business entities (Media, Video, Audio)
β βββ media/
β β βββ ffmpeg/ # FFMPEG video/audio processors
β β βββ processor/ # Factory & Strategy pattern implementations
β βββ queue/ # Redis job queue with priority support
β βββ repository/
β β βββ dynamodb/ # Metadata CRUD operations
β β βββ s3/ # Object storage with presigned URLs
β βββ service/
β βββ audio/ # Audio extraction & processing
β βββ stream/ # Playback URL generation
β βββ transcode/ # HLS transcoding pipeline
β βββ upload/ # File upload handling
βββ pkg/
β βββ logger/ # Zap structured logging
βββ deployments/
β βββ docker/ # Multi-stage Dockerfiles
β βββ kubernetes/ # K8s manifests
β βββ terraform/ # Infrastructure as Code
βββ config.yaml # Application configuration
Creates appropriate media processors based on content type:
processor := factory.CreateProcessor(domain.MediaTypeVideo) // or MediaTypeAudio
Interchangeable transcoding strategies for different output formats:
executor.AddStrategy(NewHLSTranscodeStrategy(profile1080p)) executor.AddStrategy(NewHLSTranscodeStrategy(profile720p)) executor.Execute(ctx, input, outputDir, cmdExecutor)
Concurrent job processing with configurable parallelism:
worker := transcode.NewWorker(queue, service, concurrency, logger) worker.Start(ctx)
- Go 1.22+
- Docker & Docker Compose
- FFMPEG (for local development)
- AWS CLI (configured)
# Clone repository git clone https://github.com/ichbingautam/streaming-service.git cd streaming-service # Install dependencies go mod download # Start infrastructure (Redis + LocalStack) docker-compose up -d redis localstack # Run API server make run-api # Run transcoding worker (in another terminal) make run-worker
# Start all services docker-compose up -d # View logs docker-compose logs -f api worker
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/ready |
Readiness probe |
POST |
/api/v1/upload |
Upload media file (multipart) |
POST |
/api/v1/upload/presign |
Get presigned upload URL |
POST |
/api/v1/upload/{id}/confirm |
Confirm presigned upload |
GET |
/api/v1/media |
List user's media |
GET |
/api/v1/media/{id} |
Get media details |
DELETE |
/api/v1/media/{id} |
Delete media |
GET |
/api/v1/media/{id}/playback |
Get HLS playback URL |
curl -X POST http://localhost:8080/api/v1/upload \ -H "X-User-ID: user123" \ -F "file=@video.mp4" \ -F "title=My Video" \ -F "description=Sample video"
curl http://localhost:8080/api/v1/media/{media_id}/playback \
-H "X-User-ID: user123"Configuration via config.yaml or environment variables (prefix: STREAM_):
app: name: streaming-service version: 1.0.0 environment: production server: port: 8080 readtimeout: 30s writetimeout: 30s aws: region: us-east-1 s3rawbucket: streaming-raw-media s3processedbucket: streaming-processed-media dynamodbtable: video-metadata cloudfrontdomain: d1234.cloudfront.net redis: host: redis port: 6379 ffmpeg: binarypath: ffmpeg segmentduration: 6 profiles: - name: "1080p" width: 1920 height: 1080 videobitrate: "5000k" audiobitrate: "192k" worker: concurrency: 4 jobtimeout: 30m log: level: info format: json
cd deployments/terraform # Initialize Terraform terraform init # Review plan terraform plan -var="environment=production" # Apply infrastructure terraform apply -var="environment=production"
# Create namespace kubectl create namespace streaming # Apply manifests kubectl apply -f deployments/kubernetes/ -n streaming # Check deployment kubectl get pods -n streaming
# Run tests make test # Run with coverage make test-coverage # Lint code make lint # Build binaries make build # Build Docker images make docker-build
| Metric | Target |
|---|---|
| API Latency (p99) | < 50ms |
| Transcode Time (1min video) | < 60s |
| CDN Cache Hit Ratio | > 95% |
| Concurrent Streams | 100M+ |
| Component | Technology |
|---|---|
| Language | Go 1.22+ |
| HTTP Router | Chi |
| Configuration | Viper |
| Logging | Zap |
| Media Processing | FFMPEG |
| Storage | AWS S3 |
| Metadata | AWS DynamoDB |
| CDN | AWS CloudFront |
| Queue | Redis |
| Containers | Docker |
| Orchestration | Kubernetes |
| IaC | Terraform |
MIT License - see LICENSE for details.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request