-1

I'm building a reddit-like app on which you can share memes (no videos for now). I read online on the best way to store them, and I found out that the choice comes down on whether you use file system or not. The other option is to simply store them in a database like I currently do. Since memes mostly aren't quality dependent images, I was wondering if it's worth to redesign the system to use file systems and paths stored in db.

The way I currently do it is by storing theirs representations base64-encoded in MongoDB. I also found out that this isn't optimal since base64 encoding consumes about 33% more storage space in comparison to raw binary. So the first optimization I'm thinking of is storing BLOBs

Current calculation is roughly as following - about 300 memes ~ 30mb So we get about 100KB per meme, and fetching times are pretty good. So I'm wondering if I should implement something like google buckets?

1 Answers1

0

The state of the art solution to store images is Google storage (or AWS S3 or similar). It's very cheap and scalable.
Furthermore you can add Goocle Cloud CDN (or AWS CloudFront) in front of the storage bucket and increase performance even further.

Doing this way you:

  • offload your application servers from the need to query db every time user is viewing meme and this is a big gain.
  • get out of the box Google Storage api to upload image with pre signed url

But you also need to store memes metadata (bucket name, the path to the image in bucket, who uploaded, when, with whom it's shared, how many likes it has, etc.).
And this data can be kept in MongoDB.

Pavel Bely
  • 2,245
  • 1
  • 16
  • 24