Skip to content

Performance Optimization

Sergio Soto edited this page Apr 8, 2026 · 2 revisions

Performance Optimization

Resource Sizing by File Type

Source CPU Memory Ephemeral Disk Processing Time
2K EXR (8MB) 500m 512Mi 500Mi ~5s
4K EXR (50MB) 1000m 1Gi 1Gi ~15-30s
4K DPX (25MB) 1000m 1Gi 1Gi ~10-20s
8K EXR (200MB) 2000m 2Gi 3Gi ~60-120s

Ephemeral disk usage per file: source + 2 OCIO intermediates + PNG intermediate + outputs. Formula: ~3x source size peak.

Autoscaling

Setting Value Rationale
RPS factor 1 CPU-bound work; don't share a pod
minScale 1 Avoid cold start (oiiotool + ffmpeg binary load)
maxScale 5 Cap total cluster memory (5 x 2GB = 10GB)
Scale-down delay 60s Avoid pod thrashing during burst ingestion

Bottlenecks

  1. S3 download -- Full file download required (no Range GET like exr-inspector). Mitigated by boto3 adaptive retries and connection pooling (25 connections).
  2. ffmpeg H.264 encoding -- CPU-bound, single-threaded with -preset fast. Consider -preset ultrafast for 2x speed at cost of ~30% larger files.
  3. Color transform -- CPU-bound, two transforms per file (sRGB + Rec709). Most time spent on the resize operation, not the colorconvert.
  4. S3 upload -- Two uploads per file (thumbnail + proxy). Proxy upload is the larger one (typically 1-5MB for a single-frame proxy).

Optimization Tips

  • Set delivery to unordered -- each file is independent, no sequencing needed
  • Use the same S3 endpoint for download and upload to minimize network hops
  • The function cleans up all /tmp files after each request, so ephemeral disk does not accumulate between invocations
  • If processing 8K+ files, increase OIIO_TIMEOUT beyond the default 300s

Optimization Roadmap

Change Impact Status
S3 ContentType + tags on upload Browser delivery ready Done (v2.0.0)
ffmpeg -movflags +faststart Browser streaming without full download Done (v2.0.0)
Batch color transform (single intermediate) -1 transform per file Planned
ffmpeg -preset ultrafast option 2x encode speed Planned
Sequence-aware processing (detect frame range) Skip duplicate transforms Planned

Clone this wiki locally