<?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 Ayush Raj on Medium]]></title>
        <description><![CDATA[Stories by Ayush Raj on Medium]]></description>
        <link>https://medium.com/@ayushraj.cs?source=rss-e8338c08ab12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rZ5K_7y-Fs4FEzXyk5gmow.jpeg</url>
            <title>Stories by Ayush Raj on Medium</title>
            <link>https://medium.com/@ayushraj.cs?source=rss-e8338c08ab12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:34:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayushraj.cs/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[A SQL query returns table data, but the query remains in the “Running” or “Executing” state and…]]></title>
            <link>https://medium.com/@ayushraj.cs/a-sql-query-returns-table-data-but-the-query-remains-in-the-running-or-executing-state-and-924097e1a656?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/924097e1a656</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[database-problem]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 06:38:10 GMT</pubDate>
            <atom:updated>2026-10-27T06:38:10.121Z</atom:updated>
            <content:encoded><![CDATA[<h3>A SQL query returns table data, but the query remains in the “Running” or “Executing” state and does not finish normally.</h3><p>This poroblem i troubleshoot while we are working with my application, we are developing a feature and performing database CRUD, obviously we execute query at this point of time everything is working find but sometime or in the interval of time we again and again cougting this issue if we are facing this issue in development phase, for sure if this problem might face in production, think how much you user get frustated when they feel downtime with your application.</p><p>In this article we will write what are the couses might be there when you are facing this situation and how you can resolve this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*dVx5ehSOAw0pbKo82Po-BQ.png" /></figure><p>This can happen when the database starts returning rows before the entire query has completed, when the client is still fetching results, or when the query is waiting for another operation to finish.</p><p>Getting data on the screen does not necessarily mean the query has completed. The exact reason depends on your database (SQL Server, Oracle, PostgreSQL, MySQL, etc.), the query, and the tool you are using.</p><p>Let’s go through the possible causes, how to identify the actual problem, and how to resolve it.</p><h4>Possible causes</h4><p><strong>Scenario A: The query has returned rows, but the client is still fetching data.</strong></p><ul><li>The database or client may be streaming rows gradually. The first rows appear in the results grid, but the remaining rows, network transfer, or result processing has not finished.</li></ul><p><strong>Scenario B: Another transaction is blocking the query.</strong></p><ul><li>Your query may have already done some work but is waiting for a lock held by another session or an uncommitted transaction.</li><li>Some resourses your query needed and they are not getting so the query will always waited for the resources.</li></ul><p><strong>Scenario C: CPU, memory, disk, or temporary storage pressure.</strong></p><ul><li>The query may be performing expensive joins, sorting, aggregation, or scanning a large table. It can return initial rows and still have substantial work remaining.</li><li>Proper Primary or Composite Indexing is missing.</li></ul><p><strong>Scenario D: The database is done, but the client still shows “Executing.”</strong></p><p>The SQL editor, database driver, network connection, or results grid may be slow or waiting for a completion message.</p><p>The first task is to determine whether the database is still executing, waiting, or has finished while the client is still processing the results. These are different problems and require different fixes.</p><h4>Main causes and how to recognize them</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QjmE5sedsAQQR85dXEHP2Q.png" /></figure><p>This helps identify the application and the most recently submitted command. The last command is not necessarily the statement that originally acquired the blocking lock, so you may need transaction and execution-history information as well.</p><p>How to resolve blocking:</p><ol><li>Find the session holding the lock, not just the session waiting for it.</li><li>Check whether the transaction is legitimately running or has been left open accidentally.</li><li>If it is legitimate, allow it to finish or coordinate a suitable maintenance window.</li><li>If an application has left a transaction open, fix its transaction cleanup and error-handling logic.</li><li>If termination is necessary, have the DBA assess the impact before killing the session. A rollback can itself take a long time.</li></ol><p>Avoid restarting the database or killing sessions blindly. SQL Server’s official guidance recommends identifying the head blocker and understanding the transaction before deciding how to resolve it.</p><h4>Could CPU utilization be responsible?</h4><p>Yes, but CPU is only one possibility.</p><p>Suppose the query joins several large tables, performs a sort, and groups millions of records. It may return some rows while still performing a large amount of work.</p><p>There are three useful patterns to distinguish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*o9KOby9Q7IrDh_EbZAZtnw.png" /></figure><p><strong>What to do if CPU is the problem</strong></p><ul><li>Check operating-system CPU usage and database-level CPU consumption.</li><li>Inspect the actual execution plan for expensive operators.</li><li>Review index usage and the number of rows processed versus rows returned.</li><li>Check statistics and whether the query’s plan changed.</li><li>Simplify expensive joins or filters where appropriate.</li><li>Avoid running multiple resource-intensive reports at the same time if they compete with production workloads.</li></ul><p>Do not immediately add indexes or increase CPU capacity without identifying the bottleneck. A poorly designed query can consume substantial CPU even on a powerful server.</p><p>Microsoft describes complex joins, nested-loop joins on large tables, outdated statistics, and missing indexes as common causes of exceptionally long SQL Server queries.</p><p><strong>What if the query is waiting on disk, memory, or the network?</strong></p><p>These are also common possibilities.</p><ul><li><strong>Disk I/O:</strong> A large table scan or slow storage can cause the query to spend substantial time waiting for data. Review database-file latency, read patterns, and the execution plan.</li><li><strong>Memory: </strong>Sorts and hash joins may need large memory grants. Under pressure, queries can wait for memory or spill intermediate results to disk. Review concurrent queries and execution-plan warnings.</li><li><strong>Network: </strong>A query returning a very large result set may take a long time to transfer even after much of the database processing is finished. Check network latency, throughput, and client behavior.</li><li><strong>Client application: </strong>A results grid may process, format, render, or fetch many rows slowly. Test a limited result set and compare the server-side request state with the UI state.</li><li><strong>Transaction log: </strong>Write-heavy operations may wait for log writes. Review log-file latency and log throughput before changing configuration.</li></ul><p><strong>A special case: the query has returned all rows but still does not terminate</strong></p><p>This closely matches the symptom we described earlier, and it deserves separate attention.</p><p><strong>For example:</strong></p><ol><li>You execute a SELECT query.</li><li>The result grid displays rows.</li><li>The grid appears to contain the expected data.</li><li>The query editor continues to show “Executing.”</li><li>Other operations may become slow or blocked.</li></ol><p>In SQL Server, one documented cause is that the client application has not fetched all result rows to completion. Depending on the transaction and isolation level, this can even leave locks held and block other sessions.</p><p><strong>A practical troubleshooting sequence</strong></p><p>Follow this order when the issue occurs again.</p><ol><li>Capture the running state. Record the SQL statement, database name, session ID, elapsed time, wait type, blocker ID, and CPU time.</li><li>Take another snapshot after 10–15 seconds. Determine whether CPU time and reads are increasing or whether the request is waiting.</li><li>Check blocking and transactions. Identify the head blocker and any open transactions. Do not assume the waiting session is the root cause.</li><li>Check server resources. Review CPU, storage latency, memory pressure, and concurrent workloads.</li><li>Check the client. Determine whether it is still fetching or rendering data and whether the database request has completed.</li><li>Review the execution plan. If the query is actively doing work, examine its joins, indexes, estimates, and expensive operators.</li><li>Apply the targeted fix and retest. Compare execution time, resource use, result completeness, and impact on other sessions.</li></ol><h4>Conclusion</h4><p>The query is returning data but remains in the executing state. We need to investigate whether the issue is caused by result fetching, query blocking, resource constraints, or query performance. We are checking SQL Server’s execution status and wait types to identify the root cause and apply the appropriate fix.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=924097e1a656" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Session Layer]]></title>
            <link>https://medium.com/@ayushraj.cs/session-layer-2a9a21352543?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a9a21352543</guid>
            <category><![CDATA[computer-network]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 13:12:09 GMT</pubDate>
            <atom:updated>2026-10-22T13:12:09.584Z</atom:updated>
            <content:encoded><![CDATA[<p>We have completed the transport layer where got to know about data delivery host to host using segments, reliable connection oriented communication over the internet. if you haven’t check out please check this out here <a href="https://medium.com/@ayushraj.cs/transport-layer-6a9546e64a7c"><strong><em>transport layer</em></strong></a>.</p><p>In this page we will know about the Session Layer 5 Layer of the Networking OSI model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*4rqyt9OGOCYABU3sfIRWyw.png" /></figure><p>The session layer is the 5th layer of the OSI model, responsible for establishing, managing, synchronizing, and terminating communication sessions between applications on different devices. It sits between the Transport layer and the Presentation layer, organizing the logical dialogue by controlling who sends data and when, using mechanisms like dialog control and token management.</p><p>This layer basically maintain the session while data is start being transferred from a point to another point, like when Representation layer keep ready to transmit data now come the session layer to make the session ready and being work done after that session get terminated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03G9GWosZadRB04kgcUk-g.png" /></figure><p>This is where OSI becomes less directly useful for modern Internet development.</p><p>The Session Layer conceptually manages:</p><blockquote><strong><em>A communication session between applications.</em></strong></blockquote><p>It deals with things such as:</p><ul><li>establishing sessions</li><li>maintaining sessions</li><li>terminating sessions</li><li>synchronization/recovery concepts</li></ul><p><strong>Real world Example</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*z4QZ-oOpj8zDDUffegNbcA.png" /></figure><h4>Important clarification</h4><p>Modern systems don’t usually implement a separate “Session Layer” exactly as OSI describes.</p><p>Session functionality is commonly handled through higher-level mechanisms such as:</p><ul><li>HTTP cookies</li><li>session IDs</li><li>tokens</li><li>WebSocket connections</li><li>application protocols</li></ul><p>So for backend engineering</p><blockquote><strong><em>Understand the concept, but don’t treat Session Layer as a separate physical component you must deploy.</em></strong></blockquote><h4>Session vs Connection</h4><p>This distinction is useful.</p><p><strong>Connection</strong><br>It means something established to flow transmit and pass, like Network communication channel :</p><pre>TCP connection</pre><p><strong>Session<br></strong>Application-level interaction/state:</p><pre>User logged in : User&#39;s session ID stored in cookies using this server <br>will know and recognise it is already stored, instant remember.</pre><p>They aren’t necessarily the same thing.</p><p><strong>What should you know?</strong></p><p>Understand:</p><ul><li>session</li><li>session ID</li><li>cookies</li><li>authentication state</li><li>connection vs session</li><li>session expiration</li><li>stateless vs stateful architecture : <a href="https://www.geeksforgeeks.org/system-design/stateful-vs-stateless-architecture/"><em>here you can read</em></a></li></ul><p>And that last one will become <strong>very important in system design</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFl-tmgv9gCps8XtOvdK9Q.png" /><figcaption>here some real life example how application is using mechanism.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a9a21352543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transport Layer]]></title>
            <link>https://medium.com/@ayushraj.cs/transport-layer-6a9546e64a7c?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a9546e64a7c</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[transportation]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 12:03:12 GMT</pubDate>
            <atom:updated>2026-10-04T12:03:12.788Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Transport Layer</strong> is <strong>Layer 4</strong> of the OSI model, serving as the critical bridge between the network and application layers to ensure <strong>end-to-end communication</strong> between host processes.</p><p>It is responsible for <strong>segmentation and reassembly</strong> of data, <strong>error detection and recovery</strong>, <strong>flow control</strong> to prevent receiver overload, and <strong>multiplexing</strong> to allow multiple applications to share a network connection simultaneously.</p><p>This layer ensures end-to-end delivery of entire messages. It acts as a liaison between the <strong>Application layer</strong> and the <strong>Network layer</strong>, making sure data reaches the correct application on the destination host.</p><h4>TCP</h4><p>TCP provides:</p><ul><li>connection-oriented communication</li><li>reliable delivery</li><li>ordered byte stream</li><li>retransmission</li><li>flow control</li><li>congestion control</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1YFNbQXhF3JS3mMk893_A.png" /></figure><p>How should two endpoints communicate reliably or efficiently? client and server when connect TCP connection, internally TCP Handle 3 Ways handshaking to establish the connection and communicate.<br>you can have a look here to get more view on <a href="https://medium.com/@ayushraj.cs/how-internet-works-tcp-ip-f5b0d5f4b153"><strong><em>TCP Working</em></strong></a>…</p><p>for here the Transport layer works on this TCP principle to transmit data and other way UDP will be used, we have already explained in this mention reference, please check that out…</p><p>Let’s understand the key term involved in this layer to make the communication efficient.</p><h4>Port</h4><p>Suppose your server has one <strong>IP : 10.0.0.20, </strong>But many applications are running.</p><p>How do we identify the destination service ?</p><ul><li>Using a <strong>port</strong>.</li></ul><pre>10.0.0.20:443</pre><p>Conceptually :</p><pre>IP   → machine / network destination  : village / calony address<br>Port → application endpoint         : your home where you live and identify</pre><p>Examples:</p><pre>22   → SSH<br>53   → DNS<br>80   → HTTP<br>443  → HTTPS</pre><p>Port numbers are not a guarantee that a specific protocol is actually running there; they are conventional assignments.</p><h4>Socket</h4><ul><li>A <strong>socket</strong> is one endpoint of a two way communication link between two programs running on the network.</li><li>The socket mechanism provides a means of inter-process communication (IPC) by establishing named contact points between which the communication take place.</li></ul><h4>TCP Reliability</h4><p>Imagine : when segment carries the packets and transmit via TCP, packet 1, 2 and 3 moving and somehow the 2 get lost, what happen here ?</p><pre>Packet 1<br>Packet 2 &lt;- lost : what will happen ?? 3 will move or not <br>Packet 3</pre><p>Packet 2 gets lost.</p><p>TCP can detect the missing data and <strong>retransmit</strong> it.</p><p>The application gets an ordered byte stream rather than having to handle packet loss itself. this is called reliable delivery of packet or data.</p><h4>Flow Control</h4><p>Question:</p><blockquote><em>Can the receiver keep up ?</em></blockquote><p>If the receiver is slower, TCP can prevent the sender from overwhelming it.</p><h4>Congestion Control</h4><p>Different problem:</p><blockquote><em>Can the network handle the amount of traffic ?</em></blockquote><p>TCP adjusts sending behavior based on network conditions.</p><h4>UDP</h4><p>UDP is much simpler, this is protocol comes in this layer to transmit data in more faster way but not guarantee reliability.</p><p>It provides:</p><ul><li>datagrams</li><li>no built-in delivery guarantee</li><li>no built-in ordering</li><li>no TCP-style connection establishment</li></ul><p>Applications can choose UDP when they need different trade-offs.</p><p>Examples include:</p><ul><li>DNS</li><li>real-time media</li><li>gaming</li><li>QUIC</li></ul><h4>QUIC</h4><p>QUIC is a modern transport protocol built over UDP.</p><p>HTTP/3 uses QUIC :</p><pre>HTTP/3<br>   ↓<br> QUIC<br>   ↓<br> UDP<br>   ↓<br> IP</pre><p>QUIC provides features such as:</p><ul><li>encryption integration</li><li>reliable streams</li><li>multiplexing</li><li>connection migration</li><li>congestion control</li></ul><h4>TCP vs UDP</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*97iePf_az7DoKSxpYkAXRw.png" /></figure><h4>What should you master at Layer 4?</h4><p>Definitely :</p><ul><li>ports</li><li>sockets</li><li>TCP handshake</li><li>TCP connection termination</li><li>sequence/acknowledgment concepts</li><li>retransmission</li><li>flow control</li><li>congestion control</li><li>UDP</li><li>TCP vs UDP</li><li>QUIC</li><li>connection pooling</li><li>keep-alive</li><li>timeout</li><li>retry</li><li>backoff</li></ul><p>These become <strong>very important in system design</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a9546e64a7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Layer (Computer Networking)]]></title>
            <link>https://medium.com/@ayushraj.cs/network-layer-computer-networking-0e1bc0ce8363?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e1bc0ce8363</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 07:10:29 GMT</pubDate>
            <atom:updated>2026-10-02T07:10:29.579Z</atom:updated>
            <content:encoded><![CDATA[<p>We are exploring the computer networking concept in the series we have explained from basic to depth level of working, how computer talk to each other there are several steps which comes in to the path to make the communication successfully, in my last article we have covered the 2nd layer data link layer, now we are going to cover with the 3rd layer of the Open System Interconnection (OSI) Model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiu22-v4gIPYdFtfnmoM7w.png" /></figure><p>The <strong>Network Layer</strong> is the <strong>third layer</strong> of the OSI model, responsible for <strong>logical addressing</strong>, <strong>routing</strong>, and <strong>end-to-end packet delivery</strong> across interconnected networks.</p><p>It distinguishes itself from the Data Link Layer by facilitating host-to-host communication between different networks rather than just node-to-node delivery within a single segment.</p><p>It determines the best physical path for data to reach its destination based on network conditions, the priority of service, and other factors.</p><p>This layer manages logical addressing through IP addresses and handles packet forwarding.</p><p>Key protocols at this layer include the Internet Protocol (IP), which is important for routing and addressing, Internet Control Message Protocol (ICMP) for diagnostic and error-reporting purposes, and routing protocols like Routing Information Protocol (RIP) that manage the routing of data across networks.</p><p>Network layer how work and what handle look at this…</p><ul><li><strong>Data Unit:</strong> Data segments are encapsulated into Packets.</li><li><strong>Logical Addressing:</strong> Assigns unique <a href="https://www.geeksforgeeks.org/computer-science-fundamentals/what-is-an-ip-address/"><strong>IP addresses</strong></a> (sender and receiver) to the packet header to identify devices globally.</li><li><strong>Routing:</strong> Determines the most efficient physical path from the source to the destination across interconnected networks.</li><li><strong>Hardware:</strong> Primarily implemented via <a href="https://www.geeksforgeeks.org/computer-networks/difference-between-router-and-switch/"><strong>Routers and Switches</strong></a>.</li><li><strong>Inter-networking:</strong> Facilitates communication between disparate networks by directing traffic to the correct destination.</li></ul><h4>IP Address</h4><p>It is nothing but a way to address or located the devices on network using other device can uniquely identify and communicate, it make the way and decide how the data is being Packaged, Addressed, Transmitted, Routed and Received, no matter where the device present in the world.</p><p>It’s just like a device home address which use Internet Protocol, provided by the internet service provider and make a way to transmit data over the internet, across world.</p><p>There are <a href="https://www.geeksforgeeks.org/computer-science-fundamentals/what-is-an-ip-address/"><strong>IP addresses</strong></a> Reference you can read and understand in more clear way.</p><p>Example:</p><pre>192.168.1.10</pre><p>or:</p><pre>142.x.x.x</pre><p>IPv4 uses 32-bit addresses.</p><p>IPv6 uses 128-bit addresses.</p><h4>Private vs Public IP</h4><p>Private addresses are commonly used inside local networks.</p><p>Examples:</p><pre>10.0.0.0/8<br>172.16.0.0/12<br>192.168.0.0/16</pre><p>A public IP is reachable through the public Internet subject to routing and security controls.</p><h4>Router</h4><p>A router connects different networks.</p><ul><li>This perform very important role while data transmission over internet and in mainly network layer, it sit at Local Area Network, which convert your data into packets and guarantee to take it forward where do you want to send data, now this packet get handled by router mapping in router table, this packet actually travel across network provided by ISP, when packet reaches to the end server there it will get converted back to actual format of data understand of the device.</li><li>This make the most efficient path to take your data packet to the destination..</li><li>This perform also NAT (Network Address Translation)</li></ul><p>flow we will look below…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*3VHNt_8rfdqsnzu-AVTZ8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yOoEvysbjd47_1hShVSXQQ.png" /></figure><h4>Routing Table</h4><p>A router has rules such as:</p><pre>Destination       Next Hop<br>10.0.0.0/8        Network A<br>192.168.1.0/24    Network B<br>0.0.0.0/0         ISP</pre><p>The router essentially asks:</p><blockquote><em>“Which route should I use?”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*gcj9Fg9VqhEcmKsGXUGOpA.png" /></figure><h4>Default Gateway</h4><ul><li>Your machine may not know how to reach every network.</li></ul><p>So it sends unknown destinations to its:</p><blockquote><strong><em>Default Gateway</em></strong></blockquote><p>Usually your local router.</p><pre>Laptop<br>   ↓<br>Default Gateway<br>   ↓<br>Internet</pre><h4>NAT</h4><ul><li>Very important for real-world networking.</li><li>Network Address Translation (NAT) allows multiple devices in a private network to access the internet using a single public IP address. It helps conserve IPv4 addresses and hides internal systems for added security.</li></ul><p>Your home may contain:</p><pre>Laptop → 192.168.1.10<br>Phone  → 192.168.1.11<br>TV     → 192.168.1.12</pre><p>But your router may have one public IP.</p><p>NAT translates between private and public addressing.</p><pre>Private network<br>      ↓<br>     NAT<br>      ↓<br>Public Internet</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Wzv5eTnWZvNc3-T2VV6mQg.png" /></figure><p>This is one reason many devices can share a public IPv4 address.</p><h4>ICMP (Internet Control Message Protocol)</h4><ul><li>ICMP is used for network control and diagnostic messages.</li><li>A network-layer protocol used for error reporting and diagnostics in IP networks.</li></ul><p>Two tools you should know:</p><p><strong>ping : </strong>Tests reachability and measures round-trip time.</p><pre>ping server.com</pre><p><strong>traceroute / tracert : </strong>Shows the path through intermediate routers/hops.</p><pre>Your machine<br>    ↓<br>Router 1<br>    ↓<br>Router 2<br>    ↓<br>Router 3<br>    ↓<br>Destination</pre><h4>TTL</h4><ul><li>IP packets have a TTL (IPv4) / Hop Limit (IPv6).</li><li>It prevents packets from circulating forever due to routing problems.</li></ul><p>Conceptually:</p><pre>TTL = 10</pre><pre>Router → 9<br>Router → 8<br>Router → 7<br>...</pre><p>Eventually the packet expires.</p><p>I hope you get the network layer concept how things work…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e1bc0ce8363" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Link Layer]]></title>
            <link>https://medium.com/@ayushraj.cs/data-link-layer-f000104c1aa9?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/f000104c1aa9</guid>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Tue, 29 Sep 2026 13:10:14 GMT</pubDate>
            <atom:updated>2026-09-29T13:10:14.831Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Data Link Layer</strong> (Layer 2) is the second layer of the OSI model, responsible for <strong>node-to-node data delivery</strong> between directly connected devices on the same network segment.</p><p>It sits between the Physical and Network layers, converting raw bit streams into structured <strong>frames</strong> to ensure reliable, error-free transmission over the physical medium.</p><p>The Data Link Layer deals with:</p><blockquote><strong><em>frames + local network communication</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*1axfUVRJj31_RRaPXPgfNA.png" /></figure><h4>Key functions</h4><p>Include these are the stuffs</p><ul><li><strong>framing</strong> : encapsulating network packets into frames with headers and trailers.</li><li><strong>physical addressing</strong> : using MAC addresses to identify sender and receiver devices.</li><li><strong>error detection</strong> : using checksums like CRC to identify corrupted data.</li><li><strong>flow control</strong> : regulating data speed to prevent overflow. and</li><li><strong>media access control : </strong>managing access to shared transmission media to avoid collisions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKFClmRZ_AoSCVVXbhc5Qg.png" /></figure><p>The <strong>layer</strong> is divided into two <strong>sublayers</strong> :</p><ul><li>the <strong>Logical Link Control (LLC)</strong>, which handles protocol identification and error or flow control, and</li><li>the <strong>Media Access Control (MAC)</strong>, which manages hardware addressing and access to the physical medium.<br> Common <strong>protocols</strong> include <strong>Ethernet</strong>, <strong>PPP</strong>, <strong>HDLC</strong>, and <strong>WiFi (IEEE 802.11)</strong>, while primary hardware devices operating at this layer are <strong>switches</strong> and <strong>network interface cards (NICs)</strong>.</li></ul><h4>MAC Address</h4><p>Every network interface generally has a <strong>MAC address</strong> used for communication on a local network.</p><p>Example:</p><pre>A4:5E:60:12:AB:91</pre><p>Conceptually:</p><pre>IP  → Which network destination?<br>MAC → Which interface on the local network?</pre><p>Don’t think of MAC as a globally routable Internet address. It is primarily relevant to <strong>local network delivery</strong>.</p><h4>Ethernet</h4><p>Ethernet is one of the major technologies used at the Data Link layer.</p><p>A packet at the network layer gets encapsulated into a <strong>frame</strong> for local transmission.</p><p>Conceptually:</p><pre>Network packet<br>      ↓<br>Ethernet frame<br>      ↓<br>Physical signal</pre><p>An <strong>Ethernet frame</strong> is the fundamental data unit at the <strong>Data Link Layer (Layer 2)</strong> used to encapsulate and transmit data across a local network.</p><p>It functions as a standardized envelope that wraps higher-layer data (like IP packets) with necessary metadata for local delivery, ensuring devices know the sender, recipient, and data integrity.</p><p>The frame structure consists of a <strong>header</strong>, <strong>payload</strong>, and <strong>trailer</strong>, typically totaling <strong>64 to 1,518 byte.</strong></p><h4>Frame</h4><p>A simplified frame contains things such as:</p><pre>┌──────────────┬──────────────┬─────────┐<br>│ Destination  │ Source MAC   │ Payload │<br>│ MAC          │              │         │<br>└──────────────┴──────────────┴─────────┘</pre><h4>Switch</h4><p>A <strong>network switch</strong> connects devices within a local network.</p><p>Example:</p><pre>Laptop ──┐<br>Phone  ──┼── Switch ── Router<br>Server ──┘</pre><p>The switch uses MAC addresses to forward Ethernet frames within the local network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTy787kMKTP0t7d_s78c-A.png" /></figure><h4>ARP</h4><p>It is Very important. a middle man which identify and address the local network taking IP address input understand it and map with correct local area network location in device thats ARP ( Address Resolution Protocol).</p><p><strong><em>ARP is a network protocol that maps an IP address to a device’s MAC address on a local network, and while I cannot show images, I can describe what typical ARP diagrams look like.</em></strong></p><p>ARP connects <strong>Layer 3 (IP)</strong> to <strong>Layer 2 (MAC)</strong> by answering the question:<br><strong>“Who has this IP address ? Tell me your MAC address.”</strong></p><p>Suppose your laptop knows:</p><pre>192.168.1.20</pre><p>but needs the corresponding local MAC address.</p><p>With IPv4, <strong>ARP</strong> can resolve:</p><pre>IP → MAC</pre><p>Example:</p><pre>&quot;Who has 192.168.1.20?&quot;<br>             ↓<br>        Device responds<br>             ↓<br>&quot;That&#39;s my MAC.&quot;</pre><p>For IPv6, neighbor discovery (NDP) serves related functions instead of ARP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*-59m67SvApGUd_GtuzOTkQ.png" /></figure><h4>What should you know at Layer 2?</h4><p>For backend/system design:</p><ul><li><strong>MAC address </strong>: which route request to end device identifing IP to local Address.</li><li><strong>Ethernet </strong>: which hold the frame of collection of data and pass to device.</li><li><strong>Wi-Fi at a practical level</strong> : a way of talking device using signal and protocol connecting with each other.</li><li><strong>frames </strong>: a unit where chunk of data kept and travel to device.</li><li><strong>switches :</strong> which connect devices to process request at base level mean device how talk.</li><li><strong>ARP :</strong> Address Resolution Protocol, which map IP to MAC Address.</li><li><strong>VLAN basics : </strong>A VLAN is a virtual network that lets you group devices logically on the same network even if they are not physically connected to the same switch.</li><li><strong>collision/broadcast concepts : </strong>A collision occurs when multiple devices transmit on the same shared medium simultaneously causing interference, while a broadcast is a frame sent by one device to all devices on the local network segment.</li><li><strong>local network communication : </strong>LAN communication means devices within a small area — like a home, office, or school — exchange data quickly using wired Ethernet or Wi‑Fi through switches and routers.</li></ul><p>You don’t need to memorize every Ethernet frame field initially.</p><p>I hope you get this explanation of Data Link Layer, we will meet in next lesson in next layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zulWWszn62r2QDvJujPLrw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f000104c1aa9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Networking | How Machine Communicate over internet]]></title>
            <link>https://medium.com/@ayushraj.cs/networking-how-machine-communicate-over-internet-346eab6a9770?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/346eab6a9770</guid>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 09:09:35 GMT</pubDate>
            <atom:updated>2026-09-27T09:09:35.390Z</atom:updated>
            <content:encoded><![CDATA[<p>we have know a lot of networking concepts while learning http series in the system design and architecturing to build a good foundation to start and get the thing in a understandable way we need to deep dive into several things and one of them is actually Networking, what we are trying to know and build the system that can used by people , like anything you see any application any website whatever they all are responding you mean you are communicating and getting things are done, here what happen most of people don’t know.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwfgUEp5xRYBR0KjaS51Ug.png" /></figure><p>we most of thing have covered like client server interaction, HTTP , now the vary first thing need to know the system machine how interact with each another on internet.</p><p>how message or anything get passed from one machine to other like</p><ul><li>how you are able to chat , send images videos and connect on calls.</li><li>how you are able to buy anything from home and get after sometime.</li><li>how people are facilitating with booking tickets , rents or anything.</li></ul><p>there are lot of thing come into the place including ai, when we start talking about we can’t get ending up at a place, my purpose of that to know about the communication.</p><p>there are huge thing take place to make communication possible one by one we will try to know as a software engineer.</p><p>after completing this we will be connect these all with our system design journey.</p><h3>Let me you know this important thing | Internet</h3><p>Internet is probably one of the most greatest and fantastic amazing technology invented in the modern history .</p><p>It was invented in late 1960s with the creating of ARPANET by the US Department of Defense . the idea of ARPANET came from the communication among the computer , how can two computer connect and communicate with each another in a medium this is what mean by ARPANET .</p><p>Let’s suppose how humans communicate with each other in medium or space , transmit the information or things to each another how is it possible by hearing , listing , moving or making connection , here AIR comes in between with helps to make connection so that we can pass information and data , or we can exchange the data to each other .</p><p>Similar to that a medium which allows computer to connect and communicate with each other that the key point , and here the medium works as networks . NETWORK comes into picture .</p><p>like human to human communication , you ask an apply to a person if person knows apple they will give you if they have. but if you or your machine ask to other machine same thing they initially don’t have , someone have to tell this is apply and the computer machine will give or tell about apple.</p><p>locally in same workspace i mean at same address if you thing or two machine is working they can connect with each other easily but thing about if one machine is in india and dubai, how both the computer will talk. they can’t talk until they come to at place where medium can make. at the end of the series you are able to map with everything.</p><h3>WWW comes</h3><p>After so many researchers had been done for over the years and create this “ NETWORK OF NETWORKS “ as we are using this modern internet . In late 1990s computer scientist <strong>Tim Berners-Lee</strong> invented the <strong>World Wide Web</strong>. This enabled information exchange on the Internet on an unprecedented scale using links and websites.</p><p>Today, we enjoy a colorful online world full of opportunities to learn new things, communicate with others using <strong>whatsApp ,chats , video or voice calls , watching videos , playing games etc</strong> there are huge internet of things nowadays that we are using in daily life this is how happen possible.</p><p>These all things works under the service like TCP / IP etc protocols which make it possible to transfer data and make communication between computers , use rules protocols and security .</p><h3>Now we will go to the networking concepts based one OSI Model</h3><p>while studying OSI model we will understand everything at each stage related to the learning and real purpose , without any wastage</p><p>before moving to OSI Model understand one thing, how computer talks</p><p>Computers communicate by converting data into <strong>binary signals</strong> (ones and zeros) transmitted via physical mediums like <strong>Ethernet cables</strong>, <strong>fiber optics</strong>, or <strong>radio waves</strong> (Wi-Fi, Bluetooth).</p><p>These signals are organized into structured units called <strong>packets</strong> or <strong>frames</strong>, which include headers containing source and destination addresses to ensure data reaches the correct device.</p><p>The <strong>Internet</strong> is a <strong>global system of interconnected computer networks</strong> that uses the <strong>Internet Protocol Suite (TCP/IP)</strong> to communicate between devices. It is often referred to as a “<strong>network of networks</strong>” because it links millions of private, public, academic, business, and government networks locally and globally through electronic, wireless, and optical technologies.</p><p>Key aspects of the Internet include:</p><ul><li><strong>Infrastructure</strong>: It consists of physical components like fiber-optic cables, routers, switches, and data centers that facilitate the transmission of data.</li><li><strong>Function</strong>: It enables the <strong>fast exchange of information</strong>, files, and services such as email, social media, online shopping, and streaming media.</li><li><strong>Distinction from the Web</strong>: The Internet is the underlying <strong>infrastructure</strong>, while the <strong>World Wide Web (WWW)</strong> is a service built on top of it, comprising interconnected web pages accessed via browsers.</li><li><strong>Access</strong>: Users connect to the Internet via <strong>Internet Service Providers (ISPs)</strong> using various technologies like broadband, Wi-Fi, or mobile networks</li></ul><p>you might have confusing with the term above mentioned but the fact it is we will understand everything.</p><h3>OSI MODEL</h3><p>The <strong>OSI model</strong> (Open Systems Interconnection) is a <strong>seven-layer conceptual framework</strong> developed by the <strong>ISO</strong> in <strong>1984</strong> to standardize how different computer systems communicate over a network.</p><p>It breaks down network communication into distinct layers to ensure interoperability and simplify troubleshooting.</p><p>The seven layers, from bottom to top, are:</p><ol><li><strong>Physical Layer</strong>: Handles raw bit transmission over physical media.</li><li><strong>Data Link Layer</strong>: Manages node-to-node data transfer and error detection.</li><li><strong>Network Layer</strong>: Determines routing paths and logical addressing.</li><li><strong>Transport Layer</strong>: Ensures reliable end-to-end data delivery.</li><li><strong>Session Layer</strong>: Establishes, manages, and terminates connections.</li><li><strong>Presentation Layer</strong>: Handles data formatting, encryption, and compression.</li><li><strong>Application Layer</strong>: Provides network services directly to user applications.</li></ol><p>While the modern internet primarily uses the simpler <strong>TCP/IP model</strong>, the OSI model remains a critical educational and troubleshooting tool for understanding network architecture.</p><p>here look at the picture what we are going to covered</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*_R5QLTrOz19Jz93CXPVX9Q.png" /></figure><p>another picture you can see over there</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itdriJj0fX89cXEQLOp0kQ.png" /></figure><p>Now we will understand the All layers one by one and all those important things required to know in between basic terminology come from <strong>1st Physical Layer to last Application Layer.</strong></p><p><a href="https://app.notion.com/p/Physical-Layers-3dbcf039894280eeb24bf63db340fca6?pvs=21">Physical Layers</a></p><p><a href="https://app.notion.com/p/Data-Link-Layer-3e7cf039894280cba1fbe320b625eea6?pvs=21">Data Link Layer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=346eab6a9770" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Physical Layers]]></title>
            <link>https://medium.com/@ayushraj.cs/physical-layers-bd2fcc1068dc?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd2fcc1068dc</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[physical-layer]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 09:09:13 GMT</pubDate>
            <atom:updated>2026-09-26T09:09:13.817Z</atom:updated>
            <content:encoded><![CDATA[<p>Which layer or medium talks with computer in it’s binary language only deal with 0’s and 1’s at very bottom level.</p><p>The Physical Layer deals with the <strong>actual transmission of bits through a physical medium</strong>.</p><p>Ultimately, computers communicate using:</p><pre>0 1 0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 1 1...............</pre><p>Those bits must physically travel somehow.</p><p>They can travel through:</p><ul><li>copper cable</li><li>fiber optic cable</li><li>radio waves</li><li>Wi-Fi</li><li>cellular networks</li></ul><p>look in visual how data transmission happen at machine level in the electrical signal form and somewhere present the bits, computer plays around these bits by passing this signal <strong>Analog and Digital.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iu3ByHwaEFmOFMRZlthCiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6cjK5tkv9-P8SJR5YxtuSA.png" /></figure><p>look at the wire and physical mechanism used to by pass the signal for computer work or compute.</p><h3>Bit</h3><p>The smallest unit using the computer machine process something:</p><pre>0 or 1</pre><h3>Signal</h3><p>A bit is represented physically through some signal.</p><p>For example:</p><pre>Copper → electrical signal<br>Fiber → light pulses<br>Wi-Fi → radio waves</pre><h3>Bandwidth</h3><p>The theoretical capacity of a communication channel.</p><p>For example: 1 Gbps , Mbps , Kbps , Tbps etc</p><p>doesn’t mean every application will actually transfer 1 Gbps.</p><p>That’s where <strong>throughput</strong> comes in.</p><h3>Bandwidth vs Throughput</h3><p>This is very important from your previous session.</p><pre>Bandwidth = maximum potential capacity can passed data not guaranty for successful.<br>    for successful surety comes where throughput<br>Throughput = actual amount successfully transferred per unit time or per unit amount</pre><p>Example:</p><pre>Road capacity = 1000 cars/hour<br>Actual traffic = 700 cars/hour</pre><p>Bandwidth ≈ road capacity.</p><p>Throughput ≈ actual traffic.</p><h3>Latency at Physical Layer</h3><p>Physical distance matters.</p><p>If a server is geographically far away:</p><pre>Delhi<br>   ↓<br>Singapore<br>   ↓<br>USA</pre><p>the signal has to travel a much larger distance.</p><p>That contributes to latency.</p><h3>Real-life analogy</h3><p>Think about sending water through a pipe.</p><pre>Pipe size → capacity<br>Water actually flowing → throughput<br>Time taken to reach destination → latency</pre><h3>Hub and Switch</h3><p>A <strong>hub</strong> in the physical layer is a basic networking device that connects multiple Ethernet devices, making them act as a single network segment.<br> It operates exclusively at <strong>Layer 1 (Physical Layer)</strong> of the OSI model, meaning it has no intelligence to read MAC addresses or filter data. MAC Address we will know later….</p><ul><li>Hub is functioning as non-intelligent multi-port repeaters that broadcast electrical signals to all connected ports.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*xGtINjNevnEam3B9-Zjeew.png" /></figure><ul><li><strong>Switches</strong> primarily operate at <strong>Layer 2 (Data Link Layer)</strong>, using MAC addresses to intelligently forward data frames only to the specific destination port.</li></ul><h3>Physical layer topology</h3><p>The Topology of a physical layer is the arrangement of network devices. You can work with five physical topologies, including the following.</p><h4>Star topology</h4><ul><li>Star topology is a network topology characterized by all devices connecting to a single central device or node.</li><li>This central node can be either a switch or a hub that transmits data between the devices. This type of topology can be beneficial because it is robust against single cable failure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*_J5I0KQTwHQcVq83BmBAqQ.png" /></figure><h4>Mesh topology</h4><ul><li>Mesh topology connects each device to all other devices within the network. This type of system can prevent congestion in communication between devices because it provides a dedicated path between each device in the system.</li><li>It also provides easy scaling, enabling devices to add without disrupting current communication channels. However, this type of topology can be more challenging to install because of the higher number of inter-device connections.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*uEkJmbKZ3eqUYo3Y2etmIg.png" /></figure><h4>Bus topology</h4><ul><li>Bus topology connects multiple devices along a single cable that acts as the “spine” of the system.</li><li>It can be cost-effective compared to other topologies, but it can also lead to privacy issues because all devices use the same communication line. In addition to this, adding or removing devices poses challenges as it disrupts the current system.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*lF1PulsHe30HUsBz7N4bAQ.png" /></figure><h4>Ring topology</h4><ul><li>Ring topology connects all devices along a circular path. Devices can transmit data to devices on either side of them through the ring.</li><li>This type of topology has relatively easy installation, but expansion or disruptions can affect all devices in the system..</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*0Vbcz5utVp-k1CepJ0LTUg.png" /></figure><h4>Wireless topology</h4><ul><li>Wireless topologies don’t need physical cabling between devices, which prevents disruptions due to cable breaks or the installation of new devices.</li><li>This type of topology is especially useful for remote users and easily scales to accommodate more devices on the network. However, this type of system has certain security concerns and can have higher latency than wired topologies.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztI_8FOVamVM2vMPReHddA.png" /></figure><p><strong><em>The Physical Layer handles the raw hardware transfer of unformatted bits (1s and 0s) between devices over wired or wireless mediums.</em></strong></p><h4>Key Attribute</h4><p><strong>Signal Conversion &amp; Modulation:</strong></p><ul><li>Converts digital data into physical signals (analog waves or digital pulses) using techniques like ASK, FSK, and PSK to maximize speed and reduce noise.</li></ul><p><strong>Transmission Mediums:</strong></p><ul><li>Uses physical cables (Ethernet, copper, fiber) or wireless frequencies (Wi-Fi, Bluetooth).</li></ul><p><strong>Transmission Modes:</strong><br> ◦ <strong>Simplex:</strong> One-way only (e.g., keyboard → PC).<br> ◦ <strong>Half-Duplex:</strong> Two-way, but one at a time (e.g., walkie-talkies).<br> ◦ <strong>Full-Duplex:</strong> Two-way simultaneously (e.g., phone call).</p><h3>Primary Services</h3><ul><li>Controls bit rate and synchronizes timing between sender and receiver.</li><li>Defines network topologies (star, bus, mesh) and physical connector interfaces.</li><li>Handles signal processing and error correction at the hardware level.</li></ul><h3>Key Limitations</h3><ul><li><strong>Does NOT include:</strong> Cable production/installation, data formatting, encryption, session control, or error recovery (these belong to higher OSI layers).</li></ul><h3>Common Examples &amp; Protocols</h3><p>Ethernet, USB, Bluetooth, Digital Subscriber Line (DSL), and Controller Area Network (CAN).</p><p>you can see there global view of the networking how devices work , process and communicate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*dBLUt7tT_kjPXbKhRl_IhA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd2fcc1068dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP vs HTTPS]]></title>
            <link>https://medium.com/@ayushraj.cs/http-vs-https-5884237c01d3?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/5884237c01d3</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[concept]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 09:30:03 GMT</pubDate>
            <atom:updated>2026-09-06T09:30:03.093Z</atom:updated>
            <content:encoded><![CDATA[<p>In this page we will understand the difference between HTTP and HTTPS , the protocols which enable communication and secure communication over the internet behind that the actual fact we will try to know. so let’s quickly see the http first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*v_LSUEQYzk0ba-ER7_F_1A.png" /></figure><h4>First understand HTTP ( HyperText Transfer Protocol)</h4><p>Imagine you are sending a letter through a transparent envelope</p><ul><li>HTTP is a protocol used for communication between a <strong>client and a web server</strong>.</li><li>It defines how the client sends a request and how the server sends a response.</li><li>Example: Browser sends GET /users → server returns user data.</li><li>HTTP sends data in <strong>plain text</strong>.</li><li>Anyone who can intercept the communication may be able to <strong>read or modify the data</strong>.</li><li>HTTP normally uses <strong>port 80</strong>.</li><li>It does not provide encryption by itself.</li><li>It is therefore not suitable for sensitive information such as passwords, payment details, tokens, etc</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*USPdXoIoy64A-v68lNZ5GQ.png" /></figure><p>when user type and hit the request to access something using client it can by web browser , mobile application behind the scene what actually happened , user don’t know. here HTTP comes in middle while take and make connection to transfer data. how it ivolved by the time we know in the previous page if didn’t checked out please look at those .</p><p>basically it make channel by establishing connect over the internet so that client or browser can send request to server and get some response back by the server. that basically i am trying to let you know.</p><p>it provide the way to interact with server we will get in the next page in future but before that it’s very important to understand the thing.</p><p>suppose you are trying to get login your instagram profile using web browser. what you basically do here simple open the login page and you will fill the credentials username and password. without worrying anymore.</p><p>at this point you being an user don’t no there is chance to get you username and password hacked because of HTTP don’t provide security while transferring data from client to server and back. because of being not secure HTTP the attacker can trace you data and licked. here the actual problem with this but http provide only communication not <strong>security</strong>. now comes the https into the picture to transfer data safely and securely over the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pyqFomwGZ2M_AKC3j_EdA.png" /></figure><h4>Now HTTPS</h4><ul><li>HTTPS is essentially <strong>HTTP running over a secure TLS connection</strong>.</li><li>It provides encryption between the client and server.</li><li>Data is encrypted before being transmitted over the network.</li><li>If someone intercepts the communication, they should not be able to understand the encrypted data.</li><li>HTTPS normally uses <strong>port 443</strong>.</li><li>HTTPS uses <strong>TLS certificates</strong> to help establish a secure connection and verify the server’s identity.</li><li>It protects against important attacks such as <strong>eavesdropping and data tampering</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*WqAadnGzr0MWsUXal_St5Q.png" /></figure><p>HTTPS perform action in between after taking data from client and encrypt that using private and public key keep and keep the private key to self and public key send to server along with the encrypted data. so that further server can understand the sent data by decrypt to read and process. at the time of sending response back server encrypt again response and send to the client. thus the secure communication has been done using HTTPs protocol .</p><p>This happen in quick and http manage this internally .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4cM5l7UV0k0IelLQSjnKg.png" /></figure><p>here what i explained above showing in this picture you can see how http internally do TLS. using SSL .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*SbauAjL7J4fdkN3Qga43qw.png" /></figure><h4>But HTTPS does more than encryption</h4><p>There are <strong>three important ideas</strong> to remember.</p><pre>                 HTTPS / TLS<br>                     │<br>      ┌──────────────┼──────────────┐<br>      ↓              ↓              ↓<br>Confidentiality   Integrity    Authentication<br>      │              │              │<br>      ↓              ↓              ↓<br>   Hide data      Detect         Verify<br>   from others    tampering      server<br>   <br>   --------------------------------------------------------------------<br>   ① Confidentiality<br>   <br>      Browser ─────🔐─────► Server   [ Attacker sees encrypted data ]<br>      <br>   --------------------------------------------------------------------<br>   ② Integrity<br><br>      Suppose you send: Transfer ₹100 <br>      An attacker should not be able to silently change it to : <br>      Transfer ₹10,000<br>      without the modification being detected.<br>      server will know that&#39;s 100 using public key<br>   ----------------------------------------------------------------------<br>   ③ Authentication<br>      <br>Your browser needs confidence that it is actually communicating with the <br>intended website.This is where TLS certificates come into the picture.</pre><h4>What is the certificate?</h4><p>This part often confuses beginners.</p><pre>Suppose you want to visit: &quot;&lt;https://hdfc.com&gt;&quot;</pre><p>Your browser needs to establish a secure connection with the server.</p><p>The server presents a <strong>TLS certificate</strong>.</p><p>Think of it like an official identity document:</p><pre>             BANK SERVER<br>                 │<br>                 │<br>                 ▼<br>        ┌─────────────────┐<br>        │ TLS Certificate │<br>        │                 │<br>        │  Identity       │<br>        │  Public Key     │<br>        │  Validity       │<br>        └─────────────────┘<br>                 │<br>                 ▼<br>              Browser</pre><p>The certificate helps the browser establish that the server is authorized for the domain and provides cryptographic information needed for the secure connection.</p><h4>7. What happens when you type HTTPS?</h4><pre>Suppose you type: &quot;&lt;https://hdfc.com&gt;&quot;</pre><p>A simplified picture is:</p><pre>       BROWSER<br>          │<br>          │  1. Connect<br>          ▼<br>       SERVER<br>          │<br>          │  2. Certificate<br>          ▼<br>       BROWSER<br>          │<br>          │  3. Establish TLS security<br>          ▼<br>       SERVER<br>          │<br>          │  4. Secure communication<br>          ▼<br>    🔐 ENCRYPTED DATA</pre><p>After the secure connection is established:</p><pre>Browser<br>   │<br>   │ 🔐 encrypted HTTP request<br>   ▼<br>Internet<br>   │<br>   │ 🔐<br>   ▼<br>Server<br>   │<br>   │ 🔐 encrypted HTTP response<br>   ▼<br>Browser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*tq6-DKyqH6jdVJlnrHFY6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PlGIAVYSQCY4uXEoEK3ahA.png" /></figure><h4>Important Principle</h4><p><strong>HTTP defines how communication happens. <br>HTTPS adds security to that communication through TLS.</strong></p><p>So HTTPS is not a completely different application protocol. Conceptually:</p><p><strong>HTTP + TLS = HTTPS</strong></p><h4>What HTTPS Provides</h4><p>HTTPS mainly provides three important security properties:</p><ol><li><strong>Confidentiality</strong> — others should not be able to read the transmitted data.</li><li><strong>Integrity</strong> — data should not be modified silently while travelling.</li><li><strong>Authentication</strong> — the TLS certificate helps the client verify that it is communicating with the intended server.</li></ol><p><strong>Easy way to remember:<br></strong><em>HTTP = Communication<br>HTTPS = Communication + Security</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5884237c01d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Backend Engineering Roadmap Phase 3 (Advanced Backend Engineering)]]></title>
            <link>https://medium.com/@ayushraj.cs/java-backend-engineering-roadmap-phase-3-advanced-backend-engineering-b7f2c0b08ca1?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7f2c0b08ca1</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-design]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Sat, 20 Jun 2026 06:13:14 GMT</pubDate>
            <atom:updated>2026-06-20T06:13:14.518Z</atom:updated>
            <content:encoded><![CDATA[<p>After completing the fundamentals of Java and backend development, I realized that building APIs is only one part of becoming a software engineer.</p><p>In <a href="https://medium.com/@ayushraj.cs/java-developer-important-interview-question-e97c2435189a?postPublishedType=repub"><strong>Phase 1</strong></a>, I focused on Core Java concepts such as OOP, Collections, Exception Handling, and Multithreading. These topics helped me understand how to write clean and efficient code.</p><p>In <a href="https://medium.com/@ayushraj.cs/java-developer-important-interview-question-phase-2-f6d8269c905d"><strong>Phase 2</strong></a>, I moved into backend development concepts including SQL, Database Design, REST APIs, Client-Server Architecture, SOLID Principles, Design Patterns, Spring Boot, JPA, and Hibernate. These topics taught me how modern backend applications are built and how different layers of an application communicate with each other.</p><p>Now begins Phase 3 — the stage where backend systems must handle thousands or even millions of users.</p><p>At this level, interviewers and engineers are less interested in syntax and more interested in architecture, scalability, reliability, and distributed systems.</p><p>In this phase, I will explore:</p><ul><li><strong>Microservices Architecture</strong><br>• Kafka and Event-Driven Systems<br>• Redis and Caching<br>• System Design<br>• Distributed Systems Fundamentals<br>• Core Engineering Concepts<br>• Real-world Backend Architecture Scenarios</li></ul><p>Let’s begin with one of the most important concepts in modern backend development: Microservices.</p><h4>Microservices (Top 15 Interview Questions)</h4><p><strong>Q1. What are Microservices ?</strong></p><pre>Microservices is an architectural style where an application <br>is divided into multiple small independent services.<br><br>Instead of: One Huge Application<br><br>we build:<br> 1. User Service<br> 2. Order Service<br> 3. Payment Service<br> 4. Notification Service<br> 5. Inventory Service<br>and many more we can add as per requirement that work independently like<br> 6. Discount Service<br><br>Each service has its own responsibility.<br><br>Benefits<br> - Independent deployment.<br> - Better scalability.<br> - Easier maintenance.<br> - Fault isolation.<br> - Faster development by multiple teams.</pre><p><strong>Q2. What is Monolithic Architecture ?</strong></p><pre>Before Microservices, most applications were built as a single application.<br><br>Example: E-Commerce Application  <br>         - Users<br>         - Orders<br>         - Payments<br>         - Inventory<br>         - Notifications<br><br>Everything inside one application , This is called a Monolith.<br><br>Problems : <br>  - Difficult to scale.<br>  - Slow deployments.<br>  - Large codebase.<br>  - Single point of failure.<br>  - Hard for multiple teams to work simultaneously.</pre><p><strong>Q3. Monolith vs Microservices</strong></p><pre>-------------------------------------------------------------------------<br>|            Monolith                |            Microservices         |<br>-------------------------------------------------------------------------<br>|       Single Application           |          Multiple Services       |<br>|       Single Deployment            |        Independent Deployment    |<br>|         One Codebase               |          Multiple Codebases      |<br>|       Difficult Scaling            |            Easy Scaling          |<br>|        Tightly Coupled             |           Loosely Coupled        |<br>-------------------------------------------------------------------------</pre><p><strong>Q4. Why Did Companies Move to Microservices ?</strong></p><pre>Suppose Flipkart receives:<br> - 1000 User Requests<br> - 10000 Product Requests<br> - 500 Payment Requests<br><br>Most traffic goes to Product Service.<br><br>In a monolith: Entire Application Scaled<br><br>In microservices: Only Product Service Scaled<br><br>Benefits<br> - Cost efficient.<br> - Better performance.<br> - Independent scaling.<br> - Faster deployments.<br> - Better fault tolerance.</pre><p><strong>Q5. Real Interview Scenario</strong></p><pre>Your Notification Module crashes.<br><br>- Should the entire application stop working?<br><br>Monolith : Possibly Yes<br><br>Microservices : Only Notification Service Affected<br><br>Orders and Payments continue working.<br><br>This is called: Fault Isolation</pre><p><strong>Q6. What is Service-to-Service Communication ?</strong></p><pre>Microservices communicate with each other.<br>Example: Order Service -&gt; Payment Service<br><br>Methods:<br>  - REST APIs<br>  - Kafka<br>  - RabbitMQ<br>  - gRPC<br>there are two types synchronous and asynchronous <br><br>Most common interview answer: REST + Kafka</pre><p><strong>Q7. What is an API Gateway ?</strong></p><pre><br>API Gateway acts as a single entry point for all clients.<br><br>Without Gateway:<br><br>                    Client<br>                      ↓<br>                 User Service<br>                      ↓<br>                 Order Service<br>                      ↓<br>                Payment Service<br><br>Many connections. we have to make and set config them one by on but using <br>the API Gateway request can distribute accordingly <br>We are able to manage load also using api GateWay and Load Balancer<br><br>With Gateway:<br>                    Client<br>                      ↓<br>                 API Gateway<br>                      ↓<br>                Microservices<br><br>Interact automatically by setting it up , less connections<br><br>Benefits<br>  - Authentication.<br>  - Routing.<br>  - Rate limiting.<br>  - Logging.<br>  - Security.</pre><p><strong>Q8. Why Not Allow Clients Direct Access to Services ?</strong></p><pre>Problems<br> - Security issues.<br> - Multiple endpoints.<br> - Hard maintenance.<br> - Duplicate authentication.<br> - Increased complexity.<br><br>API Gateway solves these problems.</pre><p><strong>Q9. What is Service Discovery ?</strong></p><pre>Microservices are deployed dynamically. IPs may change.<br><br>Example: Payment Service : 10.1.1.1<br><br>After restart : 10.1.2.8<br><br>How will services find each other?<br><br>Solution: <br>Service Discovery. <br>  - Services register themselves.<br>  - Other services discover them dynamically.</pre><p><strong>Q10. What is Eureka ?</strong></p><pre><br>Eureka is a Service Discovery Server commonly used in Spring Cloud.<br> <br>Flow:   1     Payment Service<br>                     ↓<br>            Registers with Eureka<br>        ------------------------------<br>        2      Order Service<br>                     ↓<br>                Asks Eureka<br>                     ↓<br>         Gets Payment Service Location<br>        ------------------------------<br>Benefits<br>  - Dynamic discovery.<br>  - Better scalability.<br>  - Reduced configuration.<br>  - High availability.<br>  - Easier management.</pre><p><strong>Q11. What is Distributed Transaction ?</strong></p><pre>Order Service: Order Created<br><br>Payment Service: Payment Failed<br><br>Now system becomes inconsistent.<br><br>This is a Distributed Transaction problem.</pre><blockquote><strong><em>Q12. Why Are Distributed Transactions Difficult ?</em></strong></blockquote><pre><br>Data exists in multiple services.<br><br>Example:<br>  - Order Database<br>  - Payment Database<br>  - Inventory Database<br><br>One transaction spans multiple systems.<br><br>Challenges<br>  - Data consistency.<br>  - Network failures.<br>  - Service failures.<br>  - Rollbacks.<br>  - Synchronization.</pre><p><strong>Q13. What is Circuit Breaker ?</strong></p><pre>Scenario : Payment Service is down.<br><br>Order Service keeps calling : Payment Service , Again and again.<br>  <br>System becomes overloaded.<br><br>Solution : Circuit Breaker.<br><br>     Failure Threshold Reached<br>                 ↓<br>        Stop Calling Service<br>                 ↓<br>     Return Fallback Response<br><br>Benefits<br>  - Prevents cascading failures.<br>  - Improves stability.<br>  - Faster recovery.<br>  - Better user experience.<br>  - System resilience.</pre><p><strong>Q14. What is Database Per Service Pattern ?</strong></p><pre>Answer : Each Microservice owns its database.<br><br>Example:<br>   User Service -&gt; User DB<br>   Order Service -&gt; Order DB<br>   Payment Service -&gt; Payment DB<br><br>Why?<br>  - Independent deployment.<br>  - Better ownership.<br>  - Better scalability.<br>  - Reduced coupling.<br>  - Service autonomy.</pre><p><strong>Q15. Most Important Interview Scenario</strong></p><pre>Question : You are designing Swiggy.<br><br>Which services would you create?<br><br>Answer<br>  - User Service<br>  - Restaurant Service<br>  - Order Service<br>  - Payment Service<br>  - Delivery Service<br>  - Notification Service<br>  - Review Service<br><br>Why?<br>  - Independent scaling.<br>  - Separate business domains.<br>  - Better maintainability.<br>  - Team ownership.<br>  - Fault isolation.</pre><p>Now we move to one of the most valuable backend technologies.</p><h4><strong>Kafka (Top 15 Interview Questions)</strong></h4><p><strong>Q1. What is Kafka ?</strong></p><pre>Kafka is a distributed event streaming platform used for:<br><br>- Real-time data processing<br>- Event-driven architecture<br>- Message communication between services<br>- Log aggregation<br>- Data pipelines<br><br>Think of Kafka as a highly scalable messaging system.<br><br>Example<br><br>Order placed:<br><br>Order Service<br>      ↓<br>    Kafka<br>      ↓<br>Payment Service<br><br>Notification Service<br>Analytics Service<br>Inventory Service<br><br>One event can be consumed by multiple services.</pre><p><strong>Q2. Why Do We Need Kafka ?</strong></p><pre>Without Kafka : The system will look like this flow <br><br>Order Service<br>      ↓<br>Payment Service<br>      ↓<br>Notification Service<br>      ↓<br>Inventory Service<br><br>Problems here are :<br>  - Tight coupling<br>  - Service dependencies<br>  - Failures propagate<br>  - Hard scaling<br>  - Complex communication<br>-----------------------------------------------------<br>With Kafka : the request will flow using producer and consumer can consume <br>             handled in asynch way using queue like messageQueue<br><br>Order Service<br>      ↓<br>     Kafka<br>      ↓<br>  Consumers<br><br>Benefits:<br>  - Loose coupling<br>  - Better scalability<br>  - Reliability<br>  - Asynchronous communication<br>  - Event-driven design</pre><p><strong>Q3. What is an Event ?</strong></p><pre>An event is something that happened in the system.<br><br>Examples:<br> - Order Created<br> - Payment Completed<br> - User Registered<br> - Product Added<br> - Delivery Assigned<br><br>Kafka transports these events.</pre><p><strong>Q4. What is a Producer ?</strong></p><pre>A Producer sends messages to Kafka.<br><br>Example: Order Service<br><br>creates:   <br>{<br>  &quot;orderId&quot;: 101,<br>  &quot;status&quot;: &quot;CREATED&quot;<br>}<br><br>and sends it to Kafka.<br><br>Producer Responsibilities<br>  - Create event<br>  - Publish message<br>  - Choose topic<br>  - Handle retries<br>  - Ensure delivery</pre><p><strong>Q5. What is a Consumer ?</strong></p><pre>A Consumer reads messages from Kafka.<br><br>Example:<br>           Kafka<br>             ↓<br>    Notification Service<br><br>reads: Order Created and sends email/SMS.<br><br>Benefits<br> - Independent processing<br> - Scalable<br> - Fault tolerant<br> - Decoupled architecture<br> - Easy extension</pre><p><strong>Q6. What is a Topic ?</strong></p><pre>A Topic is like a category where messages are stored.<br><br>Example:<br>     order-events<br>     payment-events<br>     user-events<br><br>Messages are published to topics.<br><br>Real Example<br><br>Order Service<br>     ↓<br>order-events Topic<br><br>Consumers subscribe to that topic.</pre><p><strong>Q7. What is a Partition ?</strong></p><pre>A Topic is divided into Partitions.<br><br>Example: order-events<br> - Partition 1<br> - Partition 2<br> - Partition 3<br><br>Why?<br> - Parallel processing<br> - Better scalability<br> - Higher throughput<br> - Distributed storage<br> - Load balancing</pre><p><strong>Q8. Why Are Partitions Important ?</strong></p><pre>Interview Scenario <br>Company processes: 1 Million Orders Per Day<br><br>Single partition: Slow Processing<br><br>Multiple partitions:<br><br>Consumer 1<br>Consumer 2<br>Consumer 3<br>Consumer 4<br><br>Process simultaneously. This is one of Kafka&#39;s biggest advantages.</pre><p><strong>Q9. What is a Consumer Group ?</strong></p><pre>A Consumer Group is a set of consumers working together.<br><br>Example: Consumer Group<br><br> Consumer 1<br> Consumer 2<br> Consumer 3<br><br>Kafka distributes partitions among consumers.<br><br>Benefits<br> - Parallel processing<br> - Scalability<br> - High throughput<br> - Load balancing<br> - Fault tolerance</pre><p><strong>Q10. What Happens If a Consumer Crashes ?</strong></p><pre>Kafka automatically reassigns partitions.<br><br>Example: Consumer 1 ❌<br><br>Kafka moves work to: <br>   Consumer 2<br>   Consumer 3<br><br>Benefits<br> - High availability<br> - Automatic recovery<br> - Reliability<br> - Reduced downtime<br> - Fault tolerance</pre><p><strong>Q11. What is Offset ?</strong></p><pre>Every message in a partition has a unique number.<br><br>Example:<br> - Offset 0<br> - Offset 1<br> - Offset 2<br> - Offset 3<br><br>Kafka tracks which messages have been consumed.<br><br>Why Important?<br> - Message tracking<br> - Recovery<br> - Reprocessing<br> - Reliability<br> - Consumer state management</pre><p><strong>Q12. What is Kafka Retention ?</strong></p><pre>Kafka stores messages for a configurable time.<br><br>Example:<br><br>7 Days<br>30 Days<br>90 Days<br><br>Even after consumption, messages remain available.<br><br>Benefits<br> - Replay events<br> - Audit history<br> - Recovery<br> - Analytics<br> - Debugging</pre><p><strong>Q13. Real Interview Scenario</strong></p><pre>Notification Service is down for 2 hours. Will messages be lost?<br><br>Answer : No. Kafka stores messages in the topic.<br><br>When Notification Service comes back:<br><br>Consumer resumes and processes pending messages.<br>This is a major reason companies use Kafka.</pre><p><strong>Q14. Kafka vs REST API Communication</strong></p><pre>REST :     Order Service<br>                 ↓<br>         Notification Service<br><br>Immediate call.<br><br>Problems:<br>   Tight coupling<br>   Service dependency<br>   Failure propagation<br>--------------------------------<br>Kafka :      Order Service<br>                  ↓<br>                Kafka<br>                  ↓<br>          Notification Service<br><br>Benefits:<br> - Asynchronous<br> - Scalable<br> - Reliable<br> - Decoupled<br> - Fault tolerant<br>--------------------------------</pre><p>Q<strong>15. Most Important Real-World Scenario</strong></p><pre>Step 1 : Order Service , creates order.<br><br>Step 2 : Publishes =&gt; Order Created Event =&gt; to Kafka.<br><br>Step 3 : Consumers receive event:<br>                           Payment Service<br>                           Inventory Service<br>                           Notification Service<br>                           Analytics Service<br><br>Step 4 : Each service processes independently.<br><br>Benefits<br> - Loose coupling.<br> - Scalability.<br> - Reliability.<br> - Event-driven architecture.<br> - Easy addition of new services.</pre><p><strong>Kafka Interview Cheat Sheet</strong></p><pre>--------------------------------------------------------------------------<br>|              Concept               |               Purpose             |<br>--------------------------------------------------------------------------<br>|              Producer              |            Sends messages         |<br>|              Consumer              |            Reads messages         |<br>|                Topic               |            Stores messages        |<br>|              Partition             |            Scalability            |<br>|              Consumer              |       Group Parallel processing   |<br>|               Offset               |            Message position       |<br>|              Retention             |         Message storage period    |<br>|                Kafka               |        Event streaming platform   |<br>--------------------------------------------------------------------------</pre><p>Perfect. Now we move to <strong>Redis</strong>, one of the most commonly used technologies in backend systems.</p><p>Many developers think Redis is just a cache.</p><p>In reality, Redis is used for:</p><ul><li>Caching</li><li>Session Storage</li><li>Rate Limiting</li><li>Real-time Counters</li><li>Distributed Locks</li><li>Leaderboards</li><li>Message Queue</li></ul><h4>Redis (Top 15 Interview Questions)</h4><p><strong>Q1. What is Redis ?</strong></p><pre>Redis stands for: &quot;REmote DIctionary Server&quot;<br><br>Redis is an in-memory data store.<br>Unlike databases that store data primarily on disk: MySQL , PostgreSQL<br><br>Redis stores data in RAM.<br><br>Because RAM is extremely fast, Redis can serve data much faster <br>than traditional databases.<br><br>Benefits<br> - Extremely fast.<br> - Low latency.<br> - High throughput.<br> - Supports multiple data structures.<br> - Easy integration with Spring Boot.</pre><p><strong>Q2. Why is Redis Faster Than MySQL ?</strong></p><pre>MySQL:   Request    : stored in disk it take times to retrive<br>            ↓<br>       Disk Access<br>            ↓<br>        Response<br><br>Redis:  Request<br>           ↓<br>          RAM<br>           ↓<br>        Response<br><br>RAM access is significantly faster than disk access.<br><br>Interview Point =&gt; Typical response times:<br><br>MySQL → milliseconds<br>Redis → microseconds<br><br>This is why Redis is used for frequently accessed data.</pre><p><strong>Q3. What is Caching ?</strong></p><pre>Caching means storing frequently accessed data in a faster storage layer.<br><br>Example: Product Details API<br><br>Without Cache: Request<br>                  ↓<br>               Database<br>                 ↓<br>               Response<br><br>every request hits the database direcetly . which is bad and cost high .<br>so solution is this store data somewhare that you need fequently.<br><br>With Cache:  Request<br>                ↓<br>              Redis<br>                ↓<br>             Response<br><br>Database load reduces dramatically.<br><br>Benefits :<br> - Faster response time.<br> - Reduced database load.<br> - Better scalability.<br> - Better user experience.<br> - Lower infrastructure costs.</pre><p><strong>Q4. Real Interview Scenario</strong></p><pre>Your Product API receives: <br>100,000 requests per minute , Database becomes slow. What would you do?<br><br>Answer : Add Redis caching.<br><br>Flow:   Request<br>           ↓<br>         Redis<br>           ↓<br>        Database (only if needed)<br><br>Benefits<br> - Reduced DB load.<br> - Faster API.<br> - Better scalability.<br> - Reduced latency.<br> - Improved user experience.</pre><p><strong>Q5. What is Cache Aside Pattern ?</strong></p><pre>Most commonly used caching pattern.<br><br>Flow:<br>Step 1 : Check Redis. Cache Hit?<br><br>If Yes : Return data.<br><br>         Redis<br>           ↓<br>        Response<br><br>If No :  Database<br>            ↓<br>          Redis<br>            ↓<br>         Response<br><br>Store result in Redis for future requests.<br><br>Why Popular?<br>  - Easy implementation.<br>  - Better performance.<br>  - Reduced DB traffic.<br>  - Flexible.<br>  - Common industry practice.</pre><p>Q6. What is a Cache Hit ?</p><pre>Requested data exists in Redis.<br><br>Example: GET Product 101<br><br>Redis already contains product. Response returned immediately.<br><br>Benefits<br> - Fast response.<br> - Reduced DB load.<br> - Better performance.<br> - Lower latency.<br> - Improved scalability.</pre><p><strong>Q8. What is TTL ?</strong></p><pre>TTL means : Time To Live<br><br>Defines how long data remains in Redis.<br><br>Example: Product Cache<br>         TTL = 10 minutes<br><br>After 10 minutes: Automatically Deleted<br><br>Why TTL?<br> - Prevent stale data.<br> - Automatic cleanup.<br> - Save memory.<br> - Keep cache fresh.<br> - Reduce maintenance.</pre><p><strong>Q9. What is Session Storage ?</strong></p><pre>Many applications store user sessions in Redis.<br><br>Example: User Login<br>             ↓<br>       Session Created<br>             ↓<br>     Redis Stores Session<br><br>When user sends requests: &quot; Session Retrieved &quot;  from Redis.<br><br>Benefits<br> - Fast access.<br> - Shared across servers.<br> - Scalable.<br> - Centralized storage.<br> - Better performance.</pre><p><strong>Q10. Why Store Sessions in Redis ?</strong></p><pre>Scenario<br> Application has: Server 1 , Server 2 and Server 3<br><br> - User logs into Server 1.<br> - Next request reaches Server 3.<br><br>How will Server 3 know the user?<br><br>Solution : Store session in Redis.<br>           All servers access the same session store.<br><br>Benefits<br> - Horizontal scaling.<br> - Shared sessions.<br> - Reliability.<br> - Consistency.<br> - Better user experience.</pre><p><strong>Q11. What is Rate Limiting ?</strong></p><pre>Rate limiting restricts how many requests a user can make.<br><br>Example: 100 requests/minute<br><br>After limit: 429 Too Many Requests<br><br>Why Important?<br> - Prevent abuse.<br> - Prevent DDoS attacks.<br> - Protect APIs.<br> - Fair usage.<br> - Improve stability.</pre><p><strong>Q12. How Does Redis Help in Rate Limiting ?</strong></p><pre>Store request count: User123  ,  Count = 50<br><br>Every request: Count++<br><br>If: Count &gt; 100<br><br>Reject request. Redis is ideal because counters are extremely fast.</pre><p><strong>Q13. Redis vs Database</strong></p><pre>----------------------------------------------------------<br>|           Redis          |           Database          |<br>----------------------------------------------------------<br>|           RAM            |             Disk            |<br>|        Very Fast         |            Slower           |<br>|      Temporary Data      |         Permanent Data      |<br>|        Cache Layer       |        Source of Truth      |<br>|       Microseconds       |          Milliseconds       |<br>----------------------------------------------------------<br><br>Interview Answer : Never replace a database with Redis.<br><br>Usually: Redis + Database , work together.</pre><p><strong>Q14. Real Interview Scenario</strong></p><pre>User profile is requested thousands of times.<br><br>Profile rarely changes. How would you optimize?<br><br>Answer : Store profile in Redis.<br><br>Flow:    Profile Request<br>                ↓<br>              Redis<br><br>Update Redis whenever profile changes.<br><br>Benefits<br> - Faster responses.<br> - Reduced DB load.<br> - Better scalability.<br> - Lower latency.<br> - Better performance.</pre><p><strong>Q15. Most Important Backend Scenario</strong></p><pre>E-Commerce Product Page<br><br>Without Redis:  User<br>                 ↓<br>              Backend<br>                 ↓<br>             Database<br><br>Every request hits database.<br><br>With Redis:   User<br>               ↓<br>            Backend<br>               ↓<br>             Redis<br>               ↓<br>           Database (only on miss)<br><br>Result<br> - Faster product loading.<br> - Reduced DB traffic.<br> - Better user experience.<br> - Lower server costs.<br> - Higher scalability.</pre><p><strong>How is Redis Used in Real Applications?</strong></p><pre> - Caching<br> - Session Storage<br> - Rate Limiting<br> - Counters<br> - Leaderboards</pre><p><strong>Redis Interview Cheat Sheet</strong></p><pre>--------------------------------------------------------------------<br>|          Concept           |               Purpose               |<br>--------------------------------------------------------------------<br>|           Redis            |         In-memory datastore         |<br>|           Cache            |           Faster access             |<br>|          Cache Hit         |         Data found in cache         |<br>|          Cache Miss        |           Data not found            |<br>|            TTL             |           Expiration time           |<br>|       Session Storage      |         Store user sessions         |<br>|        Rate Limiting       |          Control API usage          |<br>|           Counter          |        Track requests/events        |<br>--------------------------------------------------------------------</pre><p>This is one of the most common backend architectures you’ll see in production systems.</p><p>I hope this would have been helped you . Thank You</p><p>To be continue for more ……</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7f2c0b08ca1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Developer Important Interview Question phase 2]]></title>
            <link>https://medium.com/@ayushraj.cs/java-developer-important-interview-question-phase-2-f6d8269c905d?source=rss-e8338c08ab12------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6d8269c905d</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[java-developer]]></category>
            <dc:creator><![CDATA[Ayush Raj]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 16:32:02 GMT</pubDate>
            <atom:updated>2026-06-15T16:32:02.872Z</atom:updated>
            <content:encoded><![CDATA[<p>we are covering the most asked question in the interview of backend engineering , well we have covered the 1st phase of the module please have a look on this <a href="https://medium.com/@ayushraj.cs/java-developer-important-interview-question-e97c2435189a"><strong>here to tap</strong></a></p><p>now in this second phase we will focus on intermediate level of the question answers , we will look these are the mentioned topic of the backend designing of software . that every backend engineer interviewer expect to know from candidate .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2AgNHt95daf3Xj1pjcitVw.png" /></figure><p>Here are the topic in phase two</p><h4>Phase 2: Intermediate Backend</h4><ol><li>Design Patterns</li><li>SOLID Principles</li><li>Spring Boot</li><li>JPA/Hibernate</li></ol><p>these are the four major topic include questions that might be asked in interview , so let’s discuss those one by one ….</p><p>Many candidates know OOP, but when interviewers ask:</p><blockquote><em>“How do you design maintainable code?”</em></blockquote><blockquote><em>“How do you make your application extensible?”</em></blockquote><blockquote><em>“How do you reduce code changes when requirements change?”</em></blockquote><p>They are actually testing <strong>SOLID Principles</strong>.</p><h4>SOLID Principles (Top 15 Interview Questions)</h4><p><strong>Q1. What is SOLID ?</strong></p><p>SOLID is a set of 5 object-oriented design principles introduced by <br><strong>Robert C. Martin.</strong></p><pre>Why SOLID is Important ?<br><br> - Makes code easier to maintain.<br> - Reduces bugs when requirements change.<br> - Improves code readability.<br> - Makes unit testing easier.<br> - Helps large teams work on the same codebase.<br><br><br>SOLID Stands For<br>S → Single Responsibility Principle<br>O → Open Closed Principle<br>L → Liskov Substitution Principle<br>I → Interface Segregation Principle<br>D → Dependency Inversion Principle</pre><p><strong>Q2. What is Single Responsibility Principle (SRP) ?</strong></p><pre>Definition : A class should have only one reason to change.<br>             A class should have only one responsibility to handle<br><br>Bad Example : <br><br>class UserService {<br>    void saveUser(){}<br>    void sendEmail(){}<br>    void generateReport(){}<br>}<br><br>This class has multiple responsibilities.<br><br>Good Example : we can separate responsibility by making other classes<br><br> - UserService  : this class only handle user Service <br> - EmailService : this class only handle email Service<br> - ReportService : this class only handle report service <br><br>Benefits<br> - Easier maintenance.<br> - Easier testing.<br> - Smaller classes.<br> - Better readability.<br> - Fewer side effects during changes.<br><br>Interview Scenario<br><br>Suppose email logic changes.<br><br>Without SRP: User Service and report Service also can be changed<br><br>With SRP: Only EmailService changes</pre><p><strong>Q3. Real Interview Scenario for SRP ?</strong></p><pre>You are building an E-commerce application.<br><br>Should OrderService:<br> - Create order<br> - Send email<br> - Generate invoice<br> - Process payment<br><br>all together?<br><br>Answer No. Never , because keeping all thing in single unit might all can <br>effect after making small changes in any thing like order creation , email <br>sending or whatever so it&#39;s very important to keep all thing separate <br><br>Split responsibilities : splite and segregate the concern<br><br> - OrderService<br> - PaymentService<br> - EmailService<br> - InvoiceService<br><br>Why? Because :<br> - Easier modifications.<br> - Better testing.<br> - Independent deployment.<br> - Lower coupling.<br> - Better scalability.</pre><p><strong>Q4. What is Open Closed Principle (OCP) ?</strong></p><pre>Definition : Software entities should be:<br><br>- Open for Extension and Closed for Modification<br><br>Meaning: You should add new functionality without changing existing code.</pre><p><strong>Q5. OCP Example</strong></p><pre>There is an example of open close design priciple of payment system <br><br>Bad Design:<br><br>class PaymentService {<br><br>   void pay(String type){<br><br>      if(type.equals(&quot;UPI&quot;)){}<br>      else if(type.equals(&quot;CARD&quot;)){}<br>   }<br>}<br>here in pay method option to pay with UPI and CARD , now we need to add<br>modify crpto or net banking option to pay with , how we would handle we<br>have to either modify pay method and that&#39;s bad to annoy existing thing .<br>we would re design the scenario so that solve this in good way .<br><br>- Every new payment method requires modifying code.<br>-----------------------------------------------------------------------<br>Here is solution using Open Close Design Principle solve this problem <br><br>Good Design :<br><br>interface Payment {<br>    void pay();<br>}<br><br>using interface Payment pay method wherever we can implement as per the <br>requirement that enables the open for exensible closed for modification.<br><br>Implement:<br> - UPIPayment<br> - CardPayment<br> - NetBankingPayment<br><br>Benefits<br> - Existing code remains safe.<br> - Easier extension.<br> - Lower risk of bugs.<br> - Better maintainability.<br> - Follows polymorphism.<br> - Interview Scenario<br><br>Tomorrow company adds:<br><br> - PayPal<br> - Crypto<br> - Wallet<br><br>No existing code changes.</pre><p><strong>Q6. What is Liskov Substitution Principle (LSP) ?</strong></p><pre>Definition : Child classes should be able to replace parent classes <br>             without breaking behavior.<br><br>Example <br><br>class Bird {<br>   void fly(){}<br>}<br><br>class Sparrow extends Bird{}<br><br>Works perfectly.<br><br>Problem <br>class Ostrich extends Bird{}<br><br>Ostrich cannot fly.<br><br>Now parent assumptions break.<br><br>Violation of LSP.</pre><p><strong>Q7. Why is LSP Important ?</strong></p><pre>Benefits :<br> - Predictable behavior.<br> - Better inheritance design.<br> - Fewer runtime surprises.<br> - Better code reuse.<br> - Easier maintenance.<br> - Interview Scenario<br><br>If a method accepts:<br><br>Bird bird<br><br>it should work correctly for every Bird subclass.</pre><p><strong>Q8. What is Interface Segregation Principle (ISP) ?</strong></p><pre>Definition <br>Clients should not be forced to implement methods they don&#39;t need.<br><br>Bad Example :<br><br>interface Worker {<br>   work();<br>   eat();<br>}<br><br>Robot implementation:<br><br>class Robot implements Worker<br><br>Robot doesn&#39;t eat. and thats the Problem. having methods unecessary in <br>single interface , so segregate it out in this way .<br><br>Good Design<br><br>interface Workable {<br>   work();<br>}<br><br>interface Eatable {<br>   eat();<br>}<br><br>Benefits<br> - Smaller interfaces.<br> - Cleaner design.<br> - Better flexibility.<br> - Easier maintenance.<br> - Reduced unnecessary code.</pre><p><strong>Q9. Real Interview Scenario for ISP</strong></p><pre>Question : Design a notification system.<br><br>Some services support:<br><br>  - SMS<br>  - Email<br>  - Push Notification<br><br>Others support only Email.<br><br>Answer<br><br>Instead of one huge interface: Notification<br><br>Create:<br>   - EmailNotifier<br>   - SMSNotifier<br>   - PushNotifier<br><br>This follows ISP.</pre><p><strong>Q10. What is Dependency Inversion Principle (DIP) ?</strong></p><pre>Definition<br><br>High-level modules should not depend on low-level modules.<br><br>Both should depend on abstractions.</pre><p><strong>Q11. DIP Example</strong></p><pre>Bad Design <br><br>class OrderService {<br>   MySQLDatabase db = new MySQLDatabase();<br>}<br><br>OrderService is tightly coupled.<br><br>Good Design<br><br>interface Database {<br>   save();<br>}<br><br>class MySQLDatabase implements Database<br>class PostgreSQLDatabase implements Database<br><br>OrderService depends on interface.</pre><p><strong>Q12. Benefits of DIP</strong></p><pre>here the benefits of DIP :<br><br> - Loose coupling.<br> - Easier testing.<br> - Easier database replacement.<br> - Better scalability.<br> - Cleaner architecture.</pre><p><strong>Q13. How Does Spring Boot Use DIP ?</strong></p><pre>Spring Boot Dependency Injection is based on DIP.<br><br>Example:<br>    @Autowired<br>    UserRepository repository;<br><br>Your service depends on abstraction.<br><br>Not concrete implementation.<br><br>Benefits<br>  - Loose coupling.<br>  - Easier mocking.<br>  - Better testing.<br>  - Better maintainability.<br>  - Cleaner architecture.</pre><p><strong>Q14. Most Important SOLID Interview Scenario</strong></p><pre>Question : Company introduces a new payment method every month.<br>How would you design it?<br><br>Answer : Use this<br><br>Interface<br>  - Polymorphism<br>  - OCP<br><br>Structure: Payment<br><br>Implementations:<br>  - UPI<br>  - Card<br>  - Wallet<br>  - Crypto<br><br>Benefits<br>  - No existing code modification.<br>  - Easy extension.<br>  - Lower bug risk.<br>  - Cleaner architecture.<br>  - Better testing.</pre><p><strong>Q15. Why Do Companies Care About SOLID ?</strong></p><pre><br>Answer<br><br>Without SOLID:<br><br>Classes become huge.<br>Small changes break many modules.<br>Testing becomes difficult.<br>Features take longer to develop.<br>Maintenance cost increases.<br><br>With SOLID:<br><br>Better scalability.<br>Easier onboarding of developers.<br>Cleaner architecture.<br>Better code quality.<br>Faster feature delivery.</pre><p>Perfect. Now let’s move to <strong>Design Patterns</strong>.</p><p>This topic is extremely important because:</p><ul><li>Spring Framework uses design patterns heavily.</li><li>Interviewers ask design pattern questions even for freshers.</li><li>Design patterns show that you can write scalable and maintainable code.</li><li>SOLID principles and Design Patterns often go together.</li></ul><h4>Design Pattern ( Important Question )</h4><p><strong>What is a Design Pattern ?</strong></p><pre>A Design Pattern is a proven solution to a commonly occurring <br>software design problem.<br><br>Think of it as:<br><br>Problem → Best Practice Solution<br><br>For example:<br><br>Problem: Only one Database Connection Manager should exist.<br><br>Solution: Singleton Pattern</pre><p><strong>Why Do We Use Design Patterns ?</strong></p><pre>Benefits<br>   - Reusable solutions to common problems.<br>   - Improves code maintainability.<br>   - Encourages loose coupling.<br>   - Makes code easier to understand.<br>   - Follows SOLID principles naturally.</pre><p><strong>Q1. What is Singleton Pattern ?</strong></p><pre>Singleton ensures:<br><br>&quot; Only ONE object of a class exists throughout the application.&quot; <br><br>Example:<br>  - Configuration Manager<br>  - Logger<br>  - Cache Manager<br>  - Database Connection Pool<br><br>Only one instance is needed.</pre><p><strong>Q2. How is Singleton Implemented ?</strong></p><pre>class Singleton {<br><br>    private static Singleton instance;<br><br>    private Singleton() {}<br><br>    public static Singleton getInstance() {<br><br>        if(instance == null) instance = new Singleton();<br><br>        return instance;<br>    }<br>}<br><br>Key points:<br>  - Constructor is private.<br>  - Static instance variable.<br>  - Public access method.</pre><p><strong>Q3. Where is Singleton Used ?</strong></p><pre>Examples<br>  - Logger<br>  - Cache Manager<br>  - Configuration Manager<br>  - Spring Beans (Singleton Scope)<br>  - Database Connection Pool Managers</pre><p><strong>Q4. Interview Scenario</strong></p><pre>Question : You are building an application.<br>Configuration settings should be loaded once and shared across all modules.<br><br>Which pattern would you use ?<br><br>Answer : Singleton.<br><br>Why?<br><br> 1. Single source of truth.<br> 2. Reduced memory usage.<br> 3. Easy access throughout application.<br> 4. Consistent configuration.<br> 5. Better performance.</pre><p><strong>Q5. What is Factory Pattern ?</strong></p><pre>Factory Pattern creates objects without exposing object creation logic.<br><br>Instead of:<br>          Payment payment = new UPIPayment();<br><br>we use:<br>       Payment payment = PaymentFactory.getPayment(&quot;UPI&quot;);</pre><p><strong>Q6. Why Use Factory Pattern ?</strong></p><pre>Benefits<br> 1. Hides object creation logic.<br> 2. Reduces coupling.<br> 3. Easier maintenance.<br> 4. Easier extension.<br> 5. Supports OCP.</pre><p><strong>Q7. Real Interview Scenario</strong></p><pre><br>Question : <br>Payment methods:<br> - UPI<br> - Card<br> - Wallet<br> - Net Banking<br><br>New methods are added frequently. -&gt; How would you design it?<br><br>Answer<br><br>Use Factory Pattern.<br><br>Payment payment = factory.getPayment(type);<br><br>Benefits:<br> - Cleaner code.<br> - Easy extension.<br> - Less if-else logic.<br> - Better scalability.<br> - Supports future payment methods.</pre><p><strong>Q8. What is Strategy Pattern ?</strong></p><pre>Strategy Pattern allows selecting behavior at runtime.<br><br>Example:<br>Payment options:<br>  - UPI<br>  - Card<br>  - Wallet<br><br>Each has different payment logic.</pre><p><strong>Q9. Why Strategy Pattern ?</strong></p><pre>Without Strategy:<br><br>if(type.equals(&quot;UPI&quot;)){}<br>else if(type.equals(&quot;CARD&quot;)){}<br>else if(type.equals(&quot;WALLET&quot;)){}<br><br>Huge if-else blocks.<br><br>With Strategy:<br><br>PaymentStrategy strategy;<br>Choose implementation dynamically.</pre><p><strong>Q10. Real Interview Scenario</strong></p><pre>Question<br>Design a payment system supporting:<br><br> - UPI<br> - Credit Card<br> - Wallet<br><br>Answer<br><br>Create: interface PaymentStrategy<br><br>Implement: UPIPayment , CardPayment , WalletPayment<br><br>Benefits:<br>  - Open for extension.<br>  - Cleaner code.<br>  - Runtime flexibility.<br>  - Easier testing.<br>  - Follows OCP.</pre><p><strong>Q11. What is Observer Pattern ?</strong></p><pre>One object notifies multiple dependent objects whenever state changes.<br><br>Example:<br><br>YouTube Channel<br>     ↓<br>Subscribers<br><br>When creator uploads video:<br><br>All subscribers notified</pre><p><strong>Q12. Real Backend Example</strong></p><pre>Order placed:<br><br>Need to notify:<br>  - Email Service<br>  - SMS Service<br>  - Inventory Service<br>  - Analytics Service<br><br>Observer Pattern fits perfectly.</pre><p><strong>Q13. Benefits of Observer Pattern</strong></p><pre>1. Loose coupling.<br>2. Easy addition of new subscribers.<br>3. Event-driven architecture.<br>4. Better scalability.<br>5. Commonly used in microservices.</pre><p><strong>Q14. What is Builder Pattern ?</strong></p><pre>Used when object creation requires many parameters.<br><br>Bad:<br><br>User user = new User(&quot;Ayush&quot;, 22, &quot;Delhi&quot;, &quot;India&quot;, &quot;Male&quot;, true);<br><br>Hard to read. <br>because we don&#39;t know exact which attribue pass at which place in constructor</pre><p><strong>Q15. Builder Pattern Example</strong></p><pre>User user = User.builder()<br>                .name(&quot;Ayush&quot;)<br>                .age(22)<br>                .city(&quot;Delhi&quot;)<br>                .build();</pre><p><strong>Q16. Why Builder Pattern ?</strong></p><pre>Benefits<br> 1. Readable code.<br> 2. Optional parameters.<br> 3. Avoids constructor explosion.<br> 4. Immutable object creation.<br> 5. Common in Spring Boot projects.</pre><p><strong>Q17. What is Adapter Pattern ?</strong></p><pre>Allows incompatible classes to work together.<br><br>Think:<br><br>Indian Charger<br>      ↓<br>Adapter<br>      ↓<br>US Socket<br><br>---------------------------------------------<br><br>Real Software Example : Your application consumes<br><br>   Old Payment Gateway<br>   New Payment Gateway<br><br>Interfaces differ. so here come adapter<br><br>Adapter converts one interface into another.<br>----------------------------------------------<br>Benefits<br> 1. Reuse existing code.<br> 2. Avoid rewriting modules.<br> 3. Easier integration.<br> 4. Supports third-party APIs.<br> 5. Reduces changes.</pre><p><strong>Q18. What is Prototype Pattern ?</strong></p><pre>Creates new objects by cloning existing objects.<br><br>Instead of: new Employee()<br><br>Clone: employee.clone();<br><br>Why Use Prototype?<br>  - Faster object creation.<br>  - Useful for complex objects.<br>  - Reduces initialization cost.<br>  - Improves performance.<br>  - Useful in caching systems.</pre><p><strong>Q19. What is Dependency Injection</strong> ?</p><pre>Objects receive dependencies from outside instead of creating them internally.<br><br>Bad:<br><br>class UserService {<br><br>   MySQLDatabase db = new MySQLDatabase();<br>}<br><br>Tightly coupled.<br><br>Good:<br><br>class UserService {<br><br>   Database db;<br><br>   UserService(Database db){<br>      this.db = db;<br>   }<br>}</pre><p><strong>Q20. Why is Dependency Injection Important ?</strong></p><pre>Benefits<br>  - Loose coupling.<br>  - Easier testing.<br>  - Easier replacement of implementations.<br>  - Better maintainability.<br>  - Foundation of Spring Framework.</pre><h4>Most Asked Design Pattern Scenarios</h4><pre>Scenario 1 : Need only one Logger.<br><br>Answer: Singleton<br>-------------------------------------------<br>Scenario 2 : Need different payment methods.<br><br>Answer: Strategy and Factory<br>-------------------------------------------<br>Scenario 3 : Need notifications after order creation.<br><br>Answer: Observer<br>-----------------------------------------------------<br>Scenario 4 : Object has many optional fields.<br><br>Answer: Builder<br>--------------------------------------------<br>Scenario 5 : Need to switch database implementation.<br><br>Answer: Dependency Injection</pre><h4>Design Patterns Interview Cheat Sheet</h4><pre>       ----------------------------------------------------------<br>       |           Problem            |          Pattern        |<br>       ----------------------------------------------------------<br>       |       One Object Only        |          Singleton      |<br>       |  Create Objects Dynamically  |          Factory        |<br>       |  Runtime Behavior Selection  |          Strategy       |<br>       |     Event Notification       |          Observer       |<br>       |   Complex Object Creation    |          Builder        |<br>       |   Incompatible Interfaces    |          Adapter        |<br>       |    Clone Existing Objects    |          Prototype      |<br>       |   Loose Coupling Dependency  |          Injection      |<br>       ----------------------------------------------------------</pre><p>Now , Let’s cover the <strong>10 most important Spring Boot topics</strong> that are asked repeatedly in interviews.</p><h4>Spring Boot Important Question</h4><ol><li><strong>What is Spring Framework ?</strong></li></ol><pre>Spring Framework is a Java framework used to build enterprise applications.<br><br>Before Spring, developers had to manually create and manage objects.<br><br>Example: UserService userService = new UserService();<br><br>In large applications with hundreds of objects, this becomes difficult.<br><br>Spring solves this using:<br>  - Dependency Injection<br>  - IoC Container<br>  - Bean Management<br>  - Transaction Management<br>  - Security<br>  - REST API Development<br><br>Benefits<br>  - Reduces boilerplate code.<br>  - Supports loose coupling.<br>  - Easier testing.<br>  - Better maintainability.<br>  - Enterprise-ready architecture.<br><br>Interview Question : Why do we use Spring?<br><br>Answer:<br> - Object management<br> - Dependency injection<br> - Enterprise features<br> - Faster development<br> - Better scalability</pre><p><strong>2. What is IOC (Inversion of Control) ?</strong></p><pre>Normally developers create objects.<br>UserService service = new UserService();<br><br>With Spring:<br>   @Autowired<br>   UserService service;<br><br>Spring creates and manages the object.<br>This concept is called: Inversion of Control<br><br>because control of object creation is transferred from the programmer <br>to Spring.<br><br>Benefits<br>  - Loose coupling.<br>  - Better testability.<br>  - Centralized object management.<br>  - Easier maintenance.<br>  - Better scalability.</pre><p><strong>3. What is Dependency Injection ?</strong></p><pre>Dependency Injection is a way of providing dependencies from outside <br>rather than creating them inside the class.<br><br>Bad way :<br><br>class UserService{<br>   UserRepository repo =<br>      new UserRepository();<br>}<br>---------------------------------------------<br>Good way :<br><br>class UserService{<br><br>   UserRepository repo;<br><br>   UserService(UserRepository repo){<br>      this.repo = repo;<br>   }<br>}<br><br>Spring injects the dependency automatically.<br><br>---------------------------------------------<br><br>Types of Dependency Injection<br><br>---------------------------------------------<br>Constructor Injection (Recommended)<br><br>@Service<br>public class UserService {<br><br>   private final UserRepository repo; // here we are injecting <br> <br>   public UserService(UserRepository repo){ // here actually injected<br>      this.repo = repo;<br>   }<br>}<br><br>---------------------------------------------<br>Setter Injection<br><br>@Autowired<br>public void setRepo(UserRepository repo){<br>   this.repo = repo;<br>}<br><br>---------------------------------------------<br>Field Injection<br><br>@Autowired<br>private UserRepository repo;<br><br>---------------------------------------------<br>Interview Question : Which injection is preferred?<br><br>Answer: Constructor Injection.<br><br>Reasons:<br> - Immutable dependencies.<br> - Easier testing.<br> - Compile-time safety.<br> - Better design.<br> - Recommended by Spring.</pre><p><strong>4. What is a Bean ?</strong></p><pre>A Bean is an object managed by the Spring Container.<br><br>Example:<br><br>@Service<br>public class UserService{<br>}<br><br>Spring automatically creates and manages this object.<br><br>This object becomes a Bean.<br><br>Common Bean Annotations<br> - @Component<br> - @Service<br> - @Repository<br> - @Controller<br> - @RestController<br><br>All create Spring Beans.<br><br>Benefits<br> - Lifecycle managed by Spring.<br> - Dependency Injection support.<br> - Reusable.<br> - Centralized management.<br> - Easier configuration.</pre><p><strong>5. Difference Between @Component, @Service, @Repository, and @Controller</strong></p><pre>@Component : Generic Spring Bean.<br><br>@Service : Business logic layer.<br><br>@Service : class UserService<br><br>@Repository : Database access layer.<br><br>@Repository : class UserRepository<br><br>@Controller : MVC applications.<br><br>Returns views. : @RestController<br>REST APIs. : Returns JSON.<br><br>@RestController<br>public class UserController<br><br>Interview Tip<br><br>Internally all are Beans.<br>Difference is mainly semantic meaning.</pre><p><strong>6. Spring Boot Architecture</strong></p><pre>A typical Spring Boot application looks like:<br><br>Controller<br>    ↓<br>Service<br>    ↓<br>Repository<br>    ↓<br>Database<br>----------------------------------------------<br>Controller Layer &quot; Handles HTTP requests.&quot;<br>   @RestController<br>   @RequestMapping(&quot;/users&quot;)<br><br>Responsibilities:<br> - Receive request.<br> - Validate request.<br> - Call service.<br> - Return response.<br> - Handle API layer.<br>-----------------------------------------------<br><br>Service Layer : Business logic.<br>                @Service<br><br>Responsibilities:<br> - Apply rules.<br> - Process data.<br> - Coordinate workflows.<br> - Call repositories.<br> - Implement business requirements.<br>-----------------------------------------------<br>Repository Layer : Database interaction.<br>                   @Repository<br><br>Responsibilities:<br> - Save data.<br> - Fetch data.<br> - Update records.<br> - Delete records.<br> - Execute queries.</pre><p><strong>7. What is Spring Boot ?</strong></p><pre>Spring Boot is built on top of Spring Framework.<br><br>It simplifies development by providing:<br> - Auto Configuration<br> - Embedded Servers<br> - Starter Dependencies<br> - Production-ready features<br><br>Without Spring Boot:<br> - Large XML Configuration<br> - Manual Setup<br> - Server Configuration<br><br>With Spring Boot:<br> - Minimal Configuration<br> - Quick Development<br><br>Interview Question : Why Spring Boot?<br><br>Benefits<br> - Faster development.<br> - Embedded Tomcat.<br> - Auto configuration.<br> - Production-ready.<br> - Less boilerplate code.</pre><p><strong>8. What is Auto Configuration ?</strong></p><pre>Spring Boot automatically configures components based on dependencies<br>present in the project.<br><br>Example: <br><br>Add dependency: &#39;spring-boot-starter-web&#39;<br><br>Spring automatically configures:<br> - DispatcherServlet<br> - Jackson<br> - Tomcat<br> - REST support<br><br>You don&#39;t manually configure them.<br><br>Benefits<br> - Saves time.<br> - Less configuration.<br> - Faster setup.<br> - Cleaner project.<br> - Better developer experience.</pre><p><strong>9. What is Spring Data JPA ?</strong></p><pre><br>JPA stands for: Java Persistence API<br>It helps interact with databases using Java objects instead of raw SQL.<br><br>Without JPA:<br> - Connection<br> - PreparedStatement<br> - ResultSet<br><br>Lots of boilerplate code.<br><br>With JPA:<br> - userRepository.save(user);<br> - Spring handles SQL generation.<br><br>Benefits<br> - Less code.<br> - Faster development.<br> - Database abstraction.<br> - Easier maintenance.<br> - Better productivity.<br> - Common Interview Question<br><br>Difference between JPA and Hibernate?<br><br>JPA : Specification<br>Hibernate : Implementation of JPA<br><br>Think:<br>JPA = Interface<br>Hibernate = Implementation</pre><p><strong>10. Spring Security + JWT (Most Asked Topic)</strong></p><pre>What is Spring Security?<br><br>Framework for:<br>  - Authentication<br>  - Authorization<br>  - Security Filters<br>  - Password Encryption<br><br>Authentication : Who are you ?<br>Example:<br>        Username<br>        Password<br> <br>Authorization : What are you allowed to do? <br>Example:<br>        Admin → Delete User<br>        User → View Profile<br>-------------------------------------------------<br>JWT Authentication Flow<br><br>Step 1 : User logs in. - &gt; POST /login<br>Step 2 : Spring Security validates credentials.<br>Step 3 : JWT token generated.<br>    Example: eyJhbGciOi...<br>Step 4 : Token returned to frontend.<br>Step 5 : Frontend stores token.<br>Step 6 : Future requests:<br>    Authorization: Bearer token<br>Step 7 : Backend validates token.<br>-------------------------------------------------<br>Benefits of JWT<br> - Stateless authentication.<br> - Scalable.<br> - Secure.<br> - No session storage required.<br> - Works well with microservices.</pre><p>There are core annotations and concepts used in<strong> Spring Boot / Spring MVC</strong> to build web applications and handle incoming <strong>HTTP requests</strong>, have a quick look on these .</p><pre>-----------------------------------------------------------------------------------------------------------<br>|      Annotation        |              Primary Purpose            |          Common Use Case             |<br>-----------------------------------------------------------------------------------------------------------<br>|     @Controller        | Returns user-facing web pages.          | Traditional MVC apps (Thymeleaf/JSP).|<br>|    @RestController     | Returns raw data objects (JSON/XML).    |      Backend REST APIs.              |<br>|    @RequestMapping     | Routes a URL pattern to a method.       |  Grouping APIs under a base path.    |<br>|     @RequestBody       | Reads the payload body of a request.       | Handling POST/PUT JSON data submissions.|<br>|     @PathVariable      | Extracts values straight from the URI path.| Locating a resource by a specific ID.   |<br>|     @RequestParam      | Extracts values from URL query parameters. | Filtering, sorting, or paginating lists.|<br>-----------------------------------------------------------------------------------------------------------------</pre><p>Now move to the next stage of the final phase two , after this you will be able to complete the intermediate level of interview question</p><p><strong>JPA &amp; Hibernate (Top 15 Interview Questions)</strong></p><pre>Before starting, understand this hierarchy:<br><br>Application<br>     ↓<br>Spring Data JPA<br>     ↓<br>JPA Specification<br>     ↓<br>Hibernate<br>     ↓<br>Database<br><br>Remember<br> - JPA = Specification (rules/interfaces)<br> - Hibernate = Implementation of JPA<br> - Spring Data JPA = Makes JPA easier</pre><p>Q1. What is JPA ?</p><p>we have already covered it above in the 9th question of the SpringBoot part.</p><p><strong>Q2. What is Hibernate ?</strong></p><pre>Hibernate is the most popular implementation of JPA.<br><br>Think:<br> JPA = Interface<br> Hibernate = Class<br><br>Just like:List list = new ArrayList();<br><br>Similarly:  JPA → Hibernate<br><br>Hibernate Responsibilities<br> - Generate SQL.<br> - Manage entities.<br> - Cache data.<br> - Handle transactions.<br> - Map Java objects to tables.</pre><p><strong>Q3. Difference Between JPA and Hibernate ?</strong></p><pre>--------------------------------------------------------------------------<br>|               JPA                |                Hibernate            |<br>--------------------------------------------------------------------------<br>|          Specification           |             Implementation          |<br>|          Defines rules           |            Implements rules         |<br>|        Vendor independent        |           Specific framework        |<br>|         Cannot work alone        |          Can work independently     |<br>--------------------------------------------------------------------------<br><br>Interview Answer<br><br>Always say:<br>JPA is a specification and Hibernate is one of its implementations.<br><br>This is one of the most asked questions.</pre><p><strong>Q4. What is an Entity ?</strong></p><pre>An Entity is a Java class mapped to a database table.<br>Example:<br><br>@Entity<br>@Table(name=&quot;users&quot;)<br>public class User {<br><br>    @Id<br>    private Long id;<br><br>    private String name;<br>}<br>                <br>Database: |users|<br>          -------<br>          |id   |<br>          |name |<br><br>Benefits<br> - Object-oriented programming.<br> - Less SQL code.<br> - Easier maintenance.<br> - Cleaner architecture.<br> - Better readability.</pre><p><strong>Q5. What is @Entity ?</strong></p><pre>@Entity<br>tells Hibernate: This class should be stored in the database.<br><br>Without @Entity, Hibernate ignores the class.<br><br>Common Interview Follow-up &quot;Can an Entity exist without @Entity?&quot;<br><br>Answer: No , Hibernate won&#39;t manage it.</pre><p><strong>Q6. What is @Id ?</strong></p><pre>Every entity must have a primary key.<br><br>Example:<br>@Id<br>private Long id;<br><br>Maps to: PRIMARY KEY<br><br>Why Important?<br> - Unique identification.<br> - Updates require it.<br> - Deletes require it.<br> - Caching requires it.<br> - Entity tracking requires it.</pre><p><strong>Q7. What is @GeneratedValue ?</strong></p><pre>Used to auto-generate IDs.<br><br>@Id<br>@GeneratedValue<br>private Long id;<br><br>Database generates:<br><br>1<br>2<br>3<br>4<br>5<br><br>automatically.<br><br>Common Strategies<br>  1. GenerationType.AUTO<br>  2. GenerationType.IDENTITY<br>  3. GenerationType.SEQUENCE<br>  4. GenerationType.TABLE<br><br>Most commonly used: IDENTITY for MySQL.</pre><p><strong>Q8. What is a Repository ?</strong></p><pre>Repository provides database operations.<br><br>Example:<br>public interface UserRepository<br>       extends JpaRepository&lt;User,Long&gt;{<br>}<br><br>Now you automatically get:<br> - save()<br> - findById()<br> - findAll()<br> - delete()<br>without writing SQL.<br><br>Benefits<br> - Less code.<br> - Faster development.<br> - Built-in CRUD.<br> - Cleaner architecture.<br> - Easier testing.</pre><p><strong>Q9. What is Entity Lifecycle ?</strong></p><pre>One of the most important interview questions.<br><br>Entity states:<br><br>[Transient - &gt; Persistent -&gt; Detached -&gt; Removed ]<br><br><br>Transient: User user = new User();<br>Object exists only in memory. , Not stored in DB.<br><br>Persistent : entityManager.persist(user);<br>             Hibernate tracks object.<br><br>Detached : Object exists but Hibernate no longer tracks it.<br>Example: entityManager.detach(user);<br><br>Removed : entityManager.remove(user);<br>          Marked for deletion.</pre><p><strong>Q10. What is FetchType ?</strong></p><pre>Determines when related data is loaded.<br><br>Two types: LAZY and EAGER</pre><p><strong>Q11. Lazy vs Eager Loading ?</strong></p><pre>EAGER : Loads related data immediately.<br>Example: @OneToMany(fetch=EAGER)<br>Query: User + Orders  (loaded together)<br><br>Problem : May load unnecessary data.<br><br>-------------------------------------------<br><br>LAZY : Loads data only when required.<br>Example : @OneToMany(fetch=LAZY)<br><br>Orders fetched only when accessed.<br><br>Benefits<br> - Better performance.<br> - Lower memory usage.<br> - Faster APIs.<br> - Reduced DB load.<br> - Preferred in most cases.</pre><p><strong>Q12. What is Cascade Type ?</strong></p><pre>Defines what happens to child entities when parent changes.<br><br>Example: Customer -&gt;  Orders<br><br>Cascade Persist : Saving customer automatically saves orders.<br>Use like this : CascadeType.PERSIST<br><br>Cascade Remove : Deleting customer deletes orders.<br>Use like this : CascadeType.REMOVE<br><br>Benefits<br> - Automatic operations.<br> - Less code.<br> - Better consistency.<br> - Easier management.<br> - Cleaner logic.</pre><p><strong>Q13. What is the N+1 Problem ?</strong></p><pre>Extremely important interview question.<br><br>Scenario<br><br>Fetch: List&lt;Customer&gt;<br>Then for every customer: customer.getOrders()<br><br>Queries:<br>      1 query for customers<br>      100 queries for orders<br><br>Total: 101 queries , This is N+1 problem.<br><br>Why Bad?<br> - Slow APIs.<br> - High DB load.<br> - Increased latency.<br> - Scalability issues.<br> - Poor performance.<br><br>Solutions<br> - JOIN FETCH<br> - Entity Graph<br> - DTO Projection<br> - Batch Fetching<br> - Query Optimization</pre><p><strong>Q14. What is JPQL ?</strong></p><pre>JPQL = Java Persistence Query Language<br><br>Instead of table names: SELECT * FROM users<br>Use entity names: SELECT u FROM User u<br><br>JPQL works with Java objects, not database tables.<br>Benefits<br> - Database independent.<br> - Object-oriented.<br> - Easier maintenance.<br> - Cleaner queries.<br> - Portable code.</pre><p><strong>Q15. Most Common Real Interview Scenario</strong></p><pre>Question<br><br>You have: User and Orders Relationship.<br> Orders are rarely viewed.<br> Which FetchType would you use?<br><br>Answer : LAZY<br><br>Reason<br>- Better performance.<br>- Less memory consumption.<br>- Faster API response.<br>- Reduced DB load.<br>- Avoid unnecessary data fetching.</pre><p>Thank You for being continue , Now we have successfully completed the core backend engineering java interview question and answer phase of second . quick recap we have covered .</p><p><strong>Software Design</strong></p><ul><li>SOLID</li><li>Design Patterns</li></ul><p><strong>Spring Ecosystem</strong></p><ul><li>Spring Boot</li><li>JPA</li><li>Hibernate</li></ul><p>In the next this article we will be covering the next third phase of advance backend engineering question answer please have a look , if you want to know actual backend engineering problem .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6d8269c905d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>