<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Data Archives - ShiftMag</title>
	<atom:link href="https://shiftmag.dev/category/data/feed/" rel="self" type="application/rss+xml" />
	<link>https://shiftmag.dev/category/data/</link>
	<description>Insightful engineering content &#38; community</description>
	<lastBuildDate>Wed, 04 Nov 2026 14:12:20 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://shiftmag.dev/wp-content/uploads/2026/09/cropped-Shift-32x32.webp</url>
	<title>Data Archives - ShiftMag</title>
	<link>https://shiftmag.dev/category/data/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How WiredTiger Cache Dirty Pages and Eviction Can Throttle Your MongoDB Writes</title>
		<link>https://shiftmag.dev/how-wiredtiger-cache-dirty-pages-and-eviction-can-throttle-your-mongodb-writes-13357/</link>
		
		<dc:creator><![CDATA[Frane Jelavic]]></dc:creator>
		<pubDate>Wed, 04 Nov 2026 14:10:08 +0000</pubDate>
				<category><![CDATA[Backend]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database Performance]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[wiredtiger]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=13357</guid>

					<description><![CDATA[<p>My MongoDB primary started throttling writes with every secondary healthy, and the cause was hiding in a cache most of us never look at.</p>
<p>The post <a href="https://shiftmag.dev/how-wiredtiger-cache-dirty-pages-and-eviction-can-throttle-your-mongodb-writes-13357/">How WiredTiger Cache Dirty Pages and Eviction Can Throttle Your MongoDB Writes</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img fetchpriority="high" decoding="async" width="1280" height="720" src="https://shiftmag.dev/wp-content/uploads/2026/11/ShiftMag-article-banner-4.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2026/11/ShiftMag-article-banner-4.png 1280w, https://shiftmag.dev/wp-content/uploads/2026/11/ShiftMag-article-banner-4-300x169.png 300w, https://shiftmag.dev/wp-content/uploads/2026/11/ShiftMag-article-banner-4-1024x576.png 1024w, https://shiftmag.dev/wp-content/uploads/2026/11/ShiftMag-article-banner-4-768x432.png 768w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>


<p class="wp-block-paragraph">While continuing to learn more about MongoDB, specifically the synergy with WiredTiger, I’ve come to notice there is <strong>more than one way client writes can be throttled</strong>.</p>



<p class="wp-block-paragraph">If you haven’t followed my journey while battling with MongoDB, check out my previous post, <a href="https://shiftmag.dev/mongodb-one-write-two-logs-12267/" target="_blank" rel="noreferrer noopener">MongoDB: One write, two logs</a>, where a client write gets persisted and replicated inside a classical replica set. Supporting files for this article are on <a href="https://github.com/FraneJelavic/FraneJelavic.github.io/tree/main/content/writing/wiredtiger-cache-dirty-pages-and-eviction/media" target="_blank" rel="noopener">GitHub</a>.</p>



<p class="wp-block-paragraph">The first and best-known one is<strong> flow control</strong>, the write back pressure most of us have already met. A write counts as majority-committed once most of the replica set members acknowledge it. In a three-node replica set, that means the primary plus at least one secondary. If no secondary acknowledges, the majority commit point stops moving.</p>



<p class="wp-block-paragraph">MongoDB tries to keep that commit point within ten seconds of the primary (with default configuration). It starts throttling at half of that, around five seconds behind. Nothing is rejected, writes just slow down. The primary hands out fewer write tickets until the commit point moves again, but never fewer than a hundred tickets per second.</p>



<p class="wp-block-paragraph">We won&#8217;t talk about flow control here, because in production the throttling came from the primary itself. How is that possible? Let me explain.</p>



<h2 class="wp-block-heading" id="wiredtiger-cache">WiredTiger cache</h2>



<p class="wp-block-paragraph">You’ve read my previous post :), so let’s start assuming some basic understanding of MongoDB -&gt; WiredTiger communication. Every DML statement modifies a page in the WT cache.</p>



<p class="wp-block-paragraph">If we trace a write to a collection, the page holding that document becomes <strong>dirty</strong> inside the cache (if it is in the cache in the first place, otherwise it first gets read in from the data files). The page no longer matches what is on disk, and that mismatch is WT’s signal that the page has to be reconciled before the memory can be reused. Dirty pages leave the cache by one of two routes. <strong>Eviction</strong> runs continuously in the background. <strong>Checkpoints</strong> run every 60s by default.</p>



<p class="wp-block-paragraph">The write itself does not wait for either of them. WT appends every modification to the write-ahead <strong>journal</strong> while the affected page stays dirty in cache, and that append is what makes the write survive a crash (classical write ahead log mechanism). MongoDB flushes the journal every 100ms by default, <code>storage.journal.commitIntervalMs</code>, and immediately for a write that asks for <code>j:true</code>, so the exposure is that interval rather than the 60 seconds between checkpoints. If <em>mongod</em> dies between checkpoints, recovery replays the journal and rebuilds the pages from it. This is also what lets the primary acknowledge a write before its page is rewritten, which is how dirty content piles up between checkpoints. None of it touches <code>collection-*.wt</code> or <code>index-*.wt</code> on disk.</p>



<p class="wp-block-paragraph">Eventually the pages have to move, and that is the <strong>checkpoint’s job</strong>. It reconciles the pages that are still dirty and writes them to the data files as a snapshot consistent up to a single timestamp (MVCC), the same one across every collection and index. Pages that eviction already cleaned are skipped. The previous checkpoint stays valid while the new one is written, and the new one becomes permanent when WT updates its metadata table in one atomic step to point at it. Only then can the journal records it covers be discarded, which is what bounds journal growth.</p>



<h2 class="wp-block-heading" id="eviction-threads">Eviction threads</h2>



<p class="wp-block-paragraph">The cache has a fixed size, so something has to keep it from filling up. One eviction server walks the cache and picks candidates. Worker threads, by default four, do the heavy lifting.</p>



<p class="wp-block-paragraph">When the threads start, their progress is governed by <strong>four thresholds</strong>. They are two pairs measuring fullness and dirty percentage of the cache.</p>



<p class="wp-block-paragraph">The first pair watches how full the cache is. If we cross 80 percent, <code><strong>eviction_target</strong></code>, the workers start freeing space in the background. If we cross 95 percent, <code><strong>eviction_trigger</strong></code>, the application threads are summoned to help the workers.</p>



<p class="wp-block-paragraph">The second pair watches how much of that cache is dirty, using the same scale, with much lower numbers. Cross 5 percent, <code>eviction_dirty_target</code>, the workers start to evict dirty pages. If we cross 20 percent, <code>eviction_dirty_trigger</code>, the application threads join in.</p>



<p class="wp-block-paragraph">In a write-heavy workload the dirty pair is the one you meet first. A cache that is 30 percent full can be 30 percent dirty if every page in it was written, which is past the 20 percent trigger and nowhere near the 80 percent line.</p>



<p class="wp-block-paragraph">The logic is simple. The target starts the workers, and the trigger is the point where workers have “lost the battle” and need help from application threads. This is also the point where <strong>client writes start getting throttled</strong>.</p>



<p class="wp-block-paragraph">An excellent analogy to the upper mechanism is a restaurant. Waiters are application threads. They take orders and carry plates, which is your reads and writes. The kitchen shelf is the cache and holds a fixed number of plates. A clean plate is a page that matches the data files and can be reused. A dirty plate is a page somebody changed.</p>



<p class="wp-block-paragraph">The dishwashers are the eviction workers. While they keep up, nobody in the dining room notices. If we pass a point where there are too many dirty plates, the dishwashers cannot keep up, so we pull in the waiters. Since the waiters are now washing dishes, taking orders slows down, new dirty plates arrive more slowly, and the kitchen gets its chance to catch up. And never mind the review the customer leaves after waiting too long :D.</p>



<p class="wp-block-paragraph">Two details keep the analogy honest. A plate somebody is still eating from cannot be collected. That is a page pinned by an active reader, and it is a real reason eviction stalls while the cache keeps growing. And the trigger is not a request. An application thread that finds the cache past a trigger does the eviction itself, before it can read or write any more data. That is the latency you feel.</p>



<h2 class="wp-block-heading" id="mitigation">Mitigation</h2>



<p class="wp-block-paragraph">In my scenario this meant I needed more dishwashers, more time for them to work, or both. </p>



<p class="wp-block-paragraph">The workload was bulk writes that also triggered extra reads. That needed fixing at the source, but first I needed to <strong>reduce the backpressure</strong>. This cluster ran MongoDB 8.3.8. The version matters because the available configuration parameters differ between releases. The first change was to increase the eviction thread count from 4 to 20. On 8.3.8, dedicated server parameters allow this at startup or runtime:</p>



<pre class="wp-block-code"><code>db.adminCommand({
  setParameter: 1,
  wiredTigerEvictionThreadsMax: 20,
  wiredTigerEvictionThreadsMin: 20
})
</code></pre>



<p class="wp-block-paragraph"><strong>More threads alone were not enough</strong>. I also wanted dirty-page eviction to start earlier, giving the workers more time before application threads had to join in. That meant lowering <code>eviction_dirty_target</code> from 5 percent to 1 percent.</p>



<p class="wp-block-paragraph">There is a dedicated <code>wiredTigerEvictionDirtyTargetGB</code> parameter, but it only takes effect at startup and accepts an absolute size. For a 15.5 GiB cache, 0.155 would approximate a 1 percent target. Changing the percentage on the running instance required the raw <strong>WiredTiger configuration</strong>. The dirty-target part of that change was:</p>



<pre class="wp-block-code"><code>db.adminCommand({
  setParameter: 1,
  wiredTigerEngineRuntimeConfig: "eviction_dirty_target=1"
})
</code></pre>



<p class="wp-block-paragraph">MongoDB’s <a href="https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.wiredTigerEngineRuntimeConfig" target="_blank" rel="noopener">manual</a> advises against changing this parameter without direction from MongoDB engineers because it has implications across both WiredTiger and MongoDB.</p>



<p class="wp-block-paragraph">Neither runtime command persists across restarts. The thread parameters can be stored under <code>setParameter</code> in <em>mongod.conf</em>.</p>



<p class="wp-block-paragraph"><strong>The result was 20 eviction threads available instead of 4</strong>, with background dirty-page eviction starting at 1 percent instead of 5 percent of the cache. That target is about 159 MiB on a 15.5 GiB cache. It is not a cap: dirty content can rise above it, and the dirty trigger remains at 20 percent.</p>



<p class="wp-block-paragraph">There is a cost to starting earlier and allowing more workers to participate. <strong>Eviction can consume more CPU and disk I/O</strong>. Setting both thread limits to 20 also prevents the thread count from scaling down, although those threads can wait when there is no work. For this workload, the aim was to absorb more of the eviction work in the background before it reached the application threads.</p>



<h2 class="wp-block-heading" id="my-takeaway">My takeaway</h2>



<p class="wp-block-paragraph">Even a two-parameter change can change how the cluster behaves, from incidents and slowdowns during write inflow to steady work across all workloads. </p>



<p class="wp-block-paragraph">The important thing is to <strong>understand the underlying technology and the mechanisms underneath</strong>. Understanding the why’s and the how’s. AI is incredible at helping us gain more knowledge and understanding, but we are the ones making the decision. </p>



<p class="wp-block-paragraph">This is the next step in software engineering I’m comfortable with.</p>



<figure class="wp-block-video"><video height="900" style="aspect-ratio: 1600 / 900;" width="1600" controls src="https://shiftmag.dev/wp-content/uploads/2026/11/wiredtiger-cache-glossary-v001.mp4"></video></figure>
<p>The post <a href="https://shiftmag.dev/how-wiredtiger-cache-dirty-pages-and-eviction-can-throttle-your-mongodb-writes-13357/">How WiredTiger Cache Dirty Pages and Eviction Can Throttle Your MongoDB Writes</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		<enclosure url="https://shiftmag.dev/wp-content/uploads/2026/11/wiredtiger-cache-glossary-v001.mp4" length="1000632" type="video/mp4" />

			</item>
		<item>
		<title>MotherDuck CEO Says Single-Node Analytics Can Outperform Distributed Systems</title>
		<link>https://shiftmag.dev/motherduck-ceo-says-single-node-analytics-can-outperform-distributed-systems-12404/</link>
		
		<dc:creator><![CDATA[Marko Crnjanski]]></dc:creator>
		<pubDate>Mon, 02 Nov 2026 11:19:54 +0000</pubDate>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[AI agents]]></category>
		<category><![CDATA[Data Analytics]]></category>
		<category><![CDATA[DuckDB]]></category>
		<category><![CDATA[Jordan Tigani]]></category>
		<category><![CDATA[MCP]]></category>
		<category><![CDATA[MotherDuck]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=12404</guid>

					<description><![CDATA[<p>Jordan Tigani, MotherDuck CEO, argues that many analytics teams are paying a complexity tax for workloads that never needed it.</p>
<p>The post <a href="https://shiftmag.dev/motherduck-ceo-says-single-node-analytics-can-outperform-distributed-systems-12404/">MotherDuck CEO Says Single-Node Analytics Can Outperform Distributed Systems</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img decoding="async" width="1200" height="630" src="https://shiftmag.dev/wp-content/uploads/2026/10/ShiftMag-article-banner-4.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2026/10/ShiftMag-article-banner-4.png 1200w, https://shiftmag.dev/wp-content/uploads/2026/10/ShiftMag-article-banner-4-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2026/10/ShiftMag-article-banner-4-768x403.png 768w, https://shiftmag.dev/wp-content/uploads/2026/10/ShiftMag-article-banner-4-1024x538.png 1024w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>


<p class="wp-block-paragraph">I spoke with <a href="https://www.linkedin.com/in/jordantigani/" target="_blank" rel="noreferrer noopener">Jordan Tigani</a>, CEO of MotherDuck, about a question analytics teams should ask before building a cluster: <strong>does this workload actually need one</strong>? </p>



<p class="wp-block-paragraph">MotherDuck is a cloud analytics service built on DuckDB, an open-source SQL database for analytics; and before co-founding it, Tigani helped build Google BigQuery as an early engineer and led product at SingleStore. </p>



<p class="wp-block-paragraph">We discussed <strong>when distributed systems are worth the complexity</strong> and how analytics teams can build and govern simpler alternatives.</p>



<h2 class="wp-block-heading" id="choose-architecture-based-on-what-queries-actually-process-not-just-total-data-size">Choose architecture based on what queries actually process, not just total data size</h2>



<p class="wp-block-paragraph">First I wanted to satisfy my curiosity about how BigQuery was built, so I asked Tigani what the starting point had been. </p>



<p class="wp-block-paragraph">He said it was <strong>the need for distributed systems, which divide work across multiple machines</strong>. I then asked what had convinced him that many modern analytics workloads might no longer require that approach and he said:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">When I was working on BigQuery I used to run a lot of analytics to understand our customers and what they were doing. I noticed that most of our customers didn’t have a lot of data. And even the ones who did have a lot of data, many of their queries only processed a small amount of data at once. We had some of the largest customers in the world, Walmart, HSBC, Equifax. They were all using a tool called &#8220;Big Query&#8221; but the queries they were running were not big at all.</p>
</blockquote>



<p class="wp-block-paragraph">Tigani also noted that he mostly just filed that information away as a curiosity. Later, while he was working at SingleStore to help build its SaaS database product, he began exploring the machines available on AWS. &#8220;I was shocked; you could get a machine with hundreds of cores and terabytes of RAM, and it wasn’t even expensive,&#8221; Jordan explained.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The third piece that tied it all together was when I saw how fast you could implement things in a single-node system. I had been following DuckDB for a little bit, and they added a join optimization that was similar to something we’d done in BigQuery years earlier.</p>
</blockquote>



<p class="wp-block-paragraph"><strong>That optimization took months to build in BigQuery because of all its moving parts</strong>. DuckDB built it in days and shipped it alongside other improvements. &#8220;That was shocking, just how fast you could move if you didn’t have to deal with all of the distributed systems machinery.&#8221;</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">So machines are getting bigger. But workloads are not. And distributed systems add a tax, both in the performance you can possibly expect but also the time it takes to build and improve things. I put those together and thought, &#8220;wow, if we were going to create BigQuery today, we would have done it very differently.&#8221;</p>
</blockquote>



<h2 class="wp-block-heading" id="isolate-workloads-to-avoid-slowdowns-and-complex-resource-management">Isolate workloads to avoid slowdowns and complex resource management</h2>



<p class="wp-block-paragraph">From there, I turned to query execution in MotherDuck:<strong> how it decides whether queries run locally, in the cloud (or both)</strong> and how developers can check.</p>



<p class="wp-block-paragraph">&#8220;For context, MotherDuck has a feature we call “dual execution” which means we can run queries either locally or in the cloud,&#8221; Jordan explained.</p>



<p class="wp-block-paragraph">He also explained that this lets MotherDuck integrate seamlessly with applications already using DuckDB, and also lets customers build highly performant applications where results get cached locally and follow-up queries can run out of that local cache:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">However, we never run anything locally unless the user makes it clear that is what they want to do. For example, if they’re using a local duckdb database and then they join it against a MotherDuck database, we’ll run part of the query locally and part in the cloud.</p>
</blockquote>



<p class="wp-block-paragraph">He said there are also cases where <strong>users want to run entirely in the cloud</strong> and don’t want the dual-execution machinery, which includes a copy of DuckDB. For those cases, they can use MotherDuck’s PostgreSQL endpoint, which makes MotherDuck look just like a PostgreSQL server.</p>



<p class="wp-block-paragraph">Speaking about the advantages and limitations of MotherDuck’s hypertenancy model compared with a traditional shared data warehouse, where multiple users or workloads draw on shared computing resources, Jordan noted that hypertenancy is a fancy way of saying &#8220;everybody gets a duck.&#8221; In other words, if you have 100 users, every one of those users gets <strong>their own individual DuckDB instance running in the cloud</strong>.</p>



<p class="wp-block-paragraph">&#8220;We combine that with serverless execution, so we can start virtually instantaneously and shut down as soon as queries complete,&#8221; Tigani said and explained: </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The rationale from this was after seeing how complicated workload management was in other databases. If you have more than one user or workload accessing the same hardware, you have to figure out how to share resources. If you go from one user to 10 users querying concurrently, either that first user’s queries are going to slow down, the new users are going to run slowly, or you had vastly over-provisioned.</p>
</blockquote>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="538" src="https://shiftmag.dev/wp-content/uploads/2026/10/motherduck_1-1-1024x538.jpg?x11163" alt="" class="wp-image-13196" srcset="https://shiftmag.dev/wp-content/uploads/2026/10/motherduck_1-1-1024x538.jpg 1024w, https://shiftmag.dev/wp-content/uploads/2026/10/motherduck_1-1-768x403.jpg 768w, https://shiftmag.dev/wp-content/uploads/2026/10/motherduck_1-1-300x158.jpg 300w, https://shiftmag.dev/wp-content/uploads/2026/10/motherduck_1-1.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">MotherDuck’s architecture combines shared storage with isolated DuckDB compute instances, called Ducklings, and interfaces for developer tools and AI agents. Compute resources can scale independently for different users and workloads.</figcaption></figure>



<p class="wp-block-paragraph">What I also learned from Jordan is that <strong>workload management tends to get really complicated</strong>, both for users and for people building the database. For example, Tigani said, configuring workload management in Teradata is so complicated that one of their most anticipated features was a mechanism for machine learning to be able to help you tune it correctly. In other words, it was too hard for humans to do it well:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">For MotherDuck we thought, what if we made it so every workload was a different completely isolated database? Then workload management is simple. You don’t need to worry about one user slowing down another one, or complex priority schemes to decide who got what resources. You also don’t have to worry about over or under provisioning.</p>
</blockquote>



<p class="wp-block-paragraph">The other advantage of this, he added, is that <strong>it scales really nicely with how people actually use an analytical database</strong>. There are often a couple of users who have really heavy workloads and a lot of users who have much lighter workloads. So the heavy users scale up to big instances, the lighter users get tiny ones. And none of them slow each other down.</p>



<p class="wp-block-paragraph">&#8220;If you’re building a SaaS application this ends up being even more useful, because you can give each one of your end users a different database. In other words, let’s say you’re building a stock portfolio app and you want to give your users the ability to analyze their holdings,&#8221; Jordan explained.</p>



<p class="wp-block-paragraph">According to Tigani, each of those users gets a different DuckDB instance; these instances turn off when not being used, so it doesn’t matter how many users you have: <strong>you only pay for what’s actually running</strong>. And all of your users are nicely isolated from each other.</p>



<h2 class="wp-block-heading" id="storage-formats-and-postgresql-compatibility">Storage formats and PostgreSQL compatibility</h2>



<p class="wp-block-paragraph">Our conversation also moved to <strong>DuckLake, Apache Iceberg and Delta Lake</strong>, technologies for organizing tables and managing their metadata in a data lake. </p>



<p class="wp-block-paragraph">I asked Tigani what problem DuckLake was designed to solve that Iceberg and Delta Lake did not solve well enough. His detailed answer was:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Do you remember when everyone was putting things on the blockchain, and a handful of sane people said &#8220;wait, this is basically just an incredibly complicated database that can only do a couple of updates per second.&#8221; That’s kind of what Iceberg and Delta are; they’re a super complicated way of storing data on S3 and can only do one or two updates per second.</p>
</blockquote>



<p class="wp-block-paragraph">DuckLake he expleined, is a <strong>cleaner way of envisioning how a data lake can work </strong>by storing the metadata about how to find the active bits of the table in a database instead of on S3. This means it is a lot faster to find what you’re looking for as well as makes it much more reliable to make updates.</p>



<p class="wp-block-paragraph">Jordan also mentioned that people say that a lot of the weaknesses of Iceberg are being solved in subsequent versions, but it is very hard to get around architectural limitations by adding complexity on top:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Of course, a lot of people use Iceberg, and there is a lot of momentum behind it. So while we believe that DuckLake is a better way to store your data, Iceberg isn’t likely going anywhere. So we have first class support for iceberg, including the various Iceberg catalogs, in MotherDuck.</p>
</blockquote>



<p class="wp-block-paragraph">MotherDuck’s support for the <a href="https://www.postgresql.org/docs/current/protocol.html" target="_blank" rel="noreferrer noopener">PostgreSQL wire protocol</a>, the communication protocol used by PostgreSQL clients and servers, raised another practical topic. I asked where compatibility with Postgres ends and what differences developers should understand before using it in production.</p>



<p class="wp-block-paragraph">Explaining this, Tigani said the primary reason for Postgres wire protocol support is that it creates virtually universal connectivity. A lot of people can connect to DuckDB, but virtually everyone knows how to connect to Postgres.</p>



<p class="wp-block-paragraph">He also noted that the secondary reason is that <strong>a lot of people use Postgres for things that are really analytics and then start to hit the limits of what Postgres can do</strong>. “By switching to the postgres wire protocol, we can make it super easy to switch to MotherDuck; you don’t have to change your queries, your connector, or your code; it should just work,” Jordan explained and added:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">That said, I should add all the usual caveats. While DuckDB SQL is mostly a superset of Postgres SQL, it is not a strict superset. That is, the vast majority of Postgres functions work in DuckDB, but there are some corner cases where things might be missing. There are also cases where some things may work subtly differently in DuckDB than in postgres. We’re hard at work on ensuring compatibility, but when you take a large system as complex as Postgres, there are going to be some differences.</p>
</blockquote>



<h2 class="wp-block-heading" id="treat-ai-agents-like-any-production-tool-grant-only-the-access-they-need">Treat AI agents like any production tool: grant only the access they need</h2>



<p class="wp-block-paragraph">An important part of our conversation focused on AI agents querying production data through the <a href="https://shiftmag.dev/tag/mcp/" data-type="post_tag" data-id="573" target="_blank" rel="noreferrer noopener">Model Context Protocol</a>, or MCP, a standard for connecting AI applications to external tools and data sources. I asked Jordan which security and governance controls teams should put in place before enabling that access. He explained:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">There isn’t anything special about MCP that isn’t true with other AI tools, or with other tools in general. It is easy, and perhaps natural, for people to see tools that can produce magical results and to jump in and want to start using them in production. However, if set up poorly, these magical tools can cause embarrassing security holes. The principle of least privilege is a good one to follow.</p>
</blockquote>



<p class="wp-block-paragraph">He also urged teams to be careful about access permissions:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Be careful who can add new tools. Trim security groups. Watch out for confused deputies (things that run as privileged users that provide services to other users can accidentally give those other users access to things they shouldn’t be able to see or do).</p>
</blockquote>



<p class="wp-block-paragraph">Building on this theme, Tigani said that <strong>it is also easy to have a knee-jerk reaction to security and risk</strong>. However, it is important to think through the actual threat models. What is the actual harm that can be done? What things would happen in order for that harm to be achieved? And then what can you do to mitigate those situations?</p>



<h2 class="wp-block-heading" id="match-review-effort-to-the-risk">Match review effort to the risk</h2>



<p class="wp-block-paragraph">Before the interview ended, I asked Jordan <strong>how engineering teams should test, review and monitor work produced by AI agents</strong> as they generate more SQL queries, data pipelines and analytics applications.</p>



<p class="wp-block-paragraph">He answered that at MotherDuck, virtually everyone in the company creates Dives, which are their vibe-coded dashboards. According to Tigani, most of these people wouldn’t be comfortable using SQL, and yet they use these tools to help them in their jobs every day:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">For most cases, the advantage of having a quick and easy answer is well worth the possibility that it will be wrong. And the benefit of having the line-of-business users actually generate the visualizations is that they are the ones who can detect when something goes wrong; they are going to be better than an analyst on a centralized data team to know that the revenue from a particular customer looks off.</p>
</blockquote>



<p class="wp-block-paragraph">Tigani also mentioned that the amount of scrutiny varies depending on how important it is that the answer is right. If you’re reporting numbers to a regulator, you probably need them to be right. But the vast majority of use cases are not actually like that.</p>



<p class="wp-block-paragraph">&#8220;If you’re building dashboards to understand customers in your sales book, or trying to gauge the success of your marketing campaigns, <strong>rapid iteration is going to be more important than perfection</strong>,&#8221; Jordan said, adding:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Additionally, in my experience, the quality of AI written SQL is higher than human written SQL. You really don’t have to review it to figure if it is going to work. You don’t need to check to see if there is an off-by-one error in the bounds of the window function, or if it passed the arguments correctly. Important visualizations, important data pipelines, and context should be all treated like product code. Stored in source control. Changed via pull-requests with commit messages showing what was actually changed as well.</p>
</blockquote>



<p class="wp-block-paragraph">&#8220;Even if it is AI writing the code, <strong>you should make sure it is auditable by a human</strong>. But as AI gets better, humans are going to be doing less code review to check it to see if it is right and more auditing to see what happened when something goes wrong,&#8221; Jordan concluded.</p>
<p>The post <a href="https://shiftmag.dev/motherduck-ceo-says-single-node-analytics-can-outperform-distributed-systems-12404/">MotherDuck CEO Says Single-Node Analytics Can Outperform Distributed Systems</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MongoDB: One Write, Two Logs</title>
		<link>https://shiftmag.dev/mongodb-one-write-two-logs-12267/</link>
		
		<dc:creator><![CDATA[Frane Jelavic]]></dc:creator>
		<pubDate>Thu, 24 Sep 2026 09:04:30 +0000</pubDate>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[database internals]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[storage engines]]></category>
		<category><![CDATA[wiredtiger]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=12267</guid>

					<description><![CDATA[<p>At 55,000 operations per second across a 20 TB sharded cluster, you stop theorizing about databases and start reading their source code.</p>
<p>The post <a href="https://shiftmag.dev/mongodb-one-write-two-logs-12267/">MongoDB: One Write, Two Logs</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img loading="lazy" decoding="async" width="1200" height="620" src="https://shiftmag.dev/wp-content/uploads/2026/09/mongodb-one-write-two-logs.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2026/09/mongodb-one-write-two-logs.png 1200w, https://shiftmag.dev/wp-content/uploads/2026/09/mongodb-one-write-two-logs-300x155.png 300w, https://shiftmag.dev/wp-content/uploads/2026/09/mongodb-one-write-two-logs-766x396.png 766w, https://shiftmag.dev/wp-content/uploads/2026/09/mongodb-one-write-two-logs-1024x529.png 1024w" sizes="auto, (max-width: 1200px) 100vw, 1200px" /></figure>


<p class="wp-block-paragraph">When I first encountered MongoDB, I tried to understand it through the database I knew best: PostgreSQL. My journey was a <em>baptism by fire</em>. I was managing a sharded cluster with 20 TB of data and as many as ~55k operations per second, including ~29k writes. The cluster had six shards, each with its own replica set, a config server replica set, and six routers.</p>



<p class="wp-block-paragraph">To operate that cluster safely, I had to stop treating MongoDB like PostgreSQL and learn how it worked internally.</p>



<p class="wp-block-paragraph">At one point, while tackling a flow control problem on the stated cluster, an AI model recommended increasing the portion of memory assigned to the WiredTiger cache. At the moment, the recommendation sounded genuine and correct, but I did not know what the model had based its conclusions on. To be completely honest, I didn’t even know how RAM is used by MongoDB. The nail in the coffin was the <a href="https://www.mongodb.com/docs/manual/core/wiredtiger/#memory-use">official docs</a> saying don’t change WiredTiger cache to RAM ratio.</p>



<p class="wp-block-paragraph">That experience clarified why I wanted to learn the internals. I want/need enough understanding to connect operational advice to a mechanism, identify the evidence it depends on, and decide. This applies whether the advice comes from AI, a colleague, documentation, or my own assumptions.</p>



<p class="wp-block-paragraph">What happens after a MongoDB client sends a write?</p>



<p class="wp-block-paragraph">How does that write pass through MongoDB and WiredTiger, and when does it become durable on disk?</p>



<p class="wp-block-paragraph">And when someone recommends changing a WiredTiger setting, what would have to be true for that recommendation to make sense?</p>



<h2 class="wp-block-heading" id="following-one-write">Following one write</h2>



<p class="wp-block-paragraph">When a client sends a write operation to a sharded cluster, the request first reaches a router called <code>mongos</code>. Routers cache data from the config server about chunk &#8211; shard placements. Using this data <code>mongos</code> determine which shard owns the relevant data and forward the operation to that shard&#8217;s primary node.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="972" src="https://shiftmag.dev/wp-content/uploads/2026/09/shardedCluster-1024x972.png?x11163" alt="" class="wp-image-12271" srcset="https://shiftmag.dev/wp-content/uploads/2026/09/shardedCluster-1024x972.png 1024w, https://shiftmag.dev/wp-content/uploads/2026/09/shardedCluster-300x285.png 300w, https://shiftmag.dev/wp-content/uploads/2026/09/shardedCluster-767x728.png 767w, https://shiftmag.dev/wp-content/uploads/2026/09/shardedCluster.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Sharded MongoDB cluster&nbsp;</figcaption></figure>



<p class="wp-block-paragraph">However, this post does not compare replica sets and sharded clusters. Once routing is complete, the same question applies inside every shard.</p>



<p class="wp-block-paragraph">How does the primary <code>mongod</code> process request, persist it, and replicate it to secondary nodes?</p>



<h2 class="wp-block-heading" id="separation-of-concern">Separation of concern</h2>



<p class="wp-block-paragraph">To answer my question(s), I firstly had to understand where <code>mongod</code> ends and the storage engine <code>WiredTiger</code> begins.</p>



<p class="wp-block-paragraph"><code>mongod</code> handles client commands, authorization, query execution, transaction coordination, and replication. WiredTiger is the embedded storage engine that stores collection and index data. It provides local transactions, MVCC, caching, compression, journaling, checkpoints, and crash recovery.</p>



<pre class="wp-block-code"><code>MongoDB client
      │ write operation
      ▼
mongos query router
      │ routes to the owning shard
      ▼
shard primary (mongod)
      ├── authorization and command handling
      ├── query parsing and execution
      ├── transaction and session coordination
      ├── replication and oplog coordination
      └── storage-engine API
                  │
                  ▼
             WiredTiger
                  ├── local transactions and MVCC
                  ├── internal cache
                  ├── journal
                  ├── checkpoints
                  └── collection and index data in dbPath</code></pre>



<p class="wp-block-paragraph">Ok, but how does this come into play? Boundaries are not absolute.</p>



<p class="wp-block-paragraph">The oplog belongs to MongoDB’s (logical) replication model, but WiredTiger stores it alongside other collection data.</p>



<h2 class="wp-block-heading" id="one-write-two-logs">One write, two logs</h2>



<p class="wp-block-paragraph">At this point, I had another question. If MongoDB already has a <code>journal</code>, why does it also need an oplog?</p>



<p class="wp-block-paragraph">The WiredTiger journal is the closest equivalent to PostgreSQL&#8217;s WAL (Write Ahead Log). It records the changes needed to recover <strong>one</strong> MongoDB member (<em>keep this thought</em>) after a crash. Unlike PostgreSQL&#8217;s WAL, MongoDB does not use the journal as its replication stream.</p>



<p class="wp-block-paragraph">The <code>oplog</code> has a different purpose. It is a capped collection stored in the <code>local</code> database as <code>local.oplog.rs</code>. Secondary members copy its entries and apply them to their own data.</p>



<p class="wp-block-paragraph">This raises an important consistency question. What prevents MongoDB from committing a document change without its corresponding oplog entry?</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="597" src="https://shiftmag.dev/wp-content/uploads/2026/09/twoWritePaths-v2-1024x597.png?x11163" alt="" class="wp-image-12273" srcset="https://shiftmag.dev/wp-content/uploads/2026/09/twoWritePaths-v2-1024x597.png 1024w, https://shiftmag.dev/wp-content/uploads/2026/09/twoWritePaths-v2-300x175.png 300w, https://shiftmag.dev/wp-content/uploads/2026/09/twoWritePaths-v2-768x448.png 768w, https://shiftmag.dev/wp-content/uploads/2026/09/twoWritePaths-v2.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Client write path&nbsp;</figcaption></figure>



<h3 class="wp-block-heading" id="data-folder">Data folder</h3>



<p class="wp-block-paragraph">Let’s examine what happens on one node and then additionally complicate the story by adding secondaries.</p>



<p class="wp-block-paragraph">To understand local durability, I first looked inside the <code>dbPath</code> of a MongoDB member. A simplified listing:</p>



<pre class="wp-block-code"><code>$ ls /data/mongodb/
collection-&lt;ident>.wt
index-&lt;ident>.wt
journal/
WiredTiger
WiredTigerHS.wt
WiredTiger.lock
WiredTiger.turtle
WiredTiger.wt</code></pre>



<p class="wp-block-paragraph">The exact files and their names depend on the MongoDB version and configuration, but these are the main WiredTiger files relevant to this discussion.</p>



<p class="wp-block-paragraph">The <code>collection-&lt;ident&gt;.wt</code> and <code>index-&lt;ident&gt;.wt</code> files are WiredTiger tables that store collection records and index entries.</p>



<p class="wp-block-paragraph">MongoDB’s durable catalog maps logical objects, such as a collection namespace, to these storage-engine identifiers. WiredTiger maintains its own metadata in <code>WiredTiger.wt</code>, including its tables, their configuration, and their latest checkpoints.</p>



<p class="wp-block-paragraph">The small <code>WiredTiger</code> text file identifies the WiredTiger version used to create the database:</p>



<pre class="wp-block-code"><code>WiredTiger
WiredTiger 10.0.2: (November 30, 2021)</code></pre>



<p class="wp-block-paragraph"><code>WiredTigerHS.wt</code> is the history store. It keeps older committed versions of records needed by MVCC readers, snapshots, etc. WiredTiger removes versions once no active reader or snapshot can require them.</p>



<p class="wp-block-paragraph"><code>WiredTiger.turtle</code> contains enough metadata to locate and open the latest checkpoint of <code>WiredTiger.wt</code>. It bootstraps the metadata table during startup and recovery.</p>



<pre class="wp-block-code"><code>WiredTiger version string
WiredTiger 10.0.2: (November 30, 2021)
WiredTiger version
major=10,minor=0,patch=2
file:WiredTiger.wt
...
checkpoint_lsn=(2248,16291200)
...</code></pre>



<p class="wp-block-paragraph">The <code>checkpoint_lsn</code> identifies a position in the WiredTiger journal using a log file number and byte offset. During recovery, WiredTiger opens the last consistent checkpoint and replays later journal records.</p>



<p class="wp-block-paragraph">The <code>journal/</code> directory contains those write-ahead log files. They protect changes made after the last checkpoint from being lost during an unexpected shutdown.</p>



<p class="wp-block-paragraph">Finally, <code>WiredTiger.lock</code> is the file on which WiredTiger acquires a lock to prevent two processes from opening the same database directory simultaneously. The lock state matters, not merely the existence of the file.</p>



<h3 class="wp-block-heading" id="the-wiredtiger-cache">The WiredTiger cache</h3>



<p class="wp-block-paragraph">WiredTiger does not modify the <code>collection-*.wt</code> and <code>index-*.wt</code> files directly for every client operation. It first reads the required pages into its internal cache and applies the change there as part of a storage transaction. Modified pages become dirty until WiredTiger reconciles and writes them to disk.</p>



<p class="wp-block-paragraph">This internal cache keeps uncompressed collection data and is separate from the operating system’s filesystem cache where compressed data is stored.</p>



<p class="wp-block-paragraph">MongoDB therefore benefits from <strong>both caches</strong>, WiredTiger and the OS cache.</p>



<p class="wp-block-paragraph">Giving all available memory to the WiredTiger cache would leave too little memory for the filesystem cache and the rest of <code>mongod</code> and respecting the default, <code>max((availRAM - 1024) x 0.5, 256 MB)</code>, is strongly advised by <a href="https://www.mongodb.com/docs/manual/core/wiredtiger/#memory-use">the official docs.</a></p>



<p class="wp-block-paragraph">This is already enough to show why “increase the WiredTiger cache” is incomplete advice. A larger cache does not create memory. It transfers memory away from the filesystem cache and other allocations. Whether that trade is useful depends on the workload and the source of the observed pressure.</p>



<p class="wp-block-paragraph">When the cache approaches its limits, WiredTiger evicts pages to make room. Clean pages can be discarded and read again later. Dirty pages must first be reconciled into an on-disk representation.</p>



<p class="wp-block-paragraph">A committed change does not have to wait for its dirty page to reach the collection file. The journal supplies durability between checkpoints. This separation is the reason a write can be durable even though its final data page is still dirty in memory.</p>



<h3 class="wp-block-heading" id="recovering-after-a-crash">Recovering after a crash</h3>



<p class="wp-block-paragraph">In case of a crash, WiredTiger starts from the last complete checkpoint. The checkpoint metadata identifies a consistent view of the WiredTiger tables and the journal position associated with it.</p>



<p class="wp-block-paragraph">WiredTiger then replays the journal records created after that checkpoint. At a high level, recovery combines two inputs:</p>



<p class="wp-block-paragraph">&nbsp;last complete checkpoint + later durable journal records = recovered local state &nbsp;</p>



<h3 class="wp-block-heading" id="checkpoints-and-data-files">Checkpoints and data files</h3>



<p class="wp-block-paragraph">WiredTiger normally creates a checkpoint every (configurable default) 60 seconds. A checkpoint can take longer when there is more dirty data or the storage device is under pressure.</p>



<p class="wp-block-paragraph">During a checkpoint, WiredTiger writes a point-in-time view of dirty pages to the collection, index, history-store, and metadata files.</p>



<pre class="wp-block-code"><code>WiredTiger transaction
        │
        ├── dirty pages in cache ──checkpoint──&#x25b6; .wt data files
        │
        └── journal records ───────────────────&#x25b6; journal files

                         crash
                           │
                           ▼
       latest checkpoint + subsequent journal records
                           │
                           ▼
                    recovered state
</code></pre>



<h3 class="wp-block-heading" id="how-the-primary-records-an-operation">How the primary records an operation</h3>



<p class="wp-block-paragraph">For an incoming query, <code>mongod</code> will, among other things, determine collection and index changes and construct the oplog logical entry.</p>



<p class="wp-block-paragraph">It uses WiredTiger to start/use a transaction and either commits both parts or commits neither. This prevents a successful document change from existing on the primary without an operation (oplog entry) that secondaries can replicate.</p>



<p class="wp-block-paragraph">The oplog entry contains an operation type, namespace, timestamp, and the data required to reproduce the change. Its timestamp provides an ordering position in the replica-set history. The entry describes a logical insert, update, delete, command, or transaction operation rather than the low-level page modifications stored in the WiredTiger journal.</p>



<pre class="wp-block-code"><code>rs_a &#91;direct: primary] local> db.oplog.rs.findOne()
{
  ts: Timestamp(...),
  t: NumberLong(...),
  op: "u",
  ns: "foo.bar",
  o: { $v: 2, diff: { ... } },
  o2: { _id: 123 }
}</code></pre>



<p class="wp-block-paragraph">This is not a complete definition of how oplog and collection changes work, but the important invariant is: <strong>the primary commits the replicated data changes together with the oplog records which describe them.</strong></p>



<p class="wp-block-paragraph">Only the local commit is atomic. Sending or copying the oplog entry across the network is not part of that storage transaction.</p>



<h3 class="wp-block-heading" id="how-secondaries-copy-and-apply-oplog-entries">How secondaries copy and apply oplog entries</h3>



<p class="wp-block-paragraph">Each secondary continuously selects a sync source and streams newer oplog entries from it. The sync source is often the primary.</p>



<p class="wp-block-paragraph">The secondary writes fetched entries to its own oplog and then applies the represented operations to its local collections and indexes.</p>



<p class="wp-block-paragraph">The secondary uses its own WiredTiger instance to apply changes. They modify its cache, produce local journal records, and later become part of its checkpoints.</p>



<p class="wp-block-paragraph">This is the important distinction and the answer why we can’t just ship primaries <code>*.wt</code> binaries to the secondary.</p>



<p class="wp-block-paragraph">On two MongoDB servers, these are different files.</p>



<h3 class="wp-block-heading" id="oplog-versus-journal">Oplog versus journal</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><strong>Property</strong></td><td><strong>Oplog</strong></td><td><strong>Journal</strong></td></tr><tr><td>Layer</td><td>MongoDB</td><td>WiredTiger</td></tr><tr><td>Purpose</td><td>Replication</td><td>Crash recovery</td></tr><tr><td>Contents</td><td>Logical MongoDB operations</td><td>Storage-engine recovery records</td></tr><tr><td>Consumed by</td><td>Secondary nodes</td><td>WiredTiger during startup/recovery</td></tr><tr><td>Scope</td><td>ReplicaSet logical history</td><td>One server only</td></tr><tr><td>Replicated?</td><td>Yes, logically</td><td>No</td></tr></tbody></table></figure>



<h3 class="wp-block-heading" id="takeaways">Takeaways</h3>



<p class="wp-block-paragraph">This gives a practical sequence for evaluating operational changes:</p>



<ol start="1" class="wp-block-list">
<li>Identify which component owns the behavior</li>



<li>Describe the mechanism that is a cause of the problem</li>



<li>Find evidence supporting that mechanism</li>



<li>Clarify what the improvements should be</li>



<li>Measure</li>



<li>Iterate</li>
</ol>



<p class="wp-block-paragraph">The technical facts in this article support that way of reasoning:</p>



<ul class="wp-block-list">
<li>The WiredTiger journal and the oplog solve different problems. The journal recovers one member; the oplog replicates logical operations between members.</li>



<li>MongoDB commits a replicated data change and its oplog entry in the same local storage transaction on the primary.</li>



<li>A durable change can still exist as a dirty cache page because the journal protects it between checkpoints.</li>



<li>Primaries and secondaries have separate WiredTiger databases, caches, journals, and data files.</li>



<li>Memory assigned to WiredTiger is part of a larger allocation decision that includes the filesystem cache and other process memory.</li>
</ul>



<h2 class="wp-block-heading" id="why-i-wanted-to-understand-this">Why I wanted to understand this</h2>



<p class="wp-block-paragraph">Learning how WiredTiger works does not mean that I can derive every production decision from first principles. It gives me a way to examine a recommendation instead of accepting it because the source sounds confident, and we all know AI can sound like that.</p>



<p class="wp-block-paragraph">The quality of an (AI) recommendation depends on the question and the evidence supplied to it.</p>



<h2 class="wp-block-heading" id="further-reading">Further reading</h2>



<ul class="wp-block-list">
<li><a href="https://www.mongodb.com/docs/manual/core/wiredtiger/">MongoDB manual: WiredTiger storage engine</a></li>



<li><a href="https://www.mongodb.com/docs/manual/core/journaling/">MongoDB manual: Journaling</a></li>



<li><a href="https://www.mongodb.com/docs/manual/core/replica-set-oplog/">MongoDB manual: Replica set oplog</a></li>



<li><a href="https://www.mongodb.com/docs/manual/core/replica-set-sync/">MongoDB manual: Replica set synchronization</a></li>



<li><a href="https://github.com/mongodb/mongo/blob/master/src/mongo/db/storage/README.md">MongoDB source documentation: Storage engine</a></li>
</ul>



<p class="wp-block-paragraph"><strong><em>A note on scope</em></strong> <em>&#8211; This article records my current understanding of MongoDB and WiredTiger, built through hands-on operation and continued study. I have tried to keep the technical details accurate, but any errors or oversimplifications are mine. <a href="https://www.mongodb.com/docs/manual/">MongoDB official docs</a> and <a href="https://source.wiredtiger.com/develop/index.html">WiredTiger documentation</a> should always be consulted for correctness and clarity.</em></p>
<p>The post <a href="https://shiftmag.dev/mongodb-one-write-two-logs-12267/">MongoDB: One Write, Two Logs</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The Day Our Data Center Went Ghost</title>
		<link>https://shiftmag.dev/the-day-our-data-center-went-ghost-6756/</link>
		
		<dc:creator><![CDATA[Leo Tausanovic]]></dc:creator>
		<pubDate>Fri, 31 Oct 2025 09:47:20 +0000</pubDate>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Halloween 2025]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=6756</guid>

					<description><![CDATA[<p>It’s Halloween. Want to read a horror story? This one’s set in a data center.</p>
<p>The post <a href="https://shiftmag.dev/the-day-our-data-center-went-ghost-6756/">The Day Our Data Center Went Ghost</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img loading="lazy" decoding="async" width="1200" height="630" src="https://shiftmag.dev/wp-content/uploads/2025/10/houted-data-center.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2025/10/houted-data-center.png 1200w, https://shiftmag.dev/wp-content/uploads/2025/10/houted-data-center-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2025/10/houted-data-center-1024x538.png 1024w, https://shiftmag.dev/wp-content/uploads/2025/10/houted-data-center-768x403.png 768w" sizes="auto, (max-width: 1200px) 100vw, 1200px" /></figure>


<p class="wp-block-paragraph">It was a <strong>great vacation</strong>, packed with long walks, beach time, fun, and rest.</p>



<p class="wp-block-paragraph">I came back to work rejuvenated, knowing I’d need a few days to get back into the working rhythm. Most of the day was spent catching up with colleagues and the latest news.</p>



<p class="wp-block-paragraph">One was about a <strong>brand-new data center</strong>, ready to go live in just a few days.</p>



<h2 class="wp-block-heading" id="production-ready-turned-into-data-empty">&#8220;Production-ready&#8221; turned into &#8220;data-empty&#8221;</h2>



<p class="wp-block-paragraph">&#8220;It turns out delivering new data centers is <strong>becoming almost routine</strong>,&#8221; I thought to myself, feeling as light as a breeze.</p>



<p class="wp-block-paragraph">After catching up with my colleagues, I was greeted by a mountain of unread emails. Honestly, I can’t tackle that for hours without feeling my will to live slowly evaporate. So, I decided to shift my focus and check out the new data center, just to see how everything was set up…</p>



<p class="wp-block-paragraph">My fresh bronze tan didn’t help &#8211; I went pale as a ghost: <strong>one of the key databases in our shiny new “production-ready” data center was completely empty</strong>.</p>



<p class="wp-block-paragraph">No data. Nothing. Niente. Nada.</p>



<p class="wp-block-paragraph">The problem? We needed a full month of historical data available FROM DAY ONE. And all we got were… good vibes and positive energy.</p>



<h2 class="wp-block-heading" id="two-days-no-data-one-hero">Two days, no data, one hero</h2>



<p class="wp-block-paragraph">The clock was ticking. We had maybe two days (probably less) until go-live. Yes, it was an emergency, and no, there wasn’t a second to waste.</p>



<p class="wp-block-paragraph">We turned to our <strong>trusty old Replay app</strong>, hoping it could save the day.</p>



<p class="wp-block-paragraph">And once again &#8211; it delivered! </p>



<p class="wp-block-paragraph">The shining star of our toolkit, Replay came through, <strong>regenerating over a month’s worth of data</strong> before the deadline.</p>



<p class="wp-block-paragraph">In the end, the data was restored, the deadline met, and our sanity… mostly intact. But one thing was clear: returning from vacation had never felt more like a horror story. And you? <strong>Keep your tools close and your backups closer</strong>.</p>
<p>The post <a href="https://shiftmag.dev/the-day-our-data-center-went-ghost-6756/">The Day Our Data Center Went Ghost</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Devs and DBAs can’t find peace, but could they call a truce?</title>
		<link>https://shiftmag.dev/devs-and-dbas-relationship-4930/</link>
		
		<dc:creator><![CDATA[Toni Babic]]></dc:creator>
		<pubDate>Fri, 18 Apr 2025 13:12:40 +0000</pubDate>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database admins]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Developer Productivity]]></category>
		<category><![CDATA[development]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=4930</guid>

					<description><![CDATA[<p>Are DBAs the guardians of order or just here to give devs a hard time? Or maybe devs are a little too used to getting their way?</p>
<p>The post <a href="https://shiftmag.dev/devs-and-dbas-relationship-4930/">Devs and DBAs can’t find peace, but could they call a truce?</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img loading="lazy" decoding="async" width="1200" height="630" src="https://shiftmag.dev/wp-content/uploads/2025/02/devs-vs-dbs.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2025/02/devs-vs-dbs.png 1200w, https://shiftmag.dev/wp-content/uploads/2025/02/devs-vs-dbs-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2025/02/devs-vs-dbs-1024x538.png 1024w, https://shiftmag.dev/wp-content/uploads/2025/02/devs-vs-dbs-768x403.png 768w" sizes="auto, (max-width: 1200px) 100vw, 1200px" /></figure>


<p class="wp-block-paragraph">Picture this scenario: You&#8217;ve just joined a new tech company, excited to start onboarding and dive into your first projects. <strong>But soon, it hits you &#8211; the tension</strong>.</p>



<p class="wp-block-paragraph">Developers gripe about sluggish and obstructive DBAs, while Database Administrators grumble and murmur about the constant stream of poorly optimized queries, chaotic code, and last-minute demands from developers.</p>



<p class="wp-block-paragraph">Did you stumble upon a toxic workplace? Not exactly. <strong>It&#8217;s</strong> <strong>the age-old clash that&#8217;s been brewing for decades between two &#8216;tribes&#8217;</strong>: those who want to build quickly and those who safeguard stability.</p>



<p class="wp-block-paragraph">So, do DBAs play the role of protectors, or are devs just a tad bit spoiled?</p>



<h2 class="wp-block-heading" id="how-did-we-get-here">How did we get here?</h2>



<p class="wp-block-paragraph">The friction comes from a classic disconnect: <strong>speed vs. stability</strong>.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Developers are eager to ship features as fast as they can (preferably yesterday), often under pressure from clients, management, or some other deadline-driven force, while DBAs are focused on ensuring the database doesn’t crash tomorrow.</p>
</blockquote>



<p class="wp-block-paragraph">When these priorities clash, chaos is inevitable &#8211; and I know this firsthand because I’ve been on both sides.</p>



<h2 class="wp-block-heading" id="let%e2%80%99s-take-a-closer-look-at-it-from-a-developer%e2%80%99s-angle">Let’s take a closer look at it from a developer’s angle</h2>



<ul class="wp-block-list">
<li><strong>‘</strong><strong>We need to speed up our delivery!’</strong></li>
</ul>



<p class="wp-block-paragraph">The main argument is that developers often work under tight deadlines. <strong>To them, a database is just a tool</strong> &#8211; the simpler, the better. Why involve DBAs early if it slows down prototyping?</p>



<p class="wp-block-paragraph">There’s also a prevailing ‘good enough for now’ mentality, where getting a working prototype is the priority.</p>



<ul class="wp-block-list">
<li><strong>‘</strong><strong>Setting up new databases takes ages</strong><strong>.</strong><strong>’</strong></li>
</ul>



<p class="wp-block-paragraph">Waiting for approvals, scheme checks, or infrastructure setups feels like watching paint dry.</p>



<ul class="wp-block-list">
<li><strong>‘</strong><strong>Getting DBAs involved can feel like pulling teeth</strong><strong>.’</strong></li>
</ul>



<p class="wp-block-paragraph">When DBAs push back on quick fixes or demand documentation, developers see red tape rather than guardianship.</p>



<h2 class="wp-block-heading" id="now-let%e2%80%99s-dive-into-the-dba%e2%80%99s-side-of-the-story">Now, let’s dive into the DBA’s side of the story</h2>



<ul class="wp-block-list">
<li><strong>‘We’re called in too late!’</strong></li>
</ul>



<p class="wp-block-paragraph">DBAs often inherit <strong>poorly designed schemas or performance nightmares</strong>. Fixing a burning database at 2 a.m. is never fun, especially when you don’t know anything about it or where to begin.</p>



<ul class="wp-block-list">
<li><strong>‘Devs don’t listen.’</strong></li>
</ul>



<p class="wp-block-paragraph">Recommendations about indexing, query optimization, or security often fall on deaf ears &#8211; <strong>until an outage happens</strong>. No matter how many times you share documentation, hold knowledge-sharing sessions, or discuss the topic, it sometimes feels like no one listens.</p>



<ul class="wp-block-list">
<li><strong>‘We’re the unsung janitors.’</strong></li>
</ul>



<p class="wp-block-paragraph">While devs chase innovation, DBAs clean up the mess. Their priorities &#8211; backups, scalability, and compliance &#8211; may not be glamorous, but they’re non-negotiable.</p>



<p class="wp-block-paragraph">If a company wants to make it in the worldwide market, it needs to be compliant with numerous regulations. And that is just the beginning &#8211; <strong>data needs to be secured</strong>, and data leaks and privacy concerns aren’t fun for anyone. We need backups and replication set up for disaster recovery, satisfy numerous architecture decision records, and all that complicates the process. It will never be as simple and fast as just deploying a DB locally in Docker.</p>



<h2 class="wp-block-heading" id="so-what-do-devs-and-dbas-really-want">So, what do devs and DBAs really want?</h2>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">DBAs just want <strong>preventative care</strong> &#8211; they’re like doctors urging you to eat your veggies, not just treating heart attacks.<br></p>



<p class="wp-block-paragraph">On the other hand, devs need <strong>speed without fallout</strong>. They want to innovate without waking up to a dumpster fire.</p>
</blockquote>



<h2 class="wp-block-heading" id="but-do-devs-really-want-to-own-databases">But do devs really want to own databases?</h2>



<p class="wp-block-paragraph">Sure, devs can deploy their own database, but maintaining performance, security, and costs? <strong>That’s a full-time job</strong> &#8211; one many devs aren’t signing up for.</p>



<p class="wp-block-paragraph">It may sound great at first, but once you deploy it, the database works fine &#8211; until it doesn’t. It’s just a matter of time before the first issues arise. And surely, devs would rather spend their time programming than maintaining and troubleshooting a database.</p>



<h2 class="wp-block-heading" id="think-it-cant-get-worse-well-say-hello-to-ai">Think it can&#8217;t get worse? Well, say hello to AI</h2>



<p class="wp-block-paragraph">Enter AI and vector databases &#8211; tools promising lightning-fast analytics.</p>



<p class="wp-block-paragraph">The number of new vector databases is skyrocketing, and devs want them all, each with a specific feature they need. But for DBAs, this is a nightmare. <strong>Integrating a new database is a slow and painful process</strong>, as all checks for security, compliance, and requirements need to be tested and approved. New database types (e.g., vector DBs for ML) often lack mature tooling or expertise. DBAs scramble to secure and scale them, while devs resent the learning curve.</p>



<h2 class="wp-block-heading" id="so-who-is-right">So, who is right?</h2>



<p class="wp-block-paragraph">They both are, and at the same time, they both aren’t &#8211; <strong>much like the relationship between devs and clients</strong>.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Devs often complain about clients&#8217; broad demands, tight deadlines, and constant changes. Sound familiar? The Dev vs DBA battle is similar: devs forget that, as clients of DBAs, they’re the ones pushing for deadlines and changes, just like clients do to them.</p>
</blockquote>



<p class="wp-block-paragraph">So, devs must make compromises with clients because the company&#8217;s revenue depends on it. However, I think DBAs tend to be &#8216;harder&#8217; on their clients since they don’t face the same pressure of potentially losing business.</p>



<h2 class="wp-block-heading" id="is-there-hope-for-peace">Is there hope for peace?</h2>



<p class="wp-block-paragraph">There isn&#8217;t &#8211; at least not a simple one.</p>



<p class="wp-block-paragraph">But we can all work together to reduce tension and aim for some kind of truce. We need to be more understanding.</p>



<p class="wp-block-paragraph">Devs should recognize that <strong>DBAs aren’t just complicating things for no reason</strong> and should involve them in the service architecture process. On the other hand, <strong>DBAs should view devs as clients</strong>, understand the need for compromise, and simplify the process of providing databases by using automation or internal tools whenever possible.</p>
<p>The post <a href="https://shiftmag.dev/devs-and-dbas-relationship-4930/">Devs and DBAs can’t find peace, but could they call a truce?</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>From file frustration to streamlined data exchange: Rethinking the approach</title>
		<link>https://shiftmag.dev/from-file-frustration-to-streamlined-data-exchange-999/</link>
		
		<dc:creator><![CDATA[Alen Kosanovic]]></dc:creator>
		<pubDate>Tue, 25 Jul 2023 17:29:06 +0000</pubDate>
				<category><![CDATA[Backend]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[anti-pattern]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[data exchange]]></category>
		<guid isPermaLink="false">https://shiftmag.dev/?p=999</guid>

					<description><![CDATA[<p>Each time some data is exchanged using files, a red flag should pop up, and you should ask yourself – what is a better way to do this? There probably is one.</p>
<p>The post <a href="https://shiftmag.dev/from-file-frustration-to-streamlined-data-exchange-999/">From file frustration to streamlined data exchange: Rethinking the approach</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-post-featured-image"><img loading="lazy" decoding="async" width="1200" height="630" src="https://shiftmag.dev/wp-content/uploads/2023/07/data_exchange.png?x11163" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" style="object-fit:cover;" srcset="https://shiftmag.dev/wp-content/uploads/2023/07/data_exchange.png 1200w, https://shiftmag.dev/wp-content/uploads/2023/07/data_exchange-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2023/07/data_exchange-1024x538.png 1024w, https://shiftmag.dev/wp-content/uploads/2023/07/data_exchange-768x403.png 768w" sizes="auto, (max-width: 1200px) 100vw, 1200px" /></figure>


<p class="wp-block-paragraph">Occasionally, everyone needs to handle data stored in files. CSV files seem like the way to go and are often the first choice &#8211; but I&#8217;d rather call them an anti-pattern.</p>



<p class="wp-block-paragraph">Let&#8217;s say a customer requests an Excel report containing specific data. If this is a one-time thing, we can conveniently send it via email. In most cases, however, the data needs to be sent regularly.&nbsp;Not all clients use sophisticated software like Kafka; even when they do, we don&#8217;t always have access to it. So we need a solution that is both universally available and easily understood. SFTP and CSV files seemingly fit the bill.</p>



<p class="wp-block-paragraph">This solution seems optimal for sending data to an external client. The problem arises when an internal application needs to integrate with ours, requires some data, and we decide to solve it by exporting CSVs. At first glance, this seems a low-hanging fruit.</p>



<p class="wp-block-paragraph">Everyone can download a file.</p>



<p class="wp-block-paragraph">Everyone can read a CSV.</p>



<p class="wp-block-paragraph">It&#8217;s already developed.</p>



<p class="wp-block-paragraph"><strong>While it may appear&nbsp;<em>that</em>&nbsp;simple, ultimately, it proves to be more costly than using a dedicated component for data exchange. </strong>I learned my lesson the hard way. I&#8217;ve worked on both applications that sent and received data via files. Here are some of the issues I discovered along the way.</p>



<h2 class="wp-block-heading" id="data-storage">&nbsp;<strong>Data storage</strong></h2>



<p class="wp-block-paragraph">The first thing we need is a place to store the data. Since our data is stored in files, it must be placed within a file system. The decision we face is whether to store the files on the&nbsp;<strong>producer</strong>&nbsp;machine,&nbsp;<strong>consumer</strong>&nbsp;machine, or an&nbsp;<strong>intermediary</strong>&nbsp;machine. Each option has its advantages and disadvantages.</p>



<p class="wp-block-paragraph"><strong>Using the producer</strong>&nbsp;machine results in the consumer bearing the entire networking load. The consumer will need to periodically retrieve the data through a&nbsp;<strong>PULL</strong>&nbsp;operation. In the event of a network link failure, the producer will remain unaffected.&nbsp;</p>



<p class="wp-block-paragraph">However, this solution has a drawback &#8211; when consumers are redundant, and there are multiple instances, each instance may attempt to download the same file. Consequently, the same data will be processed multiple times. To address this,&nbsp;<strong>each instance should reserve the file before initiating the download</strong>. This can be accomplished by appending a suffix to the file name or moving the file to another folder. Once the file is reserved, the consumer application can proceed with the file download.</p>



<p class="wp-block-paragraph"><strong>Using the consumer</strong>&nbsp;machine puts all the networking burden on the producer. The producer needs to&nbsp;<strong>PUSH&nbsp;</strong>the data to the consumer machine once the file is created. The consumer machine can watch the local file system for changes and react when a new file is created. As a result, the push-based approach can yield a faster response by the consumer and does not put any networking burden on the consumer. Since the file is sent directly to the consumer instance, this approach does not need&nbsp;<em>file reservation.</em>&nbsp;</p>



<p class="wp-block-paragraph">Pushing files to consumers also has a considerable downside &#8211; the producer must balance these files between the consumer instances. Implementing effective client-side balancing is a tough nut to crack. The producer would need to adapt its balancing strategy when a consumer instance gets offline or online and is added to or removed from the group.</p>



<p class="wp-block-paragraph"><strong>Using an intermediary machine</strong>&nbsp;combines elements of both previously mentioned approaches. It eliminates the need for client-side balancing, but the consumer still needs to reserve the file before downloading it. The data storage is independent of both the consumer and producer, although both parties are still required to transfer files over the network.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="538" src="https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange1-1024x538.png?x11163" alt="" class="wp-image-1053" srcset="https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange1-1024x538.png 1024w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange1-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange1-768x403.png 768w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange1.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading" id="data-retention"><strong>Data retention</strong></h2>



<p class="wp-block-paragraph">Regardless of the chosen method for storing data, it is crucial to ensure that the disk is not filled with files. Failing to do so will render the machines (and the services running on them) unusable. The primary line of defense is to&nbsp;<strong>store files on a separate section of the disk</strong>.&nbsp;</p>



<p class="wp-block-paragraph">Even if the partition gets filled with files, it will not impact other services. This advice applies even when files are stored on an intermediary machine, as some operating system functionalities may not work properly if the disk space is occupied.</p>



<p class="wp-block-paragraph">Accumulating files can happen quite easily. For instance, the consumer application may be down (or not deployed) while the producer application continues to generate files. It can also occur if the producer generates a high volume of data the consumer cannot keep up with.&nbsp;</p>



<p class="wp-block-paragraph">In such cases, it is necessary to prevent the files from <strong>overflowing the disk.</strong> If the data represents events and skipping a few events in the event of a failure is acceptable, a retention policy should be implemented.&nbsp;</p>



<p class="wp-block-paragraph">For example, a script that periodically deletes the oldest files can be developed. This script adds <strong>another component to the architecture that needs to be created, maintained, and monitored</strong>. If the script malfunctions or contains a bug, the data retention may not work as intended.</p>



<h2 class="wp-block-heading" id="data-processing"><strong>Data processing</strong></h2>



<p class="wp-block-paragraph">A file is removed from the disk when a consumer has read and processed the whole file content. The &#8216;whole file content&#8217; is emphasized since a file represents a batch of data. Errors or failures can happen at any point between parsing and processing the data. If you delete the file without processing all the data contained within it, the data will be lost. On the other hand, if you do not delete the file but have already processed some of the data, you will end up processing the same data twice. This poses a data integrity concern that needs to be addressed. Both discarding data and processing data twice are undesirable and potentially unacceptable. That is why&nbsp;<strong>it is necessary to process a file in its entirety before deleting it</strong>.</p>



<p class="wp-block-paragraph">This can be challenging, especially if the application involves multiple processing steps, including several database writes. Errors occurring in any of these phases can result in the entire batch being reversed. Additionally, processing a batch of data within a single transaction restricts the data processing to only one thread. File reading and data processing should be performed in separate threads to optimize performance.</p>



<p class="wp-block-paragraph">One possible solution is to relax the data integrity requirement by&nbsp;<strong>implementing a queue where all the data is stored after parsing</strong>. This approach considers a file processed once all its records are inserted into the queue. Records can then be dequeued one by one, preventing the entire batch from being reverted. The issue with this approach is that the data in the queue will be lost in the event of an abrupt application failure. Since abrupt application failures are expected to be rare, this trade-off may be acceptable. If preserving data is not acceptable, a persistent queue for the data can be introduced (but we opted out of using new components in favor of using&nbsp;<em>simple CSV reading</em>).</p>



<p class="wp-block-paragraph">It is also important to&nbsp;<strong>set a reasonable limit to the number of records in a file</strong>. A large file might present a huge load of data at once. So huge that it might crash the data if it does not have the memory to read the whole file.</p>



<h2 class="wp-block-heading" id="data-sharing"><strong>Data Sharing</strong></h2>



<p class="wp-block-paragraph">Once everything is set up and all the monitoring points are implemented (excluded from this article), we can enjoy our manually implemented file-based data exchange solution… until a new consumer is needed for the same data.&nbsp;</p>



<p class="wp-block-paragraph">Fortunately, we already have this functionality (file download+reservation, data retention, data queuing, monitoring, etc.) supported, and we can easily re-use it in any new consumer. Hopefully, the code has been written well enough to be copied and pasted into a library. Otherwise, there will be significant code duplication. Let&#8217;s not forget to create<strong> documentation for the module </strong>so that the solution can be integrated effortlessly.</p>



<p class="wp-block-paragraph">Once we move this code to a module, our file-based data exchange solution will become a reusable component that any application can utilize (provided it is written in the same programming language). The only thing left is instructing the producer to export the files to a new location. There might be some duplicated data between the two locations, but let&#8217;s hope we will not add many of these consumers to the system.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="538" src="https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange-files-1024x538.png?x11163" alt="" class="wp-image-1052" srcset="https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange-files-1024x538.png 1024w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange-files-300x158.png 300w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange-files-768x403.png 768w, https://shiftmag.dev/wp-content/uploads/2023/07/data-exchange-files.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading" id="data-storage-already-handles-this-%e2%80%93-and-it-does-it-better"><strong>Data storage already handles this – and it does it better</strong></h2>



<p class="wp-block-paragraph">These are only some of the issues that we encountered. There are more of them, some not even mentioned here, and others are yet to be discovered. To resolve them, we had to invest time in development, refactoring, and as a result, we now have a code base to maintain.&nbsp;</p>



<p class="wp-block-paragraph">But <strong>these problems were not unique to us.</strong> They were common problems that most data storage software handles out-of-the-box and does it better!</p>



<p class="wp-block-paragraph">The selection of software depends on the nature of the data. In our case, the data were events, and the producer application performed some batch processing on it. A more&nbsp;suitable storage option than the one we have been using <strong>would be a messaging system:</strong></p>



<p class="wp-block-paragraph">· Producers and consumers would write and read from a topic or a queue.</p>



<p class="wp-block-paragraph">· Data would be stored and replicated to another machine, also enabling Geo-redundancy.</p>



<p class="wp-block-paragraph">· Retention would be managed by the platform, eliminating the need for manual scripts.</p>



<p class="wp-block-paragraph">· Messaging systems have a&nbsp;<em>commit</em>&nbsp;feature to indicate that a record (or batch) has been processed.</p>



<p class="wp-block-paragraph">· Some messaging systems support consumer groups, allowing concurrent processing out-of-the-box.</p>



<p class="wp-block-paragraph">· Different consumers (applications) can be subscribed to the same topic.</p>



<p class="wp-block-paragraph">· Applications can be written in the most popular programming languages.</p>



<p class="wp-block-paragraph">· Monitoring tools for popular systems are already available.</p>



<p class="wp-block-paragraph">· Popular systems are usually well-documented.</p>



<p class="wp-block-paragraph">For other types of data, the solution might be a more suitable data store like <strong>Redis or Postgres</strong>. It all depends on what the data is about and how it can be presented.</p>



<p class="wp-block-paragraph"><strong>Exchanging data via files should be considered an anti-pattern</strong> and only be used when other approaches cannot be implemented (like when integrating with a legacy system).&nbsp;Each time some data is exchanged using files, a red flag should pop up, and you should ask yourself &#8211; what is a better way to do this? There probably is.</p>
<p>The post <a href="https://shiftmag.dev/from-file-frustration-to-streamlined-data-exchange-999/">From file frustration to streamlined data exchange: Rethinking the approach</a> appeared first on <a href="https://shiftmag.dev">ShiftMag</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: shiftmag.dev @ 2026-12-01 17:02:33 by W3 Total Cache
-->