<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gendus</title>
    <description>The latest articles on DEV Community by Gendus (@gendus).</description>
    <link>https://dev.to/gendus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4260269%2F645ee0e8-67ce-4573-a667-5d33d45903aa.png</url>
      <title>DEV Community: Gendus</title>
      <link>https://dev.to/gendus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gendus"/>
    <language>en</language>
    <item>
      <title>From MongoDB to NonoDB in a day: migrating a production app without rewriting the code</title>
      <dc:creator>Gendus</dc:creator>
      <pubDate>Mon, 23 Nov 2026 10:16:54 +0000</pubDate>
      <link>https://dev.to/gendus/from-mongodb-to-nonodb-in-a-day-migrating-a-production-app-without-rewriting-the-code-2fb7</link>
      <guid>https://dev.to/gendus/from-mongodb-to-nonodb-in-a-day-migrating-a-production-app-without-rewriting-the-code-2fb7</guid>
      <description>&lt;p&gt;Masdriv is a campaign-sending app (FastAPI + Motor/PyMongo + Celery + Redis) that kept everything in MongoDB. One day we decided to find out whether we could swap the database for &lt;a href="https://nonodb.com" rel="noopener noreferrer"&gt;NonoDB&lt;/a&gt; — and it turned out that after a handful of code changes the whole migration went smoothly: the application code stayed almost untouched, the data moved in minutes, and the stack now runs on NonoDB in production.&lt;/p&gt;

&lt;p&gt;This article covers &lt;strong&gt;why&lt;/strong&gt; we did it, &lt;strong&gt;how&lt;/strong&gt; to do it step by step, and &lt;strong&gt;what we got&lt;/strong&gt; — with concrete numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why change the database at all?
&lt;/h2&gt;

&lt;p&gt;MongoDB is great, but for an app of our size (a few thousand documents, one server, no sharding) we were paying for complexity we never used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a replica set or standalone plus all the operational tooling (&lt;code&gt;mongosh&lt;/code&gt;, dumps, background index builds),&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mongodump&lt;/code&gt; backups → 510 MB on disk,&lt;/li&gt;
&lt;li&gt;a WiredTiger cache that by default reserves a large slice of the host's RAM,&lt;/li&gt;
&lt;li&gt;backups that need writes paused, or fiddling with &lt;code&gt;--oplog&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;NonoDB promises something different: &lt;strong&gt;one process, one binary, data in LMDB, and a MongoDB wire listener on top&lt;/strong&gt;. That last part was the key — the app keeps speaking "MongoDB", and we only change the host in &lt;code&gt;MONGO_URI&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is it a drop-in?
&lt;/h2&gt;

&lt;p&gt;Almost. &lt;code&gt;pymongo&lt;/code&gt; and &lt;code&gt;motor&lt;/code&gt; work unchanged, tests on &lt;code&gt;mongomock&lt;/code&gt; work unchanged, Celery works unchanged. In practice the whole switch is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;DB_BACKEND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nonodb
&lt;span class="nv"&gt;MONGO_URI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mongodb://admin:***@nonodb:27017/masdriv?authSource=admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Along the way we had to handle three things where NonoDB (still) differs from MongoDB.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. No &lt;code&gt;sparse&lt;/code&gt; and no TTL indexes
&lt;/h3&gt;

&lt;p&gt;NonoDB supports neither the &lt;code&gt;sparse&lt;/code&gt; option nor &lt;code&gt;expireAfterSeconds&lt;/code&gt;. The fix turned out to be simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sparse&lt;/code&gt;&lt;/strong&gt; → a plain unique index. The semantics are effectively the same: a missing field does not collide, only an explicit &lt;code&gt;null&lt;/code&gt; does (and the app never writes &lt;code&gt;null&lt;/code&gt; there).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TTL&lt;/strong&gt; → a &lt;code&gt;_ttl&lt;/code&gt; field (in seconds) set at insert time. NonoDB strips it before storing and expires the document in the background.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# database.py&lt;/span&gt;
&lt;span class="no"&gt;IS_NONODB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"DB_BACKEND"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mongodb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"nonodb"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_unique_opts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sparse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;IS_NONODB&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"sparse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sparse&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;with_ttl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""NonoDB: retention via a `_ttl` field instead of a TTL index."""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;IS_NONODB&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_ttl"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend picks its behaviour from a single environment variable, so the code behaves identically on both databases — which let us compare results 1:1.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. No &lt;code&gt;$toString&lt;/code&gt; in aggregations
&lt;/h3&gt;

&lt;p&gt;We had two &lt;code&gt;$lookup&lt;/code&gt; stages comparing an &lt;code&gt;_id&lt;/code&gt; (ObjectId) with an ID stored in a queue (string) via &lt;code&gt;$toString&lt;/code&gt;. NonoDB doesn't have it — and on older versions such a &lt;code&gt;$lookup&lt;/code&gt; &lt;strong&gt;silently returned empty results&lt;/strong&gt;. Instead of fighting the pipeline, we solved it in Python: one &lt;code&gt;$in&lt;/code&gt; query per collection plus an in-memory map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;names_by_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;wanted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;object_ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ObjectId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wanted&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nc"&gt;ObjectId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;object_ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"$in"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;object_ids&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wanted&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"$in"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result: fewer round-trips than &lt;code&gt;$lookup&lt;/code&gt; per row, and identical output on both databases.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Healthcheck and authentication
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;mongosh --eval "db.runCommand('ping')"&lt;/code&gt; became &lt;code&gt;nonodb-cli ping&lt;/code&gt;, and SCRAM is configured with &lt;code&gt;NONODB_MONGO_USERNAME&lt;/code&gt; / &lt;code&gt;NONODB_MONGO_PASSWORD&lt;/code&gt; — the same credentials used in &lt;code&gt;MONGO_URI&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrating the data
&lt;/h2&gt;

&lt;p&gt;This is where NonoDB positively surprised us: &lt;strong&gt;both databases speak the same protocol&lt;/strong&gt;, so we needed no &lt;code&gt;mongodump&lt;/code&gt;/&lt;code&gt;mongoimport&lt;/code&gt; and no intermediate files. A &lt;code&gt;pymongo&lt;/code&gt; script that copies documents in batches (upsert by &lt;code&gt;_id&lt;/code&gt;) was enough, followed by a comparison of document counts and a content checksum for every collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. dry run&lt;/span&gt;
python3 migrate_mongo_to_nonodb.py \
  --source &lt;span class="s2"&gt;"$MONGO_URI"&lt;/span&gt; \
  --target &lt;span class="s2"&gt;"mongodb://admin:***@nonodb:27017/masdriv?authSource=admin"&lt;/span&gt; --dry-run

&lt;span class="c"&gt;# 2. copy (idempotent — safe to re-run)&lt;/span&gt;
python3 migrate_mongo_to_nonodb.py --source &lt;span class="s2"&gt;"$MONGO_URI"&lt;/span&gt; --target &lt;span class="s2"&gt;"$NONODB_URI"&lt;/span&gt;

&lt;span class="c"&gt;# 3. verification only: count + sha256(content) per collection&lt;/span&gt;
python3 migrate_mongo_to_nonodb.py --source &lt;span class="s2"&gt;"$MONGO_URI"&lt;/span&gt; --target &lt;span class="s2"&gt;"$NONODB_URI"&lt;/span&gt; --verify-only
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result for our database: &lt;strong&gt;33 collections, 6,435 documents, zero differences&lt;/strong&gt; in verification. BSON types (&lt;code&gt;ObjectId&lt;/code&gt;, dates, &lt;code&gt;Decimal128&lt;/code&gt;) came through without conversion, indexes rebuilt themselves from &lt;code&gt;list_indexes()&lt;/code&gt;, and the only things that had to be skipped were &lt;code&gt;sparse&lt;/code&gt;/TTL — with a clear message saying so.&lt;/p&gt;

&lt;p&gt;The whole process took &lt;strong&gt;under a minute&lt;/strong&gt;, verification included.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing before and after
&lt;/h2&gt;

&lt;p&gt;Before switching production traffic we ran:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;265 backend tests&lt;/strong&gt; (&lt;code&gt;pytest&lt;/code&gt;, &lt;code&gt;mongomock&lt;/code&gt;) — green, unchanged,&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;protocol conformance test&lt;/strong&gt; (22 cases: CRUD, cursors, indexes, &lt;code&gt;$lookup&lt;/code&gt;, &lt;code&gt;$facet&lt;/code&gt;, &lt;code&gt;$group&lt;/code&gt;, upsert, BSON types) — 22/22,&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;differential test&lt;/strong&gt;: the same app against MongoDB and NonoDB, same data, 88 GET endpoints and 56 write steps — &lt;strong&gt;0 differences&lt;/strong&gt; in status codes and JSON shape,&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;send pipeline&lt;/strong&gt; (200 messages): identical 200 &lt;code&gt;sent&lt;/code&gt;, 200 &lt;code&gt;attempts&lt;/code&gt;, 200 events, 200 idempotency keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only then did we move traffic.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we gained
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;MongoDB&lt;/th&gt;
&lt;th&gt;NonoDB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Disk (6,435 docs, 33 collections)&lt;/td&gt;
&lt;td&gt;510 MB (data + journal)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9.3 MB&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database process RAM&lt;/td&gt;
&lt;td&gt;WiredTiger cache reserves a large share of host RAM&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;15–30 MiB RSS&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Idle CPU&lt;/td&gt;
&lt;td&gt;process + WT threads&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backup&lt;/td&gt;
&lt;td&gt;510 MB dump, needs consistency handling&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;656 KB&lt;/strong&gt; (gzip), online&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The LMDB map is reserved at 1 GiB (it can grow online via &lt;code&gt;nonodb-cli resize&lt;/code&gt;) but only 9.7 MB is actually used — the rest is empty, sparse space. That leaves room on the VPS we could previously only dream about.&lt;/p&gt;

&lt;h3&gt;
  
  
  New capabilities
&lt;/h3&gt;

&lt;p&gt;This isn't just "a lighter MongoDB" — NonoDB gives us things we simply didn't have before:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A JSON API and SQL&lt;/strong&gt; next to the MongoDB protocol: &lt;code&gt;{"op":"find","coll":"users","filter":{...}}&lt;/code&gt; or a plain &lt;code&gt;SELECT&lt;/code&gt; — great for diagnostics and analytics without &lt;code&gt;mongosh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;watch&lt;/code&gt; and subscriptions&lt;/strong&gt; — a change stream over SSE, i.e. a natural outbox for webhooks and notifications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document history&lt;/strong&gt; (&lt;code&gt;history&lt;/code&gt;, &lt;code&gt;get_version&lt;/code&gt;) and &lt;strong&gt;&lt;code&gt;restore --to &amp;lt;timestamp&amp;gt;&lt;/code&gt;&lt;/strong&gt; — point-in-time recovery, which MongoDB won't do with a single command.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shadow mode&lt;/strong&gt; — the daemon also forwards writes to MongoDB and records diffs as JSONL. The simplest possible way to validate a migration against real traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backups with a manifest and SHA-256&lt;/strong&gt;, &lt;code&gt;verify-backup&lt;/code&gt;, retention, and S3 upload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in vector, fuzzy and full-text indexes&lt;/strong&gt; — a replacement for a good chunk of Atlas Search without extra infrastructure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A single data file and zero replication&lt;/strong&gt; — deployment is one container and one volume.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How the maintainers responded
&lt;/h3&gt;

&lt;p&gt;During testing we found a few things that didn't behave ideally (sorting &lt;code&gt;null&lt;/code&gt; differently from MongoDB, &lt;code&gt;insert_many&lt;/code&gt; committing per document, slow &lt;code&gt;$in&lt;/code&gt; on large lists). We filed them as issues — and &lt;strong&gt;all three were fixed within hours&lt;/strong&gt;, with regression tests. After building from &lt;code&gt;main&lt;/code&gt;, the problems were gone: &lt;code&gt;insert_many&lt;/code&gt; went from 550 ms to 32 ms for 1,000 documents, &lt;code&gt;$in&lt;/code&gt; with 500 values from 1,230 ms to 10 ms, and &lt;code&gt;null&lt;/code&gt; sorting now matches MongoDB exactly.&lt;/p&gt;

&lt;p&gt;For a &lt;code&gt;0.x&lt;/code&gt; project that's a very good sign: the author responds faster than many teams inside companies do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to watch out for
&lt;/h2&gt;

&lt;p&gt;To keep it honest, here is what you should check before migrating:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Indexes&lt;/strong&gt;: review &lt;code&gt;list_indexes()&lt;/code&gt; for &lt;code&gt;sparse&lt;/code&gt;, &lt;code&gt;partialFilterExpression&lt;/code&gt;, &lt;code&gt;collation&lt;/code&gt; — those options are not supported.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aggregations&lt;/strong&gt;: check for &lt;code&gt;$toString&lt;/code&gt;/&lt;code&gt;$convert&lt;/code&gt; inside expressions; if present, move that logic into the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large &lt;code&gt;$in&lt;/code&gt; lists and bulk inserts&lt;/strong&gt;: on 0.29.1 these were slower than MongoDB (fixed on &lt;code&gt;main&lt;/code&gt;); measure your own pattern before cutover.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sorting on fields that can be &lt;code&gt;null&lt;/code&gt;&lt;/strong&gt; — check whether ordering matters for your pagination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transactions, sessions, change streams&lt;/strong&gt; — if you rely on them, NonoDB doesn't have them yet.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Migrating from MongoDB to NonoDB turned out to be &lt;strong&gt;much easier than we assumed&lt;/strong&gt;. The key was that NonoDB speaks the MongoDB protocol: we didn't rewrite queries, we didn't change drivers or architecture. Three small changes in one module (&lt;code&gt;database.py&lt;/code&gt;) and one endpoint, plus a 250-line migration script.&lt;/p&gt;

&lt;p&gt;In return we got a database that takes &lt;strong&gt;9 MB instead of 510 MB&lt;/strong&gt;, uses a few dozen megabytes of RAM instead of a cache reservation, backs up online in under a second — and, on top of that, offers features we never had: document history with point-in-time restore, change streams, SQL and vector indexes.&lt;/p&gt;

&lt;p&gt;If you run an app whose database workload is mostly CRUD plus a few aggregations, NonoDB is worth a look. Start with shadow mode, migrate a copy of your data, and run a differential test. For us it took one day and not a single sleepless night.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>python</category>
      <category>database</category>
      <category>nonodb</category>
    </item>
  </channel>
</rss>
