Does anybody know if it’s better to store images into MongoDB (Compose.io) or into AWS S3?
With MongoDB it’s easier to upload and remove and you are sure that you don’t duplicate files.
It is better from mongoDB but we are afraid of costs because we expect 1000+ users on june. Our app is generating 3 images for each data (about 300k all together) and 150 data for each user approximately (50MB each user).
Althought it is convenient, it is never a good idea to store uploads in database. Especially if you keep adding up.
Even if you will have a limited number of users, like 1500 total for the rest of the app’s lifetime, I would say go with S3. The best path to take for static files is nginx or at least a CDN, and not get Meteor or Mongo into the mix whatsoever.
It’s better to use S3 or any other direct file server because you can throw a CDN in front of it.
I noticed you said you have multiple versions of images, I would recommend a service such as Imgix to handle your ‘responsive’ images. It’s easy to integrate, and a boost to mobile performance.
The issue with mongoDB is that you will be sending large binary data over DDP and then rending that binary back out to a picture. I tried this locally for a fun experiment and it just killed the page loading time, you could feel the machine start chugging hard and the fans kick on.
My vote is s3 because it will also count as a CDN and give you more connections to open up and download with because the domain is different.
I don’t know your exact setup, but if it were me, I would choose the third option: nginx.
Use nginx on the same machine and serve everything static through nginx, without disturbing Meteor. Very low cost, very low server resource usage.
I have to agree with @sergiotapia – I went through:
- Base64 in a mongoDB
- CFS to an upload directory on the server
- Blobbing clientside to reduce the size and then uploading to s3 to serve
- Uploading straight to s3 and serving downscaled images with imgix
Things got progressively better with each step. If images are an important part of your app, I’d have a tough time going with anything but s3/imgix (or another image service)…
Thank you all, we appreciate your answers!
Like all replies are pointing in the same direction we are moving to S3 and cdn.