Handling images (and other big files) in MongoDB Realm: bandwidth limit?

I’m coming from Realm Cloud, where storing images in the database is not possible due to the limits of storage (2.5 GB) and bandwidth (20GB/month). My solution was to only store an image link and store the actual images in Firebase storage instead. The image was sent directly from the user’s device, to avoid wasting realm’s paid bandwidth.

I’ve seen that in MongoDB, you can store images in AWS S3, and use server functions to transfer the images. But to run the server functions, you have to send the image to the server in the first place right? Won’t that create a bandwidth issue? Is there any limit on the bandwidth you can use with functions?

Hi! There isn’t a bandwidth limit but some other limits to consider are:

There are limits for the free tier data egress which you can read about here.

2 Likes

@Jean-Baptiste_Beau I did see Alex’s talk at MongoDB Live where he mentioned using server functions to cut up image files after uploading them. Although it could be done this way, there are a few reasons why it should still be done the old way.

First, one typically uses blob storage like AWS S3 or Azure to store these large image assets. MongoDB Realm is not a CDN, so you still have to use this type of storage. Typically, you get a write URL to upload your image to, and then a read URL to share it with other clients. In my opinion, the purpose of the server function is to compute the read and write URLs on behalf of the client, i.e. the client should not have to worry about the details of the blob storage. However, that is what I would limit the role of the server to. Second, I would let the client do the actual work of cutting up the image. Client compute power is cheap, free from the point of view of the developer, and does not encumber paid for server resources. Since the client has to upload the image anyways, uploading the image and the cuts is not that much ‘extra’ work. Plus, the act of uploading should not have to go through a server on its way to blob storage - it should just go there directly. As a rule, when developing collaborative applications, you always want to push work away from the central server towards the client. The server should do the lightweight management, not the heavy lifting.

I hope this was useful.

Richard Krueger

6 Likes

Perfect answer, thank you!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.