DEV Community 👩‍💻👨‍💻

Cover image for Can streaming be cheaper?
Bruno Noriller
Bruno Noriller

Posted on • Originally published at linkedin.com

Can streaming be cheaper?

Before talking streaming, let’s talk caching and why there are so many and at least one is near you.


Disclaimer: I’m not a specialist. I did my research on the topic because I’ve had an idea.
And I’ll just “give it away”, so keep reading!
Of course, it might be useless, it might be unfeasible or it might be something... so let’s continue.


Server

You’ve already developed your website, now you have to deploy it.

This might be an oversimplification, but only really big or really outdated companies have on-premise servers. Most use some cloud provider.

It’s easy to see why, because it’s easier to control and scale. And scale we need.

What server can withstand millions of requisitions?

Certainly not ONE.

I mean, scaling vertically has harder limits, meanwhile scaling horizontally is easier and you can have weaker servers serving the content.

But having multiple servers still doesn’t solve the little problem of PHYSICS.

Non-code limits

Ping, lag, latency... at least one of those you’re probably heard at some point.
Because if you’re on one side of the globe and the server is on the other one, no matter how fast your server is the round trip of calling for something and getting it back would take around 133 ms... but considering a straight line in more than perfect conditions. The actual time, is much, much bigger than that.

I’ll give you two links, the first one is for a really interesting article about that, and the second one is the map of the internet cables that connect the globe.

https://www.pingdom.com/blog/theoretical-vs-real-world-speed-limit-of-ping/

https://www.submarinecablemap.com/

Why cache?

Let’s go back to the 133 ms theoretical example. Let’s say it’s actually 500 ms each roundtrip... imagine a site needing seconds to load even while you have a good internet speed...
So, by replicating the content to a CDN (content delivery network), you can have the content closer to users and they won’t need to wait seconds for things to load.
Added to that, even if you have on-premise servers, they are shielded from being overloaded with requests.

The question!

By now, maybe you’ve already come to the same conclusion, maybe not.

A CDN works great with small, static content. But we’re talking streaming here.

How I came to the idea

I’ve talked about it before, but when I was working with the player component on my interactive interview (check it out if you haven’t) I’ve learned a lot about how the media works on the internet.

And by learning that I asked myself, and then google: why do we need to cache videos?

I mean, sure, I click to open a video on youtube, I want it to start immediately... but after that?

Even if it had 500 ms delays, the buffer you have is more than enough to deal with that.

And it would be as “simple” as checking the buffer and changing the stream source to another source... let’s say, a cheaper one.

But streaming isn’t just video and music, if you have files... even 500 ms wouldn’t make a difference when downloading it!

Costs of the internet

Brazil is one of the biggest internet consumers, and yet, cloud providers will charge the South America region basically double or more from North America or Europe.

Added to that, providers put servers closer to where they can have the most impact, and not necessarily where it could be cheaper... even a place with cheaper electric costs, could end up having higher costs because of scale.

(There are multiple providers and other regions also suffer from this. You, basically and literally, have to take a course to understand all that a cloud provider provides and the costs... so, I might just not understand all the intricacies that would make this invalid.)

How to make streaming cheaper?

If you’ve skipped right here, or if you still didn’t get it...

We cache to serve only a few seconds of the streaming, enough to build a buffer.
Then we change streams to point to a cheaper source.

We increment that with ML models, which are a dime a dozen but even using simple algorithms, we can check if the buffer is enough.

We can have seamless transitions between what is fetched from a CDN near the user or somewhere the outbound costs are smaller.

Pros and cons

If my assumptions are correct, then in places where the costs are higher you can shift the costs and have massive gains. If I’m not... well... ¯\(ツ)

Not sure if a con, to operationalize that, you would need a custom player that can calculate if the buffer is enough and to be able to easily change streams between near and cheaper.

But also, if I’m right, this would probably work better on a bigger scale and if you have a large base of users in more expensive regions.

The biggest problem I see is that that would mean more traffic in the submarine cable network, and I recall something about it being overloaded with too much streaming already...

Outro

I was actually “saving” this idea in the hopes that if I got hired at a place it could make sense, I could be like: “Hey, I had this idea. Do you think this could work?”.

And start with the right foot impressing people right of the bat.

But alas, my search was less than successful... so I will just give away.

What do I want in return?

  • If I’m talking nonsense, then educate me.

I’ve already said in another post that, as a programmer, I’m wrong most of the time...
So knowing where I’m wrong can give me insight into how to be right.

  • But if it actually makes sense...

While this could mean millions in savings, it’s not like I’m expecting a seven-digit thanks... I mean, sure, even a tenth of that could mean that I could safely change jobs and focus on emigrating and getting my “dream job”.

Then again, I like to say that I can do more than just code.
First I made this interactive interview and now I could be giving away a, quite literal, “million-dollar idea”. If that’s not enough to get the attention of companies out there... I don’t know what is.

So, share my profile, or the interview link if you can... maybe we can become colleagues.


Cover Photo by Glenn Carstens-Peters on Unsplash

buy me a coffee

Top comments (2)

Collapse
 
honorbertt profile image
Ho Norbert

Why should you bother? Just buy streaming from a third party company. It's not that expensive if you buy from G-core labs or AWS

Collapse
 
nikmikhailov_ profile image
Nik Mikhailov

We work with G-core. The best company to work with the European market. Most of their servers are there.

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.