<?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 Kethavath prakash on Medium]]></title>
        <description><![CDATA[Stories by Kethavath prakash on Medium]]></description>
        <link>https://medium.com/@prakashk23?source=rss-e857421919e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3D11aFsGxS5slDHF</url>
            <title>Stories by Kethavath prakash on Medium</title>
            <link>https://medium.com/@prakashk23?source=rss-e857421919e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:57:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prakashk23/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[You finally finished the feature you had been working on for two weeks.The]]></title>
            <link>https://medium.com/@prakashk23/you-finally-finished-the-feature-you-had-been-working-on-for-two-weeks-the-6837d762258d?source=rss-e857421919e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6837d762258d</guid>
            <dc:creator><![CDATA[Kethavath prakash]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 09:42:38 GMT</pubDate>
            <atom:updated>2026-08-02T09:42:38.166Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>I Thought Backend Engineering Was About Code Until Production Proved Me Wrong</em></strong></blockquote><blockquote>It was a Friday evening.</blockquote><p>You finally finished the feature you had been working on for two weeks.The pull request was approved.The CI pipeline was green.All tests passed.The deployment completed successfully.You open the monitoring dashboard:</p><ul><li>CPU usage: normal</li><li>Memory usage: normal</li><li>Database: healthy</li><li>API health check: passing</li></ul><p>Everything looks perfect.You close your laptop with the satisfying feeling every developer knows.The feature is live.Then, thirty minutes later, your phone starts vibrating.A message from the support team:</p><blockquote><em>“Customers are reporting incorrect order totals.”</em></blockquote><p>You open the dashboard again.</p><p>Still green.</p><p>No crashes.</p><p>No exceptions.</p><p>No failed requests.</p><p>Your first thought:</p><p>“Maybe monitoring is wrong.”</p><p>You check the logs.</p><p>Nothing.</p><p>You check the database.</p><p>Everything looks consistent.</p><p>You check the API responses.</p><p>The endpoints are returning 200 OK.</p><p><strong>So what is happening?</strong></p><p>How can a system that appears completely healthy still be producing wrong results?</p><p>This is the first lesson many backend engineers learn the hard way:</p><p><strong>A backend can be technically working and still be completely wrong.</strong></p><h3>“Where Do You Even Start?”</h3><p>When developers are beginners, they often think of failures like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*Me2eSDgMA4k0hhok5zxoGQ.png" /></figure><p>That model works when learning programming.Production is different.Real systems fail in much more subtle ways.</p><p>A production failure may look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*ZCkSolSYhrvFYU2Vpry_BQ.png" /></figure><p>Backend engineering is not only about making things work.It is about understanding <strong>how things fail</strong>.</p><h3>Thinking in Layers</h3><p>When something breaks in production, experienced engineers don’t immediately start changing code.</p><p>They investigate systematically.</p><p>A request passes through multiple layers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*aHxx8BaQixPub7hsuYGRyg.png" /></figure><p>Every layer can fail.</p><p>The mistake beginners make is assuming:</p><blockquote><em>“If my code is correct, the system is correct.”</em></blockquote><p>Experienced engineers know:</p><blockquote><em>“My code is only one part of a much larger system.”</em></blockquote><p>Let’s walk through each failure point.</p><h3>The Most Dangerous Bugs Are the Ones That Don’t Crash</h3><h3>The Logic Error Problem</h3><p>Let’s go back to the order system.You investigate further.Eventually, you find the problem.The discount calculation.The business rule was:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*QDXtZBRx-3IMha_hhMgXHw.png" /></figure><p>But the implementation accidentally became:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*n99CvvcL-EtyOgZJO235ZQ.png" /></figure><p>A customer buying a $100 product with a 10% discount receives a 20% discount.The application did exactly what the code told it to do.The server did not crash.The database did not complain.The API returned successfully.But the business result was wrong.This is a <strong>logic error</strong>.</p><h3>Why Logic Errors Are Different</h3><p>Most errors announce themselves.For example:</p><p><strong>A database connection fails:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*owyI3DtlFqoa2NbFObqZHQ.png" /></figure><p><strong>A syntax Error :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*a5ijA7yE0Xy7wMfI77-Mow.png" /></figure><p>Logic errors are different. They silently pass through the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*uUb46WGZyggYemaDBUG4BQ.png" /></figure><p>This makes them one of the most expensive categories of bugs.</p><h3>Why Developers Miss Logic Errors</h3><p>Because developers often test technical behavior:</p><p>“Does the API return a response?”</p><p>“Does the database insert succeed?”</p><p>“Does the page load?”</p><p>But businesses care about something else:</p><p>“Did the system do the correct thing?”</p><p>Those are different questions.</p><h3>A Real Example</h3><p>Imagine a payment system.</p><p>The developer writes:</p><pre>total = price - discount</pre><p>The code works. But the requirement was:</p><pre>total = price + tax - discount</pre><p>The application is technically correct. The business logic is incorrect.</p><h3>How Experienced Engineers Think</h3><p>Instead of asking:</p><blockquote><em>“Does my code run?”</em></blockquote><p>They ask:</p><blockquote><em>“Does my code represent the real-world rule correctly?” </em>This is why business understanding matters for backend engineers.</blockquote><h3>Common Logic Error Mistakes</h3><h3>1. Assuming successful execution means correctness</h3><p>A 200 OK response only means:</p><p>“The server completed the request.” It does not mean: “The business outcome is correct.”</p><h3>2. Ignoring edge cases</h3><p>Example:</p><p>A banking system works for normal transfers. Nobody tested:</p><p>Transfer amount = 0 or Account balance becomes negative</p><p>Edge cases often expose logic problems.</p><h3>3. Writing code without understanding the business rule</h3><p>A backend engineer is not just translating requirements into code.</p><p>They are protecting business rules.</p><h3>Key Takeaway</h3><p><strong>The most dangerous backend bugs are often not the ones that crash the application. They are the ones that quietly produce incorrect results.</strong></p><h3>But What If the Logic Is Correct?</h3><p>You fix the discount bug. You deploy again. Everything works. Then another issue appears. Users cannot register. This time, the API returns an error. The logs show:</p><p><strong>duplicate key violates unique constraint</strong></p><p>Now the database is involved.</p><h3>Your Database Is Your Last Line of Defense</h3><p>If you’ve never seen an error like this before, it’s easy to think:</p><blockquote><em>“Why is the database rejecting perfectly valid data?”</em></blockquote><p>The interesting part is… <strong>it isn’t. </strong>The database is actually doing exactly what it’s supposed to do.</p><p>When I first started building backend systems, I assumed the application was responsible for making sure data was correct.</p><p>If a user entered valid information and my API validated everything properly, I believed the database would simply store whatever I sent it.</p><p>That assumption worked perfectly…</p><p>until multiple users started using the application at the same time.</p><p>That’s when I realized something important:</p><blockquote><strong><em>Applications can make mistakes. Databases are designed to catch them.</em></strong></blockquote><p>Think of your backend like the receptionist at a secure office building.</p><p>The receptionist checks IDs and asks visitors where they’re going.</p><p>But the receptionist isn’t the final authority.</p><p>The security gate inside the building still decides who gets access.</p><p>Your backend validation is the receptionist.</p><p>Your database constraints are the security gate.</p><p>Even if someone slips past the receptionist, the security gate makes the final decision.</p><p>That’s why databases have constraints.</p><p>Not because developers are careless.</p><p>Because distributed systems are unpredictable.</p><h3>A Simple Registration System</h3><p>Imagine you’re building a registration endpoint.</p><p>One of your business rules is straightforward:</p><blockquote><em>Every email address should belong to only one account.</em></blockquote><p>Seems simple enough. So you write some validation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*IHnr_q4kqcMG7ZdlNoHROw.png" /></figure><p>You test it. It works. You test it again. Still works.You deploy.Everything looks fine. Until one day…</p><p>Two people or perhaps the same user clicking the button twice send the exact same request at almost the same time.Now the sequence looks very different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*9Zqrhle7x-bS1RiRyIIfmA.png" /></figure><p>At almost the exact same moment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*L24a3i62iiNIGErOYOi_GQ.png" /></figure><p>Both requests looked at the database. Both saw that the email didn’t exist.Both decided it was safe to create the account.If your application were the only thing protecting uniqueness, both users would now be inserted. Your business rule would be broken.</p><h3>This Is Why Database Constraints Exist</h3><p>The database solves this problem by refusing to trust the application completely. Instead, it says:</p><blockquote><em>“I don’t care what your application checked five milliseconds ago. I’m checking again before I write.”</em></blockquote><p>That’s what a <strong>UNIQUE constraint</strong> does.</p><p>Instead of assuming your code is always right, the database verifies the rule itself.</p><p>Now the workflow becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*NSiBuOnCsMP29Oaa5W-nrg.png" /></figure><p>Meanwhile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*U0njq2wZcR8xYi7Ib6M_7Q.png" /></figure><p>Only one request succeeds. The other fails. At first glance, that might feel frustrating. Your application throws an error .A user receives a failure response .But think about the alternative.</p><p>Without the constraint, your database now contains two users with the same email address.Recovering from that mistake later is much harder than rejecting the second request immediately.Sometimes an error is actually the database protecting your system.</p><h3>Validation Is Important… But It Isn’t Enough</h3><p>This is one of the biggest mindset shifts for junior developers.</p><p>Many developers think:</p><blockquote><em>“I already validated the request. Why should the database validate it again?”</em></blockquote><p>Because validation and database constraints solve different problems.</p><p>Validation is about giving users fast, meaningful feedback.</p><p>Database constraints are about protecting the integrity of your data.</p><p>One improves the user experience.</p><p>The other guarantees correctness.You need both.Imagine a signup form.</p><p>The user enters an invalid email address.</p><p>Should you wait until the database rejects it?</p><p>Of course not.</p><p>You should reject it immediately and explain what’s wrong.</p><p>Now imagine two perfectly valid signup requests arriving simultaneously.</p><p>Your validation won’t detect the race condition.</p><p>The database will.</p><p>They’re solving two completely different problems.</p><h3>Your Database Is More Than Just Storage</h3><p>This is another lesson that took me a while to appreciate.</p><p>Early , I thought of databases as giant storage boxes.</p><p>Something that simply remembered information.</p><p>Production systems taught me otherwise.</p><p>A relational database is an active participant in your application.</p><p>It enforces rules.</p><p>It protects relationships.</p><p>It prevents impossible states.</p><p>It refuses operations that would corrupt your data.</p><p>That’s not an inconvenience.</p><p>That’s one of its most valuable features.</p><p>Whenever you find yourself thinking,</p><blockquote><em>“I’ll remove this constraint because it keeps causing errors,”</em></blockquote><p>pause for a moment.</p><p>Ask yourself a different question instead:</p><blockquote><em>“What incorrect data is this constraint preventing from entering my system?”</em></blockquote><p>Very often, the error you’re seeing isn’t the problem.</p><p>It’s evidence that the database just prevented a much bigger one.</p><h3>Not Every Database Error Means Bad Data</h3><p>So far we’ve looked at constraint violations.</p><p>But databases can fail for another reason too.</p><p>Sometimes the data is perfectly valid.</p><p>The problem is the query itself.</p><p>Imagine writing a SQL query in a hurry.</p><p>Maybe you reference a table that doesn’t exist anymore.</p><p>Maybe you misspell a column name.</p><p>Maybe your SQL syntax is incorrect.</p><p>The request reaches the database.</p><p>The database tries to understand the query.</p><p>Then it stops.</p><p>Not because the data is invalid.</p><p>Because the instruction itself doesn’t make sense.</p><p>That’s a <strong>query error</strong>.</p><p>Unlike constraint violations, query errors are almost always developer mistakes.</p><p>The database isn’t protecting business rules anymore.</p><p>It’s simply telling you,</p><blockquote><em>“I don’t understand what you’re asking me to do.”</em></blockquote><p>That’s why it’s helpful to separate database failures into two categories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CjjUbDw9sKgDH8Ie9mSZg.png" /></figure><blockquote><strong><em>Constraint Error = The data is wrong.</em></strong><em><br> </em><strong><em>Query Error = The SQL is wrong.</em></strong></blockquote><p>Or think of it this way:</p><ul><li><strong>Constraint Error</strong> → <em>“Your data breaks the rules.”</em></li><li><strong>Query Error</strong> → <em>“Your SQL breaks the rules.”</em></li></ul><p>Understanding this distinction makes debugging much easier.</p><p>Instead of treating every database exception the same way, you begin asking the right question first:</p><blockquote><em>“Is the data wrong, or is my query wrong?”</em></blockquote><p>The answer tells you where to investigate next.</p><h3>What I Learned the Hard Way</h3><p>One mistake I see many new developers make is trying to solve database errors by weakening the database.</p><p>They remove a constraint.</p><p>They disable a foreign key.</p><p>They make a required column nullable because “it’s causing problems.”</p><p>The application starts working again.</p><p>At least temporarily.</p><p>A few weeks later, someone discovers duplicate users, orphaned records, or inconsistent data that can no longer be trusted.</p><p>The original error disappeared.</p><p>The real problem got much bigger.</p><p>Production systems reward engineers who respect the database rather than fight against it.</p><p>Your application can have bugs.</p><p>Your users can make mistakes.</p><p>Concurrent requests can create situations you never anticipated.</p><p>The database exists to keep your data correct even when everything around it isn’t.</p><h3>Key Takeaway</h3><p>A database constraint isn’t there because the database doesn’t trust you.</p><p>It’s there because <strong>production systems are unpredictable</strong>.</p><p>Your application should validate input to help users.</p><p>Your database should enforce rules to protect data.</p><p>Those two layers don’t compete with each other.</p><p>They work together to build systems that stay correct even under pressure.</p><p>At this point, we’ve explored two layers where failures can originate:</p><ul><li>Your <strong>business logic</strong> can produce the wrong outcome even when everything appears healthy.</li><li>Your <strong>database</strong> can reject operations to protect the integrity of your data.</li></ul><p>But there’s another category of failure that’s even trickier.</p><p>Sometimes your code is correct.</p><p>Sometimes your database is healthy.</p><p>And yet… your application still doesn’t work.</p><p>Not because of anything inside your system.</p><p>Because of something <strong>outside</strong> it.</p><h3>Your Code Is Fine. So Why Is Production Still Broken?</h3><p>You fixed the logic bug.</p><p>You fixed the database issue.</p><p>The registration system is stable again.</p><p>For a while, everything runs smoothly.</p><p>Then one morning, something strange happens.</p><p>Users suddenly cannot log in.</p><p>You check your recent deployments.</p><p>Nothing changed.</p><p>You check the application logs.</p><p>No obvious errors.</p><p>You check the database.</p><p>Healthy.</p><p>CPU usage?</p><p>Normal.</p><p>Memory?</p><p>Normal.</p><p>Your backend servers are running perfectly.</p><p>So why are users unable to authenticate?</p><p>After digging deeper, you finally find the problem.</p><p>The authentication provider your application depends on is having an outage.</p><p>Your code is fine.</p><p>Your database is fine.</p><p>Your infrastructure is fine.</p><p>But your users are still experiencing a failure.</p><p>This is one of the biggest mindset shifts when moving from building small applications to building production systems:</p><blockquote><strong><em>Your application can fail even when your code is working perfectly.</em></strong></blockquote><p>Because modern applications don’t live alone.</p><p>They depend on other systems.</p><p>And every dependency introduces another possible failure point.</p><h3>The Reality of Modern Backends</h3><p>A beginner’s mental model of an application often looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*LsBveumauvv7ZL7l8lHBog.png" /></figure><p>Simple.Easy to reason about. But production systems rarely look like this anymore.</p><p>A real backend usually looks more like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*ZNi3pBkmRhpgapBI3hSq6Q.png" /></figure><p>Your application is now part of an ecosystem.</p><p>The moment you introduce another service, you also introduce another thing that can fail.</p><h3>The Dependency Problem</h3><p>Think about ordering food online.</p><p>You open the app.</p><p>You select your food.</p><p>You click “Place Order.”</p><p>Behind the scenes, many things happen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*DDmKgynCaZ9nMFWuofOtcg.png" /></figure><p>The customer sees one button.</p><p>The system sees multiple conversations between different services.</p><p>If any one of those conversations fails, the user feels the impact.</p><h3>Network Failures: The Invisible Enemy</h3><p>One of the first external problems developers encounter is network failure.</p><p>When your application calls another service, you are assuming something:</p><p>“That service will receive my request.”</p><p>But between your application and that service are many things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*wUCtKo2Cq427KRvd_1_d6Q.png" /></figure><p>Every step can fail.</p><p>The external service might be perfectly healthy.</p><p>Your backend might be perfectly healthy.</p><p>The connection between them can still break.</p><p>Example: The Authentication Request</p><p>Imagine this flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*U3odBQ6zNpVdrolR5vdiUA.png" /></figure><p>Normally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*VocvnrFVv8lUMyhBow3K8w.png" /></figure><p>But what if the network request times out?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*azsCsl2k9eWnHcGi_aqlQw.png" /></figure><p>Your backend has no answer.</p><p>The user sees:</p><p>“Login failed.”</p><p>From the user’s perspective, your application is broken.</p><p>But the actual problem is communication.</p><h3>Why Timeouts Matter</h3><p>One mistake beginners make is waiting forever for external services.</p><p>Imagine your backend sends a request:</p><pre> id=&quot;timeout-example&quot;<br>response = callExternalService()</pre><p>What happens if the service never responds?</p><p>Your server keeps waiting.</p><p>One request becomes:</p><ul><li>one open connection</li><li>one occupied thread</li><li>one waiting resource</li></ul><p>Now multiply that by thousands of users.</p><p>A slow external service can eventually make your own application unavailable.</p><p>This is why production systems use timeouts.</p><p>The idea is simple:</p><blockquote><em>“If a dependency does not respond within a reasonable time, stop waiting.”</em></blockquote><h3>Authentication Failures Are Not Always Your Fault</h3><p>Many applications use external authentication systems.</p><p>Instead of building everything themselves, they rely on dedicated authentication providers.</p><p>This is useful because authentication involves many complicated problems:</p><ul><li>Identity management</li><li>Token handling</li><li>Security flows</li><li>Password management</li></ul><p>But outsourcing authentication does not mean failures disappear.</p><p>The authentication provider can still reject requests.</p><p>Common reasons include:</p><ul><li>Invalid credentials</li><li>Expired tokens</li><li>Insufficient permissions</li></ul><p>The important part is understanding the difference:</p><p>A rejected login attempt is not necessarily an application failure.</p><p>Sometimes the system is correctly refusing access.</p><h3>The Logging Mistake That Creates Security Problems</h3><p>There is another subtle lesson here.</p><p>Many developers think:</p><p>“If authentication fails, I’ll just log everything so I can debug it.”</p><p>That sounds reasonable.</p><p>Until someone accidentally logs:</p><ul><li>Access tokens</li><li>Password information</li><li>Personal user data</li></ul><p>Now the debugging system has become a security risk.</p><p>Logs are valuable.</p><p>But logs are also sensitive.</p><p>A production engineer must constantly balance:</p><p>“Do I have enough information to debug?”</p><p>with:</p><p>“Am I exposing information I should protect?”</p><h3>Rate Limiting: When You Are Too Successful</h3><p>Now imagine your application is growing.</p><p>You have thousands of users.</p><p>Your backend communicates with an external API.</p><p>Everything works.</p><p>Until suddenly requests start failing.</p><p>The response:</p><p>HTTP 429 Too Many Requests</p><p>At first, it seems confusing.</p><p>The service is running.</p><p>Your request is correct.</p><p>Why is it rejecting you?</p><p>Because the service is protecting itself.</p><h3>Why Rate Limits Exist</h3><p>External services cannot allow unlimited traffic.</p><p>Imagine a public API without limits.</p><p>One customer accidentally creates a bug:</p><pre>while(true){<br>    sendRequest();<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*w31P_Dk3dW2CIafv3F3LqQ.png" /></figure><p>Rate limiting prevents one consumer from affecting everyone else.</p><h3>The Beginner Retry Mistake</h3><p>A common reaction to failure is:</p><p>“Let’s try again.”</p><p>That sounds logical.</p><p>But imagine a rate-limited service.</p><p>Your application receives:</p><p>429 Too Many Requests</p><p>Your code says:</p><p>“Try again immediately.”</p><p>Now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*aeAuuRk7gOSA-dYmW-fI2g.png" /></figure><p>You are not recovering.</p><p>You are making the problem worse.</p><h3>Exponential Backoff</h3><p>This is where exponential backoff comes in.</p><p>Instead of retrying immediately, you increase the waiting time.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/115/1*H8nhdJGymeSHPbrDHcM_vw.png" /></figure><p>The system gradually reduces pressure on the dependency.</p><p>The goal isn’t just:</p><p>“Make my request succeed.”</p><p>The goal is:</p><p>“Help the entire system recover.”</p><p>That is the difference between beginner thinking and production thinking.</p><h3>Service Outages: When Dependencies Go Down</h3><p>Eventually, every important service experiences downtime.</p><p>Even large cloud providers have outages.</p><p>The question is not:</p><p>“How do we prevent every outage?”</p><p>You cannot.</p><p>The better question is:</p><p>“How does our application behave when something we depend on fails?”</p><h3>Example: Redis Goes Down</h3><p>Imagine your application uses Redis for caching.</p><p>Normally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*qhPjSR_WhatEJMM8ekPVdg.png" /></figure><p>Now Redis becomes unavailable.</p><p>A fragile system does this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*EayxLco7bmtJ46rXUHLIaw.png" /></figure><p>A resilient system thinks differently:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/164/1*NA77uHduiVBr9pskVUQ4pA.png" /></figure><p>The fallback might be:</p><ul><li>Another cache source</li><li>Temporary in-memory storage</li><li>Reduced functionality</li></ul><p>The important idea:</p><p><strong>One dependency failure should not automatically become a complete application failure.</strong></p><h3>Graceful Degradation</h3><p>This concept appears repeatedly in production systems.</p><p>A perfect system is unrealistic.</p><p>A resilient system accepts that failures happen and reduces their impact.</p><p>For example:</p><p>If recommendations are unavailable:</p><p>Bad approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*mGYgLBTuI5S9i8T1b9uO0g.png" /></figure><p>Better approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*4DbxM641pBORTcGEkTsH8Q.png" /></figure><p>The user loses a feature.</p><p>They do not lose the entire application.</p><h3>Common Mistakes With External Dependencies</h3><h3>1. Assuming external services never fail</h3><p>They will.</p><p>The question is when.</p><h3>2. No timeout configuration</h3><p>A slow dependency can consume your resources.</p><h3>3. Retrying immediately</h3><p>This often increases the failure.</p><h3>4. No fallback plan</h3><p>A single outage becomes a complete outage.</p><h3>5. Logging sensitive information</h3><p>Debugging should never compromise security.</p><h3>Production Mindset</h3><p>Experienced backend engineers design systems with one assumption:</p><blockquote><em>“Something outside my control will eventually fail.”</em></blockquote><p>That assumption changes how you build systems.</p><p>You start adding:</p><ul><li>Timeouts</li><li>Retries</li><li>Backoff strategies</li><li>Circuit breakers</li><li>Fallback mechanisms</li><li>Better monitoring</li></ul><p>Not because you expect failure every day.</p><p>Because when failure happens, you want your system to fail gracefully.</p><h3>Key Takeaway</h3><p>Your backend does not exist in isolation.</p><p>Your code can be perfect.</p><p>Your database can be healthy.</p><p>Your servers can be running.</p><p>And your users can still experience failure because another system failed.</p><p>The goal of backend engineering is not creating systems where nothing ever breaks.</p><p>That is impossible.</p><p>The goal is creating systems where failures are <strong>contained, understood, and handled gracefully</strong>.</p><h3>Never Trust User Input — The First Line of Defense in Backend Systems</h3><p>You have fixed the logic bug.</p><p>You have protected your database.</p><p>You have handled external service failures.</p><p>Your backend now feels much more reliable.</p><p>Then one day, a new bug report arrives.</p><p>A user is trying to create an account, but the system behaves strangely.</p><p>You open the logs and see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*zpjjznnwIoPyhcBiKayEWA.png" /></figure><p>At first, you think:</p><p>“How did this even reach my backend?”</p><p>The frontend already has validation.</p><p>The form prevents incorrect values.</p><p>The UI only allows proper input.</p><p>So why is the backend receiving garbage data?</p><p>Because the backend made a dangerous assumption:</p><blockquote><em>“The client will send correct data.”</em></blockquote><p>That assumption is one of the easiest ways to create unreliable systems.</p><h3>The Backend Cannot Trust the Client</h3><p>When building applications, developers often think about the frontend and backend as one system.</p><p>They imagine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/119/1*2SA7mHNlY2Zxiun6ATjJhg.png" /></figure><p>The frontend validates the data.</p><p>The backend receives it.</p><p>Everything works.</p><p>But production systems do not work this way.</p><p>The backend does not know who is sending the request.</p><p>The request could come from:</p><ul><li>Your frontend application</li><li>A mobile app</li><li>A third-party integration</li><li>A script</li><li>Someone manually calling your API</li></ul><p>The backend only sees an HTTP request.</p><pre>{<br>  &quot;email&quot;: &quot;john.example.com&quot;,<br>  &quot;age&quot;: -5<br>}</pre><p>The backend has no idea where this came from.</p><p>That is why backend engineers follow a simple rule:</p><blockquote><em>Never trust input coming from outside your system.</em></blockquote><h3>Validation Is the First Gate</h3><p>Think about entering an airport.</p><p>Before boarding a plane, you pass through multiple checks.</p><p>The airport does not wait until you are inside the aircraft to verify your ticket.</p><p>The security process happens at the entrance.</p><p>Backend validation works the same way.</p><p>The request should pass through validation before reaching the rest of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*SqkYgkV7E33M8ZzX19sCwA.png" /></figure><p>The earlier you reject invalid data, the safer your system becomes.</p><h3>Why Validate Before Business Logic?</h3><p>Imagine an order system.</p><p>A customer sends:</p><pre>{<br>  &quot;productId&quot;: 123,<br>  &quot;quantity&quot;: -10<br>}</pre><p>Without validation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*ikwPwCMUWy3unQ-6V4bVAQ.png" /></figure><p>Now your system has already performed unnecessary work.</p><p>Worse, something unexpected may happen.</p><p>With validation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*DSclEWa6FaNmYuJoL8IxfQ.png" /></figure><p>The invalid request never enters the system.</p><p>This is cheaper, safer, and easier to debug.</p><h3>The Three Types of Validation</h3><p>Validation is not just checking whether a field exists.</p><p>There are multiple dimensions.</p><p>A value can exist and still be invalid.</p><p>Let’s look at the common categories.</p><h3>1. Format Validation</h3><p>The first question is:</p><blockquote><em>“Does this value look like the type of data we expect?”</em></blockquote><p>For example:</p><p>A valid email: <a href="/service/mailto:alice@example.com">alice@example.com</a></p><p>An invalid email: alice.example.com</p><p>The second value exists.</p><p>It is a string.</p><p>The application can technically process it.</p><p>But it does not represent a valid email address.</p><p>The format is wrong.</p><p>Other Format Examples</p><p>Phone numbers</p><p>Valid: <strong>+91 9876543210</strong></p><p>Invalid: hello123</p><h3>Dates</h3><p>Valid: 2026–08–02</p><p>Invalid: 99–99–9999</p><h3>Why Format Validation Matters</h3><p>Incorrect formats create problems later.</p><p>Imagine storing invalid dates.</p><p>A reporting system might break.</p><p>Imagine storing invalid emails.</p><p>A notification system might fail.</p><p>The mistake may not appear immediately.</p><p>It appears weeks later when another part of the system depends on that data.</p><p>Good validation prevents bad data from entering the system.</p><h3>2. Range Validation</h3><p>Now imagine the format is correct.</p><p>The value is still wrong.</p><pre>{<br>  &quot;age&quot;: 500<br>}</pre><p>The value is an integer.</p><p>The format is correct.</p><p>But the business meaning is wrong.</p><p>This is where range validation comes in.</p><p>Examples:</p><h3>Age</h3><pre>18 ≤ age ≤ 100</pre><h3>Product Quantity</h3><p>Valid: 1 to 100 items</p><p>Invalid: -5 items</p><h3>Why Range Validation Matters</h3><p>Data types only answer one question:</p><blockquote><em>“Can this value exist technically?”</em></blockquote><p>Range validation asks:</p><blockquote><em>“Does this value make sense for this business?”</em></blockquote><p>Those are completely different questions.</p><h3>3. Required Field Validation</h3><p>Some information is necessary for an operation.</p><p>A user registration might require:</p><pre>Name<br><br>Email<br><br>Password</pre><p>Without those fields, the operation cannot continue.</p><p>The workflow becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*VFfk8Al7qtxNM2rPNygU_Q.png" /></figure><h3>Why Missing Fields Are Dangerous</h3><p>Imagine a payment request:</p><pre>{<br>  &quot;amount&quot;: 500<br>}</pre><p>But the payment system requires:</p><pre>{<br>  &quot;userId&quot;: 123,<br>  &quot;amount&quot;: 500,<br>  &quot;paymentMethod&quot;: &quot;card&quot;<br>}</pre><p>Without validation, the system has incomplete information.</p><p>Now different parts of the application may fail in unpredictable ways.</p><p>A good backend fails early with a clear message.</p><h3>Validation Errors Are Not Server Errors</h3><p>This distinction is important.</p><p>A beginner might see an error and think:</p><p>“Something failed on the server.”</p><p>But not every error is a server problem.</p><p>If the user sends invalid data, the server is actually behaving correctly.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*WbgFzRPd2LG9hLAAi24FGA.png" /></figure><p>The backend did its job.</p><p>The problem was the input.</p><h3>Why This Matters for Security</h3><p>Validation is not only about correctness.</p><p>It is also about protecting the system.</p><p>Bad input can cause:</p><ul><li>Unexpected application behavior</li><li>Database problems</li><li>Security vulnerabilities</li></ul><p>A backend should assume:</p><blockquote><em>Any external input may be incorrect or intentionally manipulated.</em></blockquote><h3>Common Mistakes Developers Make</h3><h3>1. Trusting frontend validation</h3><p>A frontend check is useful.</p><p>But it is not security.</p><p>Anyone can bypass the UI and call your API directly.</p><h3>2. Validating too late</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/1*XH20R3G2eQYlCBAEbssyTw.png" /><figcaption>Bad</figcaption></figure><p>The damage may already be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/1*FCyBDdeqnMsIm0a59ebwIg.png" /><figcaption>Better</figcaption></figure><p>3. Checking only data types</p><pre>typeof age === &quot;number&quot;</pre><p>This only tells you:</p><p>“The value is a number.”</p><p>It does not tell you:</p><p>“The value is a valid age.”</p><h3>4. Returning unclear errors</h3><p>Bad:</p><pre>{<br>  &quot;error&quot;: &quot;Invalid request&quot;<br>}</pre><p>Better:</p><pre>{<br>  &quot;error&quot;: &quot;Age must be between 18 and 100&quot;<br>}</pre><p>Good errors help developers and users understand what went wrong.</p><h3>Production Best Practices</h3><p>Experienced backend systems usually:</p><h3>Validate at the boundary</h3><p>The moment data enters your system.</p><h3>Keep validation rules clear</h3><p>Business rules should not be hidden inside random parts of the code.</p><h3>Return meaningful errors</h3><p>Help the caller fix the request.</p><h3>Never depend only on validation</h3><p>Remember:</p><p>Validation improves experience.</p><p>Database constraints protect integrity.</p><p>Both are needed.</p><h3>The Bigger Picture</h3><p>At this point, our request journey looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*lI4rAYop9XBUvG78oNZ2Gg.png" /></figure><p>Each layer protects the next one.</p><p>Validation protects your business logic.</p><p>Business logic protects your data operations.</p><p>Database constraints protect your data.</p><p>External dependency handling protects your application from outside failures.</p><p>A reliable backend is built through layers of protection.</p><h3>Key Takeaway</h3><p>Your backend should assume every incoming request is wrong until proven otherwise.</p><p>Validation is not about being strict with users.</p><p>It is about protecting your system from unexpected data.</p><p>The earlier you detect invalid input, the fewer problems you create later.</p><p>There is only one major failure category left in our journey.</p><p>So far, we have discussed:</p><ul><li>Wrong code decisions (<strong>logic errors</strong>)</li><li>Invalid data operations (<strong>database errors</strong>)</li><li>Failures outside your system (<strong>external dependencies</strong>)</li><li>Bad incoming requests (<strong>validation errors</strong>)</li></ul><p>But there is one problem that surprises many developers:</p><blockquote><em>“The code works perfectly on my machine. Why did production break?”</em></blockquote><p>The answer is often not the code.</p><p>It is the environment.</p><h3>The Code Was Perfect. Production Still Failed. The Configuration Problem Nobody Talks About</h3><p>The logic is correct.</p><p>The database is protected.</p><p>External services have proper handling.</p><p>Input validation is in place.</p><p>The application works perfectly on your laptop.</p><p>You are confident.</p><p>You merge the pull request.</p><p>The deployment pipeline starts.</p><pre>Building application...<br>✓ Completed<br><br>Running tests...<br>✓ Passed<br><br>Deploying...<br>✓ Successful</pre><p>Everything looks good.</p><p>Then, an hour later, a customer reports:</p><blockquote><em>“The document upload feature is not working.”</em></blockquote><p>You immediately check the code.</p><p>Nothing changed.</p><p>You check the logs.</p><p>This time, you see something unexpected:</p><pre>Missing OPENAI_API_KEY</pre><p>You open your local environment file.</p><p>The key exists.</p><p>Your code works.</p><p>Your tests passed.</p><p>So why is production failing?</p><p>The answer is something many developers experience sooner or later:</p><p><strong>Your code was correct. Your environment was not.</strong></p><h3>The Problem With “Works on My Machine”</h3><p>Every developer has said this sentence at some point:</p><blockquote><em>“But it works on my machine.”</em></blockquote><p>And usually, they are telling the truth.</p><p>The code does work on their machine.</p><p>The problem is that their machine is not production.</p><p>A developer’s local environment usually contains things like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*E4iH4FlmiZhEhJWsvJgh7w.png" /></figure><p>Production is a completely different world:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*13LTYFPRMFzAU1O907tSkw.png" /></figure><p>The code might be identical.</p><p>The environment is not.</p><h3>What Is Configuration?</h3><p>Before introducing the problem, let’s understand what configuration actually means.</p><p>Configuration is everything your application needs to know about its environment.</p><p>Examples:</p><ul><li>Database connection strings</li><li>API keys</li><li>Authentication secrets</li><li>External service URLs</li><li>Feature flags</li><li>Third-party credentials</li></ul><p>Your code says:</p><blockquote><em>“I need to communicate with this service.”</em></blockquote><p>Configuration tells it:</p><blockquote><em>“Here is where that service is and how to access it.”</em></blockquote><p>A simple example:</p><pre>connectDatabase(<br>    process.env.DATABASE_URL<br>)</pre><p>The code does not contain the actual database address.</p><p>It reads it from the environment.</p><p>Why?</p><p>Because the database changes depending on where the application runs.</p><p>Local: localhost:5432</p><p>Production: production-database.company.com</p><p>Same code.</p><p>Different configuration.</p><h3>The Hidden Production Risk</h3><p>Let’s revisit the API key example.</p><p>Imagine you add a feature that uses an external AI service.</p><p>Your code:</p><pre>const response = await openAI.generate(document);</pre><p>Your local environment: OPENAI_API_KEY=abc123</p><p>Everything works.</p><p>You commit the code.</p><p>You deploy.</p><p>But production has: OPENAI_API_KEY=</p><p>or maybe it does not exist at all.</p><p>Now what happens?</p><p>The application starts.</p><p>The server is running.</p><p>The health check passes.</p><p>Everything appears normal.</p><p>Until someone actually uses that feature.</p><p>Then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*AfGZRjaJiJzG9k7e7_ffhA.png" /></figure><p>The failure appears hours after deployment.</p><p>This is dangerous because the deployment looked successful.</p><h3>Two Ways Applications Handle Missing Configuration</h3><p>When required configuration is missing, there are two possible approaches.</p><h3>Approach 1: Discover the Problem During Runtime</h3><p>This is the approach many beginners accidentally implement.</p><p>The application starts normally.</p><p>It accepts traffic.</p><p>The problem appears only when someone uses the affected feature.</p><p>The flow looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*OFBjx3d7XAumY-sfexd7yQ.png" /></figure><p>The biggest problem?</p><p>Your users become your testing system.</p><p>Production users discover configuration mistakes.</p><p>That is the worst possible place to find them.</p><h3>Approach 2: Fail Fast During Startup</h3><p>A better approach is to check configuration before the application starts serving requests.</p><p>The flow becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*hgOinz6rCCQHortQXnuWyw.png" /></figure><p>If something important is missing, the application refuses to start.</p><p>At first, this might seem worse.</p><p>You might think:</p><blockquote><em>“Why would I intentionally make my application fail?”</em></blockquote><p>Because this failure happens before users are affected.</p><h3>Why Failing Early Is Better</h3><p>Imagine two scenarios.</p><h3>Scenario A: Runtime Failure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*ZiWFBdNoC_ApL4nW_NlfuA.png" /></figure><h3>Scenario B: Startup Failure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*XVo3WDRUGdbeopqrYXy-Tw.png" /></figure><p>Users continue using the old working version.</p><p>The problem is discovered by engineers, not customers.</p><p>This is the philosophy behind:</p><blockquote><em>Fail fast.</em></blockquote><h3>Fail Fast Is Not About Breaking Things</h3><p>Some developers misunderstand this idea.</p><p>They think:</p><p>“Fail fast means making applications fragile.”</p><p>It is actually the opposite.</p><p>Failing fast means:</p><blockquote><em>“Detect problems at the earliest possible moment when they are cheapest to fix.”</em></blockquote><p>Compare:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*7konj2YrGRSuE3vGOo8Vdg.png" /></figure><p>versus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*ikp-xqw5OY8d2JqWLx6Bkw.png" /></figure><p>The first one is a controlled failure.</p><p>The second one is a production incident.</p><h3>1. Missing Environment Variables</h3><p>Example:</p><p>Local: DATABASE_URL=localhost</p><p>Production: DATABASE_URL=</p><p>The application cannot connect.</p><h3>2. Incorrect Secrets</h3><p>The variable exists.</p><p>But the value is wrong.</p><p>Example: API_KEY=old_expired_key</p><p>The application starts.</p><p>Requests fail later.</p><h3>3. Different Configuration Between Environments</h3><p>Example:</p><p>Development: PAYMENT_MODE=test</p><p>Production: PAYMENT_MODE=test</p><p>Now real customers are using the test payment system.</p><p>The code is correct.</p><p>The environment is wrong.</p><h3>4. Forgetting Configuration During Deployment</h3><p>A developer adds:</p><p>NEW_SERVICE_API_KEY</p><p>Locally.</p><p>But forgets to add it to:</p><ul><li>Production server</li><li>Docker configuration</li><li>Kubernetes secrets</li><li>Deployment pipeline</li></ul><p>The feature works locally and fails after release.</p><h3>Why Configuration Errors Are Different From Bugs</h3><p>This distinction is important.</p><p>A bug usually means:</p><p>“The code does something incorrectly.”</p><p>A configuration problem means:</p><p>“The code expected something that was not provided.”</p><p>The implementation might be completely correct.</p><p>The environment simply did not satisfy the application’s requirements.</p><h3>Common Mistakes Developers Make</h3><h3>1. Hardcoding Configuration</h3><p>Bad:</p><pre>const apiKey = &quot;abc123&quot;;</pre><p>Why is this dangerous?</p><p>Because:</p><ul><li>Secrets leak into repositories.</li><li>Different environments become difficult.</li><li>Rotation becomes painful.</li></ul><h3>2. Assuming Local Environment Matches Production</h3><p>It rarely does.</p><p>Local: Everything configured</p><p>Production:</p><pre>Different permissions<br>Different secrets<br>Different services</pre><h3>3. Not Validating Configuration</h3><p>The application should know what it requires.</p><p>If the database URL is missing:</p><p>Do not start.</p><p>If authentication secrets are missing:</p><p>Do not start.</p><h3>4. Finding Configuration Problems Through Users</h3><p>This is the worst debugging strategy.</p><p>Users should not be your configuration testing system.</p><h3>Production Best Practices</h3><h3>Validate configuration at startup</h3><p>Before accepting traffic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*gF36q4kJH2G7RVeBYcpAVg.png" /></figure><h3>Keep configuration separate from code</h3><p>The same application artifact should run in multiple environments.</p><p>Only configuration should change.</p><h3>Document required configuration</h3><p>Every service should clearly define:</p><pre>Required Environment Variables:<br><br>DATABASE_URL<br>JWT_SECRET<br>PAYMENT_API_KEY</pre><h3>Monitor startup failures</h3><p>A failed deployment should be visible immediately.</p><h3>The Complete Backend Failure Mindset</h3><p>Now we have travelled through the entire lifecycle of a backend request.</p><p>A request can fail at every stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*YQVWq-cgYgk0Aph7cVA3gg.png" /></figure><p>Each layer has a different responsibility.</p><p>Configuration ensures the application can run.</p><p>Validation ensures requests make sense.</p><p>Business logic ensures rules are followed.</p><p>Database constraints protect data.</p><p>External dependency handling protects against outside failures.</p><h3>The Bigger Lesson</h3><p>When I started building backend systems, I thought error handling meant:</p><p>“Catch exceptions and return error messages.”</p><p>That is only the smallest part of it.</p><p>Real error handling is about designing systems that behave predictably when things go wrong.</p><p>Because things will go wrong.</p><p>Users will send unexpected data.</p><p>Business rules will be misunderstood.</p><p>Databases will reject operations.</p><p>Networks will fail.</p><p>External services will go down.</p><p>Someone will forget an environment variable.</p><p>These are not unusual situations.</p><p>They are normal parts of running software in production.</p><h3>Key Takeaway</h3><p>A reliable backend is not a backend where nothing fails.</p><p>That system does not exist.</p><p>A reliable backend is one where failures happen in controlled places, with clear explanations, and without unnecessary impact on users.</p><p>The best engineers are not the ones who prevent every failure.</p><p>They are the ones who design systems that know how to fail gracefully.</p><h3>Final Conclusion</h3><p>Building backend systems is not just about making requests succeed.</p><p>Anyone can build a happy-path application.</p><p>The real challenge begins when reality arrives.</p><p>The user sends unexpected input.</p><p>The database rejects data.</p><p>The network disappears.</p><p>A third-party API becomes unavailable.</p><p>A production environment misses a secret.</p><p>The difference between a beginner and an experienced backend engineer is not knowing every technology.</p><p>It is understanding that failure is part of the system.</p><p>Good backend engineering is not about asking:</p><blockquote><em>“How do I make sure nothing breaks?”</em></blockquote><p>It is asking:</p><blockquote><em>“When something breaks, how does my system respond?”</em></blockquote><p>Because production does not reward systems that only work when everything is perfect.</p><p>Production rewards systems that remain reliable when nothing is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6837d762258d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>