简体   繁体   中英

How do you host user-uploaded mp3 files on FireBase without quickly running out of bandwith when users access page?

My website provides artists with an audio visualization of their uploaded mp3 files. Firebase Storage isn't necessarily the issue, but rather a bandwidth. Every time a fan accesses the website, the website downloads the mp3 from Firebase Storage in order to access the frequency data to visualize it. Given each mp3 is ~8MB, you could see how even having 200 fans accessing the website would go over the 1GB free quota, so having thousands of people viewing the website would become expensive and not scalable. I've considered hosting on SoundCloud, but I wouldn't be able to download the mp3 data in that case, only stream. What do people commonly do in this situation, where they need to have larger files like mp3s downloaded to display to the user without quickly running out of bandwidth?

Firebase 带宽

Firebase Storage isn't necessarily the issue, but rather the bandwidth. Every time a fan accesses the website, the website downloads the mp3 from Firebase Storage in order to access the frequency data to visualize it.

So most likely, that's why you're having that problem related to the bandwidth because you're downloading all audio files, each time a user opens the website. That's not how you should handle this kind of situation. Instead of downloading all audio files, you should only display the name of the files, and only download them on demand. For example, you should store the name of the files and corresponding URLs from Cloud Storage, either in Cloud Firestore or in the Realtime Database , and as soon as the user clicks the download/play button, only then does start playing/downloading them.

Given each mp3 is ~8MB, you could see how even having 200 fans accessing the website would go over the 1GB free quota, so having thousands of people viewing the website would become expensive and not scalable.

The problem isn't about scalability, it's about costs. Cloud Storage for Firebase can easily scale to millions of files. Besides that, please also bear in mind that the free quota, it's used for testing puposes and not for real-world applications. For that scenario, you should consider upgrading to the Blaze Plan .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM