MongoDB
A popular NoSQL document database storing data as JSON-like documents (BSON). Flexible schema — each document can have different fields. Good for rapid development and changing data. MongoDB Atlas is the managed cloud version. Used by many startups.
Eliot Horowitz, Dwight Merriman · Co-founded MongoDB (10gen) in 2007
- Rapid prototyping with changing schemas.
- Document-oriented data (CMS, catalogs).
- Node.js stacks (Mongoose).
- Highly relational data (use PostgreSQL).
- ACID-heavy transactions (use SQL).
- Key-value-only workloads (use Redis).
Definition
MongoDB is a document-oriented NoSQL database. Data is stored as BSON (binary JSON) documents in collections. No fixed schema — documents can have different fields. Supports indexing, aggregation pipelines, and sharding for horizontal scale. Atlas is the managed cloud service.
Why it exists
To let developers store flexible, nested data without defining a rigid schema upfront, and to scale horizontally via sharding — useful for rapid prototyping and content with varying structure.
How it works
Insert JSON documents into collections. Query by fields. Indexes speed up queries. Aggregation pipelines transform data. Sharding distributes data across nodes by a shard key. Replica sets provide high availability. Mongoose (Node.js) adds schemas/validation.
Scaling limits
No JOINs (denormalize or use $lookup). Document size limit (16MB). Sharding requires good shard key choice. Transactions added late and are limited. Memory usage for large working sets.
Cost shape
Free tier (Atlas). Paid per usage/storage. Self-hosted is free.
Alternatives
- PostgreSQL (JSONB) — SQL + JSON in one, stricter, more powerful queries.
- DynamoDB — Managed, scales writes, but vendor lock-in and less flexible.
Failure modes
- No schema validation without Mongoose.
- Poor shard key causing hot shards.
- No JOINs requiring denormalization.