MongoDB: Document Database With a Licence Caveat

MongoDB: Document Database With a Licence Caveat

MongoDB stores documents rather than rows, and the thing to check before adopting it is the licence.

The licence first

MongoDB moved from AGPL to the SSPL in 2018. SSPL requires anyone offering the software as a service to open source their entire service stack, which is practically impossible and therefore functions as a prohibition.

That means MongoDB is not open source by the OSI definition. Our licences guide covers the distinction and the fork pattern that followed elsewhere, though unlike Redis or Elasticsearch, MongoDB never acquired a major fork.

For self-hosting your own application, SSPL triggers nothing. For building a product that hosts MongoDB for others, read it carefully.

When documents are the right model

Genuinely useful when records vary in shape, nest deeply, and are read as a whole. Event payloads, catalogue items with per-category attributes, API responses cached verbatim.

Less useful than it appeared in 2012. PostgreSQL’s JSONB does most of what people wanted from MongoDB while keeping transactions, joins and constraints, and our PostgreSQL guide covers it. A great many MongoDB deployments would be better as Postgres tables with a JSONB column.

The honest test: if your documents all have the same fields and you find yourself wanting joins, you wanted a relational database.

Operational shape

mongosh
db.serverStatus().connections
db.collection.getIndexes()

Replica sets are how availability works, and a single-node deployment cannot use transactions or change streams, so even one node is often configured as a one-member replica set.

Indexes matter enormously and are easy to miss, since a missing index produces a working query that scans the collection. explain() is the tool.

Operational caution

Bind to localhost or a private interface. Unsecured internet-facing MongoDB was the subject of mass ransom campaigns, and the lesson generalises: our Valkey guide makes the same point about datastores designed for trusted networks.

Enable authentication explicitly. Recent versions default to localhost-only, which is a guard rather than authentication.

Working set memory is the sizing constraint, as with any database, and our memory pressure guide covers what happens when it does not fit.

License

MongoDB Community Edition is released under the Server Side Public License, which is not OSI approved.