<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Pranay Agarwal, Engineering Log</title>
    <link>https://pranaybuilts.com/</link>
    <description>Notes from architecting real-time systems, autonomous AI agent swarms, high-concurrency microservices, and distributed cloud backends.</description>
    <language>en</language>
    <atom:link href="https://pranaybuilts.com/rss.xml" rel="self" type="application/rss+xml" />
    <lastBuildDate>Sun, 29 Nov 2026 02:50:00 +0530</lastBuildDate>

    <!-- ARTICLE 1 -->
    <item>
      <title>What to ask a freelance full-stack engineer before you pay a deposit</title>
      <link>https://pranaybuilts.com/work</link>
      <guid isPermaLink="true">https://pranaybuilts.com/work#questions-to-ask-before-hiring</guid>
      <pubDate>Thu, 15 Oct 2026 11:00:00 +0530</pubDate>
      <dc:creator>Pranay Agarwal</dc:creator>
      <description>Most bad web development projects went wrong on the first call. Here are the questions that tell you early whether someone can actually deliver, written by the engineer on the other side of the screen.</description>
      <category>Engineering</category>
      <category>Full-Stack</category>
      <category>Architecture</category>
      <content:encoded><![CDATA[<p>I’ve been the lead engineer on dozens of discovery calls. Almost every project that ever went sideways in this industry showed the warning signs in that very first conversation. Nobody asked the right questions about scale, concurrency, or ownership, so nobody noticed until the staging server collapsed under real load.</p>
<p>Here’s what I’d ask if I were the founder or product lead doing the hiring.</p>
<h2>Can I see something live under real production load?</h2>
<p>Not a Figma mockup, not a slick video recording. A working system you can open right now. If you're building a real-time auction, a trading leaderboard, or a high-concurrency bot, ask to see it handling 1,000+ simultaneous connections. A toy demo with three static database rows tells you nothing about how a WebSocket gateway behaves when traffic spikes.</p>
<h2>Who will own the Git repository, the database, and the cloud logins?</h2>
<p>This is the question founders regret skipping. Upon final delivery, the entire codebase, Dockerfiles, environment secrets, and cloud accounts should be 100% in your name. If a developer hosts your platform on their private server with proprietary locked runtimes, that is not an asset—it’s an agency hostage trap.</p>
<h2>How do you handle real-time latency and database contention?</h2>
<p>If your project involves live updates, ask whether they rely on brute-force HTTP polling or persistent WebSocket streams with in-memory Redis caching. A developer who proposes polling a relational PostgreSQL database every 500ms for 5,000 active users is building an instant crash.</p>
<h2>What happens after launch when a bug appears?</h2>
<p>Every system interacts with unexpected edge cases: third-party API rate limits, expired Webhooks, or memory leaks under stress. Ask who monitors errors, how fast they respond, and whether post-launch bug fixes are included. “We’ll figure it out later” is not a contract.</p>
<h2>Red Flags to watch for</h2>
<ul>
<li>A firm quote given in two minutes before asking about data volume or concurrent users.</li>
<li>No live production links or GitHub contributions they can point to.</li>
<li>Insisting on proprietary closed-source CMS platforms where you can't export your data.</li>
<li>Promising zero bugs on a 4-week timeline without writing automated test suites.</li>
</ul>
<h2>Where I fit</h2>
<p>I’m the Founder & Lead Engineer at Elite Development in Beawar, Rajasthan, India. I build full-stack web applications, real-time WebSocket systems, autonomous AI agent pipelines, and high-concurrency microservices. <a href="https://pranaybuilts.com/work">Explore my live work</a>, and if you have a project ready to build, <a href="https://pranaybuilts.com/contact">let’s talk architecture</a>.</p>
]]></content:encoded>
    </item>

    <!-- ARTICLE 2 -->
    <item>
      <title>Scaling WebSockets to 35,000 Concurrent Bidders with Zero Lag</title>
      <link>https://pranaybuilts.com/work</link>
      <guid isPermaLink="true">https://pranaybuilts.com/work#scaling-websockets-35000-bidders</guid>
      <pubDate>Mon, 28 Sep 2026 16:30:00 +0530</pubDate>
      <dc:creator>Pranay Agarwal</dc:creator>
      <description>When 35,000 bidders submit offers in the final 5 seconds of an auction, relational database locks will kill your server. Here is how I architected a sub-5ms clustered Node.js and Redis pub/sub gateway.</description>
      <category>WebSockets</category>
      <category>Redis</category>
      <category>High-Concurrency</category>
      <content:encoded><![CDATA[<p>An auction platform can afford to have a plain design. It can never afford to show two different winners on two different screens. When thousands of people hit "BID" in the final 10 seconds, traditional SQL queries will bottleneck at row locks.</p>
<h2>The Problem: The Lock Contention Bottleneck</h2>
<p>If 10,000 bids hit <code>UPDATE auctions SET highest_bid = $1 WHERE id = $2</code> simultaneously, PostgreSQL will queue those transactions. Connection pools exhaust within seconds, Node.js event loops choke, and users see stale timestamps.</p>
<h2>The Solution: Redis Atomic Transactions &amp; Lua Scripts</h2>
<p>To achieve sub-5ms bid evaluation, all active auction states are held in memory via Redis:</p>
<ul>
<li><strong>Atomic Lua Scripts:</strong> The incoming bid value, user timestamp, and minimum increment are evaluated inside a single atomic Redis Lua script. If the bid is valid, it updates the sorted set immediately in under 0.8ms.</li>
<li><strong>Redis Pub/Sub Fanout:</strong> The new winning price is published to an internal Redis channel. Clustered Node.js WebSocket worker threads listen to this channel and broadcast the packet to connected clients across separate TCP sockets without touching the database.</li>
<li><strong>Asynchronous Write-Behind Persistence:</strong> A background worker reads finalized auction states from a Redis stream and writes batches to PostgreSQL every 2 seconds. The client never waits on disk I/O.</li>
</ul>
<h2>Result in Production</h2>
<p>During peak live events, the architecture successfully handled 35,000 concurrent active bidders streaming live WebSocket frames with a median latency of 3.8ms and zero packet drops.</p>
]]></content:encoded>
    </item>

    <!-- ARTICLE 3 -->
    <item>
      <title>Why Sofia Bot Never Crashed: Scaling to 4.2M+ Discord Users</title>
      <link>https://pranaybuilts.com/work</link>
      <guid isPermaLink="true">https://pranaybuilts.com/work#sofia-bot-architecture</guid>
      <pubDate>Wed, 12 Aug 2026 14:00:00 +0530</pubDate>
      <dc:creator>Pranay Agarwal</dc:creator>
      <description>Most audio bots crash once they hit 1,000 servers due to audio frame starvation and unhandled gateway heartbeats. Here is the sharded cluster setup that kept Sofia online across 6,799+ servers.</description>
      <category>Node.js</category>
      <category>Microservices</category>
      <category>Docker</category>
      <content:encoded><![CDATA[<p>Streaming high-definition audio across thousands of concurrent voice channels is fundamentally different from serving web pages. If an HTTP request is delayed by 150ms, the user hardly notices. If a voice packet is delayed by 20ms, audio stutters and users leave.</p>
<h2>1. Process Isolation with Sharded Clusters</h2>
<p>A single Node.js process cannot process audio encoding, gateway heartbeats, and user commands at scale. We split the architecture into three dedicated layers:</p>
<ul>
<li><strong>Gateway Shards:</strong> Lightweight Node.js processes responsible solely for maintaining Discord WebSocket heartbeats and dispatching incoming slash commands.</li>
<li><strong>Audio Worker Threads:</strong> Native C++ worker threads handling Opus encoding and RTP packet pacing via libsodium, completely isolated from the main JavaScript thread.</li>
<li><strong>Redis State Sync:</strong> Shared guild configurations, playlists, and user permissions cached in memory with sub-millisecond retrieval.</li>
</ul>
<h2>2. Memory Leak Eradication</h2>
<p>Audio streaming buffers in Node.js easily leak if audio resource references aren't garbage collected upon voice channel disconnection. By implementing explicit buffer recycling and strict lifecycle listeners on voice connection states, heap usage remained rock-solid below 280MB per 1,000 servers over months of continuous uptime.</p>
]]></content:encoded>
    </item>

    <!-- ARTICLE 4 -->
    <item>
      <title>Building Autonomous AI Agent Swarms with RAG Vector Ingestion</title>
      <link>https://pranaybuilts.com/work</link>
      <guid isPermaLink="true">https://pranaybuilts.com/work#autonomous-ai-swarms</guid>
      <pubDate>Mon, 06 Jul 2026 10:15:00 +0530</pubDate>
      <dc:creator>Pranay Agarwal</dc:creator>
      <description>Simple LLM prompts fail when applied to complex enterprise datasets. Here is how I design autonomous multi-agent pipelines with vector search, tool calling, and deterministic JSON outputs.</description>
      <category>Autonomous AI</category>
      <category>LangChain</category>
      <category>Vector DB</category>
      <content:encoded><![CDATA[<p>Chatbots that regurgitate generic LLM answers are everywhere. What enterprises actually need are autonomous systems that can decompose goals, query vector knowledge bases, dispatch external API tools, and return validated structured outputs without human micromanagement.</p>
<h2>The Multi-Agent Pipeline Pattern</h2>
<p>Rather than relying on a single monolithic prompt, we split the execution into sequential specialized agents:</p>
<ol>
<li><strong>Goal Decomposition Agent:</strong> Takes the raw user request and breaks it into discrete computational sub-tasks.</li>
<li><strong>Context Retrieval Agent:</strong> Queries Qdrant/Pinecone vector embeddings using hybrid dense-sparse search to pull the top 5 most relevant policy or code snippets.</li>
<li><strong>Reasoning &amp; Tool Dispatch:</strong> Calls Claude 3.5 Sonnet with strict JSON schema function definitions to execute live API calls or calculations.</li>
<li><strong>Validation Guardrail:</strong> Validates the output against Pydantic schema contracts before delivering the response.</li>
</ol>
<p>This architecture reduced hallucinations to under 0.2% and automated data ingestion across 100,000+ support records with sub-400ms turnaround times.</p>
]]></content:encoded>
    </item>

    <!-- ARTICLE 5 -->
    <item>
      <title>PostgreSQL Schema Optimization: Sub-4ms Query Times Under Heavy Indexing</title>
      <link>https://pranaybuilts.com/stack</link>
      <guid isPermaLink="true">https://pranaybuilts.com/stack#postgres-schema-optimization</guid>
      <pubDate>Thu, 21 May 2026 09:30:00 +0530</pubDate>
      <dc:creator>Pranay Agarwal</dc:creator>
      <description>Database performance isn't about throwing bigger RAM at the cloud server. It's about composite B-Tree indexes, partial filters, and connection pooling. Here is how I tune schemas for high-traffic SaaS.</description>
      <category>PostgreSQL</category>
      <category>Databases</category>
      <category>Performance</category>
      <content:encoded><![CDATA[<p>Too many teams build Next.js frontends and wonder why their platform slows to a crawl after onboarding 50 enterprise clients. The culprit is almost always unindexed foreign keys, unbounded table scans, and unpooled database connections.</p>
<h2>1. Partial Indexes for Active Records</h2>
<p>Most SaaS tables have thousands of soft-deleted or inactive records. An index that covers every historical row wastes disk space and memory. A partial index like <code>CREATE INDEX idx_active_orders ON orders (tenant_id, created_at) WHERE status != 'archived';</code> keeps the index tree tiny and cache-resident.</p>
<h2>2. PgBouncer Connection Pooling</h2>
<p>Each PostgreSQL connection consumes 5-10MB of server RAM. When a Node.js cluster spins up 20 instances, each opening 50 connections, the database server runs out of memory before executing any queries. Introducing PgBouncer in transaction pooling mode allows 1,000 client instances to share 30 physical backend connections with zero latency penalty.</p>
<h2>3. Strict Query Benchmarks</h2>
<p>Every production endpoint is required to execute in under 50ms total response time, with SQL queries taking less than 4ms. By combining proper index strategy, Prisma ORM select narrowing, and Redis caching layers, query performance remains constant whether there are 1,000 rows or 5,000,000 rows.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
