<?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 Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML on Medium]]></title>
        <description><![CDATA[Stories by Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML on Medium]]></description>
        <link>https://medium.com/@rohandevaki?source=rss-120bb3c4b1cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZSCJajnU7mu82CMLadUbZQ.jpeg</url>
            <title>Stories by Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML on Medium</title>
            <link>https://medium.com/@rohandevaki?source=rss-120bb3c4b1cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 00:57:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rohandevaki/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[Why Your Backend Feels Slow?]]></title>
            <link>https://medium.com/@rohandevaki/why-your-backend-feels-slow-2566b2234e14?source=rss-120bb3c4b1cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2566b2234e14</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[backend-engineering]]></category>
            <dc:creator><![CDATA[Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML]]></dc:creator>
            <pubDate>Mon, 23 Mar 2026 10:39:32 GMT</pubDate>
            <atom:updated>2026-03-23T10:39:32.800Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Your Backend Feels Slow? Async, Concurrency, Threading, and gRPC Explained with a Burger Restaurant</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Q8RJ0KK1iwOyh9noFscQg.png" /></figure><h3>Imagine You Walk Into Burger Mania on a Busy Evening</h3><p>You walk into Burger Mania at peak hours.</p><p>There are 20 people waiting in line.<br> The restaurant has 5 chefs, 5 stoves, 5 staff at the counter, and 10 tables.</p><p>On paper, this place should run smoothly.</p><p>But something feels off.</p><p>There is only one queue.</p><p>One staff member is taking orders. One by one.</p><p>You are standing 5th in line, just waiting to say what you want. The person at the counter takes the first order, writes it down, sends it to the kitchen, waits a bit, then moves to the next person.</p><p>Nothing else is happening.</p><p>Now look around.</p><p>Four staff members are doing nothing.<br> Chefs are waiting because orders are not reaching them fast enough.<br> Stoves are sitting unused.<br> Tables are empty.</p><p>Everything is available, but everything is stuck.</p><p>The system is technically working, but it is slow, inefficient, and frustrating.</p><p>This is what a <strong>blocking system</strong> looks like.</p><p>Every step waits for the previous one to finish before anything else can begin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AacZ4rYowtntGqvz" /></figure><h3>What Changed in the Story, and What That Means in System Design</h3><p>Let’s go back inside Burger Mania.</p><p>Nothing about the restaurant changed.</p><p>Still the same chefs.<br> Same stoves.<br> Same staff.<br> Same tables.</p><p>But suddenly, the place started working smoothly.</p><p>So what actually changed?</p><h3>Asynchronous Processing (Handling Multiple Requests)</h3><p>Splitting one queue into many means requests are handled independently. One customer placing an order no longer blocks the next.</p><p>In system design terms, this is <strong>asynchronous processing</strong>.</p><p>What you introduce:</p><ul><li>Async frameworks like FastAPI, aiohttp</li><li>Event loop based execution</li></ul><p>What changes:</p><ul><li>Requests are handled independently</li><li>System handles multiple requests concurrently</li><li>Throughput increases without adding hardware</li></ul><h3>Non-Blocking I/O (The Real Game Changer)</h3><p>Earlier, order taking slowed down while the kitchen processed requests. Now, orders keep coming in while cooking happens separately.</p><p>That’s <strong>non-blocking I/O</strong>.</p><p>What you introduce:</p><ul><li>Async DB drivers like asyncpg</li><li>Async HTTP clients like httpx</li></ul><p>What changes:</p><ul><li>API doesn’t wait for DB or network</li><li>Threads are not blocked</li><li>System continues processing other requests</li></ul><h3>Concurrency (Handling Multiple Tasks Together)</h3><p>Each chef picks an order independently.</p><p>That’s <strong>concurrency</strong>.</p><p>What you introduce:</p><ul><li>asyncio.gather</li><li>Parallel task execution inside a request</li></ul><p>What changes:</p><ul><li>One request can trigger multiple operations</li><li>Tasks are in progress simultaneously</li></ul><h3>Parallelism and Threading (Actual Execution)</h3><p>Multiple chefs cooking at the same time represents <strong>parallelism</strong>.</p><p>What you introduce:</p><ul><li>ThreadPoolExecutor</li><li>Worker processes</li></ul><p>What changes:</p><ul><li>CPU-bound work runs in parallel</li><li>Better utilization of compute resources</li></ul><h3>Semaphore and Rate Limiting (Preventing System Overload)</h3><p>Only 5 stoves and 10 tables. Not everything can run at once.</p><p>That’s a <strong>semaphore</strong>.</p><p>What you introduce:</p><ul><li>Semaphores in code</li><li>Rate limiting</li><li>API gateways</li></ul><p>What changes:</p><ul><li>System enforces limits</li><li>Prevents crashes under high load</li></ul><h3>Task Queues and Background Jobs</h3><p>Each chef maintains their own list of orders.</p><p>That’s <strong>task queues and background processing</strong>.</p><p>What you introduce:</p><ul><li>Kafka, RabbitMQ, AWS SQS</li><li>Celery workers</li></ul><p>What changes:</p><ul><li>Work is distributed</li><li>Tasks are decoupled</li><li>System becomes scalable</li></ul><h3>gRPC and Fast Service Communication</h3><p>Orders move instantly between counter and kitchen.</p><p>That’s efficient internal communication.</p><p>What you introduce:</p><ul><li>gRPC</li><li>Protocol Buffers</li></ul><p>What changes:</p><ul><li>Faster service-to-service calls</li><li>Lower latency than REST</li><li>Efficient data transfer</li></ul><h3>Connection Pooling and Database Performance</h3><p>Instead of everyone waiting for a single notebook, access is shared.</p><p>That’s <strong>connection pooling + async DB access</strong>.</p><p>What you introduce:</p><ul><li>PgBouncer</li><li>Async DB engines</li></ul><p>What changes:</p><ul><li>Connections reused</li><li>Queries don’t block each other</li><li>Handles high concurrency efficiently</li></ul><h3>Why Asynchronous Systems Matter, How They Differ from Synchronous Ones, and Where They Can Hurt You</h3><p>By now, the Burger Mania setup should feel intuitive.</p><p>Let’s translate that intuition into real system behavior.</p><h3>1. The Core Idea Behind Asynchronous Systems</h3><p>At a high level, asynchronous systems are not about making one task faster.</p><p>They are about making sure:</p><p><strong>nothing sits idle while waiting.</strong></p><p>In most modern applications, the slowest parts are:</p><ul><li>Database queries</li><li>External API calls</li><li>Disk operations</li></ul><p>A synchronous system waits for these to complete.</p><p>An asynchronous system moves on and does something else.</p><p>That single shift changes everything.</p><h3>2. Key Benefits of Asynchronous Processing</h3><h3>2.1 Better Resource Utilization</h3><p>In a synchronous system:</p><ul><li>A thread makes a DB call</li><li>It waits</li><li>CPU sits idle</li></ul><p>In an asynchronous system:</p><ul><li>That waiting time is reused</li><li>The same thread handles other requests</li></ul><p>What this really means is:<br> you can handle more traffic without increasing hardware.</p><p>This is one of the biggest performance gains highlighted in research on async frameworks combined with connection pooling. Systems handle higher concurrency without exhausting resources.</p><h3>2.2 Higher Throughput</h3><p>Throughput is how many requests your system can handle per second.</p><p>With async:</p><ul><li>Requests don’t block each other</li><li>The system keeps moving</li></ul><p>Result:</p><ul><li>More requests processed</li><li>Better scalability</li></ul><h3>2.3 Lower Latency Under Load</h3><p>Important nuance.</p><p>Async does not always make a single request faster.</p><p>But under load:</p><ul><li>Synchronous systems create queues</li><li>Requests pile up</li><li>Response time increases</li></ul><p>Async systems keep processing in parallel.</p><p>Result:</p><ul><li>Lower average latency</li><li>Much better worst-case latency</li></ul><h3>2.4 Efficient Handling of High Concurrency</h3><p>If 1000 users hit your system:</p><p>Synchronous:</p><ul><li>Needs many threads</li><li>High memory usage</li><li>Context switching overhead</li></ul><p>Asynchronous:</p><ul><li>Uses fewer threads</li><li>Handles many tasks through an event loop</li></ul><p>This is why async is widely used in:</p><ul><li>APIs</li><li>Real-time systems</li><li>Streaming applications</li></ul><h3>2.5 Works Best for I/O Heavy Systems</h3><p>Async shines when your system spends time waiting.</p><p>Examples:</p><ul><li>Database-heavy apps</li><li>Microservices calling other services</li><li>File uploads and processing</li></ul><p>This aligns with practical system design guidance:<br> async is ideal for I/O-bound workloads.</p><h3>2.6 Works Well with Connection Pooling</h3><p>Modern systems combine:</p><ul><li>Async processing</li><li>Database connection pools</li></ul><p>Instead of opening a new connection per request:</p><ul><li>Connections are reused</li><li>Requests don’t block</li></ul><p>Research shows this combination significantly improves performance in high-concurrency environments.</p><h3>2.7 Improved User Experience</h3><p>Because:</p><ul><li>The system does not freeze</li><li>Background tasks don’t block responses</li></ul><p>Example:</p><ul><li>User uploads a file</li><li>Processing happens in background</li><li>User continues using the app</li></ul><h3>3. Synchronous vs Asynchronous Systems</h3><p>Let’s make the difference very clear.</p><h3>Synchronous system</h3><ul><li>One task at a time</li><li>Each step waits for the previous one</li><li>Easy to understand</li><li>Poor scalability</li></ul><h3>Asynchronous system</h3><ul><li>Multiple tasks in progress</li><li>No waiting on slow operations</li><li>More efficient</li><li>More complex</li></ul><h3>A simple mental model</h3><p><strong>Synchronous:</strong><br> wait, then work</p><p><strong>Asynchronous:</strong><br> work while waiting</p><h3>4. Where Asynchronous Systems Fit</h3><p>Use async when:</p><ul><li>You have frequent DB calls</li><li>You depend on external APIs</li><li>You expect high concurrent users</li></ul><p>Avoid relying only on async when:</p><ul><li>Tasks are CPU-heavy</li></ul><p>In that case:</p><ul><li>Use threads or processes</li></ul><h3>5. Drawbacks of Asynchronous Systems</h3><p>This is where most people underestimate the cost.</p><h3>5.1 Increased Complexity</h3><p>Async code is harder to read and reason about.</p><p>Flow is not linear.</p><p>Instead of:</p><ul><li>Step 1 → Step 2 → Step 3</li></ul><p>You now have:</p><ul><li>Multiple tasks running</li><li>Execution happening at different times</li></ul><p>This makes development and debugging harder.</p><h3>5.2 Harder Error Handling</h3><p>Errors in async systems:</p><ul><li>May occur later</li><li>May occur in a different context</li></ul><p>This can lead to:</p><ul><li>Missed exceptions</li><li>Silent failures</li></ul><p>You need proper logging and monitoring.</p><h3>5.3 Not Suitable for CPU-Heavy Tasks</h3><p>Async does not make computation faster.</p><p>If a task is CPU-heavy:</p><ul><li>It still blocks execution</li></ul><p>You need:</p><ul><li>Threading</li><li>Multiprocessing</li></ul><h3>5.4 Race Conditions and Data Issues</h3><p>When multiple tasks run together:</p><ul><li>Shared data can get corrupted</li><li>Execution order is unpredictable</li></ul><p>This introduces:</p><ul><li>Race conditions</li><li>Hard-to-reproduce bugs</li></ul><h3>5.5 Requires Strict Resource Control</h3><p>If you allow unlimited async tasks:</p><ul><li>Too many DB queries</li><li>Too many API calls</li><li>System overload</li></ul><p>That’s why:</p><ul><li>Semaphores</li><li>Rate limiting</li><li>Connection pools</li></ul><p>are essential.</p><h3>5.6 Debugging and Observability is Harder</h3><p>Tracking issues becomes difficult because:</p><ul><li>Execution is not sequential</li><li>Multiple tasks interact</li></ul><p>You need:</p><ul><li>Structured logging</li><li>Distributed tracing</li><li>Metrics</li></ul><h3>6. The Balanced View</h3><p>Asynchronous systems are powerful, but they are not a silver bullet.</p><p>The right approach is:</p><ul><li>Use async for I/O-heavy work</li><li>Use threads or processes for CPU-heavy work</li><li>Always control concurrency</li></ul><h3>7. Final Thought</h3><p>The biggest mistake is thinking async is about speed.</p><p>It is not.</p><p>It is about removing wasted time.</p><p>Once you remove waiting, your system naturally becomes faster, more efficient, and more scalable.</p><h3>Python Examples That Map to the System Design Concepts</h3><p>We’ll keep this practical and aligned with the story.</p><p>Each example shows what changes when you move from blocking to async, and how you control concurrency.</p><h3>1. Blocking vs Asynchronous Execution</h3><h3>Blocking version</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*GqzR8mgDlzWsekB_cHP9zA.png" /></figure><p>What happens here:</p><ul><li>Each request waits for the previous one</li><li>Total time is roughly 6 seconds</li></ul><p>This is your single queue restaurant.</p><h3>Asynchronous version</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HD2qlpCfxp5_B7O-42O6nQ.png" /></figure><p>What changes:</p><ul><li>All tasks run together</li><li>Total time drops to around 2 seconds</li></ul><p>This is multiple order counters working at once.</p><h3>2. Concurrency with asyncio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GthOq7kKTzqt-231KE5iw.png" /></figure><p>What this shows:</p><ul><li>Multiple requests are handled at the same time</li><li>No one waits unnecessarily</li></ul><p>This maps to concurrency in the restaurant.</p><h3>3. Threading for Parallel Work (Chefs Cooking)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GthOq7kKTzqt-231KE5iw.png" /></figure><p>What this shows:</p><ul><li>Multiple tasks actually execute in parallel</li><li>Useful for blocking operations</li></ul><p>This is like multiple chefs cooking at the same time.</p><h3>4. Controlling Load with Semaphore</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-26HDnKOzXkpq8um2c_fqw.png" /></figure><p>What this shows:</p><ul><li>Only 2 tasks run at a time</li><li>Prevents overload</li></ul><p>This is your limited stoves in the kitchen.</p><h3>5. Simulating Async Database Calls</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mS0rbJTh4tPMijmSitpQqA.png" /></figure><p>What this shows:</p><ul><li>Database calls don’t block each other</li><li>Multiple queries execute concurrently</li></ul><p>This is non-blocking I/O in action.</p><h3>6. Connection Pool Concept (Controlled DB Access)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wyXF_V0ksz36r0AJ6IV3ag.png" /></figure><p>What this shows:</p><ul><li>Only 3 DB connections used at a time</li><li>Prevents database overload</li></ul><p>This directly maps to connection pooling in real systems.</p><h3>7. Background Tasks (Decouplig Work)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*Q1JF56CoB_3bEz6ShCtSUA.png" /></figure><p>What this shows:</p><ul><li>User does not wait for long tasks</li><li>Work continues in the background</li></ul><p>This is how modern async systems improve user experience.</p><h3>8. Parallel Service Calls (gRPC Style Thinking)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*ZzaFrshG8DH85LQzibfbDw.png" /></figure><p>What this shows:</p><ul><li>Multiple services are called at the same time</li><li>Faster overall response</li></ul><p>This is how internal services communicate efficiently in real systems.</p><h3>9. What You Should Take Away from These Examples</h3><ul><li>asyncio.gather gives you concurrency</li><li>await prevents blocking</li><li>Semaphore protects your system</li><li>Threads help with parallel execution</li><li>Background tasks decouple work</li></ul><p>Together, these patterns form the backbone of modern scalable systems.</p><h3>Final Thought</h3><p>Async is not about making things faster.</p><p>It’s about eliminating wasted time.</p><p>Once you remove waiting, your system naturally becomes faster, more efficient, and scalable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2566b2234e14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VLM vs OCR: Choosing the Right Tool for Document Intelligence]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@rohandevaki/vlm-vs-ocr-choosing-the-right-tool-for-document-intelligence-bf9bc303bdb1?source=rss-120bb3c4b1cb------2"><img src="https://cdn-images-1.medium.com/max/1536/1*V8MH1rAxphk_Lyw7C6AHzA.png" width="1536"></a></p><p class="medium-feed-snippet">OCR and VLM are not competitors in the way people usually frame them. They solve different layers of the same problem.</p><p class="medium-feed-link"><a href="https://medium.com/@rohandevaki/vlm-vs-ocr-choosing-the-right-tool-for-document-intelligence-bf9bc303bdb1?source=rss-120bb3c4b1cb------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@rohandevaki/vlm-vs-ocr-choosing-the-right-tool-for-document-intelligence-bf9bc303bdb1?source=rss-120bb3c4b1cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf9bc303bdb1</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[visual-language-model]]></category>
            <dc:creator><![CDATA[Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 07:14:10 GMT</pubDate>
            <atom:updated>2026-02-26T07:14:10.655Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The “DRY” Principle: A Lesson I Learned the Hard Way]]></title>
            <link>https://medium.com/@rohandevaki/the-dry-principle-a-lesson-i-learned-the-hard-way-0d3ddc8d570b?source=rss-120bb3c4b1cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d3ddc8d570b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[dry-principle]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 08:43:35 GMT</pubDate>
            <atom:updated>2025-03-02T08:52:15.771Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writing Smarter Code: The Power of the DRY Principle in Software Development</h3><p>🚀 <strong>Why is DRY important?</strong></p><ul><li>Encourages <strong>code reusability</strong></li><li>Reduces <strong>redundant logic</strong></li><li>Improves <strong>maintainability &amp; debugging</strong></li><li>Saves <strong>development time &amp; effort</strong></li></ul><h3>A Lesson from My Experience 🎯</h3><p>While working on a <strong>GenAI chatbot at Amdocs</strong>, I had to <strong>scrape content for the D1 Domain</strong> and create an index for chatbot queries.</p><p>✔️ <strong>What I Did:</strong></p><ul><li>Checked the existing code ✅</li><li>My approach to scraping was different, so I <strong>wrote a new function from scratch</strong> instead of reusing existing logic.</li></ul><p>❌ <strong>What Went Wrong?</strong></p><ul><li>My approach <strong>failed</strong> after <strong>3 days</strong> of effort in coding &amp; testing.</li><li>After discussing with a senior, I realized that <strong>a better, existing approach</strong> could have saved me all that time.</li></ul><h3>🔥 Lesson Learned:</h3><p>✅ <strong>Discuss your approach with seniors (more than one, if possible) before diving into coding.</strong><br>✅ <strong>Think like an engineer constructing a building — consult the architect before building!</strong></p><h3>📌 The Role of Modular Design</h3><p>Breaking a feature into independent <strong>modules</strong> ensures:<br>🔹 <strong>Scalability</strong> — Each module works independently.<br>🔹 <strong>Maintainability</strong> — Easier debugging &amp; updates.<br>🔹 <strong>Efficiency</strong> — Faster development &amp; testing.</p><h3>Example: A Modular Chatbot for D1 Domain</h3><p>🔹 <strong>Data Collection</strong></p><ul><li>Scraping <strong>Confluence pages</strong> or <strong>PDFs</strong><br>🔹 <strong>Storage</strong></li><li>Storing vector data in <strong>ChromaDB</strong><br>🔹 <strong>Indexing</strong></li><li>Organizing vector data by <strong>user-chosen domain</strong><br>🔹 <strong>Model Initialization</strong></li><li>Using <strong>LangChain &amp; OpenAI</strong> to query the RAG model<br>🔹 <strong>API Handling</strong></li><li>Creating APIs to handle <strong>train, query, and index</strong> requests</li></ul><p>💡 <strong>The Takeaway?</strong> Always <strong>reuse existing solutions</strong> when possible and structure your code in a <strong>modular</strong> way to save time and effort.</p><p>#SoftwareDevelopment #DRYPrinciple #CodingBestPractices #AI #GenAI #CareerGrowth</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d3ddc8d570b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ REST API vs GRAPHQL , which one is better? ]]></title>
            <link>https://medium.com/@rohandevaki/rest-api-vs-graphql-which-one-is-better-10ba29f1aef4?source=rss-120bb3c4b1cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/10ba29f1aef4</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Rohan Devaki | AI ML Engineer | AgenticAI/GenAI,ML]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 13:38:07 GMT</pubDate>
            <atom:updated>2023-02-24T06:45:11.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>👉 REST API vs GRAPHQL , which one is better? 🤔</h3><figure><img alt="rest api vs graphql . which is better?" src="https://cdn-images-1.medium.com/max/297/1*7JvnKD_i-ihhVmFXbGEjNQ.jpeg" /></figure><p>🙋‍♂️ Hi guys , I always had a small doubt when I heard there are more than one API, I heard about GRAPHQL, and REST, so I got a doubt that which one should I use and which one is better to use.</p><p>👉In this post, I would like to give a brief on which is the best, I know only REST API, but not GRAPHQL, so I am using some reference materials for completing this post.</p><p><strong>👉 REST API vs GRAPHQL</strong></p><p>Let me start with which one is the best</p><p>✍️ GraphQL is the better than REST</p><p>👨‍💻 The main difference between GRAPHQL and REST</p><p>👉 A REST API is an architectural concept for network-based software. GraphQL, on the other hand, is a query language, a specification, and a set of tools that operates over a single endpoint using HTTP</p><p>👨‍💻 Where GraphQL is better than REST API</p><p>👉 When using a REST API to fetch information, you’ll always get back a complete dataset. For example, if you wanted to request information from two objects, you’d need to perform two REST API requests.</p><p>Lets say you need initial user data, and you need to fetch it from /users/:userID, and secondly you need posts data for that user, so another end point may be. /users/:userID/posts.</p><p>So when the end point is REST API. It would take two HTTP GET requests. They are (I am using json data in this example)</p><pre>/users/:userID<br></pre><pre>{</pre><pre>         “user”:{</pre><pre>             “id”:”user1”,</pre><pre>             “firstName”:”rohan”,</pre><pre>              “lastName”:”devaki”</pre><pre>         }</pre><pre>}</pre><pre>And one more request for posts of userID with end point /users/:userID/posts</pre><pre> {</pre><pre>     “posts”: [{</pre><pre>         “id” :”post1”,</pre><pre>         “title”: “REST_vs_GRAPHQL”,</pre><pre>         “content”:”graphql is better than REST”</pre><pre>      }]</pre><pre>}</pre><p>In GRAPHQL, on the other hand, you need to simply send a query to the GRAPHQL server that includes the data requirements. Then the server responds with the JSON object where the requirements are fulfilled</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*7JvnKD_i-ihhVmFXbGEjNQ.jpeg" /></figure><pre>Query{</pre><pre>  User(id:”user1”){</pre><pre>      Name</pre><pre>      Posts{</pre><pre>           Title     </pre><pre>      }</pre><pre>}</pre><p>👉 So by this we can understand that the GRAPHQL is powerful, flexible and efficient , where as REST is not that much flexible and inefficient.</p><p>👉 GRAPHQL also fetches the data , that is actually required in the query. But REST in the other hand, it fetches all the data that is not even required.</p><p>👨‍💻 as in the above example you can see REST fetched, all of the user and the post details, where as GRAPHQL only fetched the user’s name and the post’s title.</p><p>Don’t just read it ,and get the knowledge, like and share so that others also get the knowledge 😃.</p><p>you are welcomed to tell the points which are need to be improved in the comments section 😃.</p><p>Follow me on<a href="https://www.linkedin.com/in/rohandevaki"> Linkedin here</a> , and I will be back with an informative post soon 😃.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10ba29f1aef4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>