Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pangkalizer/504f4d7253fe089a5d6b161fe5fe94dc to your computer and use it in GitHub Desktop.

Select an option

Save pangkalizer/504f4d7253fe089a5d6b161fe5fe94dc to your computer and use it in GitHub Desktop.
⏺ Capacity Pricing Model — How It Works
Core idea
A tenant pays a fixed monthly fee determined upfront by their expected usage profile (how many hosts, how big the audience, how long streams run, how often). It's prepaid — charged at the start of each billing period,
not at the end.
---
The four inputs (sliders)
┌─────────────────┬────────────────────────────────────────┐
│ Input │ What it means │
├─────────────────┼────────────────────────────────────────┤
│ Hosts │ Number of hosts + co-hosts per stream │
├─────────────────┼────────────────────────────────────────┤
│ Audience │ Expected concurrent viewers per stream │
├─────────────────┼────────────────────────────────────────┤
│ Duration │ Length of each stream in minutes │
├─────────────────┼────────────────────────────────────────┤
│ Monthly streams │ How many streams per month │
└─────────────────┴────────────────────────────────────────┘
---
Step 1 — Compute raw minutes
host_minutes = hosts × duration × monthly_streams
audience_minutes = hosts × audience × duration × monthly_streams
Example: 2 hosts, 100 audience, 60 min, 4 streams/month
host_minutes = 2 × 60 × 4 = 480 min
audience_minutes = 2 × 100 × 60 × 4 = 48,000 min
---
Step 2 — Apply free allowance
free_applied = min(free_allowance, host_minutes)
billable_host_minutes = host_minutes - free_applied
The free allowance comes from the tenant's config, falling back to the system-wide default. Only host minutes get a free tier — audience minutes are always billable.
---
Step 3 — Compute cost
Rates are stored as cents per 1,000 minutes (so ₱180/1k min is stored as 18000).
cost_cents = (billable_host_minutes × host_rate + audience_minutes × audience_rate) / 1000
Example: host_rate = 18000 (₱180/1k min), audience_rate = 18000, free_allowance = 0
cost_cents = (480 × 18000 + 48000 × 18000) / 1000
= (8,640,000 + 864,000,000) / 1000
= 872,640 cents = ₱8,726.40 / month
---
Billing flow
Activate subscription
Create billing period (due_at = now) ← prepaid, charged immediately
processPaymentForPeriod (stub payment)
┌── success ──────────────────────────────────────────────────┐
│ Mark period PAID │
│ Advance subscription dates by 1 month │
│ Create NEXT billing period (due_at = next period start) │
└─────────────────────────────────────────────────────────────┘
Scheduler runs hourly → picks up any period where due_at ≤ now
Repeat each month
---
Key distinction from metered pricing
┌──────────────┬─────────────────────────────────┬────────────────────────────────┐
│ │ Capacity │ Metered │
├──────────────┼─────────────────────────────────┼────────────────────────────────┤
│ Cost basis │ Planned/estimated usage │ Actual streaming minutes │
├──────────────┼─────────────────────────────────┼────────────────────────────────┤
│ When charged │ Start of period (prepaid) │ End of period │
├──────────────┼─────────────────────────────────┼────────────────────────────────┤
│ Cost varies? │ Fixed each month │ Varies with actual usage │
├──────────────┼─────────────────────────────────┼────────────────────────────────┤
│ Free tier │ Applied to planned host minutes │ Applied to actual host minutes │
└──────────────┴─────────────────────────────────┴────────────────────────────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment