<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Suryansh Tiwari on Medium]]></title>
        <description><![CDATA[Stories by Suryansh Tiwari on Medium]]></description>
        <link>https://medium.com/@suryansh.a.tiwari?source=rss-bc994c370dce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dhBRWzXLGuUvMS0d.</url>
            <title>Stories by Suryansh Tiwari on Medium</title>
            <link>https://medium.com/@suryansh.a.tiwari?source=rss-bc994c370dce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:47:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suryansh.a.tiwari/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Arrow, Parquet, and Distributed System — A Practical Guide to Columnar Storage at Terabyte Scale]]></title>
            <link>https://medium.com/@suryansh.a.tiwari/arrow-parquet-and-distributed-system-a-practical-guide-to-columnar-storage-at-terabyte-scale-2c05dedc8c0c?source=rss-bc994c370dce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c05dedc8c0c</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-arrow]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Suryansh Tiwari]]></dc:creator>
            <pubDate>Tue, 03 Mar 2026 18:16:53 GMT</pubDate>
            <atom:updated>2026-03-03T18:16:53.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I’m Processing Terabytes of Data Across distributed system — And Why Columnar Storage Changed Everything</h3><p><em>A practical guide to Apache Arrow, Parquet, and building a distributed data conversion pipeline with C++ performance and Python simplicity.</em></p><p>If you work with big data — e-commerce, IoT, ad-tech, logistics — you’ve probably faced this exact problem:</p><blockquote><em>You’ve got </em><strong><em>terabytes of data</em></strong><em>, spread across </em><strong><em>100+ Unix machines</em></strong><em>, stored in heavy, row-oriented formats that make analytics painfully slow.</em></blockquote><p>That was my reality. And the solution wasn’t writing more Spark jobs or throwing hardware at it. It was rethinking how the data was <strong>stored on disk</strong> in the first place.</p><p>This article walks through the journey: the problem, why columnar storage is the answer, what Apache Arrow and Parquet actually are (without the hand-waving), and the architecture I’m building to convert TB-scale data across a distributed fleet.</p><h3>The Problem: Row-Oriented Formats Don’t Scale for Analytics</h3><p>Most legacy data pipelines store data in row-oriented formats — CSV, JSON, fixed-width text, or proprietary binary formats. They look like this in memory:</p><pre>Row 1: | 1001 | &quot;Laptop&quot;   | 999.99  | &quot;Electronics&quot; |<br>Row 2: | 1002 | &quot;T-Shirt&quot;  | 29.99   | &quot;Apparel&quot;     |<br>Row 3: | 1003 | &quot;Headphone&quot;| 149.50  | &quot;Electronics&quot; |</pre><p>This works fine when you’re reading <strong>entire records</strong> — which is what transactional systems do.</p><p>But when you’re running <strong>analytics</strong> — “What’s the average price?” or “How many products are in Electronics?” — you only need <strong>one or two columns</strong>. Yet your system reads <strong>every single column</strong> for every row. On a terabyte dataset, that means you’re reading 10x more data than you need.</p><p>Multiply that across 100 nodes, and you’ve got a serious I/O bottleneck.</p><h3>The Answer: Columnar Storage</h3><p>Columnar formats flip the storage model. Instead of storing data row by row, they store it <strong>column by column</strong>:</p><pre>Column &quot;product_id&quot;: | 1001      | 1002     | 1003        |  ← contiguous on disk<br>Column &quot;name&quot;:       | &quot;Laptop&quot;  | &quot;T-Shirt&quot;| &quot;Headphone&quot; |  ← contiguous on disk<br>Column &quot;price&quot;:      | 999.99    | 29.99    | 149.50      |  ← contiguous on disk<br>Column &quot;category&quot;:   | &quot;Elec&quot;    | &quot;Aprl&quot;   | &quot;Elec&quot;      |  ← contiguous on disk</pre><p><strong>Why this is dramatically better for analytics:</strong></p><ol><li><strong>Column Pruning</strong> — Query only needs “price”? Read only the “price” column. Skip everything else. Instant I/O savings.</li><li><strong>Better Compression</strong> — Values in a column are the same type and often similar. “Electronics” repeated 50,000 times? Dictionary encoding compresses that to almost nothing.</li><li><strong>CPU Vectorization</strong> — Contiguous memory of the same type lets modern CPUs use SIMD instructions, processing 4–8 values per clock cycle.</li><li><strong>Predicate Pushdown</strong> — Column metadata (min/max stats per chunk) lets you skip entire blocks without reading them.</li></ol><p>On real workloads, I’ve seen <strong>60–80% file size reduction</strong> and <strong>5–10x faster analytical queries</strong> just by converting from CSV to columnar.</p><h3>Meet the Two Heroes: Apache Arrow &amp; Apache Parquet</h3><p>If you Google “columnar data,” you’ll find these two names everywhere. But most articles conflate them. Let me be precise.</p><h3>Apache Parquet — Columnar on Disk</h3><p>Parquet is a <strong>file format</strong> designed for efficient storage on disk.</p><pre>Feature Detail<br>Layout Column-oriented with row groups (chunks of rows)<br>Compression Snappy, Zstd, LZ4, Gzip, Brotli<br>Encoding Dictionary, RLE, Delta, Bit-packing<br>Metadata Schema, column stats (min/max/null count), page indexes<br>Ecosystem Spark, Presto, Trino, Dask, DuckDB, BigQuery — everything reads Parquet</pre><p><strong>Think of Parquet as the ZIP file for analytics data.</strong> Small on disk, fast to query, universally supported.</p><h3>Apache Arrow — Columnar in Memory</h3><p>Arrow is a <strong>specification for how columnar data lives in RAM</strong>.</p><pre>Feature Detail<br>Layout Column-oriented, fixed-size buffers, null bitmaps<br>Zero-copy Share data between processes without serialization<br>Cross-language Same memory layout in C++, Python, Java, Rust, Go<br>Computation Built-in compute kernels (filter, sort, aggregate, cast)<br>I/O Readers/writers for CSV, JSON, Parquet, ORC, IPC</pre><p><strong>Think of Arrow as the RAM layout that makes computation fast.</strong> It’s not a file format — it’s how your data should look in memory while you’re working with it.</p><h3>How They Work Together</h3><pre>┌─────────────────┐          ┌─────────────────┐<br>│  Parquet File   │  Read →  │  Arrow Table    │<br>│  (on disk)      │          │  (in memory)    │<br>│  Compressed     │          │  Fast compute   │<br>│  ~200MB         │          │  Zero-copy      │<br>└─────────────────┘          └─────────────────┘<br>                                     │<br>                              Analytics / ML<br>                                     │<br>                             ┌───────▼─────────┐<br>                             │  Parquet File   │<br>                             │  (back to disk  │<br>                             └─────────────────┘</pre><p>Parquet is for <strong>persistence</strong>. Arrow is for <strong>performance</strong>. You typically read Parquet into Arrow, do your work, and write back to Parquet.</p><h3>Arrow C++ is the Real Engine</h3><pre>#include &lt;arrow/api.h&gt;<br>#include &lt;arrow/csv/api.h&gt;<br>#include &lt;parquet/arrow/writer.h&gt;<br><br>// Read CSV into Arrow Table<br>auto input = arrow::io::ReadableFile::Open(&quot;data.csv&quot;).ValueOrDie();<br>auto reader = arrow::csv::TableReader::Make(<br>    arrow::io::default_io_context(), input,<br>    arrow::csv::ReadOptions::Defaults(),<br>    arrow::csv::ParseOptions::Defaults(),<br>    arrow::csv::ConvertOptions::Defaults()<br>).ValueOrDie();<br>auto table = reader-&gt;Read().ValueOrDie();<br><br>// Write as compressed Parquet<br>auto outfile = arrow::io::FileOutputStream::Open(&quot;data.parquet&quot;).ValueOrDie();<br>parquet::WriterProperties::Builder builder;<br>builder.compression(parquet::Compression::ZSTD);<br>parquet::arrow::WriteTable(*table, arrow::default_memory_pool(), outfile, 65536, builder.build());</pre><p>That’s a CSV-to-Parquet converter in ~15 lines of C++. Production-grade, with compression.</p><pre>import pyarrow.csv as pcsv<br>import pyarrow.parquet as pq<br><br># Read CSV → Write Parquet (C++ running underneath)<br>table = pcsv.read_csv(&quot;data.csv&quot;)<br>pq.write_table(table, &quot;data.parquet&quot;, compression=&quot;zstd&quot;)</pre><p><strong>Two lines.</strong> And the performance difference? Maybe 10–20% slower than raw C++, because PyArrow is literally calling the same C++ code through bindings.</p><h3>When to Drop Down to C++</h3><p><strong>My rule of thumb:</strong> Start with PyArrow. Profile. If a specific piece is the bottleneck, rewrite <em>just that piece</em> in C++ and call it from Python via pybind11.</p><h3>Real-World Results: What to Expect</h3><p>Based on benchmarks with real-world analytical data:</p><pre>┌──────────────────────┬───────────────┬──────────────────────────┐<br>│ Metric               │ CSV (Before)  │ Parquet + Zstd (After)   │<br>├──────────────────────┼───────────────┼──────────────────────────┤<br>│ File Size (1B rows)  │   ~240 GB     │   ~45 GB (81% reduction) │<br>│ Full Scan            │   ~180 sec    │   ~22 sec                │<br>│ Single Column Read   │   ~180 sec    │    ~3 sec (60x faster)   │<br>│ Filter + Aggregate   │   ~120 sec    │    ~8 sec                │<br>└──────────────────────┴───────────────┴──────────────────────────┘</pre><p>The size reduction compounds across 100 nodes. If each node stores 1 TB: <strong>100 TB → ~20 TB</strong>. That’s 80 TB of saved storage.</p><h3>Data Governance Advantages</h3><p>Columnar storage also unlocks powerful governance capabilities:</p><ol><li><strong>Column-Level Access Control</strong> — Since columns are stored independently, you can restrict access to sensitive columns without touching others.</li><li><strong>Column-Level Encryption</strong> — Parquet 2.0 supports encrypting individual columns with different keys. Your analytics team can query open columns while sensitive data stays encrypted.</li><li><strong>Selective Reads</strong> — Compliance requests? Read only the columns required. No need to deserialize entire records.</li><li><strong>Efficient Rewrites</strong> — Need to update or purge specific records? Rewrite only the affected row groups, not the entire file.</li></ol><h3>Getting Started — Your First 30 Minutes</h3><p>Try this on your laptop:</p><pre>pip install pyarrow pandas<br><br>import pyarrow as pa<br>import pyarrow.csv as pcsv<br>import pyarrow.parquet as pq<br><br># Generate sample analytics data<br>import pandas as pd<br>import numpy as np<br><br>n = 10_000_000  # 10M rows<br>df = pd.DataFrame({<br>    &quot;order_id&quot;: np.arange(n),<br>    &quot;product&quot;: np.random.choice([&quot;Laptop&quot;, &quot;Phone&quot;, &quot;Tablet&quot;, &quot;Monitor&quot;, &quot;Keyboard&quot;], n),<br>    &quot;quantity&quot;: np.random.randint(1, 20, n),<br>    &quot;region&quot;: np.random.choice([&quot;US-East&quot;, &quot;US-West&quot;, &quot;EU&quot;, &quot;APAC&quot;, &quot;LATAM&quot;], n),<br>    &quot;revenue&quot;: np.random.uniform(10, 2000, n).round(2),<br>})<br>df.to_csv(&quot;sample.csv&quot;, index=False)<br><br># Convert to Parquet<br>table = pcsv.read_csv(&quot;sample.csv&quot;)<br>pq.write_table(table, &quot;sample.parquet&quot;, compression=&quot;zstd&quot;)<br><br># Compare sizes<br>import os<br>csv_size = os.path.getsize(&quot;sample.csv&quot;) / 1e6<br>pq_size = os.path.getsize(&quot;sample.parquet&quot;) / 1e6<br>print(f&quot;CSV:     {csv_size:.1f} MB&quot;)<br>print(f&quot;Parquet: {pq_size:.1f} MB&quot;)<br>print(f&quot;Reduction: {(1 - pq_size/csv_size)*100:.1f}%&quot;)<br><br># Read just one column<br>table = pq.read_table(&quot;sample.parquet&quot;, columns=[&quot;revenue&quot;])<br>print(f&quot;\nRead only &#39;revenue&#39; column: {table.num_rows:,} rows&quot;)</pre><h3>Key Takeaways</h3><ol><li><strong>Row-oriented formats are wasting your I/O</strong> — if your workload is analytics, you’re reading 10x more data than you need.</li><li><strong>Parquet and Arrow are complementary</strong> — Parquet for disk, Arrow for memory. Together they’re the standard columnar stack.</li><li><strong>You probably don’t need custom C++</strong> — PyArrow wraps the Arrow C++ engine. You get 90% of C++ speed with Python simplicity. Drop to C++ only for specific bottlenecks.</li><li><strong>Distributed conversion is an orchestration problem</strong> — the per-node logic is simple (read → convert → write). The hard part is managing 100 nodes reliably.</li><li><strong>Columnar enables better data governance</strong> — column-level encryption, selective access, and efficient data management come naturally with the format.</li></ol><p><em>If you’re sitting on terabytes of row-oriented data and wondering why your analytics are slow — stop tuning your queries and start converting your storage. The format is the bottleneck.</em></p><p><strong>Tags:</strong> #BigData #DataEngineering #ApacheArrow #Parquet #Python #CPP #DistributedSystems #Analytics</p><p><em>Follow me for more practical big data engineering content.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c05dedc8c0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>