HomeBlogComparison

MongoDB vs Amazon S3: 3 Checks Before You Store Files Inside Your Database

A white robot slides a radiant file cube off a row of three colored storage shelves into a quick tray

MongoDB is a database for records you query and update field by field; Amazon S3 is object storage for files you save and fetch whole. Keep job records, customers and settings in MongoDB, keep photos, PDFs and videos in S3, and store each file's S3 key inside the MongoDB document that needs it; putting large files in the database raises the cost per GB and the size of every backup.

How do MongoDB and Amazon S3 store data differently?

MongoDB's document reference describes records as BSON documents made of field-and-value pairs, with a maximum document size of 16 mebibytes. S3 stores objects of up to 50 TB, each identified by a key, with a small set of metadata. One answers questions about records; the other hands back a file when asked for it by name.

Check 1: Is each item small, structured and searched by its fields?

A work order with a status, a technician, a list of parts and a timestamp is a document. You filter it, update one field and index it. A 6 MB photo of a water heater is not: nobody queries inside it. Anything bigger than 16 MiB cannot be a single MongoDB document at all.

Check 2: Would GridFS be doing a job S3 already does?

People who search "Amazon S3 vs MongoDB GridFS" have usually met MongoDB's own answer for big files. The GridFS documentation says it splits files larger than 16 MiB into 255 KiB chunks stored as separate documents in two collections. It also lists limits: do not use GridFS if you need to replace a whole file atomically, GridFS does not support multi-document transactions, and files under 16 MiB can simply go in one document as binary data.

QuestionMongoDB documentMongoDB GridFSAmazon S3
Size per itemUp to 16 MiBLarger files, in 255 KiB chunksUp to 50 TB per object
Query inside itYes, by field and indexMetadata onlyNo; fetch by key
Atomic whole-file replaceYes, one documentNot supported, per MongoDBYes; each upload replaces the object or adds a version
Cheapest storage tierThe cluster's diskThe cluster's diskGlacier Deep Archive, $0.00099 per GB-month in US East as of December 2026
Serving to browsersThrough your applicationThrough your applicationPresigned links or a CDN in front

GridFS still fits when files must travel with the database, for example an on-premises install with no cloud storage. In AWS, S3 is the purpose-built home for them.

Check 3: What does a gigabyte cost on each side?

As of December 2026, MongoDB's Atlas pricing lists a Free tier with 512 MB of storage, Flex clusters at up to $30 a month with 5 GB, and Dedicated clusters starting at $0.08 an hour for an M10 with 10 to 128 GB of storage; Dedicated tiers range up to 4 TB. Those are base cluster prices: the same page says data transfer out of a cluster and backup storage are charged on top for Dedicated clusters. On S3 pricing, Standard storage is $0.023 per GB-month in US East, with requests at $0.005 per 1,000 uploads and $0.004 per 10,000 downloads.

A field-service app's records and photos

This example is illustrative; S3 figures are AWS list prices for US East (N. Virginia) and Atlas figures are MongoDB's list prices, both as of December 2026. A 45-person home inspection company has an app with 200,000 inspection reports (about 5 GB of documents) and 1.5 TB of photos, growing by 60 GB of photos a month.

  • Everything in MongoDB: the photos alone exceed the 128 GB ceiling of an M10, so the company would need a much larger Dedicated tier, priced for compute it does not use, plus backups that copy every photo.
  • Records in Atlas, photos in S3: an M10 holds the 5 GB of reports with room to grow, starting at $0.08 an hour. 1,536 GB of photos in S3 Standard is $35.33 a month, and each new month adds about $1.38. Photos older than a year can move by lifecycle rule to Glacier Instant Retrieval at $0.004 per GB-month.

The document for each inspection stores the S3 keys of its photos. The app asks S3 for a short-lived presigned link when a user opens one, so the database never handles the image bytes.

When the line between database and bucket moves

  • Relational data with strict transactions points to a relational engine; see Amazon RDS vs Amazon S3 and AWS vs Azure database.
  • Public downloads at volume need a delivery network in front of S3; see Amazon S3 vs CDN.
  • Tiny files that change with the record, such as thumbnails under a few kilobytes, can live in the document.

Our AWS consulting team can review where your application's files and records should sit; to begin, Review my storage design.

More on this topic: Storage and files guides.

Frequently asked questions

MongoDB vs Amazon S3: can MongoDB store files?

Yes, as binary data inside a document up to 16 MiB, or through GridFS for larger files. For large or numerous files in AWS, S3 is usually cheaper and keeps backups small.

Amazon S3 vs MongoDB: which is cheaper per GB?

S3. As of December 2026, S3 Standard is $0.023 per GB-month in US East, and S3's archive classes go lower. MongoDB Atlas prices clusters by tier, so storage comes bundled with compute you pay for by the hour.

Amazon S3 vs MongoDB GridFS: when is GridFS the better choice?

When files must live with the database, such as an install with no object storage. MongoDB's documentation notes GridFS cannot replace a whole file atomically and does not support multi-document transactions.

What is the MongoDB document size limit?

16 mebibytes per BSON document, according to MongoDB's documentation.

Sources

Read on December 2, 2026:

AWS Consulting for Business

Discuss AWS Consulting for Business for your business.

Tell us about your current systems, the result you need and your timeline. We will discuss the work, responsibilities and pricing before you decide on an engagement.

Explore AWS Consulting for Business 845-203-3914