Jephph
Jephph•8mo ago

Strategies to reduce file bandwidth?

Currently on the free plan and am using Convex to store my user's profile images (as well as all other data because its awesome). I hit the file bandwidth limit pretty quickly this month and am concerned that even the pro plan might not be enough when I put my app out to the public. Image urls are stored on a user as profileImage. I have a feed type UI that renders cards with user profiles. Hoping to allow users to add images outside of profile images as well so the demand will only increase. Using Convex with React Native Expo
9 Replies
ballingt
ballingt•8mo ago
First up you'll want to encode these images to smaller sizes on upload
Jephph
JephphOP•8mo ago
@ballingt should have thought of this sooner lol big difference from 5mb pictures to compressed 9kb
ballingt
ballingt•8mo ago
The next steps if that isn't enough get more complicated, you can call out to a third party CDN after upload as a scheduled/async action if that's useful. If you're doing video this is just about required, even if you write Convex functions to do the encoding dealing with every type of video thrown at you gets complicated and the bandwidth costs get large so you want to make sure you're not missing the encoding. Not required as it in won't work, but as cost-prohibitive. And not just a Convex thing, probably don't build a video sharing platform in general: even Twitch and YouTube have trouble making that profitable because the costs are so high.
Jephph
JephphOP•8mo ago
Gotcha! That makes sense, I'll stick to images for now lol Leaning towards Cloudflare for image storage in the long term since they're suuuper cheap
FleetAdmiralJakob 🗕 🗗 🗙
Theo's Cloudflare vid incoming @Jephph Which encoding strategy (which algorithm) will u use?
Jephph
JephphOP•8mo ago
@FleetAdmiralJakob 🗕 🗗 🗙 I ended up using expo's image manipulator package to compress the image (not sure what they use under the hood?) then just convert to blob and upload!
FleetAdmiralJakob 🗕 🗗 🗙
hmmm, im interested if this package works in a next.js app too nvm I don't think so hmmm, will see what I find to optimize and compress the image
i-bangash
i-bangash•7mo ago
I'm using sharp with nextjs, works great for my usecase
FleetAdmiralJakob 🗕 🗗 🗙
can you share an example? like code snippet or repo?

Did you find this page helpful?