Skip to content

[Performance] Thread Pool Size Limits Segment Upload Throughput #547

@filthyrake

Description

@filthyrake

Summary

The ThreadPoolExecutor for segment I/O only has 16 workers for ALL segment uploads across all streams.

Impact

Severity: HIGH

Throughput calculation:

  • 50 concurrent streams × 3 qualities = 150 segments/10s = 15 segments/sec
  • Each segment write takes ~200ms (50MB at 250MB/s NAS)
  • 15 seg/sec × 0.2s = 3 workers busy on average
  • Current capacity: 16 workers = 80 seg/sec max

This is acceptable for 200 concurrent streams but becomes a hard bottleneck at 500+ streams.

Files Affected

  • /api/live_ingest.py (line 66)

Recommended Fix

  1. Increase max_workers to 64 for write-heavy workloads
  2. Consider using os.O_DIRECT flag to bypass page cache for large segments (reduces memory pressure)
  3. Monitor thread pool queue depth with metrics
_io_executor = ThreadPoolExecutor(max_workers=64, thread_name_prefix="live_io")

Scaling Characteristics

  • Current: 80 seg/sec max (hard limit)
  • After fix: 320 seg/sec max

🤖 Generated by automated performance review

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions