<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nagesh Madhu]]></title><description><![CDATA[Nagesh Madhu]]></description><link>https://nageshmadhu.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:03:46 GMT</lastBuildDate><atom:link href="https://nageshmadhu.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[From Production Logs to Analytics: Understanding WAL, CDC, and Streaming on AWS]]></title><description><![CDATA[Learn how Write-Ahead Logs (WAL) and Change Data Capture (CDC) stream live Postgres data into an AWS Medallion data lake using DMS, Kinesis, and S3.]]></description><link>https://nageshmadhu.hashnode.dev/from-production-logs-to-analytics-understanding-wal-cdc-and-streaming-on-aws</link><guid isPermaLink="true">https://nageshmadhu.hashnode.dev/from-production-logs-to-analytics-understanding-wal-cdc-and-streaming-on-aws</guid><category><![CDATA[AWS]]></category><category><![CDATA[dataengineering]]></category><category><![CDATA[cdc]]></category><category><![CDATA[postgrtesql]]></category><category><![CDATA[data-engineering]]></category><dc:creator><![CDATA[NAGESH MADHU]]></dc:creator><pubDate>Sun, 29 Nov 2026 08:43:12 GMT</pubDate><content:encoded><![CDATA[<p>If you have ever wondered how companies move live transactional data from an application database into an analytics warehouse without slowing down their app—or losing a single deleted row—the answer lies in two foundational concepts: <strong>Write-Ahead Logs (WAL)</strong> and <strong>Change Data Capture (CDC)</strong>.</p>
<hr />
<h2>1. Why Simple Polling Breaks Down</h2>
<p>Imagine a busy supermarket (your <strong>OLTP Database</strong>, like PostgreSQL). Thousands of customers are buying, returning, and updating items every second.</p>
<p>If your analytics team runs a batch query every hour (<code>SELECT * WHERE updated_at &gt; ...</code>), it is like sending an auditor onto the crowded store floor with a clipboard. Two things go wrong:</p>
<ul>
<li><strong>Heavy Load:</strong> The auditor gets in the way of customers, slowing down the live database.</li>
<li><strong>Missed Deletes:</strong> If a row is hard-deleted between 9:00 AM and 10:00 AM, it vanishes completely. There is no row left with a new <code>updated_at</code> timestamp, so your hourly query never knows it was deleted.</li>
</ul>
<h2>2. The Write-Ahead Log (WAL): The Chef’s Ticket Rail</h2>
<p>To guarantee no data is ever lost during a crash, databases use a built-in feature called the <strong>Write-Ahead Log (WAL)</strong>.</p>
<p>Think of it like a chef's ticket rail: before the chef cooks a single dish, they write the order on a slip and pin it up. In the same way, before a database modifies its main tables, it writes the exact operation (<code>INSERT</code>, <code>UPDATE</code>, or <code>DELETE</code>) and the row's state into a sequential, raw binary file on its own local storage drive (for example, inside the <code>pg_wal</code> folder in PostgreSQL).</p>
<p>To keep disk space from filling up forever, the database periodically runs <strong>checkpoints</strong>—flushing committed changes to the main tables and recycling old WAL files.</p>
<h2>3. How WAL Works in the Cloud</h2>
<p>In the cloud, the database still writes to real storage—you just don't manage the hardware:</p>
<ul>
<li><strong>Managed Databases (e.g., Amazon RDS):</strong> The database writes the WAL to an attached virtual disk (like AWS EBS) and backs it up to S3 for point-in-time recovery.</li>
<li><strong>Cloud-Native Databases (e.g., Amazon Aurora):</strong> The log <em>is</em> the database. Aurora streams the WAL directly to 6 distributed storage copies across 3 Availability Zones, so even if an entire data center goes down, the log survives.</li>
</ul>
<p>Because you can't SSH into a managed cloud database to open raw log files, you enable <strong>logical replication</strong> and create a <strong>replication slot</strong>—which acts like a bookmark so the database knows not to delete old WAL files until your pipeline has read them.</p>
<h2>4. Log-Based CDC &amp; Why We Need a Streaming Buffer</h2>
<p>Instead of querying the live tables, a <strong>CDC tool</strong> quietly reads the WAL in the background and streams every change out in exact chronological order—capturing inserts, updates, and hard deletes with virtually zero impact on the production database.</p>
<p>Rather than connecting the source database directly to your analytics warehouse, we place a streaming platform like <strong>Apache Kafka</strong> or <strong>Amazon Kinesis</strong> in the middle. It acts as a <strong>shock absorber and decoupler</strong>:</p>
<ul>
<li>If your target warehouse goes down, events safely buffer in the stream instead of backing up and crashing your production database.</li>
<li>Multiple downstream systems (data lakes, search indexes, real-time alerts) can consume the exact same stream independently.</li>
</ul>
<h2>5. End-to-End AWS Medallion Architecture</h2>
<p>Here is how all of these pieces connect in a real-world AWS pipeline:</p>
<ol>
<li><strong>Source (OLTP):</strong> Transactional data lives in <strong>Amazon RDS</strong> or <strong>Amazon Aurora (PostgreSQL)</strong> with WAL logical replication enabled.</li>
<li><strong>CDC Ingestion:</strong> <strong>AWS DMS (Database Migration Service)</strong> reads the WAL and captures every change event.</li>
<li><strong>Streaming &amp; Batching:</strong> DMS pushes events into <strong>Amazon Kinesis Data Streams</strong>. <strong>Kinesis Data Firehose</strong> buffers the continuous stream and automatically batches records into manageable files (like JSON or Parquet) based on time or size thresholds (e.g., every 5 minutes or 128 MB).</li>
<li><strong>Bronze Layer (Amazon S3):</strong> Raw, batched event files land in S3.</li>
<li><strong>Silver Layer (Amazon S3 + AWS Glue / EMR):</strong> Processing jobs sort and sequence the batched records by their original timestamps, deduplicate them, enforce schemas, and apply updates/deletes accurately.</li>
<li><strong>Gold Layer (Amazon S3 / Amazon Redshift):</strong> Clean data is aggregated into business-ready, dimensional tables for dashboards and OLAP analytics.</li>
</ol>
]]></content:encoded></item></channel></rss>