<?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 Yamoksh Verma on Medium]]></title>
        <description><![CDATA[Stories by Yamoksh Verma on Medium]]></description>
        <link>https://medium.com/@yamokshverma?source=rss-6984c93809a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZxuyjycIqH5qVE-_yLQBKQ.png</url>
            <title>Stories by Yamoksh Verma on Medium</title>
            <link>https://medium.com/@yamokshverma?source=rss-6984c93809a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:03:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yamokshverma/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[5 AI Terms Every Engineer Should Actually Understand]]></title>
            <link>https://medium.com/@yamokshverma/5-ai-terms-every-engineer-should-actually-understand-08431b92bbea?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/08431b92bbea</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 13:19:43 GMT</pubDate>
            <atom:updated>2026-06-10T13:19:43.005Z</atom:updated>
            <content:encoded><![CDATA[<p>Most engineers can name three. The ones who can explain all five are the ones shipping production-grade AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oq_3TO2buY1F2dRZs1qJ_g.png" /></figure><p>Every engineer can spell GPT. Most can sketch what an LLM does. A surprising number have shipped a ChatGPT wrapper into production. But ask them to explain why their RAG pipeline returns garbage at 10,000 tokens, or why their agent silently truncates tool outputs, and the room gets quiet.</p><p>The gap isn’t model knowledge. It’s vocabulary — the specific terms that describe what’s actually happening inside the system you just glued together.</p><p>These five terms separate engineers who use AI APIs from engineers who reason about them. If you can explain each one in a sentence, plus the failure mode it causes, you’re ahead of 90 percent of the field.</p><h3>1. Context Window</h3><p>The context window is the maximum number of tokens the model can see in a single request — both your input and its output combined.</p><p>Why this matters more than it sounds: every other AI failure mode you’ll encounter ultimately traces back to context window mechanics. The model isn’t “forgetting” your earlier instructions in a long conversation. The model is making decisions under a fixed token budget, and something had to be dropped or truncated to fit. When you understand that the context window is a finite physical resource — not a memory metaphor — you start designing systems that manage it explicitly instead of hoping the model figures it out.</p><p>The failure mode to watch for: you build a chatbot that works beautifully for the first 20 turns, then starts hallucinating user preferences it was told 30 minutes ago. The conversation history exceeded the window and got truncated from the front. The fix isn’t a smarter model. It’s a summarization step or a retrieval layer over the conversation history.</p><p>Tokens are not characters. A token is roughly 0.75 English words. The string “antidisestablishmentarianism” is one word but six tokens. Always count tokens with the model’s actual tokenizer, never estimate from character count.</p><h3>2. Embeddings</h3><p>An embedding is a vector — typically 768 to 3,072 floating-point numbers — that represents the semantic meaning of a piece of text. Two pieces of text with similar meanings produce vectors that point in similar directions, measurable by cosine similarity.</p><p>Why this matters: embeddings are the substrate of every search-augmented AI system. RAG, semantic search, recommendation systems, deduplication, clustering — all of it runs on the same primitive. You take text, turn it into a vector, store the vector, and later compare it against a query vector to find “things that mean roughly this.”</p><p>The failure mode to watch for: you build semantic search and get baffling results. The query “how do I cancel my subscription” returns a doc about canceling appointments. The embedding model doesn’t know your domain — it was trained on the internet, where “cancel” near “subscription” might cluster differently than your support context expects. The fix is either fine-tuning the embedding model, hybrid search that combines embeddings with keyword matching, or a re-ranking step that filters the top-k candidates with a smaller LLM.</p><p>A subtle trap: embedding models are not interchangeable. If you switch from OpenAI’s text-embedding-3-small to Cohere’s embed-v3, every vector in your database becomes meaningless. You can’t mix vectors from different models — they live in different geometric spaces.</p><h3>3. RAG (Retrieval-Augmented Generation)</h3><p>RAG is the pattern of fetching relevant documents from an external store, stuffing them into the model’s context window, and asking the model to answer using only those documents.</p><p>Why this matters: RAG is how you make an LLM know things it wasn’t trained on — your internal docs, last week’s pricing changes, a customer’s order history — without retraining the model. It’s the dominant production pattern for “AI that knows about my company.”</p><p>But RAG is deceptively hard. The pipeline has four moving pieces, and each one can silently degrade quality.</p><p>You chunk your documents (wrong chunk size, and you split a sentence across two chunks that never get retrieved together). You embed the chunks (wrong embedding model, and semantically related content doesn’t cluster). You retrieve the top-k matches (k too low, you miss the answer; k too high, the model gets confused by noise). You inject them into the prompt (wrong format, and the model can’t tell quoted source material from its own reasoning).</p><p>The failure mode to watch for: your RAG system confidently answers questions using documents that don’t contain the answer. This is the “lost in the middle” problem — LLMs pay more attention to the start and end of their context window than the middle. If your answer is in the third of seven retrieved chunks, the model may genuinely not see it. The fix is re-ranking retrieved chunks so the most relevant ones go at the start and end of the injected context, not the middle.</p><h3>4. Temperature</h3><p>Temperature is a scalar (usually between 0 and 2) that controls how randomly the model samples from its probability distribution when picking the next token.</p><p>At temperature 0, the model is deterministic — it always picks the highest-probability next token. At temperature 1, it samples according to the natural probability distribution. At temperature 2, it samples with extra randomness, frequently picking low-probability tokens.</p><p>Why this matters: most production bugs in LLM apps come from the wrong temperature for the task. Engineers default to 0.7 because some tutorial used it, then wonder why their JSON extractor produces malformed output 5 percent of the time, or why their creative writing tool produces the same three opening sentences across every call.</p><p>The rule: temperature 0 for anything that has a single correct answer (classification, extraction, structured output, code generation). Temperature 0.7 to 1.0 for anything where variety is the goal (brainstorming, creative writing, generating examples). Temperature above 1.0 almost never. Above 1.5, the model often goes incoherent.</p><p>The failure mode to watch for: you set temperature 0 expecting determinism and still get different outputs across runs. Temperature 0 reduces randomness in token sampling but doesn’t eliminate it — floating-point non-determinism in GPU kernels, batch composition effects, and model routing on the provider’s backend all introduce small variations. If you need true determinism, you need to cache responses, not chase it through the temperature dial.</p><h3>5. Tool Use (Function Calling)</h3><p>Tool use is the mechanism by which an LLM, instead of generating a natural-language response, generates a structured request for the application to execute a function — then receives the result back into its context and continues reasoning.</p><p>This is the foundation of every “AI agent” you’ve heard about. An agent is fundamentally just a loop: the model decides whether to answer or call a tool, you execute the tool, you feed the result back, the model decides again, and so on until it answers or hits a limit.</p><p>Why this matters: tool use is what turns LLMs from text generators into systems that can do things — query databases, send emails, run code, browse the web. It’s also where most agents quietly fail in ways that look like model failures but aren’t.</p><p>The failure mode to watch for: your agent works perfectly with two tools and falls apart with twelve. As the tool count grows, the model’s tool-selection accuracy degrades — not because the model is bad, but because the tool descriptions all live in the system prompt, eating context window and creating confusion about which tool fits which intent. The fix is hierarchical tool routing: instead of exposing 12 tools, expose 3 “domains” and let the model pick a domain first, then expose only the relevant sub-tools.</p><p>The other quiet killer: tool outputs that exceed the model’s context budget. If your get_customer_orders tool returns 50 KB of JSON, you’ve just blown your context window on a single call. Always design tools to return summaries or paginate, and let the model request more detail explicitly.</p><p>The Common Thread</p><p>Notice what every one of these terms has in common.</p><p>They’re all about resource management — tokens, vectors, probabilities, function calls — under finite constraints. The engineers shipping reliable AI systems aren’t the ones who know the most about transformer architecture. They’re the ones who understand the model as a system with budgets, failure modes, and operational characteristics.</p><p>If you can hold all five of these terms in your head and reason about how they interact — context window constrains how much RAG you can inject, embeddings determine what RAG retrieves, temperature governs whether tool calls are deterministic, tool outputs consume the same context budget as your prompt — you’re not just using AI. You’re engineering with it.</p><p><strong>And that’s the 10 percent.</strong></p><p>If you found this useful, the next post in this series covers the 5 AI terms most engineers think they understand but actually don’t (spoiler: “fine-tuning” is one of them).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08431b92bbea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Click That Lied: A Developer’s War Against Ad Fraud]]></title>
            <link>https://medium.com/@yamokshverma/the-click-that-lied-a-developers-war-against-ad-fraud-051f96ec4ac4?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/051f96ec4ac4</guid>
            <category><![CDATA[adtech]]></category>
            <category><![CDATA[timing-attacks]]></category>
            <category><![CDATA[geek]]></category>
            <category><![CDATA[hmac]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 12:01:27 GMT</pubDate>
            <atom:updated>2026-06-10T12:01:27.826Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A story about impressions, signatures, and the sneaky attack hiding in a single nanosecond.</em></p><h3>Act I: The Suspicious Number</h3><p>It was a Tuesday afternoon when I noticed something odd in the dashboard.</p><p>Our biggest advertiser was paying for 40,000 clicks on a campaign that had run for only three hours. The product had 8,000 daily active users.</p><blockquote>Math doesn’t lie. Someone else is clicking.</blockquote><p>I stared at the number. Each click meant money — real money flowing out of the advertiser’s budget and into a fraudster’s pocket. And the system was happily counting every single one.</p><p>The problem was elegantly simple: one user impression was being counted multiple times. A single real ad view was being replayed, re-submitted, and re-counted dozens — sometimes hundreds — of times. The system had no memory. It couldn’t tell the difference between a genuine click and a replay.</p><p>Time to fix it.</p><h3>Act II: The Impression ID</h3><p>My first instinct was clean and logical. If each legitimate click event gets a unique ID, I can track which IDs I’ve already seen. No duplicate IDs, no duplicate counts.</p><p>I built an Impression ID system. When the ad server served an ad, it generated a unique token — a UUID tied to that specific ad slot, for that specific user, at that specific time. The click event had to carry that token back to the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHiThjm9hZpEqh7sDlECtg.png" /></figure><p>I deployed it. The fraudulent spike dropped dramatically. The advertiser breathed easy.</p><p>I felt good. For about two weeks.</p><h3>Act III: They’re Just Making Up IDs</h3><p>The dashboard twitched again. A different campaign. Same pattern.</p><p>I dug into the logs. The impression IDs coming in were valid-looking UUIDs — but they’d never been issued by my server. The fraudsters had figured out the format.</p><p>They were just generating their own IDs.</p><p>A UUID is just a string. There’s nothing secret about it. Anyone with import uuid could mint millions of them and flood the endpoint. The deduplication logic dutifully marked each new fake ID as seen and counted the click.</p><p>The system wasn’t checking authenticity — only uniqueness.</p><p>I needed the impression ID to be something only my server could create.</p><p>I reached for cryptography.</p><h3>Act IV: HMAC, Signing the Evidence</h3><p>HMAC, or Hash-based Message Authentication Code, is a way to attach a cryptographic signature to a piece of data using a secret key. Only someone who knows the secret key can produce a valid signature, and anyone with the key can verify it.</p><p>The plan was simple. When the server generates an impression, it creates an ID and signs it with a secret key. The full token sent to the client is impression_id.signature. On click receipt, the server re-computes the expected signature and checks if it matches. No secret key means no valid signature means rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FyA1KN_TKmXgSmNkIHqLnA.png" /></figure><p>I deployed it. Fraud dropped again, sharply this time. The cryptography was doing its job.</p><p>I was proud. The system felt airtight.</p><p>Three months passed quietly.</p><h3>Act V: The Ghost in the Nanoseconds</h3><p>A security researcher reached out. Not a hacker — someone doing a routine audit for a new enterprise client.</p><p>Her message was short.</p><p>Your HMAC verification endpoint is vulnerable to a timing attack. Line 22 of your verify function. You’re using == to compare signatures.</p><p>I read it twice.</p><blockquote>== is wrong?</blockquote><p>I wrote back asking for clarification. She explained it like this.</p><p><strong>The Timing Attack, Explained</strong></p><p>When a computer compares two strings with ==, it doesn’t compare the whole thing at once. It goes character by character, left to right, and stops the moment it finds a mismatch.</p><blockquote>“abc123” == “abcXXX” → stops at character 4 (fast)</blockquote><blockquote>“abc123” == “abc123” → stops at character 7 (slower)</blockquote><p>The first comparison bails out early. The second runs to completion. These take measurably different amounts of time — often just nanoseconds, but measurable.</p><p>Now imagine an attacker probing your HMAC verification endpoint systematically.</p><p>Send a completely wrong signature. The server rejects instantly, stopped at character 1. Send one with the correct first character. Slightly slower reject. Send one with the correct first two characters. Even slower. Repeat for every position.</p><p>By measuring the tiny differences in server response time, the attacker can guess the correct HMAC signature one character at a time — without ever knowing the secret key.</p><p>It’s like cracking a combination lock by feel instead of sight.</p><p>For a 64-character hex HMAC-SHA256 signature, brute force would take 16 to the power 64 attempts. A timing attack reduces this to roughly 64 times 16, or 1,024 attempts to map out the correct signature.</p><p>I sat back in my chair.</p><p>A single == operator. That’s all it took.</p><h3>Act VI: The Fix, Constant-Time Comparison</h3><p>The solution isn’t complex. It’s a different comparison function — one that always checks every character, regardless of where the mismatch occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zzMvYlPi7fF3n_2GeJSmzA.png" /></figure><p>hmac.compare_digest() takes the same amount of time whether the strings match at character 1 or character 64. The timing channel disappears.</p><p>Here’s the same function in other languages.</p><blockquote><strong>In Python</strong>, use hmac.compare_digest(a, b).</blockquote><blockquote><strong>In Node.js</strong>, use crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b)).</blockquote><blockquote><strong>In Go,</strong> use subtle.ConstantTimeCompare([]byte(a), []byte(b)).</blockquote><blockquote><strong>In Ruby,</strong> use ActiveSupport::SecurityUtils.secure_compare(a, b).</blockquote><blockquote><strong>In PHP,</strong> use hash_equals($a, $b).</blockquote><blockquote><strong>In Java,</strong> use MessageDigest.isEqual(a.getBytes(), b.getBytes()).</blockquote><p>The fixed verify function in full:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9a6XJySWjmaqkHoK9NFwA.png" /></figure><p>One line changed. The timing channel closed.</p><h3>Act VII: Do We Even Need to Re-Verify Every Time?</h3><p>A week after the timing fix, I was reviewing latency metrics when a colleague leaned over.</p><p>You’re running HMAC-SHA256 on every single click request. That’s a cryptographic hash computation on your hottest endpoint. Have you thought about caching verified signatures?</p><p>I hadn’t.</p><p>Here’s the thing most developers miss. HMAC verification isn’t free, but it isn’t slow either. A single SHA256 computation takes roughly 1 to 5 microseconds on modern hardware. At 100 requests per second, that’s invisible. But at 50,000 clicks per second during a peak campaign, you’re burning meaningful CPU just re-proving something you’ve already proved.</p><p>More importantly, a valid, verified signature doesn’t change. If you verified this token five milliseconds ago and it was genuine, it’s still genuine now. You already did the math.</p><p>The pattern is: verify once, cache the result, skip re-verification on repeat hits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Klg4Enzryh7JUQhx2baPjA.png" /></figure><p>Two rules worth tattooing on your monitor.</p><ol><li>First, only cache positive results. Never cache a failed verification. An attacker flooding your endpoint with garbage signatures would fill your cache with False entries — a cache poisoning vector you don’t want. Failed verifications are cheap. Re-compute them every time.</li><li>Second, use a hash of the full token as the cache key, not the signature itself. If you use received_sig as the Redis key directly, you’re storing raw attacker-controlled data in your cache namespace. Use sha256(full_token) instead. It’s deterministic, compact, and reveals nothing about the actual signature to anyone inspecting your keyspace.</li></ol><p>This change brought HMAC CPU utilization from 18 percent down to 2 percent. The cache hit rate was 94 percent, because most legitimate clicks arrive within seconds of the impression being served, and a real user rarely clicks the same ad more than once. The dedup check was already hitting Redis anyway — the signature cache piggybacked on the same infrastructure for free.</p><p>When traffic is low, under 1,000 requests per second, caching is optional. The CPU savings are negligible. Once you cross 10,000 requests per second, it becomes strongly worth doing.</p><p>The Full Defense Stack</p><p>Here’s what the system looked like after all seven acts.</p><blockquote><strong>Step 1. </strong>The ad server generates an impression ID and HMAC-signs it with a secret key.</blockquote><blockquote><strong>Step 2. </strong>The client receives the signed token and attaches it to the click event.</blockquote><blockquote><strong>Step 3.</strong> The click endpoint receives the token and checks the signature cache first, the fast path. On a cache miss, it re-computes the HMAC using hmac.compare_digest(), the safe path, then stores the verified result.</blockquote><blockquote><strong>Step 4.</strong> Replay dedup checks Redis to confirm this token hasn’t already been counted.</blockquote><blockquote><strong>Step 5.</strong> The count is recorded only if all checks pass.</blockquote><p>Each layer blocks a different class of attack. Impression ID deduplication stops replay attacks. HMAC signing stops forged tokens. Constant-time comparison closes the timing channel. Signature caching keeps the system efficient under load. Rate limiting adds a final friction layer against floods.</p><p>The Lesson That Costs Nothing to Learn</p><p>The most expensive bugs aren’t the ones that crash your server. They’re the ones that quietly drain your advertiser’s budget while your metrics look perfectly healthy.</p><p>This is a pattern every developer building any kind of token verification encounters. Whether it’s ad impressions, OAuth tokens, webhook signatures, API keys, or password reset links — if you’re comparing secrets, the rule is short enough to memorize.</p><p>If you’re comparing a value that proves authenticity, never use ==. Use hmac.compare_digest(), or its equivalent in your language.</p><p>Standard == is for checking if two strings happen to be equal. hmac.compare_digest() is for checking if a secret was correctly produced. They look identical in code. They behave very differently under adversarial conditions.</p><p><strong>One More Thing: Rate Limiting: </strong>I added one final layer — rate limiting per IP at the very front of the endpoint. Even with everything above in place, a sophisticated attacker who somehow obtains a valid token could still attempt high-volume replays in a distributed system before deduplication catches up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XS7mQUdUgQak5cZEA-zWUw.png" /></figure><p>Defense in depth. No single mechanism is enough. Stack them.</p><p>Security isn’t a feature you add. It’s a discipline you practice — one nanosecond at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=051f96ec4ac4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s Next for the Senior Software Engineer: Charting Your Course on the Technical Ladder]]></title>
            <link>https://medium.com/@yamokshverma/whats-next-for-the-senior-software-engineer-charting-your-course-on-the-technical-ladder-e4a5a536888c?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4a5a536888c</guid>
            <category><![CDATA[reliability]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[careers]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Fri, 19 Sep 2025 07:19:57 GMT</pubDate>
            <atom:updated>2025-09-19T07:19:57.658Z</atom:updated>
            <content:encoded><![CDATA[<p>You’ve mastered the craft. You’ve navigated countless complex systems, debugged the most elusive bugs, mentored junior colleagues, and delivered impactful features. You’re a Senior Software Engineer, a linchpin in your team, and a valuable asset to your organization. But a familiar question starts to echo in the quiet moments: “What’s next?”</p><p>The journey doesn’t end here. The technical ladder extends upwards, branching into exciting new territories. This guide is for every Senior Engineer ready to elevate their impact, hone new skills, and strategically chart their path to the next challenging and rewarding role.</p><h3>The Crossroads: Why Move On From Senior?</h3><p>Before diving into the “how,” let’s acknowledge the “why.” The “Senior” title, while respected, can become a comfortable plateau. As “Why Every Senior Developer I Know Is Planning Their Exit” provocatively highlighted, stagnation is a real concern. Moving to the next technical tier isn’t just about a title bump or a salary increase; it’s about:</p><ul><li><strong>Amplified Impact:</strong> Influencing broader architectural decisions, setting technical strategy, and mentoring at scale.</li><li><strong>New Challenges:</strong> Tackling problems of system design, distributed computing, reliability, and innovation at a higher level.</li><li><strong>Continued Growth:</strong> Avoiding professional obsolescence by acquiring advanced skills in a rapidly evolving industry.</li><li><strong>Leadership (Technical, Not Managerial):</strong> Leading initiatives, driving best practices, and shaping the technical culture without necessarily managing people.</li></ul><p>So, if you’re feeling that familiar itch for more, you’re on the right track. Let’s explore the prominent paths.</p><h3>The Technical Ladder: Your Next Destinations</h3><p>While titles vary across companies (Staff Engineer, Principal Engineer, Distinguished Engineer, etc.), the roles generally coalesce around these archetypes as you ascend the technical ladder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MAELJ3BEGW1vfqUScSrPSw.png" /></figure><h4>1. The Staff Engineer: Architect of Specific Domains</h4><p>This is often the most common next step for a Senior Engineer who wants to remain hands-on but expand their influence.</p><ul><li><strong>What it entails:</strong> Staff Engineers typically own the technical vision and execution for a significant area or system. They are individual contributors (ICs) who lead complex projects, define architectural patterns, and mentor multiple teams on specific technologies or domains. They translate high-level business goals into concrete technical strategies.</li><li><strong>Day-to-day might look like:</strong> Designing a new microservice architecture, troubleshooting cross-team integration issues, leading a technical task force, writing design documents (RFCs), and hands-on coding for critical components or proofs-of-concept.</li><li><strong>Impact:</strong> Influences 1–3 teams, driving technical excellence and alignment within their domain.</li></ul><h4>2. The Principal Engineer: Visionary and Cross-Organizational Leader</h4><p>The Principal Engineer operates at an even higher altitude, shaping the technical direction across multiple domains or even an entire engineering organization.</p><ul><li><strong>What it entails:</strong> Principal Engineers are highly experienced ICs who drive major technical initiatives, identify strategic technical problems, and propose solutions that have broad organizational impact. They are often responsible for setting long-term technical roadmaps, evaluating new technologies, and resolving architectural disputes.</li><li><strong>Day-to-day might look like:</strong> Crafting multi-year technical strategies, consulting across departments on critical infrastructure decisions, leading complex system-wide migrations, representing the company externally (conferences, standards bodies), and influencing product direction with technical insights.</li><li><strong>Impact:</strong> Influences 3+ teams, multiple departments, or an entire product line.</li></ul><h4>3. The Distinguished/Fellow Engineer: Industry Luminary and Innovator</h4><p>These are the technical titans, the equivalent of a C-level executive on the IC track. They are rare, deeply specialized, and often considered thought leaders within their companies and the broader industry.</p><ul><li><strong>What it entails:</strong> Distinguished Engineers are responsible for solving the hardest, most ambiguous technical problems. They identify future technical challenges, drive innovation, establish fundamental engineering principles, and often hold significant intellectual property. Their work can define new product categories or shift company strategy.</li><li><strong>Day-to-day might look like:</strong> Researching cutting-edge technologies, inventing new algorithms or architectural paradigms, defining company-wide technical standards, advising senior leadership on strategic technical investments, and speaking at major industry events.</li><li><strong>Impact:</strong> Influences the entire organization, potentially the industry, defining the future of technology for the company.</li></ul><h3>The Skills Gap: What to Learn and Focus On</h3><p>Transitioning to these advanced roles isn’t just about more coding. It requires a significant shift in focus. Here’s a breakdown of the critical skills to cultivate:</p><h4>1. System Design &amp; Architecture (Deep Dive)</h4><ul><li><strong>What:</strong> Beyond designing a single service, you’ll need to think about distributed systems, scalability, reliability (SLOs/SLAs), fault tolerance, disaster recovery, data consistency models (CAP theorem), performance optimization, security, and cost-effectiveness across an entire ecosystem.</li><li><strong>How to learn:</strong></li><li><strong>Study Design Patterns:</strong> Beyond software design patterns, delve into architectural patterns like microservices, event-driven architectures, serverless, message queues, and distributed databases.</li><li><strong>Read Industry Case Studies:</strong> Sites like High Scalability, Netflix Tech Blog, Uber Engineering, Amazon Science, and Google AI Blog offer invaluable insights into how large-scale systems are built and operated.</li><li><strong>Practice with Real-World Problems:</strong> Take a hypothetical company (e.g., “design a real-time analytics platform for a million users”) and try to design it end-to-end. Diagram everything.</li><li><strong>Courses &amp; Books:</strong> Look for advanced courses on distributed systems, cloud architecture (AWS, Azure, GCP certifications), and books like “Designing Data-Intensive Applications” by Martin Kleppmann.</li></ul><h4>2. Technical Leadership &amp; Mentorship (Scaling Your Influence)</h4><ul><li><strong>What:</strong> This isn’t about managing people, but leading <em>ideas</em> and <em>initiatives</em>. It involves guiding technical discussions, driving consensus, elevating the skills of those around you, and setting high technical standards.</li><li><strong>How to learn:</strong></li><li><strong>Proactive Mentoring:</strong> Seek out opportunities to formally and informally mentor junior and mid-level engineers. Help them with career growth, not just code.</li><li><strong>Lead Design Reviews:</strong> Take ownership of facilitating design review meetings, asking probing questions, and ensuring robust solutions.</li><li><strong>Evangelize Best Practices:</strong> Advocate for coding standards, testing methodologies, and architectural principles through presentations, internal documentation, and code reviews.</li><li><strong>Conflict Resolution:</strong> Learn to mediate technical disagreements constructively, focusing on objective criteria and common goals.</li></ul><h4>3. Strategic Thinking &amp; Business Acumen (Connecting Tech to Value)</h4><ul><li><strong>What:</strong> Understanding <em>why</em> a feature is being built, not just <em>how</em>. Connecting technical decisions to business outcomes, user needs, and company strategy. This involves understanding market trends, competitive landscapes, and financial implications.</li><li><strong>How to learn:</strong></li><li><strong>Engage with Product &amp; Business Teams:</strong> Proactively attend product strategy meetings, ask “why” questions about requirements, and understand the user journey.</li><li><strong>Understand Your Company’s Metrics:</strong> Know your company’s KPIs (Key Performance Indicators) and how your team’s work contributes to them.</li><li><strong>Read Business News:</strong> Follow publications like Harvard Business Review, Wall Street Journal, or tech industry analysis sites to broaden your perspective.</li><li><strong>Propose Technical Solutions for Business Problems:</strong> Don’t just implement; identify technical opportunities that can unlock new business value or mitigate risks.</li></ul><h4>4. Communication &amp; Storytelling (Articulating Complex Ideas)</h4><ul><li><strong>What:</strong> The higher you go, the less you code and the more you communicate. You need to articulate complex technical ideas clearly, concisely, and persuasively to diverse audiences — engineers, product managers, executives, and even external stakeholders.</li><li><strong>How to learn:</strong></li><li><strong>Master Design Documents (RFCs/Tech Specs):</strong> Practice writing clear, comprehensive, and well-reasoned technical proposals.</li><li><strong>Presentation Skills:</strong> Give internal tech talks, present at team meetings, and volunteer to speak at company-wide events. Learn to tailor your message to your audience.</li><li><strong>Active Listening:</strong> Understand the concerns and perspectives of others before presenting your own solutions.</li><li><strong>Whiteboarding:</strong> Become proficient at explaining complex systems visually.</li></ul><h4>5. Influence Without Authority (The Art of Persuasion)</h4><ul><li><strong>What:</strong> In an IC role, you don’t have direct reports to “tell” what to do. You must inspire, persuade, and build consensus through your expertise, logical arguments, and collaborative spirit.</li><li><strong>How to learn:</strong></li><li><strong>Build Strong Relationships:</strong> Network across teams and departments. Trust is a powerful currency.</li><li><strong>Demonstrate Value Consistently:</strong> Be known as someone who delivers reliable, high-quality solutions.</li><li><strong>Empathy:</strong> Understand the motivations and constraints of other teams and stakeholders. Frame your proposals in a way that addresses their needs.</li><li><strong>Strategic Prototyping:</strong> Sometimes, the best way to persuade is to build a small, compelling prototype that proves a concept.</li></ul><h3>Your Strategic Learning Roadmap: Where to Focus</h3><ol><li><strong>Identify Your Passion:</strong> Do you love deep-diving into specific domains (Staff)? Or do you crave a broader, more strategic impact (Principal)? Your natural inclination will guide your path.</li><li><strong>Gap Analysis:</strong> Look at the skills listed above. Honestly assess your strengths and weaknesses. Where are your biggest gaps for your desired next role?</li><li><strong>Seek Out Opportunities:</strong></li></ol><ul><li><strong>Volunteer for Cross-Team Projects:</strong> This is invaluable for gaining system design experience and building influence.</li><li><strong>Lead a Critical Initiative:</strong> Ask to own the technical vision for a new feature or system.</li><li><strong>Join an Architecture Guild/Review Board:</strong> If your company has one, get involved to see how high-level decisions are made.</li><li><strong>Mentor Formally:</strong> Take on a designated mentee.</li></ul><ol><li><strong>Continuous Learning:</strong></li></ol><ul><li><strong>Dedicated Reading Time:</strong> Block out time each week for tech blogs, industry papers, and relevant books.</li><li><strong>Online Courses:</strong> Platforms like Coursera, edX, Udemy, and Pluralsight offer excellent advanced courses in system design, cloud architecture, and leadership.</li><li><strong>Conferences &amp; Meetups:</strong> Attend industry events to learn about emerging trends and network with peers.</li></ul><ol><li><strong>Document Your Impact:</strong> As you take on more significant responsibilities, explicitly document your contributions in terms of impact (e.g., “Led the redesign of X service, resulting in a 30% reduction in latency and saving $Y annually”). This will be crucial for promotion packets.</li></ol><h3>Don’t Wait For Permission</h3><p>The most effective way to advance on the technical ladder is to <strong>start acting like you’re already in the next role.</strong> Take initiative. Identify problems that aren’t “yours” but affect the broader system. Propose solutions. Lead discussions. Mentor.</p><p>The landscape for Senior Software Engineers is rich with opportunity. By intentionally developing a broader skill set and strategically seeking out challenges, you won’t just move to the next role — you’ll redefine it.</p><p>What’s your next move? Share your thoughts and aspirations in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4a5a536888c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Bugs to Better: A Performance Engineer’s Guide to Reliability Growth Testing]]></title>
            <link>https://medium.com/@yamokshverma/from-bugs-to-better-a-performance-engineers-guide-to-reliability-growth-testing-f3a9567d0041?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a9567d0041</guid>
            <category><![CDATA[reliability]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Fri, 19 Sep 2025 03:21:13 GMT</pubDate>
            <atom:updated>2025-09-19T03:21:13.697Z</atom:updated>
            <content:encoded><![CDATA[<p>As engineers, we’re excellent at finding bugs. We run unit tests, integration tests, and performance tests to hunt down and eliminate issues before they reach production. But this often gives us a simple pass/fail snapshot. It answers the question, “Does it work right now?”</p><p>What if you needed to answer a different question: “<strong>How reliable is our system, and how can we prove it’s getting better?</strong>”</p><p>This is the purpose of <strong>Reliability Growth Testing (RGT)</strong>. It’s a systematic process for not just finding failures, but for measuring and improving a system’s stability over time to meet a specific reliability target.</p><h3>What Exactly is Reliability Growth Testing?</h3><p>At its core, <strong>Reliability Growth Testing (RGT)</strong> is a procedure where you repeatedly test a system, find failures, implement robust fixes, and track the rate of improvement. The goal is to “grow” the system’s reliability to a desired level before release.</p><p>Think of it like learning to play a difficult piece of music on the guitar 🎸. You don’t just test yourself once.</p><ol><li>You play the piece (test).</li><li>You hit a wrong note (a failure).</li><li>You analyze why you made the mistake and practice that specific part (fix).</li><li>You play the whole piece again, tracking how many mistakes you make over time.</li></ol><p>Your goal is to see the time between mistakes get longer and longer until you can play the song perfectly. RGT applies this exact “practice-and-improve” logic to software.</p><h3>The RGT “Test-Find-Fix” Cycle 🔄</h3><p>RGT operates on a continuous loop. This cycle is the engine that drives reliability improvement.</p><h4>1. Set a Reliability Goal</h4><p>You can’t achieve a target you haven’t set. The goal for RGT is usually defined by a <strong>Service Level Objective (SLO)</strong>, often expressed as a <strong>Mean Time Between Failures (MTBF)</strong>. For example, your goal might be “The system must achieve an MTBF of 100 hours under a realistic production load.”</p><h4>2. Test Under Realistic Conditions</h4><p>You run the system under a workload that mimics real production traffic. This isn’t a short, 15-minute test. It’s often an <strong>endurance test</strong> that runs for many hours or even days. The total time the test runs is the <strong>Cumulative Test Time</strong>.</p><h4>3. Find and Analyze Failures</h4><p>When a failure occurs (e.g., a crash, a process hanging, a critical error), you stop the clock. The time the system ran successfully since the last failure is the <strong>inter-failure time</strong>. A dedicated team immediately begins a <strong>Root Cause Analysis (RCA)</strong> to understand the underlying bug. This isn’t about fixing the symptom; it’s about finding the deep-seated cause.</p><h4>4. Implement a Robust Fix</h4><p>Once the root cause is identified, developers implement a fix. It’s crucial that this fix is robust and verified, as an incomplete fix can cause the same failure to reappear later, skewing your reliability data.</p><h4>5. Repeat and Measure</h4><p>After the fix is deployed to the test environment, you reset the clock and resume the test. You continue this <strong>Test-Find-Fix</strong> cycle, logging each failure and the cumulative test time at which it occurred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ht55vQqr5ZXFmXNudG825g.png" /></figure><h3>Visualizing Progress: The Reliability Growth Curve 📈</h3><p>This is where the magic happens. By plotting the cumulative number of failures against the cumulative test time, you create a <strong>Reliability Growth Curve</strong>.</p><ul><li><strong>The X-axis:</strong> Cumulative Test Time</li><li><strong>The Y-axis:</strong> Cumulative Number of Failures</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hdrTqdSTNhWuJywNBm2zug.png" /></figure><p>Initially, you’ll likely find many failures close together, creating a <strong>steep curve</strong>. This is expected as you’re finding the most obvious bugs. As you implement robust fixes, the time between failures increases. This causes the curve to <strong>flatten out</strong>.</p><p>The flattening of the curve is the visual proof that your system’s reliability is <strong>growing</strong>. You can overlay your target MTBF on this chart to track whether you’re on a trajectory to meet your release criteria.</p><h3>Where Does RGT Fit?</h3><p>RGT is not a replacement for other forms of testing; it’s a complementary practice. It is most valuable during the later stages of the development lifecycle, such as:</p><ul><li><strong>Integration Testing:</strong> When different system components are first brought together.</li><li><strong>System and Acceptance Testing:</strong> To stabilize the entire system before release.</li><li><strong>Beta or Early Access Programs:</strong> Using real user traffic in a controlled manner to find and fix the final set of issues.</li></ul><p>It differs from <strong>Chaos Engineering</strong>, which tests for <em>unexpected</em> failure modes. RGT is designed to stabilize a system against its <em>expected</em> workload by finding and eliminating the inherent bugs within the code.</p><h3>Summary: Why Adopt Reliability Growth Testing?</h3><p>While traditional testing validates functionality, Reliability Growth Testing provides quantitative confidence. It moves the conversation from “Did we find all the bugs?” to “Have we met our reliability goal?”</p><p>By adopting RGT, you gain:</p><ul><li>A <strong>quantitative measure</strong> of your system’s current reliability (MTBF)</li><li><strong>Data-driven confidence</strong> that your software is stable enough for a production release.</li><li>A clear visual model to <strong>track progress</strong> and make informed release decisions.</li></ul><p>It’s the ultimate bridge between simply fixing bugs and strategically engineering a system that you can prove is dependable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a9567d0041" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Full Lifecycle: A Performance Engineer’s Detailed Guide to Building Unbreakable Systems]]></title>
            <link>https://medium.com/@yamokshverma/the-full-lifecycle-a-performance-engineers-detailed-guide-to-building-unbreakable-systems-6b3f703c7168?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b3f703c7168</guid>
            <category><![CDATA[chaos-engineering]]></category>
            <category><![CDATA[reliability-engineering]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Fri, 19 Sep 2025 03:12:30 GMT</pubDate>
            <atom:updated>2025-09-19T03:12:55.614Z</atom:updated>
            <content:encoded><![CDATA[<p>As performance engineers, we are the masters of speed and scale. Our world is defined by latency, throughput, and CPU utilization. But a system that is fast yet fragile delivers a poor user experience. True excellence comes from merging our expertise in performance with the principles of <strong>Reliability Engineering</strong>, a discipline dedicated to designing and maintaining consistently dependable systems.</p><p>This guide provides a comprehensive walk through of the <strong>Reliability Engineering Lifecycle</strong>, showing how reliability is a continuous practice, not a one-time task.</p><h3>1. Requirements and Planning</h3><p>This initial phase is where the foundation for reliability is laid. Clear goals are set, and potential risks are identified before a single line of code is written.</p><ul><li><strong>Define Service Level Objectives (SLOs):</strong> We move from vague goals like “the site should be fast” to precise, user-centric promises. An SLO is a measurable target for a Service Level Indicator (SLI), such as uptime, latency, or error rate. For example: “<strong>99.9%</strong> of API login requests will complete successfully in under <strong>400ms</strong>.”</li><li><strong>Create Error Budgets:</strong> Based on the SLO, an <strong>error budget</strong> defines the acceptable amount of unreliability. If the SLO is 99.9%, the error budget is 0.1%. This budget is a powerful tool that allows development teams to balance the pace of innovation with system stability. When the budget is depleted by outages or performance issues, feature development is paused to focus on reliability.</li><li><strong>Conduct Risk Assessment:</strong> We proactively hunt for what could go wrong. A <strong>Failure Mode and Effects Analysis (FMEA)</strong> is a structured process to identify potential failure points (e.g., database timeout, third-party API failure), analyze their impact on users, and prioritize them for mitigation.</li></ul><h3>2. Design and Architecture</h3><p>During this phase, reliability is built directly into the system’s structure. As a performance engineer, you’ll recognize many of these patterns as essential for scalability as well.</p><ul><li><strong>Design for Resilience:</strong> We implement design patterns to make the system resistant to failure.</li><li><strong>Retries &amp; Timeouts:</strong> For transient failures, clients should retry requests with exponential backoff. Every network call should have a timeout to prevent it from hanging indefinitely.</li><li><strong>Circuit Breakers:</strong> This pattern prevents cascading failures. If a downstream service is failing, the circuit breaker “trips” and stops sending requests to it for a period, allowing it to recover.</li><li><strong>Bulkheads:</strong> This pattern isolates system components. A failure in a non-critical component (like a recommendation service) won’t exhaust resources and take down the entire application.</li><li><strong>Ensure Fault Tolerance and Redundancy:</strong> We incorporate redundant components to prevent a single point of failure. This means running multiple copies of servers, databases, and load balancers, often in different physical locations (e.g., active-active or active-passive setups).</li><li><strong>Plan for Observability:</strong> We build in instrumentation from the beginning. This isn’t just about monitoring; it’s about providing rich <strong>logs</strong>, <strong>metrics</strong>, and <strong>traces</strong> (the three pillars of observability) that allow us to understand the system’s internal state and diagnose novel problems in production.</li></ul><h3>3. Implementation and Development</h3><p>This stage focuses on writing reliable code and building automated processes that support reliability throughout the continuous integration/continuous delivery (CI/CD) pipeline. It’s about fostering a culture where every developer understands their role in maintaining the SLOs.</p><h3>4. Testing and Quality Assurance</h3><p>Testing activities in this phase are explicitly aimed at validating reliability, going far beyond functional correctness. This is where a performance engineer’s skills are directly applicable.</p><ul><li><strong>Chaos Testing:</strong> We intentionally inject faults into the system (e.g., shutting down a server, introducing network latency) to test its resilience and ability to recover under pressure. It’s the practice of finding weaknesses before your users do.</li><li><strong>Load and Stress Testing:</strong> We assess the system’s performance under heavy and unexpected workloads to find performance bottlenecks before they become reliability issues.</li><li><strong>Endurance Testing:</strong> We run the system under a significant load for an extended period to uncover subtle issues like memory leaks or resource exhaustion that only appear over time.</li><li><strong>Validate SLOs:</strong> We design specific tests to ensure that our SLIs can meet the targets defined in our SLOs under various conditions.</li></ul><h3>5. Deployment</h3><p>This stage focuses on minimizing the risk of introducing new issues into the production environment.</p><ul><li><strong>Use Progressive Delivery:</strong> We deploy new versions using strategies like <strong>canary releases</strong> (releasing to a small subset of users first) or <strong>blue/green deployments</strong> (running two identical production environments). This allows us to test a new version with real traffic before a full rollout.</li><li><strong>Implement Automated Rollbacks:</strong> Deployments are closely monitored. If key SLOs are violated after a release, the system should automatically roll back to the previous stable version.</li><li><strong>Integrate Release Gates:</strong> We use metrics and SLOs as automated “gates” in the CI/CD pipeline. A deployment is automatically prevented from proceeding if reliability targets are not met in the staging environment.</li></ul><h3>6. Operations and Maintenance</h3><p>Reliability engineering does not end with deployment. This phase is a continuous loop of monitoring, incident response, and improvement.</p><ul><li><strong>Monitor SLOs and Error Budgets:</strong> We continuously monitor system performance against our SLOs. The status of our error budget is a key metric that informs our development priorities.</li><li><strong>Incident Response:</strong> When an incident occurs, we follow a structured process to mitigate the impact and restore service. The most crucial part is the <strong>blameless postmortem</strong>, where we analyze the root cause and create actionable plans to prevent the issue from recurring.</li><li><strong>Practice Continuous Improvement:</strong> The feedback loop is everything. Insights from incidents, postmortems, and performance data are used to refine the design, address technical debt, and strengthen the system. Production data informs the entire lifecycle for all future iterations.</li></ul><h3>Summary: From Fast to Fault-Tolerant</h3><p>For a performance engineer, the journey into reliability is a natural evolution. It’s about expanding our focus from a system’s behavior under ideal conditions to its resilience under chaotic, real-world conditions.</p><p>This lifecycle provides a comprehensive framework:</p><ol><li><strong>Plan</strong> with clear, measurable goals (<strong>SLOs</strong> and <strong>Error Budgets</strong>).</li><li><strong>Design</strong> resilience directly into the architecture using patterns like <strong>Circuit Breakers</strong> and <strong>Redundancy</strong>.</li><li><strong>Implement</strong> with a culture of reliability.</li><li><strong>Test</strong> not just for peak performance, but for graceful failure using <strong>Chaos</strong> and <strong>Endurance Testing</strong>.</li><li><strong>Deploy</strong> safely with <strong>Progressive Delivery</strong> and automated rollbacks.</li><li><strong>Operate</strong> with a continuous feedback loop, learning from every incident through <strong>Blameless Postmortems</strong>.</li></ol><p>By embracing this lifecycle, we move from being reactive firefighters to proactive architects of robust systems. We shift our goal from simply making things fast to making them fundamentally trustworthy. The result is a system that delivers an excellent user experience not just on a good day, but every day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b3f703c7168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Basic Storage Engine: A Deep Dive into Log Structured Systems]]></title>
            <link>https://medium.com/@yamokshverma/building-a-basic-storage-engine-a-deep-dive-into-log-structured-systems-935f7172dd5f?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/935f7172dd5f</guid>
            <category><![CDATA[lsm]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 14:02:30 GMT</pubDate>
            <atom:updated>2025-04-23T14:02:30.036Z</atom:updated>
            <content:encoded><![CDATA[<p>At the heart of every database lies a critical component: the <strong>storage engine</strong>. This unsung hero is responsible for the behind-the-scenes magic of storing, retrieving, and managing your precious data, both in memory and on disk. Understanding the intricacies of storage engines is crucial for selecting the right database for your needs.</p><p>This blog post focuses on <strong>Log Structured storage engines</strong>, contrasting them with their Page Oriented counterparts, and walks you through building a basic system with a hash index for enhanced read performance.</p><h3>Log Structured vs. Page Oriented: Understanding the Difference</h3><p>Before diving into the nitty-gritty, let’s differentiate between the two most popular storage engine types:</p><ul><li><strong>Log Structured:</strong> Imagine a constantly growing journal. That’s the essence of a log structured engine. It treats the database as an append-only log file where new data is sequentially added to the end, resembling systems like Log Structured Merge Trees (LSM Trees).</li><li><strong>Page Oriented:</strong> Picture a neatly organized library with fixed-size pages. This is the approach of page oriented engines, like B-Trees, where data is divided into fixed-size pages, historically 4KB, allowing for efficient page-by-page reads and writes.</li></ul><h3>Building a Basic Log Structured Engine</h3><p>Our focus today is on the elegance and efficiency of log structured engines. Our goal is to build a simple system capable of handling key-value pairs with two core functions:</p><ol><li>db_set(key, value)<strong>:</strong> Stores a key-value pair, updating the value if the key already exists.</li><li>db_get(key)<strong>:</strong> Retrieves the value associated with a given key, returning null if the key is absent.</li></ol><p><strong>The Append-Only Powerhouse</strong></p><p>At its core, our engine maintains a log — an append-only sequence of records containing our key-value pairs. This log, often in a binary format, grows with every db_set operation as new pairs are appended to the end.</p><p>This append-only strategy offers a significant performance advantage: sequential writes. Sequential writes are significantly faster than random writes, especially on traditional spinning-disk hard drives and, to some extent, even on solid state drives.</p><p><strong>The Challenge of Reads and the Index Solution</strong></p><p>While db_set enjoys O(1) time complexity thanks to efficient appending, db_get presents a challenge. Searching the entire log for a key leads to O(n) time complexity—a potential bottleneck as our log grows.</p><p>This is where the power of indexing comes into play.</p><p><strong>Hash Indexes: Speeding Up Reads</strong></p><p>Database indexes act as intelligent look-up tables, offering shortcuts to locate data within our log. A <strong>hash index</strong>, implemented as an in-memory hash table, provides an elegant solution for our engine.</p><p>Each key in our log becomes a key in our hash table. The value associated with this key in the hash table is the byte offset in the log file where the corresponding key-value pair resides. This allows for near-instantaneous lookups.</p><p><strong>Managing Growth: Segmentation and Compaction</strong></p><p>As our database grows, we inevitably face disk space limitations. The solution: segmentation.</p><p>We break our log into smaller segments. Once a segment reaches a predetermined size, it’s closed, and subsequent writes are directed to a new segment. This segmentation strategy enables a powerful optimization: <strong>compaction</strong>.</p><p>Compaction, running in the background, merges older segments and removes duplicate entries, keeping only the most recent value for each key. This ensures disk space efficiency and maintains optimal read performance.</p><p><strong>Real-World Inspiration: The Bitcask Engine</strong></p><p>The methodology we’ve explored closely resembles <strong>Bitcask</strong>, a robust storage engine powering the Riak database. Bitcask, written in Erlang, further enhances this model by persisting snapshots of in-memory hash tables to disk, ensuring data recovery in case of crashes. You can delve deeper into the nuances of Bitcask in their <a href="https://gen-studio.app.intuit.com/studio/link-to-bitcask-whitepaper"><strong>whitepaper</strong></a>.</p><p><strong>Challenges and Future Exploration</strong></p><p>While powerful, log structured engines with hash indexes present certain limitations:</p><ul><li><strong>Memory Constraints:</strong> The hash table must reside in memory for optimal performance, limiting scalability for datasets larger than available RAM.</li><li><strong>Range Query Inefficiency:</strong> Scanning ranges of keys (e.g., all keys starting with ‘a’) requires individual lookups, making range queries inefficient.</li></ul><p>Addressing these challenges requires exploring more sophisticated indexing structures and data organization techniques, which we’ll delve into in future posts. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=935f7172dd5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating PostgreSQL Wraparound: Comprehensive Strategies for Data Integrity and System Efficiency]]></title>
            <link>https://medium.com/@yamokshverma/navigating-postgresql-wraparound-comprehensive-strategies-for-data-integrity-and-system-efficiency-f6ce1c6183e8?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6ce1c6183e8</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 13:50:04 GMT</pubDate>
            <atom:updated>2025-04-23T13:50:04.036Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction to PostgreSQL and Transaction ID (XID) Wraparound:</strong><br>A well-known and respected name in relational database technology, PostgreSQL provides strong features that guarantee data consistency and dependability. To avoid interruptions that might jeopardize data integrity, database administrators must be aware of some of its less obvious maintenance features, particularly the transaction ID (XID) wraparound.</p><p><strong>Deep Dive into XID Wraparound:</strong><br>In PostgreSQL, each transaction is given a distinct Transaction ID (XID) at the time of execution. In addition to designating the transaction, this ID aids in controlling data visibility across multiple ongoing transactions. Similar to an odometer, the XID is a limited resource that can record up to two billion transactions before wiping out, a process called “wraparound.” Despite being effective, this system may cause PostgreSQL to incorrectly interpret transaction ages, marking recent transactions as out-of-date. This could result in serious data inconsistencies or a sudden system failure.</p><p><strong>Autovacuum: PostgreSQL’s Built-in Mechanism Against Wraparound:</strong><br>Autovacuum plays a crucial part in maintaining the integrity of databases. It does this by periodically going through the database, clearing out old transactions and putting very old ones in a “frozen” state, which essentially resets their age. This procedure avoids a wraparound situation by keeping the transaction count from approaching the two-billion mark.<br>However, the autovacuum’s configuration has a significant impact on how effective it is. It needs to be adjusted to strike a balance between maintenance frequency and performance impact, which differs significantly depending on the workload and use case of the database.</p><p><strong>Identifying Early Signs of Potential Wraparound Issues:</strong><br>Recognizing early symptoms can prevent catastrophic outcomes. These signs include:</p><ul><li><strong>Warning Logs</strong>: PostgreSQL will log a warning when a database is nearing the need for a vacuum operation critical to prevent wraparound.</li><li><strong>Slowed Performance</strong>: Unusual slowdowns in query response times can indicate that autovacuum is struggling to process a backlog of data needing freezing.</li><li><strong>System Logs and Monitoring Tools</strong>: Tools like pgAdmin or custom scripts can help monitor autovacuum activity and transaction ages across the database.</li></ul><p><strong>Proactive Measures for Wraparound Prevention:</strong><br>Adopting a proactive stance can significantly mitigate the risks associated with XID wraparound. Here are key strategies:</p><ol><li><strong>Optimize Autovacuum Configuration</strong>:</li></ol><ul><li>autovacuum_freeze_max_age: Ensure this setting is low enough to trigger frequent enough vacuums to prevent wraparound.</li><li>autovacuum_vacuum_scale_factor and autovacuum_vacuum_threshold: These settings determine when autovacuum triggers based on the number of updated rows and should be configured to reflect typical usage patterns.</li></ul><p><strong>2. Regular and Manual Vacuuming</strong>:</p><ul><li>For particularly large or seldom-modified tables, a manual VACUUM FREEZE might be necessary to ensure that all rows are correctly frozen.</li><li>Strategic scheduling of these operations during low-traffic periods can minimize the impact on database performance.</li></ul><p><strong>3. Routine Monitoring</strong>:</p><ul><li>Regular checks using SQL queries can provide insights into the age of data and forecast potential wraparound risks.</li><li>Advanced monitoring setups can automatically alert administrators when critical thresholds are approaching.</li></ul><p><strong>4. Database Updates</strong>:</p><ul><li>Keeping PostgreSQL up to date ensures access to the latest optimizations and features related to transaction handling and vacuum processes, further safeguarding against potential wraparound events.</li></ul><p><strong>Wrapping Up:</strong><br>Although the idea of XID wraparound may seem overwhelming, it is a completely manageable part of PostgreSQL administration with the correct combination of knowledge, planning, and proactive management. The defensive trifecta of routine maintenance, attentive monitoring, and timely updates keeps your PostgreSQL databases operating smoothly, effectively, and — above all — constantly accessible for business operations. By doing this, PostgreSQL not only upholds its reputation as a trustworthy data steward but also accommodates changing business requirements without sacrificing security or performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6ce1c6183e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behind the Scenes: Performance Testing of Backend Services]]></title>
            <link>https://medium.com/@yamokshverma/behind-the-scenes-performance-testing-of-backend-services-a990390bd6ea?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a990390bd6ea</guid>
            <category><![CDATA[load-test-script]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[performance-test]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 11:08:18 GMT</pubDate>
            <atom:updated>2025-04-23T11:09:27.980Z</atom:updated>
            <content:encoded><![CDATA[<p>In the age of modern software, a stunning UI is useless if the backend can’t keep up. With millions of users tapping, clicking, and swiping their way through, ensuring that your backend services are equipped to handle the load isn’t merely intelligent practice – it’s survival. Performance testing is the trump card that lets developers and ops teams build systems that stay fast, responsive, and reliable under load.</p><p>This article dives deep into the world of performance testing: its various forms, how big tech companies test their services at scale, what’s new in the field, and where it’s headed next.</p><h3>The Spectrum of Performance Testing</h3><p>Performance testing is a broad category, covering many different tests, each with a unique purpose:</p><ul><li><strong>Load testing: </strong>Simulates system behavior under expected usage. It tells you if your system can handle the average day.</li><li><strong>Stress Testing:</strong> Pushes the system to its breaking point to observe how it fails – and if it bounces back. Resilience is the goal here.</li><li><strong>Spike Testing:</strong> Simulates sudden and extreme bursts in load. This is useful for scenarios like flash sales or viral promotions.</li><li><strong>Soak Testing (Endurance Testing):</strong> Ensures system stability over a long period of time. Memory leaks, depletion of DB connections, and disk space issues usually arise here.</li><li><strong>Scalability Testing:</strong> This tests how horizontally or vertically scalable your system is with increasing load.</li><li><strong>Configuration Testing: </strong>Tests different configurations of infrastructure to determine the best performing configuration.</li></ul><p>Each of them has its own reason for creating a performance profile for your application.</p><h3>Load Testing at Scale: Insights from Big Tech Giants</h3><p>Big tech companies operate at a scale where even milliseconds of latency can translate into significant revenue loss and a degraded user experience. To ensure resilience and optimal performance, they employ sophisticated load testing strategies. Let’s delve into the approaches of a few industry leaders:</p><h4>Netflix</h4><p>Netflix places a strong emphasis on resilience and failure testing. Their Failure Injection in Distributed Operations (FIDO) system is indeed a cornerstone, allowing them to simulate various failures and observe how their distributed systems degrade in real-time. This proactive approach helps identify weaknesses before they impact users.</p><p>Beyond FIDO, Netflix actively practices chaos engineering, intentionally injecting faults across their infrastructure to build confidence in their systems’ ability to withstand unexpected issues.</p><p>For load testing, while they might leverage open-source tools, Netflix has also developed internal, highly scalable frameworks tailored to their unique streaming ecosystem. These frameworks simulate millions of concurrent users accessing streaming content, authenticating logins, and interacting with their extensive APIs. They likely extend tools like Gatling or develop proprietary solutions to handle the complexities of video streaming protocols and global content delivery networks.</p><h4>Amazon</h4><p>Amazon prioritizes rigorous testing under production-like conditions. They utilize sophisticated synthetic traffic generation tools that meticulously mimic real-world user workloads, including various user journeys and transaction types.</p><p>Their well-known “GameDay” simulations involve running full production-scale traffic against their systems during controlled off-peak hours. These exercises are crucial for validating the readiness and scalability of their infrastructure and applications under extreme load.</p><p>Canary deployments are another vital aspect of Amazon’s release strategy. By gradually rolling out new service versions to a small subset of users and closely monitoring their performance under real load, they can detect and mitigate potential issues before a full-scale deployment, minimizing user impact.</p><h4>Google</h4><p>Google employs intent-based load testing, a sophisticated methodology where performance test scenarios are directly derived from anticipated user behavior patterns and business goals. This ensures that testing aligns with real-world usage and critical user flows.</p><p>Their infrastructure monitoring has evolved. While Borgmon was a foundational system, Google now widely utilizes Prometheus (which originated within Google as Borgmon’s successor) and their internal monitoring tools to gain real-time visibility into key performance indicators during load tests.</p><p>Google places significant emphasis on Service Level Objectives (SLOs), particularly around latency. Their load testing practices are designed to ensure that these stringent latency targets are consistently met, even during massive traffic surges. They likely employ advanced techniques to model and simulate peak load scenarios, including flash crowds and viral events.</p><h4>Uber</h4><p>Uber operates a highly complex, distributed system that powers ride-sharing, food delivery (Uber Eats), and other services. Their load testing needs to address the intricacies of real-time dispatch systems, mapping services, payment processing, and a massive number of concurrent users and drivers.</p><p>Based on their blog posts, here are some key aspects of how Uber likely approaches load testing:</p><ul><li>Traffic Replay: Uber has developed tools like Ballast, an adaptive load testing framework that leverages traffic capture using Berkeley Packet Filter (BPF). This allows them to capture real-world traffic patterns from their services and replay them in a controlled testing environment. This ensures that the load tests accurately reflect production usage.</li><li>Adaptive Load Generation: Ballast uses a PID (Proportional-Integral-Derivative) controller mechanism to dynamically adjust the number of requests per second (RPS) sent to the target service. This adaptive approach helps in efficiently stressing the system and identifying its breaking points.</li><li>Golden Signals Monitoring: During load tests, Uber monitors the “four golden signals” (latency, traffic, errors, and saturation) of the tested service using their metrics platform (M3). Ballast uses these signals to understand the service’s health and availability under load and to automatically stop the test when predefined Service Level Objectives (SLOs) are reached (e.g., CPU usage exceeding a certain threshold).</li><li>Load Shedding Behavior Testing: Uber utilizes Ballast to specifically test the behavior of their load shedding mechanisms. By injecting various combinations of requests with different priorities, they can ensure that the system correctly drops lower-priority requests under heavy load, preserving the quality of service for critical functions.</li><li>Short-Lived Application Testing Environments (SLATE): To overcome the limitations of shared staging environments, Uber has built SLATE. This system allows developers to create on-demand, ephemeral testing environments within the production infrastructure. This provides isolated and realistic environments for load testing individual services without impacting other teams or production traffic. Test traffic is isolated using tenancy injection and routing overrides.</li><li>Continuous Load Testing: While not detailed as extensively as at some other companies, Uber emphasizes the importance of integrating load testing into their CI/CD pipelines. This allows them to detect performance regressions early in the development cycle with every deployment.</li></ul><h3>New Advancements in Performance Testing</h3><p>As cloud-native architectures become the norm, performance testing is evolving in these key ways:</p><ul><li><strong>Serverless Load Testing:</strong> Tools now support testing AWS Lambda, Azure Functions, and Google Cloud Functions at scale, considering cold start times and concurrency limits.</li><li><strong>AI-Driven Test Generation: </strong>Machine learning models analyze real user traffic and auto-generate performance test scenarios, reducing manual effort.</li><li><strong>Distributed Testing as a Service:</strong> Platforms like k6 Cloud, BlazeMeter, and Artillery Pro enable massive-scale testing from global locations without managing infrastructure.</li><li><strong>Observability Integration: </strong>Performance tests are now tightly integrated with observability stacks (e.g., Grafana, Datadog, OpenTelemetry) to give real-time insights and root cause analysis.</li><li><strong>Shift-left Performance Testing: </strong>Performance testing is moving earlier in the CI/CD pipeline, with lightweight tools running during PR reviews or pre-merge checks.</li></ul><h3>The Future of Load Testing</h3><p>Looking ahead, performance testing will be smarter, faster, and more embedded in the development lifecycle:</p><p>•	Autonomous Performance Testing: Future systems will auto-detect performance regressions, run targeted tests, and suggest optimizations without human intervention.</p><p>•	Performance Testing in Production (with Safety Nets): As deployments become more continuous, testing in prod environments with real traffic but scoped impact will become common.</p><p>•	Digital Twin for Testing: Simulated replicas of full production environments will be used to test under realistic conditions, without impacting real users.</p><p>•	Unified Testing Strategy: Functional, security, and performance testing will merge into a single pipeline to ensure complete coverage with minimal duplication.</p><p>•	Performance as a KPI: More organizations will treat performance as a first-class KPI, with incentives tied to reducing latency and improving throughput.</p><h3>Conclusion</h3><p>Performance testing is no longer just a checkbox before release – it’s a strategic advantage. As applications grow more complex and users more demanding, the ability to proactively test, detect, and resolve performance bottlenecks becomes a must-have skill.</p><p>Whether you’re testing a small API or managing infrastructure that supports millions, investing in the right kind of performance testing can be the difference between delighting users and losing them. Want to go deeper? Explore tools like k6, Locust, Artillery, and JMeter to start crafting your own performance testing stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a990390bd6ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KubeCon + CloudNativeCon India 2024 — Experience Unveiled]]></title>
            <link>https://medium.com/@yamokshverma/kubecon-cloudnativecon-india-2024-experience-unveiled-cb900d8a6344?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb900d8a6344</guid>
            <category><![CDATA[kubecon]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloudnativecon]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 08:49:16 GMT</pubDate>
            <atom:updated>2024-12-14T08:49:16.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>KubeCon + CloudNativeCon India 2024 — Experience Unveiled</h3><p>A grand event unfolded on the 11th and 12th of December, 2024, at the vibrant Yashobhoomi venue in New Delhi, India.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcU2O5pIN6vDIrQUMlyl0g.png" /><figcaption>KubeCon + CloudNativeCon 2024</figcaption></figure><p>The conference buzzed with excitement around several leading-edge topics, but some of the most captivating discussions were centered on Cloud Native AI and the ever-expanding Kubernetes ecosystem. These technologies are not just growing; they are evolving at a pace that is hard to keep up with, offering a plethora of tools tailored to meet a variety of use cases. For an elaborate view of this expanding landscape, take a look at <a href="https://landscape.cncf.io/?group=cnai">the Cloud Native landscape here</a>.</p><h4>Key Learning</h4><p>The two-day conference was packed with insightful sessions including:</p><ul><li><a href="https://drive.google.com/file/d/1W8dPshPK2QoN_b0rLNgaSoK8n1f2BzQD/view?usp=sharing">Istio adoption at Flipkart: Learn how one of India’s e-commerce giants is leveraging Istio for their microservices architecture.</a></li><li><a href="https://drive.google.com/file/d/1OXSsZQBWGBE10TATHTaSTw-E3kbk6LMF/view?usp=sharing">Cilium: Connecting, Observing, and Securing Kubernetes and Beyond with eBPF</a></li><li><a href="https://drive.google.com/file/d/12eThrLrm1hn1jtWDV4Nh6RvgbMzQXyIL/view?usp=sharing">GenAI + Kubernetes at Shopify: Old school reliability saves the day for modern workloads!</a></li><li><a href="https://drive.google.com/file/d/1j1sB-f7b1KcXtYsJIMisLkktiFWfL041/view?usp=sharing">Unleashing Generative AI with Open Data Hub: Discover the potential of open-source tools in powering AI initiatives.</a></li><li><a href="https://drive.google.com/file/d/1XmlLhPqvmTQSIi_CcGe8RBYIK9CiCQ5U/view?usp=sharing">Expedia Group’s journey to implement GitOps with ArgoCD</a></li><li><a href="https://drive.google.com/file/d/1WxxIpzUxjMn1eDxUn7CyPTNSEMQA9H4E/view?usp=sharing">Developing Kubernetes Applications Beyond Go</a></li><li><a href="https://www.youtube.com/watch?v=xF0h-vHgyvU">Inside Argo: Automating the future</a></li></ul><p>There were many more sessions which you can find <a href="https://kccncind2024.sched.com/overview/area/Yes">here.</a></p><h4>Who should attend and Why?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NID-P2ggDG5Nyt0qN2pP0A.jpeg" /><figcaption><strong>The Road to Mandala</strong></figcaption></figure><p><strong><em>KubeCon + CloudNativeCon</em></strong> is the ultimate gathering for technology enthusiasts, especially those passionate about open source and Kubernetes. It’s not only an excellent opportunity for learning and expanding one’s knowledge but also a prime networking venue.</p><p>If you are keen on advancing in the tech world and following new developments in cloud-native technologies, this conference is a crucial date in your calendar.</p><h4>Conclusion</h4><p>At the last conference I attended, which focused on Contributing to Kubernetes, one of the standout presentations was given by a student. He spoke about his experience contributing to Kubernetes and highlighted the importance of starting small, embracing errors, and maintaining consistency. His narrative inspired hundreds of engineers, reinforcing the idea that modest beginnings and perseverance can lead to substantial success in the technology field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-OdLaJVBmkpho-QGnvDQ2A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibc-1LMFIuMjSmY219CpUA.jpeg" /></figure><p>All sessions will be available on the <a href="https://www.youtube.com/@cncf">CNCF YouTube channel</a> shortly after the event’s conclusion. Ready yourself for a wealth of information, inspiration, and networking at upcoming <a href="https://www.cncf.io/kubecon-cloudnativecon-events/">KubeCon + CloudNativeCon events</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb900d8a6344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Low Level Design — for SDE1/SDE2]]></title>
            <link>https://medium.com/@yamokshverma/low-level-design-for-sde1-sde2-752926e5bd6a?source=rss-6984c93809a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/752926e5bd6a</guid>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[lld]]></category>
            <category><![CDATA[low-level-design]]></category>
            <category><![CDATA[solid]]></category>
            <dc:creator><![CDATA[Yamoksh Verma]]></dc:creator>
            <pubDate>Mon, 27 May 2024 12:33:57 GMT</pubDate>
            <atom:updated>2024-05-27T12:33:57.023Z</atom:updated>
            <content:encoded><![CDATA[<h3>Low Level Design — for SDE1/SDE2</h3><p>Following the coding round in a software engineer interview, questions about low-level design are commonly posed to SDE 1 and SDE 2 candidates. To date, I have conducted over 100 interviews for Intern, SDE 1, and SDE 2 positions. Based on my experience, I have noticed that many candidates are unprepared for low-level design questions. This is often due to their limited hands-on experience in software development, including coding and design principles.</p><h3>Understanding Low-Level Design with an example</h3><p>Low-level design is the phase in the software engineering process that involves breaking down high-level design components into smaller, manageable, and more detailed parts. It often includes defining data models, detailed algorithms, and precise interface specifications.</p><p>let’s dive into an example to better understand low-level design with a use case. We will explore the design of a simple yet common system — a URL shortening service similar to bit.ly.</p><p><strong><em>Use Case</em></strong>: Design a URL Shortening Service</p><p><strong>Overview</strong><br>A URL shortening service allows users to input a long URL, and it generates a shorter, unique alias that redirects users to the original URL when accessed. This service is particularly useful for sharing links on platforms with character limits or for simplifying complex URLs.</p><p><strong>Requirements</strong></p><ol><li>The short link should be a unique identifier that maps to the original URL.</li><li>The service should handle redirects efficiently.</li><li>The service should handle high traffic with minimal latency.</li><li>The server should log basic usage stats (e.g., click counts).</li></ol><p><strong>Low-Level Design Components</strong></p><ol><li><strong><em>Data Model:</em></strong></li></ol><p>URLMap Table: To store mappings between the shortened URL code and the original URL.</p><pre>Fields: id (primary key), original_url, short_url, created_at, accessed_count, etc.</pre><p><strong><em>2. API Endpoints:</em></strong></p><p>To create a short URL from the given original URL.</p><pre>POST /shorten</pre><p>To redirect to the original URL associated with the given short code.</p><pre>GET /{shortCode}</pre><p>3. <strong><em>Algorithms:</em></strong></p><ul><li><em>Hashing</em>: Employ a hashing function to generate the unique part of the shortened URL. Consider using MD5 of the original URL and encode a portion of it in base62 ([a-zA-Z0–9]) to ensure it is alphanumeric and URL-friendly.</li><li><em>Collision Handling:</em> Since hash functions may generate the same hash for different inputs, implement a collision resolution strategy, such as appending or changing characters until a new non-colliding hash is generated.</li></ul><p>4. <strong><em>Service Classes and Methods:</em></strong></p><p><strong><em>Class:</em></strong> <em>URLService</em></p><p><strong>Methods:</strong></p><ol><li><em>createShortLink(originalUrl)</em>: Takes the original URL, applies hashing, checks for collisions, and stores the mapping in the URLMap table.</li></ol><ul><li><em>getOriginalUrl(shortCode)</em>: Retrieves the original URL from the URLMap table using the short code, increments the accessed_count, and handles the redirection.</li></ul><p><strong><em>5. Infrastructure:</em></strong></p><ul><li><em>Databases</em>: Select a fast lookup database like Redis for caching frequently accessed URLs and a persistent database like PostgreSQL for long-term storage.</li><li><em>Load Balancing: </em>To distribute traffic evenly across servers.</li><li><em>Caching: </em>Implement caching strategies to keep popular URLs in-memory for faster retrieval.</li></ul><p>6<strong><em>. Monitoring and Logging:</em></strong></p><ul><li>Set up monitoring to track system health, like server loads and response times.</li><li>Implement logging to record access patterns, errors, and system anomalies.</li><li>Provide analytics, such as a dashboard that displays click counts and popular URLs.</li></ul><p>Let’s visit the SOLID design principles and how they would apply to ensure a robust low-level design.</p><p><strong>SOLID</strong> is an acronym for the following five principles:</p><p><strong>1. Single Responsibility Principle (SRP): </strong>SRP states that a class should have one, and only one, reason to change, meaning it should have only one job or responsibility.</p><p><em>In our URL shortening service:</em> The URLService class could be responsible exclusively for managing URL-related operations such as creating short links and fetching original URLs. Another class, such asStatsService, would handle statistics and logging, ensuring that the roles are clearly defined and separate.</p><p><strong>2. Open/Closed Principle (OCP): </strong>According to OCP, software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.</p><p><em>For the URL Service:</em> When adding new features like custom short URL aliases or additional metadata storage, it should be possible to extend the existing services without altering the core functionality significantly, ensuring backward compatibility and minimal regression.</p><p><strong>3. Liskov Substitution Principle (LSP): </strong>The LSP indicates that objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.</p><p><em>In our system:</em> If we have a superclass that represents a genericDataService class used throughout the system, any subclass likeURLDataServiceshould be directly substitutable without disturbing the application’s operations.</p><p><strong>4. Interface Segregation Principle (ISP)</strong><br>ISP advises that clients should not be forced to depend on interfaces they do not use.</p><p><em>Applied to our service:</em> Instead of having a monolithicServiceInterfacewith unused methods, we can create more granular interfaces likeIURLShortener for URL shortening andIStatsRecorder for logging and statistics. This allows different clients to interact with only the parts of the service that are relevant to them.</p><p><strong>5. Dependency Inversion Principle (DIP)</strong><br>DIP suggests that high-level modules should not depend on low-level modules; both should depend on abstractions. Additionally, abstractions should not depend on details; details should depend on abstractions.</p><p><em>Within our URL service:</em> The high-level components like the service handlers should depend on abstract interfaces or base classes rather than concrete implementations of databases or cache systems. This way, if the implementation details of the database change, the high-level modules remain unaffected.</p><p>These SOLID principles support a design that is resilient, adaptive, and maintainable, allowing the system to evolve over time with minimal disruption. As we construct our URL shortening service, adhering to these principles ensures that our design remains clear, flexible, and scalable — attributes highly coveted in the realm of software development.</p><h3>Conclusion</h3><p>Low-level design is not just an interview hurdle, but a necessary skill set that distinguishes competent software engineers from the rest. It is an advocate for your ability to turn theoretical concepts into concrete, operational components of software. For aspiring SDEs, mastering LLD will undoubtedly pave the path to success in their roles and beyond.</p><p>Whether preparing for your next interview or looking to strengthen your software engineering skills, remember that understanding and applying low-level design principles will serve you in every line of code you write. So, keep practicing, keep designing, and let your code speak for itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=752926e5bd6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>