<?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 Anurag on Medium]]></title>
        <description><![CDATA[Stories by Anurag on Medium]]></description>
        <link>https://medium.com/@anuragbal08?source=rss-d187c0a0b851------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*T7hj2L_Ccyl0ZHHq</url>
            <title>Stories by Anurag on Medium</title>
            <link>https://medium.com/@anuragbal08?source=rss-d187c0a0b851------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:04:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anuragbal08/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[Beyond Star Schema: Designing for High-Concurrency with One Big Table (OBT)]]></title>
            <link>https://medium.com/@anuragbal08/beyond-star-schema-designing-for-high-concurrency-with-one-big-table-obt-0740ea6ebf55?source=rss-d187c0a0b851------2</link>
            <guid isPermaLink="false">https://medium.com/p/0740ea6ebf55</guid>
            <category><![CDATA[obt]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-modeling]]></category>
            <dc:creator><![CDATA[Anurag]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 09:57:26 GMT</pubDate>
            <atom:updated>2025-12-31T09:57:26.616Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of data warehousing, the <strong>Star Schema</strong> has reigned supreme for decades. By organizing data into centralized “fact” tables surrounded by descriptive “dimension” tables, it offered a perfect balance of storage efficiency and query flexibility.</p><p>However, as we move into the era of real-time analytics and thousands of concurrent users, the “join-heavy” nature of the Star Schema is hitting a performance wall. Enter <strong>OBT (One Big Table)</strong> — a denormalized design pattern optimized for raw speed and high-concurrency environments.</p><h3>The Shift: Why Star Schema is Struggling</h3><p>The Star Schema was designed when storage was expensive and compute was limited. In modern cloud warehouses (like BigQuery, Snowflake, or ClickHouse), storage is cheap, and the bottleneck has shifted to the <strong>CPU overhead of joining tables</strong> during execution.</p><p>When hundreds of users refresh a dashboard simultaneously, the database must perform complex hash joins across multiple tables for every single request. This leads to:</p><ul><li><strong>Increased Latency:</strong> Joins take time to compute at runtime.</li><li><strong>Concurrency Bottlenecks:</strong> CPU spikes cause query queuing.</li><li><strong>Complexity in BI Tools:</strong> Analysts must correctly map relationships between tables.</li></ul><h3>What is OBT (One Big Table)?</h3><p>OBT is a single, massive, flat table that contains both the metrics (facts) and the descriptors (dimensions). There are <strong>no joins</strong> at query time because the “joining” happens during the ETL/ELT process.</p><h3>The Benefits</h3><ul><li><strong>Extreme Performance:</strong> Scanning one table is almost always faster than joining five.</li><li><strong>Higher Concurrency:</strong> Without join overhead, the database handles more simultaneous queries.</li><li><strong>Simplicity:</strong> Optimized for columnar storage where only the necessary columns are read.</li></ul><h3>Real-Life Use Cases</h3><h3>1. E-commerce Real-Time Personalization</h3><p>Imagine “Black Friday” with millions of browsing users. A recommendation engine needs to query user history and inventory instantly.</p><ul><li><strong>OBT Approach:</strong> A pre-computed table allows the frontend to pull everything with a simple SELECT * WHERE user_id = X, avoiding expensive joins during peak traffic.</li></ul><h3>2. SaaS Customer Health Dashboards</h3><p>A B2B SaaS company provides dashboards to 10,000+ customers who all log in at 9:00 AM.</p><ul><li><strong>The OBT Solution:</strong> By flattening logs and account details into one table, the company ensures sub-second load times even during the morning “login spike.”</li></ul><h3>Technical Implementation: Moving to OBT</h3><p>To move from a Star Schema to OBT, we perform the joins during the <strong>Transformation</strong> phase. Below is the SQL logic for creating a “Gold Layer” OBT.</p><p>SQL</p><pre>-- Creating a &#39;Gold Layer&#39; OBT for Sales Analytics<br>CREATE TABLE obt_sales_performance AS<br>SELECT<br>    f.sale_id,<br>    f.sale_date,<br>    f.revenue,<br>    p.product_name,<br>    p.category,<br>    s.store_name,<br>    s.region,<br>    c.customer_segment<br>FROM fact_sales f<br>LEFT JOIN dim_products p ON f.product_key = p.product_key<br>LEFT JOIN dim_stores s ON f.store_key = s.store_key<br>LEFT JOIN dim_customers c ON f.customer_key = c.customer_key;</pre><blockquote><strong><em>Pro Tip:</em></strong><em> Use </em><strong><em>Incremental Models</em></strong><em> (in dbt) to only append new records to your OBT, rather than rebuilding the entire table daily.</em></blockquote><h3>The Trade-offs: The Drawbacks of OBT</h3><p>While OBT is a powerhouse for speed, it isn’t a silver bullet. You must consider these challenges:</p><ul><li><strong>Data Redundancy &amp; Cost:</strong> Storing “Product Name” millions of times instead of once increases storage footprints and costs.</li><li><strong>The “Update” Nightmare:</strong> If a dimension changes (e.g., a product is renamed), you must update millions of rows in the OBT rather than a single row in a dimension table.</li><li><strong>Cognitive Overload:</strong> An OBT with 300+ columns can be overwhelming for analysts to navigate compared to a structured Star Schema.</li><li><strong>ETL Complexity:</strong> Moving the “logic” from the query phase to the transformation phase makes your data pipelines more complex to build and maintain.</li></ul><h3>Conclusion</h3><p>The best modern architecture is often a <strong>hybrid</strong>. Maintain a <strong>Star Schema (Silver Layer)</strong> for data integrity and exploration, then “materialize” specific <strong>OBT views (Gold Layer)</strong> to power high-concurrency dashboards.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0740ea6ebf55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Built a 100TB+ Risk Engine Using Snowflake Cortex]]></title>
            <link>https://medium.com/@anuragbal08/scaling-financial-intelligence-how-we-built-a-100tb-risk-engine-using-snowflake-cortex-768c8979ea40?source=rss-d187c0a0b851------2</link>
            <guid isPermaLink="false">https://medium.com/p/768c8979ea40</guid>
            <category><![CDATA[snowflake-cortex]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Anurag]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 12:47:27 GMT</pubDate>
            <atom:updated>2026-01-01T06:11:44.956Z</atom:updated>
            <content:encoded><![CDATA[<p>We were recently tasked with a massive challenge: Extracting actionable compliance risk from over 100TB of unstructured communication logs and structured transaction data.</p><p>The catch? We had to maintain strict data residency (no data leaving the firm perimeter) and keep operational overhead at a minimum. Here is the architectural journey of how we implemented <strong>Snowflake Cortex</strong> to solve this.</p><blockquote><strong><em>Note:</em></strong><em> The code blocks provided in this guide are sample implementations intended to demonstrate architectural patterns and should be adapted to your specific environment and data schemas.</em></blockquote><h3>The Rational: Why We Abandoned the “Standard” LLM Stack</h3><p>Before Cortex, our prototype used an external LLM provider via APIs and a standalone Vector Database. At <strong>100TB</strong>, this failed for three reasons:</p><ol><li><strong>Data Sovereignty:</strong> Sending PII-heavy data over the internet to a third-party LLM triggered every “red flag” for risks .Every byte that leaves the firm perimeter introduces potential data breach that we simply could not accept.</li><li><strong>The “Tax” of Data Movement:</strong> The egress costs and latency of moving 100TB+ between a storage layer and a separate compute layer for embeddings were astronomical.</li><li><strong>Infrastructure Fatigue:</strong> Managing a separate vector database cluster for millions of embeddings required a dedicated DevOps squad.</li></ol><p><strong>The Solution:</strong> Snowflake Cortex. By bringing the models to the data, we kept everything inside the governed boundary.</p><h3>The Architecture: A Unified Intelligence Loop</h3><p>We designed a “Medallion AI” architecture. The goal was to transform raw, noisy logs into high-fidelity “Compliance Signals.”</p><h3>1. The Bronze Layer: Iceberg &amp; Managed Stages</h3><p>We didn’t want to move 100TB of legacy data into Snowflake’s proprietary format. We used <strong>Apache Iceberg</strong> tables, allowing Snowflake to query data directly from our S3 buckets as if it were internal.</p><h3>2. The Silver Layer: Smart Chunking &amp; Native Embeddings</h3><p>Instead of writing complex Python scripts to chunk text, we used Snowflake’s native functions. This is where we optimized for cost.</p><p>SQL</p><pre>-- RATIONALE: We use a Dynamic Table to ensure we only process NEW logs (incremental) <br>-- rather than re-scanning the 100TB daily.<br>CREATE OR REPLACE DYNAMIC TABLE silver_risk_embeddings<br>TARGET_LAG = &#39;1 hour&#39;<br>WAREHOUSE = AI_DATA_ENG_WH<br>AS<br>SELECT <br>    id,<br>    metadata,<br>    -- We use the native embed function inside the SQL pipeline<br>    SNOWFLAKE.CORTEX.EMBED_TEXT_768(&#39;e5-base-v2&#39;, chunk_content) as vector_embedding<br>FROM (<br>    SELECT id, metadata, func_chunk_logic(raw_text) as chunk_content <br>    FROM raw_compliance_logs<br>);</pre><h3>3. The Gold Layer: The “Judge-Led” Inference</h3><p>This is the “secret sauce.” To save costs, we didn’t send every log to a heavy model like llama3-70b. We implemented a <strong>Triage System</strong>.</p><ul><li><strong>Level 1 (The Filter):</strong> A fast, cheap model (mistral-7b) identifies if a log is &quot;Suspicious&quot; or &quot;Neutral.&quot;</li><li><strong>Level 2 (The Analyst):</strong> Only “Suspicious” logs are sent to mistral-large for a deep-dive compliance analysis.</li></ul><h3>End-to-End Implementation Code</h3><h3>Step 1: Creating the Search Service</h3><p>To allow our compliance officers to query the 100TB of policies, we built a <strong>Cortex Search Service</strong>. This replaces the need for a separate Pinecone or Milvus instance.</p><p>SQL</p><pre>CREATE OR REPLACE CORTEX SEARCH SERVICE risk_policy_search<br>  ON text_content<br>  ATTRIBUTES department, region<br>  WAREHOUSE = COMPLIANCE_WH<br>  TARGET_LAG = &#39;30 minutes&#39;<br>  AS (<br>    SELECT text_content, department, region FROM internal_compliance_docs<br>  );</pre><h3>Step 2: High-Performance Batch Processing</h3><p>For the daily 10TB delta of transaction data, we used this optimized block:</p><p>SQL</p><pre>-- RATIONALE: Using a Case statement to bifurcate workloads saves 70% in compute credits<br>CREATE OR REPLACE TABLE compliance_results_daily AS<br>SELECT <br>    memo_id,<br>    original_text,<br>    CASE <br>        WHEN SNOWFLAKE.CORTEX.COMPLETE(&#39;mistral-7b&#39;, CONCAT(&#39;Is this suspicious? &#39;, original_text)) ILIKE &#39;%YES%&#39; <br>        THEN SNOWFLAKE.CORTEX.COMPLETE(&#39;mistral-large&#39;, CONCAT(&#39;Explain the AML risk in: &#39;, original_text))<br>        ELSE &#39;Low Risk&#39;<br>    END AS risk_report<br>FROM raw_stream<br>WHERE score &gt; 0.85; -- Pre-filter with standard regex/logic</pre><h3>Lessons from the Trenches</h3><h3>1. Monitoring is Non-Negotiable</h3><p>At 100TB, “hidden” costs can spiral. We built a dashboard using the CORTEX_FUNCTIONS_USAGE_HISTORY view to track which business units were burning the most credits.</p><h3>2. Guardrails are the Safety Net</h3><p>We implemented <strong>Cortex Guard</strong> to ensure that any model output containing “toxic” or “non-factual” financial advice was flagged before reaching an employee’s screen.</p><h3>3. Provisioned Throughput</h3><p>For time critical reporting, we switched from “on-demand” to <strong>Provisioned Throughput</strong>. This gave us a dedicated lane for our LLM calls, ensuring that our 100TB batch processing didn’t slow down during peak trading hours.</p><h3>Final Thoughts</h3><p>By moving to a native AI stack within Snowflake, we reduced our data pipeline complexity and cut our compliance processing time from days to minutes. The data never left our premise, and the 100TB of data is finally working for us, not against us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=768c8979ea40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling to 100TB: A Modern Lakehouse Architecture for the Banking Sector]]></title>
            <link>https://medium.com/@anuragbal08/scaling-to-100tb-a-modern-lakehouse-architecture-for-the-banking-sector-8e84e4c8804d?source=rss-d187c0a0b851------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e84e4c8804d</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Anurag]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 07:30:40 GMT</pubDate>
            <atom:updated>2025-12-29T07:30:40.201Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The Scenario:</strong> You’re working for a large retail bank. Your team is tasked with moving from a legacy on-premise system to a cloud-native platform. You are dealing with <strong>100+ Terabytes</strong> of data, including transactional logs, customer profiles, and real-time ATM interactions.</p><p><strong>The Challenges:</strong></p><ol><li><strong>Complexity:</strong> Data arrives in messy formats (JSON, XML, CSV).</li><li><strong>Concurrency:</strong> Hundreds of analysts and data scientists need to query the same data simultaneously without performance degradation.</li><li><strong>Governance:</strong> In a bank, you can’t just “move” data; you need strict audit trails, encryption, and role-based access.</li></ol><h3>The Solution: The Multi-Engine Lakehouse Architecture</h3><p>To solve this, we move away from a monolithic database to a <strong>Decoupled Architecture</strong>. This means we separate <strong>Storage</strong> (where the data sits) from <strong>Compute</strong> (the “engines” that process it).</p><p>We use a <strong>Medallion Architecture</strong> (Bronze, Silver, Gold) to logically refine data as it flows through our system.</p><h4>The Tech Stack:</h4><ul><li><strong>Storage:</strong> Cloud Object Storage (S3/ADLS) using <strong>Delta Lake</strong> or <strong>Iceberg</strong> formats.</li><li><strong>Heavy Lifting (ETL):</strong> <strong>PySpark</strong> on <strong>Databricks</strong> for distributed processing.</li><li><strong>Analytics &amp; Serving:</strong> <strong>Snowflake</strong> for high-concurrency SQL queries.</li><li><strong>Infrastructure:</strong> <strong>Kubernetes (K8s)</strong> to manage containerized ingestion microservices.</li></ul><h3>The Architecture: Step-by-Step</h3><h4>1. Ingestion Layer (The Entry Point)</h4><p>We use containerized applications running on <strong>Kubernetes</strong> to pull data from APIs and legacy mainframes. These microservices are lightweight and can scale horizontally as the number of data sources grows. The raw data is dumped “as-is” into the <strong>Bronze Layer</strong> (Raw Zone).</p><h4>2. Processing Layer (The Refined Engine)</h4><p>This is where <strong>Databricks</strong> and <strong>PySpark</strong> shine. For TB-scale data, a single machine isn’t enough. PySpark distributes the cleaning work across a cluster of machines.</p><ul><li><strong>Silver Layer (Cleansed Zone):</strong> We use <strong>Python/PySpark</strong> to remove duplicates, enforce schemas, and handle PII (Personally Identifiable Information) masking. The data is stored in a “Lakehouse” format (like Delta) which allows for ACID transactions on raw files.</li></ul><h4>3. Serving Layer (The Gold Standard)</h4><p>Once the data is clean, we move it to <strong>Snowflake</strong> (The <strong>Gold Layer</strong>). Snowflake’s “Virtual Warehouse” architecture allows mupltiple teams to run massive <strong>SQL</strong> queries at the same time without slowing each other down. Each team gets its own dedicated compute power, but they all look at the same “Source of Truth.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*YqSpScA4ePxFR7sKddURQg.png" /></figure><h3>Why This Progression Works for TBs of Data</h3><ul><li><strong>Scale:</strong> By using <strong>PySpark</strong>, we can process 100TB of data just by adding more nodes to our cluster.</li><li><strong>Efficiency:</strong> Using <strong>SQL</strong> in Snowflake for the final layer means your business analysts don’t need to learn Python to get insights.</li><li><strong>Cost Management:</strong> We keep the “heavy” raw data in low-cost object storage and only move the high-value, “refined” data into the data warehouse (Snowflake).</li><li><strong>Reliability:</strong> <strong>Kubernetes</strong> ensures our ingestion pipelines are resilient. If a pod fails, K8s restarts it automatically.</li></ul><h3>Bonus Deep Dive: Why Kubernetes for Data Ingestion?</h3><p>In a Terabyte-scale architecture, the <strong>Ingestion Layer</strong> is the most volatile. It has to deal with varying network speeds from legacy mainframes and unpredictable spikes in API traffic. Traditional “fixed” virtual machines either sit idle (wasting money) or crash under pressure.</p><p>We use <strong>Kubernetes (K8s)</strong> to solve this through three core principles:</p><h4>1. Horizontal Pod Autoscaling (HPA)</h4><p>In banking, data volume isn’t flat. It peaks during market hours and dips at night. With K8s, we define <strong>Horizontal Pod Autoscalers</strong>. If the CPU usage on an ingestion microservice hits 70% due to a massive burst of transaction logs, K8s automatically spins up new “Pods” (containers) to distribute the load. When the burst ends, it kills the extra pods to save costs.</p><h4>2. Resilience via Self-Healing</h4><p>Data pipelines often fail due to network timeouts or “poison pills” in the source data. If a traditional script crashes, the pipeline stops. In K8s, if an ingestion container crashes, the <strong>Kubelet</strong> detects the failure and restarts the pod instantly. This “self-healing” ensures that our 100TB migration doesn’t stall at 3:00 AM.</p><h4>3. Decoupled Microservices</h4><p>We don’t build one “giant” ingestion app. Instead, we use K8s to run a fleet of small, specialized microservices:</p><ul><li><strong>Service A:</strong> Polling the REST API for customer profiles.</li><li><strong>Service B:</strong> Listening to Kafka topics for real-time ATM logs.</li><li><strong>Service C:</strong> Handling heavy batch uploads from the Mainframe.</li></ul><p>By decoupling these, a failure in the Customer API service doesn’t stop the flow of critical transaction logs.</p><h3>Conclusion</h3><p>Modern data engineering is no longer about writing the “perfect” script; it’s about orchestrating the right <strong>engines</strong> for the right <strong>tasks</strong>. By combining the distributed power of <strong>Databricks</strong>, the analytical elegance of <strong>Snowflake</strong>, and the reliability of <strong>Kubernetes</strong>, you build a system that doesn’t just store data — it powers a business.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e84e4c8804d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>