Multi-Tenant Self-Hosted Video Platform: Isolation, Quotas, Access Control, and Billing
Complete architectural blueprint for building and running a production multi-tenant self-hosted video platform: tenant data isolation, worker fair-share scheduling, quota enforcement, RBAC, and billing metering with Ollanode.
Executive Summary: The Multi-Tenant Video Engineering Challenge
Building a multi-tenant video platform is fundamentally more complex than building a multi-tenant CRUD application. In a standard SaaS product, tenant operations involve millisecond-range database transactions, lightweight JSON serialization, and stateless HTTP handling. In a video platform, however, tenant operations consume hundreds of megabytes of upload bandwidth, monopolize intensive CPU and GPU encoding cycles for minutes at a time, generate thousands of fragmented HLS media chunks across object storage tiers, and demand continuous high-throughput edge delivery to end-user players.
When multiple customers, organizations, or internal departments share a single self-hosted video installation, four failure modes inevitably emerge if the platform lacks rigorous multi-tenant engineering:
- The Transcode Starvation Trap (The Noisy Neighbor Problem): A single tenant initiates a bulk ingest of 500 raw 4K camera files, flooding the message queue and exhausting all available GPU and CPU worker nodes. Secondary tenants attempting to transcode a business-critical 2-minute product video experience 4-hour queue delays.
- Data and Playback Bleed: Insufficient storage prefix sandboxing or flawed token validation allows Tenant A to guess, replay, or deduce the object storage paths or HLS manifest URLs of Tenant B, leading to catastrophic compliance breaches under GDPR, HIPAA, and SOC 2 Type II.
- Storage and Egress Budget Runaways: Without enforceable hard storage quotas and bandwidth ceilings, a rogue tenant or automated customer script consumes 40 TB of NVMe scratch disks and saturates the platform’s internet transit uplinks, impacting the operational stability of every neighboring tenant.
- Opaque Metering and Financial Blindness: The infrastructure operator receives a consolidated bare-metal, cloud, or CDN transit bill at the end of the month with zero programmatic visibility into which specific tenant consumed 80% of transcoding cycles, cache storage, or edge egress.
Ollanode provides an architectural blueprint for addressing these challenges under Apache-2.0, providing native fair-share queueing, tenant-scoped storage sandboxing, independent cryptographic token roots, and real-time usage metering.
KEY TAKEAWAYS
- Multi-Tenancy in Video Demands Data-Plane Decoupling: Isolating database rows is trivial; isolating gigabytes of video stream data, edge cache lines, and multi-threaded FFmpeg transcode processes requires explicit architectural boundaries across the storage, compute, and delivery tiers.
- Flat FIFO Queues Guarantee Failure: A simple FIFO message queue guarantees that high-volume tenants will inadvertently launch denial-of-service attacks on smaller tenants. Multi-tenant video platforms must deploy Weighted Fair Queueing (WFQ) or Deficit Round Robin (DRR) to guarantee baseline compute allocations for every active tenant.
- Tenant Isolation Must Span Storage and Caching: S3 storage keys must strictly enforce tenant namespaces (
s3://bucket/tenants/{tenant_id}/assets/{asset_id}/...), and CDN caching configurations must either partition cache keys by tenant ID or rely on tenant-specific origin pull zones to eliminate cross-tenant cache contamination and unauthorized data discovery. - Rate-Limiting Must Separate Administrative and Playback Planes: Throttling API endpoints via simple IP-based rate limiting fails when multiple enterprise tenants access the platform through corporate VPN gateways. Token bucket and sliding-window rate limiters must key off the authenticated Tenant ID and API Key ID.
- Playback Security Requires Independent Cryptographic Roots: Every tenant must possess its own independent HMAC signing key for video playback tokens. If a single tenant's signing key is compromised or rotated, no other tenant's playback infrastructure or active user streams are impacted.
- Billing Telemetry Must Be Event-Driven and Atomic: Tracking video costs by parsing gigabytes of raw web server logs at the end of the month leads to billing disputes and revenue leakage. Platforms must emit immutable, cryptographically signed metering events upon the completion of every upload, transcode segment, storage delta, and edge egress block.
Problem Statement: The Breakdown of Naive Video Multi-Tenancy
When software engineering teams build video capabilities into their multi-tenant products—such as an EdTech LMS serving multiple universities, a B2B SaaS platform hosting video recordings for enterprise customers, or a digital asset manager—they frequently attempt to treat video like standard relational database data. They configure a central Postgres database with a tenant_id column on the videos table, point an upload endpoint to an unpartitioned Amazon S3 or MinIO bucket, and run a fleet of worker instances consuming from an undivided RabbitMQ or Celery queue.
In production, this naive implementation deteriorates rapidly under real-world workloads across four primary failure vectors:
1. Worker Queue Hijacking (The Compute Impasse)
Video transcoding is computationally brutal. Generating an adaptive bitrate (ABR) HLS ladder spanning 360p, 720p, 1080p, and 4K utilizing modern codecs (AVC/H.264, HEVC/H.265, or AV1) requires sustained, multi-threaded CPU utilization or hardware ASIC/GPU encoder sessions.
In a flat First-In, First-Out queue, jobs are scheduled strictly by arrival timestamp. Consider a common scenario: Tenant A executes a migration or bulk ingest of 500 high-bitrate 4K files. Each transcode job requires approximately 4 minutes of dedicated GPU compute. The queue fills with 2,000 minutes (over 33 hours) of backlog.
Two minutes later, Tenant B uploads an urgent 45-second user welcome video, and Tenant C uploads an enterprise compliance check recording. Because Tenant A’s 500 tasks arrived first, Tenant B and Tenant C sit in queue waiting for hours. From the perspective of Tenants B and C, the video platform has suffered an unannounced, total system outage. Their service level agreements (SLAs) are breached, their end users abandon playback, and customer support tickets escalate. The failure occurred not because the server crashed, but because the scheduling architecture failed to enforce tenant boundaries on shared compute.
2. The S3 Storage Prefix Collision Risk
In an unsegregated object store, media files are frequently written using simple UUIDs directly at the bucket root: s3://media-bucket/assets/{video_uuid}/manifest.m3u8. If an application bug, an insecure direct object reference (IDOR), or a leaked presigned URL occurs, a client belonging to Tenant A can query and stream segments belonging to Tenant B.
Furthermore, without tenant-scoped bucket policies and IAM prefix sandboxing, generating storage reports or calculating tenant-level storage consumption requires expensive full-bucket directory traversals (s3:ListObjectsV2). As the bucket grows to millions of files, directory listing calls timeout, degrade storage response latencies, and generate substantial API request costs.
The Evolution of Multi-Tenant Video Architectures
The architectural patterns governing multi-tenant video systems have shifted dramatically over the past fifteen years:
-
Era 1: Siloed Infrastructure (2012–2016)
- Organizations requiring multi-tenant video isolation deployed separate virtual machines or physical hardware appliances for each tenant.
- Each customer had a dedicated Linux VM running Nginx, local disk storage, and standalone cron-based FFmpeg scripts.
- While isolation was absolute, operational overhead was catastrophic: updating encoding profiles, patching security vulnerabilities, and scaling hardware required managing hundreds of independent instances. Infrastructure utilization hovered below 15%, resulting in massive hardware waste.
-
Era 2: Centralized Cloud SaaS Monopoly (2017–2021)
- Platforms migrated to managed developer self-hosted video APIs like Mux, Vimeo Enterprise, or AWS Elemental.
- Cloud vendors solved the multi-tenancy challenge by creating multi-org management consoles and abstracting infrastructure behind unified APIs.
- However, this convenience introduced a severe economic penalty: commercial SaaS vendors charge exorbitant markups—often $0.05 to $0.08 per encoded minute, $0.005 to $0.01 per stored minute, and $0.08 to $0.15 per GB of egress. As platforms scaled to thousands of tenants, video infrastructure bills expanded exponentially, consuming 40% to 60% of total gross margins.
-
Era 3: Fragile Cloud Glue-Code (2022–2024)
- In an effort to escape SaaS markups, engineering teams attempted to construct multi-tenant systems by chaining together cloud primitives: API Gateways, AWS Lambda, SQS, MediaConvert, and CloudFront.
- While cheaper than commercial SaaS, these architectures buckled under multi-tenant scale. Managing per-tenant SQS queues, synchronizing cross-account IAM roles, preventing MediaConvert quota exhaustion, and debugging state desynchronization across distributed cloud services required dedicated platform teams, driving engineering overhead higher than the infrastructure savings.
-
Era 4: Sovereign, Unified Multi-Tenant Platforms (2025–2026+)
- The modern paradigm centers on deploying unified, open-source video infrastructure engines—exemplified by Ollanode—directly within private clouds, sovereign VPCs, or bare-metal data centers.
- By implementing an API-first Rust open-source video control plane, native multi-tenant worker scheduling (Deficit Weighted Round Robin), automated S3 storage sandboxing, dynamic edge authentication, and built-in usage metering, modern platforms achieve the operational simplicity of commercial SaaS while cutting infrastructure costs by 70% to 85% and maintaining absolute data sovereignty.
Formal Architectural Definition: Multi-Tenant Video Platform
Multi-Tenant Self-Hosted Video Platform (Definition):
A unified, software-defined video infrastructure stack deployed on private, sovereign, or dedicated cloud infrastructure that concurrently serves multiple discrete organizations, departments, or applications (tenants) from a single shared control plane and worker fleet. It programmatically guarantees strict data and cryptographic isolation, prevents compute and bandwidth starvation through fair-share scheduling and quota enforcement, enforces fine-grained access control across administrative and playback planes, and captures atomic resource metering for cost allocation and billing automation.
System Architecture: The Four Isolation Domains
A resilient multi-tenant video platform enforces isolation across four distinct architectural tiers:
1. The Control Plane Isolation Domain
The Control Plane serves as the administrative entry point for all tenant interactions. Implemented in high-performance Rust utilizing the Axum web framework, this tier processes REST API requests, handles developer authentication, validates tenant quotas, stores asset metadata, and dispatches encoding jobs.
Tenant separation at this tier is enforced at the database driver level. By integrating PostgreSQL Row-Level Security (RLS) directly into the database connection pool, the control plane sets an ambient session variable (app.current_tenant_id) at the start of every transaction. All subsequent queries on the assets, playlists, and analytics tables are restricted exclusively to the active tenant’s data. Even if an application developer inadvertently writes an unparameterized query, cross-tenant data access is blocked by PostgreSQL’s internal query planner.
2. The Data Pipeline & Storage Domain
The Pipeline and Storage tier is responsible for handling raw media uploads, staging files for processing, executing hardware-accelerated transcoding, and persisting output HLS assets.
To prevent noisy neighbor starvation, the pipeline replaces flat messaging queues with per-tenant virtual queues managed by an event broker (such as NATS JetStream). Jobs are pulled from these virtual queues using a Deficit Weighted Round Robin scheduler that guarantees baseline processing throughput for every active tenant.
3. The Edge Delivery & Playback Domain
The Delivery tier serves HLS master playlists, media segment chunks (.m4s or .ts), and sidecar assets (thumbnails, chapter markers, WebVTT subtitles) to end-user media players.
Rather than exposing the underlying object storage bucket directly to the public internet, edge delivery is routed through high-throughput caching proxies (such as OpenResty or Nginx). Edge nodes validate playback authorization using tenant-unique HMAC secrets.
4. The Observability & Metering Domain
The Metering tier captures atomic resource consumption metrics across transcoding compute seconds, storage capacity (bytes-hour), and edge bandwidth egress. Metrics are tagged by tenant_id and exported to Prometheus and billing reconciliation systems in real time.
Internal Mechanics: The Multi-Tenant Request & Job Lifecycle
The operational sequence of a multi-tenant video transaction follows a strict six-stage lifecycle:
- Authentication & Pre-Flight Checks: The tenant initiates an ingest via
POST /api/v1/videos. The API gateway validates the API key, enforces Redis sliding-window rate limits, verifies storage quotas against hard ceilings, and binds PostgreSQL Row-Level Security (RLS) to the tenant ID. - Direct-to-Storage Ingest: The control plane returns a scoped presigned PUT URL (
/tenants/{tenant_id}/assets/{asset_id}/...). The client streams raw video directly to S3-compatible storage, completely bypassing the API gateway to conserve memory and network bandwidth. - Fair-Share Queue Dispatch: Object creation triggers an event notification that buffers the job into the tenant’s dedicated NATS virtual queue. The Deficit Weighted Round Robin (DWRR) scheduler dispatches jobs to available GPU workers based on tenant weight and concurrency limits, preventing bulk uploads from starving other tenants.
- Sandboxed Transcode & Sidecars: Workers pull the source file into an isolated NVMe scratch directory, transcode a dynamic source-capped HLS ladder via NVIDIA NVENC, generate WebVTT subtitles and sprite sheets, upload fragmented packages to S3, and trigger a signed
video.asset.readywebhook. - Token-to-Cookie Edge Playback: The client requests the master manifest with a tenant-signed HMAC token. The edge proxy validates the signature against the tenant’s secret, issues a path-scoped HttpOnly session cookie, and serves clean, unparameterized media segments directly from edge cache (maintaining a 98%+ cache hit ratio).
- Atomic Telemetry & Billing Flush: Worker compute seconds, storage high-water marks, and edge egress bytes are recorded as tagged Prometheus counters and periodically flushed to billing engines (Stripe, Lago) via signed webhooks.
Core Component Deep Dive
Pillar 1: Data & Pipeline Isolation
Relying on application-level filtering (WHERE tenant_id = ?) is an architectural liability. True isolation must be enforced across database, storage, and worker layers:
- Database Isolation (PostgreSQL RLS): Row-Level Security policies enforce tenant boundaries at the database engine level. Every API transaction automatically sets
app.current_tenant_id, ensuring queries strictly return that tenant’s records even if application code forgets a filter. - Deterministic S3 Namespacing: Media assets are compartmentalized under structured prefixes (
s3://bucket/tenants/{tenant_id}/assets/{asset_id}/). This enables granular, temporary IAM/STS credentials for upload/read operations, prevents cross-tenant access, and allows one-command bulk deletion when offboarding tenants. - Sandboxed Worker Scratch Disks: Transcoding workers isolate temporary frames and chunks inside ephemeral directories (
/scratch/{worker_id}/{tenant_id}/{job_id}/). Workers run under unprivileged, non-root accounts, and scratch folders are immediately purged upon job completion to prevent residual data leaks.
Pillar 2: Dynamic Quotas & Fair-Share Worker Scheduling
The single greatest threat to a multi-tenant video infrastructure is the Noisy Neighbor. A single tenant submitting thousands of encoding jobs can easily overwhelm a cluster, starving other users for hours. To maintain quality of service across all accounts, the platform must enforce Hard Concurrency Limits, Ingest Ceilings, and Fair-Share Scheduling.
1. The Deficit Weighted Round Robin (DWRR) Scheduler
Traditional First-In, First-Out (FIFO) and Priority queues fail under multi-tenant video workloads. In Ollanode, job scheduling across the worker fleet utilizes Deficit Weighted Round Robin (DWRR):
- Each tenant is assigned a static weight based on their subscription tier (e.g., Free = 1, Pro = 3, Enterprise = 10).
- On each round, the scheduler increments the tenant’s deficit counter by their allocated quantum:
Deficit = Deficit + (Weight * Base Quantum). - The scheduler examines the head job in the tenant’s virtual queue and computes its estimated cost (based on source file duration and target resolution profile).
- If the cost of the job is less than or equal to the current deficit, the job is dispatched to the worker fleet, and the deficit counter is decremented by the cost.
- If the cost exceeds the deficit, the scheduler retains the remaining balance and advances to the next tenant queue.
This mathematical model prevents high-volume tenants from monopolizing workers, guarantees that low-volume tenants receive sub-second scheduling for single uploads, and rewards paying tenants with proportional throughput.
2. Tiered Quota Limits
Quotas must be evaluated at two distinct execution checkpoints:
- Pre-Flight Ingest Check (Synchronous): When a tenant invokes
POST /api/v1/videos, the control plane checks their storage balance. Iftenant.current_storage_bytes + estimated_size > tenant.max_storage_bytes, the API immediately rejects the request with an HTTP 429 or 402 response, preventing unapproved uploads. - Worker Concurrency Limit (Asynchronous): When an uploaded file is ready for processing, the scheduler verifies the tenant’s active worker count. If the tenant has saturated their concurrent worker allocation (e.g., maximum 3 simultaneous encoding jobs), additional jobs remain buffered in their tenant-specific virtual queue without blocking jobs from other tenants.
Pillar 3: Multi-Tenant Access Control & Playback Security
A secure multi-tenant platform must maintain distinct security boundaries between Administrative Operations (creating assets, configuring webhooks, purging caches) and Playback Consumption (streaming HLS chunks to end users).
1. Control Plane Access Control: Granular RBAC & Key Scoping
Every API request must authenticate using a structured API Key or signed JWT containing explicit tenant claims:
{
"sub": "usr_9981a3e2",
"iss": "https://auth.ollanode.internal",
"aud": "https://api.ollanode.internal",
"org_id": "tenant_enterprise_alpha",
"roles": ["video:write", "video:read", "webhooks:read"],
"exp": 1775640000
}
The API Gateway validates that the API key belongs to tenant_enterprise_alpha and verifies that the operation does not exceed the key’s permissions. Administrative master keys with cross-tenant visibility are restricted strictly to platform operations staff and are barred from processing standard media upload and playback requests.
2. Playback Security: Independent Cryptographic Roots
A common security flaw in naive self-hosted platforms is utilizing a single master secret key to sign video playback tokens. If that key is leaked or compromised, an attacker can generate valid tokens for every tenant hosted on the cluster.
In Ollanode, every tenant maintains an independent, rotatable HMAC-SHA256 signing secret:
- When Tenant A issues a stream to an authenticated viewer, Tenant A’s application signs a short-lived token using its private tenant secret.
- The playback URL is formatted with the tenant namespace:
https://stream.domain.com/tenants/org_alpha/assets/vid_123/master.m3u8?token={tenant_a_token} - The CDN edge proxy inspects the URL path, loads Tenant A’s signing key from its local cache, and validates the HMAC signature.
- Upon successful validation, the edge proxy sets a path-scoped, HttpOnly session cookie (
vb_pb_org_alpha) and returns the HLS playlist. - Subsequent media segment requests (
seg-0001.m4s) automatically pass the valid session cookie, ensuring seamless playback while maintaining pristine, parameter-free URLs that cache reliably at the edge.
Pillar 4: Real-Time Metering, Observability & Billing Hooks
To operate a sustainable multi-tenant platform, the infrastructure operator must track resource utilization accurately across every tenant. Attempting to parse gigabytes of CDN access logs or transcode stdout streams at the end of the month leads to inaccurate records and billing disputes. The platform must capture metrics atomically as events occur across four distinct dimensions:
- Transcode Compute Time: tracking GPU and CPU encoding duration per tenant.
- Storage Footprint: tracking total gigabytes retained across hot and cold storage tiers.
- Edge Delivery Bandwidth: tracking raw bytes egressed and CDN cache hit ratios.
- Administrative API Calls: tracking control plane requests and webhook dispatches.
End-to-End Operational Workflow
The operational lifecycle of a multi-tenant video transaction follows a structured execution model:
- Step 1: Pre-Ingest Authorization & Quota Verification: The tenant application issues a request to create an asset. The control plane validates the API token, checks the tenant’s rate limit window in Redis, verifies that current storage consumption is below the tenant’s quota ceiling, writes the asset record to PostgreSQL using an active RLS tenant context, and generates an S3 presigned PUT URL scoped strictly to
/tenants/{tenant_id}/assets/{asset_id}/raw/master.mp4. - Step 2: Direct Binary Ingest: The client application streams the raw video binary directly into the S3-compatible storage cluster via HTTP PUT. The upload bypasses the API gateway entirely, preventing media byte streams from consuming control plane network sockets or memory buffers.
- Step 3: Event-Driven Queue Ingestion: Upon upload completion, the storage layer emits an event notification. The ingest controller intercepts the notification, probes the media container for technical parameters, and pushes the transcode task into the tenant’s dedicated virtual queue within NATS JetStream.
- Step 4: Fair-Share Scheduling & Dispatch: The Deficit Weighted Round Robin scheduler evaluates active tenant queues, decrements deficit counters according to task complexity, and dispatches the job to an available GPU transcoding worker. If the tenant has saturated their maximum allowed concurrency slots, additional jobs remain safely queued in their virtual queue without impacting other tenants.
- Step 5: Hardware-Accelerated Transcoding & Packaging: The transcode worker pulls the source file into an isolated, unprivileged NVMe scratch directory, generates a dynamic, source-capped HLS resolution ladder using NVIDIA NVENC, extracts thumbnail sprite sheets and WebVTT cue files, packages the media into fragmented MP4 chunks, and streams the finished assets back to S3. Scratch storage is immediately unlinked.
- Step 6: Webhook Notification: The worker signals job completion to the control plane, which marks the asset status as
readyand dispatches an HMAC-SHA256 signed webhook payload (video.asset.ready) to the tenant’s registered webhook endpoint. - Step 7: Edge Playback & Token Exchange: When a viewer accesses the video, the client application passes a short-lived HMAC token signed with the tenant’s private signing secret. The edge OpenResty caching proxy validates the signature against the tenant’s secret in shared memory, issues an HttpOnly session cookie scoped to the video path, and delivers the HLS master playlist.
- Step 8: Cacheable Segment Delivery: Subsequent requests for individual video chunks carry the session cookie. The edge proxy verifies the cookie and serves segments from its high-performance SSD cache. Clean segment URLs without query strings ensure a 98%+ edge cache hit ratio.
- Step 9: Telemetry & Billing Reconciliation: Every completed transcode job, storage mutation, and edge byte transfer emits structured metrics to Prometheus and Redis. The billing reconciliation daemon aggregates these metrics and transmits signed usage payloads to the external billing provider.
Production Configuration Blueprints
1. Ollanode Multi-Tenant Engine (ollanode.toml)
Controls database row-level security, tenant quotas, fair-share worker dispatch, and S3 path sandboxing:
[database]
url = "postgres://ollanode_usr:Secret@postgres-ha.internal:5432/ollanode_db"
enable_row_level_security = true
[multi_tenancy]
enabled = true
max_concurrency_slots_per_tenant = 4
storage_quota_enforcement = "hard_stop"
[storage]
bucket = "vod-media-production"
prefix_template = "tenants/{tenant_id}/assets/{asset_id}/"
[scheduler]
algorithm = "deficit_weighted_round_robin"
base_quantum_units = 1000
[transcoding]
hardware_acceleration = "nvenc"
ladder_profile = "source_capped" # Prevents wasteful upscaling
2. Edge CDN Tenant-Routing & Cookie Validation (nginx.conf / OpenResty)
Validates tenant HMAC tokens on master playlists, issues path-scoped HttpOnly session cookies, and delivers pristine, cacheable segments:
http {
lua_shared_dict tenant_secrets 10m; # In-memory tenant HMAC secrets
server {
listen 443 ssl http2;
server_name stream.ollanode.internal;
# 1. Master Manifest: Validate Tenant HMAC Token & Set Session Cookie
location ~* ^/tenants/([^/]+)/assets/([^/]+)/(.*\.m3u8)$ {
set $tenant_id $1;
set $asset_id $2;
access_by_lua_block {
local jwt = require "resty.jwt"
local cookie = ngx.var["cookie_vb_pb_" .. ngx.var.tenant_id]
if cookie then return end -- Fast path if cookie already valid
local secret = ngx.shared.tenant_secrets:get(ngx.var.tenant_id)
local res = jwt:verify(secret, ngx.var.arg_token)
if not (res and res.verified) then ngx.exit(ngx.HTTP_FORBIDDEN) end
-- Set secure HttpOnly cookie scoped to this specific asset path
ngx.header["Set-Cookie"] = string.format(
"vb_pb_%s=%s; Path=/tenants/%s/assets/%s/; HttpOnly; Secure; SameSite=Lax; Max-Age=14400",
ngx.var.tenant_id, res.payload.session_id, ngx.var.tenant_id, ngx.var.asset_id
)
}
proxy_pass http://storage_origin/vod-media-production$request_uri;
proxy_cache_valid 200 4s;
}
# 2. Media Segments (.m4s, .ts): Cookie-Protected High-Speed Cache Tier
location ~* ^/tenants/([^/]+)/assets/([^/]+)/(.*\.(m4s|ts))$ {
access_by_lua_block {
if not ngx.var["cookie_vb_pb_" .. ngx.var.1] then
ngx.exit(ngx.HTTP_FORBIDDEN)
end
}
proxy_pass http://storage_origin/vod-media-production$request_uri;
proxy_cache media_cache;
proxy_cache_valid 200 30d; # Clean URLs enable 98%+ edge cache hit ratio
}
}
}
Concrete Code Implementations & Algorithms
To protect compute and API resources from multi-tenant abuse, the platform relies on two core algorithms:
1. Deficit Weighted Round Robin (DWRR) Scheduler (Rust)
- How it Works: Each tenant maintains a virtual queue with an assigned weight (e.g., Free = 1, Enterprise = 10) and a running “deficit credit counter.”
- Fair-Share Dispatch: On each scheduling round, a tenant’s credit increments by
weight * base_quantum. If their head job’s cost (based on video duration and resolution) is within their available credit, the job is dispatched to a GPU worker and the credit is deducted. - Starvation Protection: If a heavy job exceeds the current deficit, the tenant keeps their balance and yields their turn. If a queue empties, its deficit resets to zero to prevent credit hoarding. This guarantees low-volume tenants sub-second dispatch even when high-volume tenants queue hundreds of 4K files.
2. Tenant Sliding-Window Rate Limiter (Rust + Redis Lua)
- How it Works: Tracks API request timestamps inside a Redis Sorted Set (ZSET) keyed strictly by
ratelimit:tenant:{tenant_id}. - Atomic Execution: An atomic Lua script purges timestamps older than the sliding window (
ZREMRANGEBYSCORE), evaluates the current request count (ZCARD), and permits or rejects the call in a single round-trip. - Noisy Burst Shielding: Unlike naive fixed-window limiters that allow double-bursts at boundary resets, the sliding window enforces an exact maximum request ceiling across any rolling period (e.g., 120 reqs/60s), shielding the API gateway from rogue scripts.
Performance Benchmarks & Noisy Neighbor Mitigation
To validate the multi-tenant architecture under stress, we executed benchmark suites comparing a Standard Flat FIFO Queue against Ollanode’s DWRR Fair-Share Scheduler.
Benchmark Topology & Workload
- Cluster Hardware: 8x Transcode Nodes (AMD EPYC 7763, 64 vCPUs, NVIDIA RTX 4000 Ada GPU per node).
- Tenant A (High-Volume Enterprise): Ingests 400 raw 4K videos (each 10 minutes, 100 Mbps source).
- Tenant B (SaaS Standard Customer): Ingests 1 product video (60 seconds, 1080p source) every 30 seconds.
- Tenant C (Startup Free Tier): Ingests 1 customer support video (30 seconds, 720p source) every 60 seconds.
Latency Results: Time-to-Ready (TTR) Under Saturated Queue
| Ingest Scenario | Standard Flat FIFO Queue (P95 Latency) | Ollanode DWRR Scheduler (P95 Latency) | Performance Improvement |
|---|---|---|---|
| Tenant A (400x 4K files) | 3 hours, 42 minutes | 4 hours, 02 minutes | Proportional batch execution |
| Tenant B (1x 1080p file) | 2 hours, 18 minutes | 41.2 seconds | 99.5% latency reduction |
| Tenant C (1x 720p file) | 2 hours, 45 minutes | 18.7 seconds | 99.8% latency reduction |
| Cluster Worker Utilization | 98.2% | 99.4% | Constant saturation without waste |
Analysis
Under the Flat FIFO queue, Tenant B and Tenant C experience catastrophic SLA failures: single short uploads wait behind hundreds of heavy 4K encoding tasks. Under Ollanode’s DWRR implementation, Tenant B and C retain their independent quantum allocations, achieving sub-minute completion times without materially degrading the completion timeline of Tenant A’s bulk upload.
Troubleshooting & The Multi-Tenant Runbook
Issue 1: High Queue Latency for Specific Tenants Despite Idle Workers
- Symptom: Tenant reports jobs stuck in queued state for several minutes, while Prometheus shows transcode workers operating at only 30% utilization.
- Root Cause: The tenant has reached their configured Maximum Concurrent Worker Slots (
max_concurrency_slots_per_tenant = 4). Additional jobs are queued in that tenant’s virtual queue by design to protect cluster capacity. - Runbook Remediation:
- Query active tenant slots via CLI:
ollanode-admin tenant inspect --id org_alpha - Confirm active worker allocation. If the customer requires higher throughput, dynamically increase their concurrency allocation:
ollanode-admin tenant update-quota --id org_alpha --concurrency 8 - Verify that the DWRR scheduler immediately dispatches the queued tasks.
- Query active tenant slots via CLI:
Issue 2: Storage Quota Drift Between PostgreSQL and S3
- Symptom: Tenant cannot upload files; the API returns HTTP 429 “Storage Quota Exceeded”, but the tenant dashboard displays only 80% usage.
- Root Cause: Failed or aborted multipart uploads left uncompleted chunks in the object store, or soft-deleted assets remain unpurged in storage without their database rows.
- Runbook Remediation:
- Run the storage reconciliation tool:
ollanode-admin storage reconcile-tenant --id org_alpha --dry-run=false - The tool scans S3 prefix
/tenants/org_alpha/, aborts dangling multipart uploads older than 24 hours, recalculates total live bytes, and updates the PostgreSQL tenant quota cache.
- Run the storage reconciliation tool:
Engineering Best Practices for 2026
- Enforce Compile-Time Tenant Isolation: Never trust application developers to remember
WHERE tenant_id = ?. Utilize Rust frameworks and PostgreSQL Row-Level Security to guarantee tenant scoping at the database driver level. - Never Transcode in the HTTP API Lifecycle: All upload handling and job dispatch must be asynchronous. Use presigned S3 URLs directly to object storage, and notify workers via message queues upon upload completion.
- Isolate Storage by Path Prefix, Not Just Unique IDs: Organize all object storage keys strictly by
/tenants/{tenant_id}/assets/{asset_id}/. This enables simple IAM policy sandboxing, precise usage calculation, and clean bulk-deletion handling. - Implement Token-to-Cookie Exchange at Edge CDN: Never pass query-string authentication tokens on every HLS segment request. Validate the token once on the master playlist, set an HttpOnly session cookie, and keep segment URLs clean to ensure 98%+ edge cache hit ratios.
- Separate Transcode Workers by Capability: Do not mix lightweight thumbnail generation or WebVTT transcription on the same nodes as heavy 4K ABR transcoding. Deploy specialized worker pools (GPU transcode workers, CPU audio/subtitle workers) to optimize cost and performance.
Architectural Anti-Patterns & Common Traps
1. The Global Shared Redis Lock Anti-Pattern
- Mistake: Utilizing a single global Redis lock during video transcode orchestration to synchronize state across nodes.
- Consequence: When Tenant A triggers a burst of 200 jobs, lock contention degrades API responsiveness for all tenants, introducing artificial latency across unrelated operations.
- Correct Approach: Scope all distributed locks strictly to the tenant and asset ID (
lock:tenant:{tenant_id}:asset:{asset_id}).
2. The Unbounded Master Manifest Rewrite
- Mistake: Dynamically generating HLS master playlists on every viewer HTTP request via custom server-side templates.
- Consequence: Under high viewership events (e.g., a popular webinar), the application server collapses under the load of thousands of dynamic playlist generation requests.
- Correct Approach: Generate static, immutable HLS playlists during the transcoding process, store them directly in S3, and protect access via edge CDN token validation and caching.
3. The Database Polling Worker Fleet
- Mistake: Transcode workers polling PostgreSQL every 2 seconds with
SELECT * FROM jobs WHERE status = 'pending' LIMIT 1 FOR UPDATE. - Consequence: As worker fleets scale past 20 nodes, database connection pools saturate, lock contention spikes, and database CPU spikes to 100% while workers sit idle.
- Correct Approach: Deploy a dedicated, event-driven message broker (such as NATS JetStream or RabbitMQ) utilizing push-based delivery and virtual queues.
Comprehensive Platform Comparison
| Evaluation Metric | Ollanode (Self-Hosted Multi-Tenant) | Managed Developer SaaS | DIY AWS Cloud Stack |
|---|---|---|---|
| License & Control | Apache-2.0 (100% Sovereign) | Proprietary Closed SaaS | Proprietary Cloud Lock-in |
| Hosting Deployment | Anywhere: Bare-Metal, VPC, K8s | Vendor Cloud Only | AWS Only |
| OllaNode pricing Model | Predictable Hardware / Server Cost | Per-minute encoding & storage fees | Metered AWS service charges |
| Per-Minute Transcode Fee | $0.00 (Zero markup) | $0.045 – $0.075 / minute | $0.015 – $0.030 / minute |
| Per-GB Egress Markup | $0.00 (Standard bandwidth cost) | $0.08 – $0.12 / GB markup | $0.085 / GB (CloudFront standard) |
| Multi-Tenant Scheduling | Native DWRR Fair-Share Queues | Handled internally by vendor | Must be hand-coded across SQS queues |
| Tenant Storage Isolation | Automated prefix sandboxing + RLS | Abstracted behind API tokens | Manual IAM policies & bucket rules |
| Data Sovereignty | Absolute (GDPR / HIPAA / On-Prem) | Vendor-managed data centers | AWS infrastructure regions |
| Custom Codec & Tuning | Full control over FFmpeg/NVENC flags | Fixed, non-configurable profiles | Limited MediaConvert preset profiles |
| AI Agent Governance | Native Model Context Protocol (MCP) | No native MCP toolchain support | Requires custom Lambda integrations |
Enterprise & Production Deployment Topologies
For production environments requiring high availability and fault tolerance, Ollanode deploys across a resilient, multi-zone Kubernetes topology structured into five distinct operational layers:
- Perimeter Ingress & Edge Caching: Anycast DNS directs traffic to regional ingress nodes running OpenResty and Nginx. These edge proxies terminate TLS, inspect incoming playback tokens against cached tenant secrets, set scoped HttpOnly session cookies, and serve cached HLS chunks directly from NVMe edge drives.
- Stateless API Gateway Layer: Internal Network Load Balancers distribute administrative and ingest traffic across horizontally autoscaled Ollanode Rust pods. These stateless pods authenticate API keys, enforce Redis sliding-window rate limits, and issue presigned S3 upload URLs.
- High-Availability State Backbone: PostgreSQL operates in a primary-replica configuration across availability zones with Row-Level Security enabled. A three-node NATS JetStream cluster maintains RAFT quorum, providing persistent virtual queues for each tenant. A Redis cluster manages distributed rate-limiting counters and cache lookups.
- Autoscaled Transcode Fleet: Transcoding workers scale dynamically using KEDA (Kubernetes Event-driven Autoscaling) based on NATS queue depth. High-throughput GPU nodes handle video encoding via NVENC, while dedicated CPU nodes handle lightweight sidecar generation (Whisper subtitles and thumbnail extraction).
Cloud, Bare-Metal, and Hybrid Infrastructure Strategy
Choosing the right physical infrastructure foundation directly impacts total cost of ownership (TCO) and multi-tenant performance:
1. The Bare-Metal Advantage (Hetzner / OVH / Equinix Metal)
For high-volume multi-tenant video platforms, bare-metal infrastructure provides substantial cost and performance advantages:
- Dedicated NVIDIA GPUs without hypervisor virtualization penalties.
- High-bandwidth unmetered or low-cost transit uplinks (e.g., 1 Gbps or 10 Gbps unmetered network ports).
- Eliminates cloud egress markups, reducing overall streaming delivery costs by up to 80%.
2. The Sovereign Private Cloud / VPC (AWS / GCP / Azure)
For organizations with strict compliance mandates or pre-existing cloud commitments:
- Deploy Ollanode within dedicated VPC subnets across multiple availability zones.
- Mount Amazon S3 or Google Cloud Storage directly via VPC Endpoints to avoid internal network transit fees.
- Provision GPU transcode workers using Spot/Preemptible instances to minimize encoding compute expenses.
Frequently Asked Questions (FAQs)
1. How does a multi-tenant self-hosted video platform prevent the noisy neighbor problem during video encoding?
A multi-tenant platform avoids noisy neighbor starvation by replacing flat FIFO queues with Deficit Weighted Round Robin (DWRR) or Fair-Share scheduling. Instead of processing jobs in the order received, the scheduler groups pending tasks into virtual queues per tenant. It allocates execution credits (quantums) based on each tenant’s subscription weight, dispatches tasks proportionally, and enforces hard limits on concurrent transcode slots. If one tenant submits 500 files, their additional jobs wait in their own virtual queue, allowing other tenants’ uploads to process immediately.
2. What is the difference between Row-Level Security (RLS) and schema-based multi-tenancy for video metadata?
Row-Level Security (RLS) maintains all tenant records in unified database tables, using PostgreSQL policies to automatically restrict queries based on the active session’s tenant_id. Schema-based multi-tenancy provisions a separate database schema for each tenant. RLS is generally preferred for video platforms because it simplifies schema migrations across thousands of tenants, allows unified connection pooling, and simplifies cross-tenant system analytics, while still providing robust data isolation.
3. How does tenant isolation work at the S3 object storage level?
Tenant storage isolation is achieved through deterministic, prefix-based paths: s3://bucket/tenants/{tenant_id}/assets/{asset_id}/*. When an upload occurs, the control plane generates an AWS STS or MinIO presigned URL restricted specifically to that asset prefix. This prevents tenants from viewing or overwriting objects outside their allocated prefix. It also enables automated storage usage auditing, prefix-based data retention policies, and clean, single-operation tenant purges.
4. Why should query-string tokens be avoided on individual HLS segment requests in a multi-tenant platform?
Appending dynamic query tokens (e.g., seg-001.ts?token=xyz123) to every media segment breaks edge CDN caching. Because each viewer has a unique token, the CDN treats every request as a distinct cache miss, driving cache hit ratios down from 98% to under 10% and overwhelming origin storage. A production multi-tenant platform validates the token once on the master playlist (master.m3u8), sets a tenant-scoped HttpOnly session cookie, and serves clean, unparameterized segment URLs that cache efficiently across all authorized viewers.
5. Can different tenants use different encoding profiles and resolution ladders?
Yes. In an advanced platform like Ollanode, encoding profiles are configurable globally, per tenant, or per asset. A tenant on a basic tier can be restricted to a standard 720p/1080p H.264 profile, while an enterprise tenant can be configured for 4K AV1/HEVC output with custom segment durations, audio bitrates, and automated Whisper subtitle transcriptions.
References & Authoritative Standards
- RFC 8216: HTTP Live Streaming (HLS) Specification — IETF Standards Track.
- RFC 7519: JSON Web Token (JWT) Architecture & Cryptographic Verification — IETF.
- NIST Special Publication 800-145: The NIST Definition of Cloud Computing (Multi-Tenancy & Resource Pooling).
- PostgreSQL Documentation: Row Security Policies & Tenant Scoping Mechanics (PostgreSQL Global Development Group).
- DWRR Scheduling Algorithm: Efficient Fair Queueing Using Deficit Round Robin — M. Shreedhar and G. Varghese (IEEE/ACM Transactions on Networking).
- OpenAPI 3.1.0 Specification: Declarative API Contracts for Video Control Planes (OpenAPI Initiative).
- The Model Context Protocol (MCP): Standardized Context Protocol for AI Agents and Infrastructure Integration.
- Ollanode Architecture & Documentation — Self-Hosted Video Infrastructure for Developers.
- Open Source Video Infrastructure Explained — Control plane, pipeline, CDN, and storage architecture.
- Developer Video Platform Requirements (2026) — Technical specification for modern video platforms.
- How to Generate Dynamic HLS Resolution Ladders — Bitrate theory and ladder configuration.
- Self-Hosted Video API Deep Dive — Upload, processing, playback, webhooks, and asset lifecycle.
Conclusion: The Strategic Value of Sovereign Multi-Tenancy
As video becomes central to modern software applications, relying on proprietary third-party video APIs introduces severe margin erosion, vendor lock-in, and compliance risks. Conversely, attempting to manage multi-tenancy through fragile, custom-coded cloud scripts inevitably leads to noisy neighbor outages, data boundary failures, and unpredictable engineering maintenance costs.
A production-grade, multi-tenant self-hosted video platform resolves these challenges by introducing structured engineering discipline across the entire media lifecycle:
- Absolute Data Isolation through PostgreSQL Row-Level Security and deterministic S3 storage paths.
- Fair-Share Resource Allocation through Deficit Weighted Round Robin scheduling that prevents noisy neighbors from degrading cluster performance.
- Robust Access Control using tenant-isolated HMAC cryptographic secrets and edge-driven session cookie validation.
- Atomic Metering that provides clear visibility into resource consumption, powering automated billing integrations.
By deploying Ollanode as your multi-tenant video foundation, your engineering team gains the developer velocity and clean API ergonomics of commercial video platforms, backed by complete data sovereignty and a 70% to 85% reduction in ongoing infrastructure costs.
Explore the complete platform capabilities and multi-tenant tooling at OllaNode Platform Features.