Let's say you're planning to launch a website or app with live streaming content. You know you'll need a Content Delivery Network (CDN) to deliver the stream, but you're not sure how much data you'll need. I've run into this situation myself, and came up with this handy "live stream calculator" to help estimate your costs. You'll need a few key pieces of information to plug into the calculator, including:
- Cost Per GB (USD). Generally, CDNs charge on a cost-per-gigabyte basis. The higher the volume of traffic that you're willing to commit to, the lower the price-point they'll be willing to offer.
- Stream Bit Rate (Kbps). This is the quality of the stream. Now, it's likely that you're doing Adaptive Bit Rate (ABR) streaming, which means that you'll have multiple stream qualities. The simplest approach for our estimate is to use an average bitrate.
- Average Duration (Mins). How much of the broadcast will each user watch on average? Or, you could enter the entire duration of your broadcast and assume that all viewers will watch the entire event.
- Number of Viewers. How many people will watch the broadcast?
So, what's the formula? Let's break down the math step-by-step. First, it would be helpful to know how much data is transferred in one minute. Since Kbps stands for "Kilobits per second," all we need to do is multiply the stream bitrate by 60 seconds.
1200 Kbps * 60 seconds = 72,000 Kilobits per minute.
Now let's convert that from Kilobits to Megabytes. The formula for that is Kilobits ÷ 8,192 = Megabytes.
72,000 Kb ÷ 8,192 = 8.7890625 MB
If you had 1 user watch 1 minute of video, they would have consumed approximately 8.79 MB of data.
Next, let's convert this to Gigabytes. The formula for this is Gigabytes = Megabytes ÷ 1,024
8.7890625 ÷ 1,024 = 0.008583068848 GB
From here it's pretty straightforward. We simply need to multiply our GB data delivered times the number of viewers and the number of minutes they'll watch.
0.008583068848 GB * 1,000 Viewers * 60 min broadcast = 514.98413088 GB
Finally, to get our cost we multiply the Gigabytes delivered times our quoted rate.
514.98413088 GB * $0.05 = $25.749206544
Nice! An hour long broadcast, with an average bitrate of 1200 Kbps, delivered to an audience of 1000 viewers who watch the whole thing, at $.05 cents per GB would cost $25.75. We can now put it all together:
cost = (X Kbps * 60 sec / 8192 / 1024) * Y viewers * Z mins * D price