Skip to content
Next.js app hosting is now in early beta testing. Request access
In this postMongoDBDocumentDBFerretDB

MongoDB alternatives at 10 million records: DocumentDB vs. FerretDB vs. MongoDB

I tested MongoDB, DocumentDB and FerretDB on 10 million records. DocumentDB led on reads, and even on the write-heavy test it handled far more updates than a typical app will ever send.

By Bob Bass4 min read
MongoDBDocumentDBFerretDBBenchmarks
A vintage punch-card machine beside the words 10M Records, a YCSB benchmark of MongoDB, DocumentDB and FerretDB.

MongoDB lost a read benchmark to an open-source engine built on PostgreSQL, over MongoDB's own protocol. DocumentDB answered about 30% more reads per second than MongoDB Community on identical machines. I loaded 10 million records into MongoDB, DocumentDB and FerretDB and ran the same YCSB workloads against all three. Here's where each one won, and what it means if you're building something smaller than a benchmark rig.

I run Layerbase, a serverless database platform. When people ask me for MongoDB hosting, licensing shapes my answer. Section 13 of MongoDB Community's license sets source-sharing conditions for offering the software as a service. I chose to host two MongoDB-compatible alternatives, DocumentDB and FerretDB. For this comparison I also wanted the actual MongoDB Community server on a box of its own. MongoDB's Server Side Public License

Same quiz, three boxes

I gave each engine its own temporary 4-vCPU, 8 GB machine with a 100 GB data volume. Each loaded 10 million synthetic documents using 32 client threads. Then YCSB ran point reads and single-record updates at 16, 64 and 256 threads. The client ran locally on each box. Each phase aimed for a million operations with a ten-minute limit.

Here are successful operations per second at 64 client threads. Higher is better.

Engine testedAll reads95% reads, 5% updatesHalf reads, half updates
MongoDB Community 9.0.82,9592,9032,048
Standalone DocumentDB 1.2.0 (PostgreSQL 17.12)3,8353,5121,757
FerretDB 2.7.0 (PostgreSQL 17.6 backend)2,8392,6921,639

DocumentDB handled about 30% more point reads per second than MongoDB at 64 threads. Its 99th-percentile read took 49 ms, versus 82 ms for MongoDB. DocumentDB also led both read-heavy workloads at 16 and 256 threads.

Once half the work was updates, MongoDB led at every thread count, so if your app spends its day maxing out writes, MongoDB had the edge. At 64 threads its 99th-percentile update took 157 ms, against 302 ms for FerretDB and 525 ms for DocumentDB. MongoDB also loaded the original dataset at 8,592 inserts per second, about three times DocumentDB's 2,835. If your Monday starts with a big import, that result deserves its own line.

What this means for a normal app

Don't read the update column as "DocumentDB is slow at writes." 64 threads here means 64 clients firing requests back to back with no pause until the machine is maxed out. Even then, DocumentDB finished about 880 updates and 880 reads every second on a 4-vCPU box. Kept up all day, that's over 75 million updates. A SaaS app with a few thousand customers will use a small slice of that. The gap with MongoDB shows up when you run a database at its limit, and most apps never get there.

For what it's worth, the blog I maintain for my tutorial videos runs Payload CMS on DocumentDB instead of MongoDB, through Payload's regular MongoDB adapter.

Your app keeps the same MongoDB driver and connection string. Before you switch, test the less common features: the Atlas alternatives post covers Atlas Search, change streams and $lookup.

Try your own queries on a branch

The numbers above are point reads and single-record updates. Your app does something else, so the real test is your queries on your data. On Layerbase you can run that test without touching production: branch your DocumentDB database, point a test run or a preview deploy at the branch, and delete it when you're done. Turn on Branching in the database's Settings tab and branches are copy-on-write, so one is ready in seconds and doesn't use up another database slot.

DocumentDB is also on the Free plan. It sleeps when nobody is using it, wakes on the next connection, and comes with a branch per database. The pricing page has the current limits.

The fine print I'd want as a reader

Each engine ran the suite once, in the same order, with warm caches carrying over between phases. Five evenly mixed phases hit the time limit, including FerretDB at 64 threads (983,768 operations). The table uses completed work. All three finished with 10 million records. One wrinkle for my own compatibility checklist: DocumentDB's full collection count over the MongoDB protocol timed out even with 15 minutes allowed. I verified the count through PostgreSQL. These timings cover point operations. A Payload query with filters and sorting is a different test.

October's FerretDB images also served as my control. The same FerretDB stack delivered about 35% fewer point reads per second at 64 threads this time. I'd use the December columns to compare engines and leave claims about how much a version upgrade changed performance for a repeat experiment.

I have a lot of respect for the FerretDB team. FerretDB paved the way for me to offer a MongoDB-compatible service, and its developers spent a year working with Microsoft on the technology behind FerretDB 2.0. Its PostgreSQL backend uses the DocumentDB extension. Testing FerretDB alongside standalone DocumentDB lets me compare the two ways my customers can actually connect. FerretDB's account of that collaboration

For a read-heavy app like that tutorial blog, DocumentDB is the one I'd try first. Start it on the Free plan, branch it, and run the query your busiest page actually runs. Create a managed DocumentDB database on Layerbase

Earlier benchmarks