<?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 Aggarwalgunjan on Medium]]></title>
        <description><![CDATA[Stories by Aggarwalgunjan on Medium]]></description>
        <link>https://medium.com/@aggarwalgunjan597?source=rss-a203de864c05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*g1_rxkEMjhkdUHO0</url>
            <title>Stories by Aggarwalgunjan on Medium</title>
            <link>https://medium.com/@aggarwalgunjan597?source=rss-a203de864c05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 09:43:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aggarwalgunjan597/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why we need Cache in system?]]></title>
            <link>https://medium.com/@aggarwalgunjan597/why-we-need-cache-in-system-1c7e7016d8b8?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c7e7016d8b8</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[lru-cache]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[cache-memory]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Fri, 27 Feb 2026 16:37:23 GMT</pubDate>
            <atom:updated>2026-02-27T16:37:23.065Z</atom:updated>
            <content:encoded><![CDATA[<h3>Caching</h3><p>Caching is a high-speed storage layer (typically RAM) used to store frequently accessed or repeated query responses so they can be served quickly to clients. It is generally much smaller than disk storage but significantly faster.</p><h3>Why Do We Need Caching?</h3><ul><li>Reduce network calls to the database</li><li>Improve performance for read-heavy operations</li><li>Reduce database load</li><li>Improve latency and overall user experience</li><li>Increase system scalability</li><li>Handle traffic spikes efficiently</li><li>Reduce operational cost by minimizing database scaling</li></ul><h3>Where Can We Introduce Cache?</h3><h3>1. External Caching</h3><p>External caching uses a separate cache server (such as Redis) placed between the application server and the database layer.</p><p>Before querying the database, the application checks the cache:</p><ul><li>If the data is found, it is returned immediately (Cache Hit).</li><li>If not found (Cache Miss), the request goes to the database, and the response is stored in the cache before being returned to the client.</li></ul><p>Advantages:</p><ul><li>Better scalability</li><li>Shared across multiple application servers</li><li>Better isolation</li></ul><p>Disadvantages:</p><ul><li>Network overhead</li><li>Additional infrastructure to manage</li></ul><h3>2. In-Process Caching</h3><p>In this approach, the application server’s own memory is used as a cache.</p><p>It is generally not preferred for large-scale systems due to:</p><ul><li>Lack of isolation</li><li>Risk of data loss if the server crashes</li><li>Inconsistency across multiple application servers</li></ul><p>However, it is faster than external caching because it avoids network calls.</p><p>It is suitable for:</p><ul><li>Configuration data</li><li>Small lookup tables</li><li>Data required in almost every request</li></ul><h3>3. Client-Side Caching</h3><p>Client-side caching stores data on the client (browser, mobile app, etc.).</p><p>It is generally less preferred because:</p><ul><li>Limited control over data</li><li>Risk of stale data</li><li>Hard to maintain freshness</li></ul><p>However:</p><ul><li>It is the fastest form of caching</li><li>Useful for offline mode applications</li><li>Reduces server load significantly</li></ul><p>Common examples include browser caching and CDN caching.</p><h3>Caching Architectures / Patterns</h3><h3>1. Cache Aside (Lazy Loading)</h3><p>This is the most common caching architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*k587ii1cqYCLfVYQPyVq3w.png" /></figure><p>Flow:</p><ol><li>Application checks the cache.</li><li>If data is present → serve directly (Cache Hit).</li><li>If not → fetch from database.</li><li>Store the result in cache.</li><li>Return response to client.</li></ol><p>Downside:</p><ul><li>On write operations, stale cache must be invalidated (either removed or updated).</li><li>Risk of temporary inconsistency.</li></ul><h3>2. Write-Through</h3><p>Used where strong consistency between cache and database is required (e.g., banking systems).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*UEOvo4n0QtrWWBgMNGYOlA.png" /></figure><p>Flow:</p><ul><li>Every write goes to the cache.</li><li>The cache synchronously updates the database.</li></ul><p>Advantages:</p><ul><li>Strong consistency</li><li>No stale data</li></ul><p>Disadvantages:</p><ul><li>Higher latency</li><li>Tight coupling between cache and database</li><li>Slower write performance</li></ul><h3>3. Write-Behind (Write-Back)</h3><p>Similar to write-through, but updates to the database happen asynchronously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*45fCnW7D4TquxPmixMKx1g.png" /></figure><p>Flow:</p><ul><li>Write to cache first.</li><li>Cache updates the database later in the background.</li></ul><p>Advantages:</p><ul><li>Faster write performance</li><li>Lower latency</li></ul><p>Disadvantages:</p><ul><li>Risk of data loss if cache fails before database update</li><li>Temporary inconsistency</li></ul><h3>4. Read-Through</h3><p>Similar to cache-aside, but the cache layer itself is responsible for fetching data from the database on a cache miss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*ZZ2NzQBuVg4JBd8IkPuKVQ.png" /></figure><p>In this case:</p><ul><li>The application only interacts with the cache.</li><li>The cache handles database communication.</li></ul><p>This pattern is commonly used in CDN systems.</p><h3>Additional Important Concepts</h3><ul><li><strong>Cache Hit</strong> — Data found in cache</li><li><strong>Cache Miss</strong> — Data not found in cache</li><li><strong>TTL (Time To Live)</strong> — Time after which cached data expires</li><li><strong>Eviction Policies</strong> — LRU (Least Recently Used), LFU (Least Frequently Used), FIFO, etc.</li><li><strong>Cache Invalidation</strong> — Strategy to remove or update stale data</li></ul><p>reference — <a href="https://www.youtube.com/watch?v=1NngTUYPdpI">https://www.youtube.com/watch?v=1NngTUYPdpI</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c7e7016d8b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrency Issue in Program]]></title>
            <link>https://medium.com/@aggarwalgunjan597/concurrency-issue-in-program-3f6694db388c?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f6694db388c</guid>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[concurrent-programming]]></category>
            <category><![CDATA[multithread]]></category>
            <category><![CDATA[java-concurrency]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 13:15:12 GMT</pubDate>
            <atom:updated>2026-02-26T13:15:12.804Z</atom:updated>
            <content:encoded><![CDATA[<p>firstly how do we identify where the concurrency issue can happen?</p><p>Concurrency issue in simpler terms is an issue where a shared resources that can variable or state can be modified by more than one thread at a time that results into inconsistent and incorrect state that can corrupt the whole system or we can lost the data.</p><p>Example — Imagine IRCTC (Indian railways) where user can book a train ticket , two user is trying to book the ticket, they both check status of seat that is available, they both trying to book at same time that result in situation where both threads are trying to book a seat as result second thread overwrite the first thread that is basically should not happen.</p><p>Here are the Problem of Concurrency</p><ol><li>Correctness</li><li>Co-ordination</li><li>Scarcity</li></ol><h3>Correctness</h3><p>Correctness is the inconsistent state of system due to shared resources</p><p>Check and act where two thread check the state and modify the state , the problem arise because check and act is not an atomic operation to make it atomic when can two solution</p><p>1. Lock — we can use Synchronize(lock) in Java where we put the code in the block.</p><pre>HashMap&lt;int,int&gt; seats = new HashMap&lt;&gt;();<br><br>boolean bookSeat(int seatId,int visitorId){<br>  synchronize(lock){<br>    if(seats.containsKey(seatId)){<br>        seats.put(seatId,vistorId);<br>         return true;<br>    }<br>  return false<br>}</pre><p>2. Atomic Integer — it is usually use for counter need to searelized and synchronized. it ensures the consistency at Hardware level where counter is updated in single CPU cycle.</p><pre>AtomicInteger counter =  new AtomicInteger();<br><br>void Increment(){<br>  counter.incrementAndGet();<br>}</pre><h3>Co-ordination</h3><p>this is problem where thread need to communicate to other process threads. In an Asynchronous way we can simple use a message queue to insure system should not block. the Background threads are responsible for putting the message in queue.</p><p>the problem arise how the consumer threads knows the message is arrived in queue?</p><p>to solve this the worst solution will be keep the thread always running in while queue that check whether new message is arrived or not. this can lead to CPU burn out.</p><p>solution for this problem is we can use Blocking queue that sleep the thread if there is nothing in a queue and autmatically awake it when there is message in a queue.</p><pre>BlockingQueue&lt;Task&gt; queue = new LinkedBlockingQueue&lt;&gt;();<br><br>//producer<br>void AddInQueue(Task message){<br>   queue.put(message)<br>}<br><br>//consumer<br>while(true){<br>      Task task = queue.take(); // if queue is empty thread will sleep<br>       process(task);<br>}</pre><p>second problem in co-ordination is when the queue is overloaded and consumer speed it lesser than producer speed.</p><p>here we can use bounded Blocking queue which can be done by restricting the size of queue in case of overload excess message can be blocked and back — pressure will be maintained.</p><h3>Scarcity</h3><p>It is a problem where the system need to limit the concurrent access of finite resources.</p><p>example — we are calling external api that have rate limit of 10 (can handle 10 concurrent resources) and 20 threads are trying to call external api at same to insure the limited concurrency we can use semaphore</p><p>Semaphore — it ensure to providing locking mechanism to the critical section a example binary semaphore it used to insure one thread at a time in critical section.</p><pre>Semaphore permits = new Semaphore(5); // 5 concurrent processes can be in CS<br><br>void process(){<br>    permits.acquire(); //aquire a lock<br>    try{<br>       taskprocess();<br>    }finally{<br>      permits.release(); //  release a lock even the taskprocess throw error<br>    }<br><br>}</pre><p>Extra Notes</p><p>In general while maintaining the DB connection we don’t want a new TCP connection on each query here we use connection pool so each time we need to query to database we pick up a free connection from connection and after completion but that that connection in pool again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f6694db388c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform(IOC)]]></title>
            <link>https://medium.com/@aggarwalgunjan597/terraform-ioc-28f4a16d4a06?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/28f4a16d4a06</guid>
            <category><![CDATA[terraform-modules]]></category>
            <category><![CDATA[terraform-provider]]></category>
            <category><![CDATA[terraform-cloud]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 08:56:00 GMT</pubDate>
            <atom:updated>2026-01-04T08:56:00.408Z</atom:updated>
            <content:encoded><![CDATA[<p>It is a tool for provision of resouces or we can say setting up various cloud resouces like virtual server, buckets and many more by writing script with permissible credentials.It is as Stateful tool means it maintain a .tfstate file to keep the configuration of resouces that will avoid recontruction of same untaint resource by mistake. It uses a HCL language (Hashicorp configuration language).</p><p>File structure of Terraform :-</p><p>terraform-do/<br>├── main.tf<br>├── variables.tf<br>├── provider.tf<br>└── outputs.tf</p><p>main.tf :- Actual resource definitions (EC2, S3, VPC)<br>variables.tf :-Input variables (reusable &amp; configurable)<br>provider.tf:- Cloud provider configuration (AWS, GCP, Azure)<br>output.tf:- Output values (IP address, instance ID)</p><p>example of given file</p><h3>provider.tf</h3><pre>provider &quot;aws&quot; {<br>  region = &quot;ap-south-1&quot;<br>}</pre><h3>variables.tf</h3><pre>variable &quot;ami_id&quot; {<br>  description = &quot;AMI ID for EC2&quot;<br>  type        = string<br>}<br><br>variable &quot;instance_type&quot; {<br>  type = string<br>}<br><br>variable &quot;key_name&quot; {<br>  type = string<br>}</pre><h3>main.tf</h3><pre>resource &quot;aws_instance&quot; &quot;linux_vm&quot; {<br>  ami           = var.ami_id<br>  instance_type = var.instance_type<br>  key_name      = var.key_name<br><br>  user_data = file(&quot;script.sh&quot;)<br><br>  tags = {<br>    Name = &quot;Terraform_Linux_VM&quot;<br>  }<br>}</pre><h3>outputs.tf</h3><pre>output &quot;public_ip&quot; {<br>  value = aws_instance.linux_vm.public_ip<br>}</pre><pre>Don’t forget to add ACCESS_KEY_ID and SECRET_ACCESS_KEY<br>export AWS_ACCESS_KEY_ID=xxxx<br>export AWS_SECRET_ACCESS_KEY=xxxx</pre><p>Commands to run terraform-</p><p>terraform init # initialize provider &amp; backend<br>terraform plan # show execution plan<br>terraform apply # create/update resources<br>terraform destroy # delete resources</p><p>Key Feature of Terraform</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*JjjCOui3szxxMsV2so05yA.png" /></figure><ol><li>we can also introduce Module for each resource-</li></ol><ul><li>Improves maintainability and Reusable Terraform code</li></ul><p>2. Drift Detection (detect manual changes and difference between actual state and infra state)</p><p>3. Idempotency — Running terraform apply multiple times gives the <strong>same result</strong></p><p>Key Points to remender</p><ol><li>Remote Backend:- A <strong>remote backend</strong> stores the terraform.tfstate file <strong>outside local machine</strong> (e.g., S3, Terraform Cloud).<br>it supports Team collab, state consistency, Disaster recovery</li><li>State Locking:- Prevents <strong>multiple users</strong> from modifying infrastructure <strong>at the same time</strong>.</li><li>Modules:- A <strong>reusable Terraform configuration</strong> (like a function).<strong>Terraform context:</strong></li><li>Variables &amp; Outputs:- Make Terraform code <strong>dynamic and reusable</strong>.</li><li>Plan vs Apply : -terraform plan</li></ol><ul><li>Shows <strong>what will change</strong></li><li>No resources are created</li><li>Used for review</li></ul><pre>terraform plan</pre><h3>terraform apply</h3><ul><li>Executes the changes</li><li>Creates/updates/deletes resources</li></ul><pre>terraform apply</pre><p><strong>Key point:</strong><br> plan = preview<br> apply = execution</p><pre>module &quot;ec2&quot; {<br>  source         = &quot;./modules/ec2&quot;<br>  instance_type  = &quot;t2.micro&quot;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28f4a16d4a06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Important Commands]]></title>
            <link>https://medium.com/@aggarwalgunjan597/linux-important-commands-06e71298cfd3?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/06e71298cfd3</guid>
            <category><![CDATA[scp-command]]></category>
            <category><![CDATA[linux-commands]]></category>
            <category><![CDATA[ssh-keygen]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[rsync-command]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 08:48:57 GMT</pubDate>
            <atom:updated>2025-12-27T08:48:57.450Z</atom:updated>
            <content:encoded><![CDATA[<h3>SSH Key Generation and Connection Guide</h3><h3>1. Generate Key Pair</h3><p>Run the following command on your <strong>local machine</strong> to generate a new SSH key pair.</p><p><strong>Syntax:</strong></p><pre>ssh-keygen -t &lt;encry-algo&gt; -b &lt;bits&gt; -f ~/.ssh/&lt;file_name&gt;</pre><p><strong>Example:</strong></p><pre>ssh-keygen -t rsa -b 4096 -f ~/.ssh/server_key_one</pre><h3>Output Files</h3><p>This command will generate two files in your ~/.ssh/ directory:</p><ul><li><strong>&lt;file_name&gt;</strong>: The <strong>Private Key</strong> (Keep this safe on your local machine).</li><li><strong>&lt;file_name&gt;.pub</strong>: The <strong>Public Key</strong> (This goes to the server).</li></ul><h3>2. Copy Public Key</h3><p>View and copy the content of your public key.</p><pre>cat ~/.ssh/&lt;file_name&gt;.pub</pre><p><em>Copy the output starting from </em><em>ssh-rsa ...</em></p><h3>3. Configure Remote Server</h3><p>Log in to your <strong>remote server</strong> and add the public key to the authorized list.</p><ol><li>Open the authorized keys file:</li></ol><ul><li>sudo nano ~/.ssh/authorized_keys</li></ul><ol><li><strong>Paste</strong> the copied public key into this file.</li><li><strong>Save and Exit</strong>:</li></ol><ul><li>Press Ctrl + O then Enter (to save).</li><li>Press Ctrl + X (to exit)</li></ul><h3>4. Connect to Server</h3><p>Use the following command on your <strong>local machine</strong> to connect using the specific key.</p><pre>ssh -v -i ~/.ssh/&lt;file_name&gt; ubuntu@&lt;public ipv4&gt;</pre><p><strong>Flag Explanation:</strong></p><ul><li>-i: Stands for <strong>identity</strong>. It tells SSH which specific private key file to use for authentication.</li><li>-v: Verbose mode (optional, helps debug connection issues).</li></ul><h3>File Transfer (SCP &amp; Rsync)</h3><p>Once SSH is configured, you can transfer files securely between your local machine and the server.</p><h3>Option A: SCP (Secure Copy Protocol)</h3><p>Best for simple, one-time file transfers. It works just like the cp command but over a network.</p><p><strong>Syntax:</strong></p><pre>scp -i &lt;key_path&gt; &lt;source&gt; &lt;destination&gt;</pre><p><strong>1. Upload a file (Local -&gt; Remote):</strong></p><pre>scp -i ~/.ssh/server_key_one ./my_file.txt ubuntu@&lt;public ipv4&gt;:/home/ubuntu/</pre><ul><li><strong>Explanation:</strong> Copies my_file.txt from your current folder to the /home/ubuntu/ directory on the remote server.</li></ul><p><strong>2. Download a file (Remote -&gt; Local):</strong></p><pre>scp -i ~/.ssh/server_key_one ubuntu@&lt;public ipv4&gt;:/home/ubuntu/backup.zip ./Downloads/</pre><ul><li><strong>Explanation:</strong> Copies backup.zip from the server to your local Downloads folder.</li></ul><p><strong>3. Upload a directory (Recursive):</strong> Add the -r flag to copy entire folders.</p><pre>scp -r -i ~/.ssh/server_key_one ./my_project_folder ubuntu@&lt;public ipv4&gt;:/var/www/html/</pre><h3>Option B: Rsync (Remote Sync)</h3><p>Best for large files, backups, or syncing directories. Unlike scp, rsync checks existing files and only transfers the <strong>differences</strong>, making it much faster for updates.</p><p><strong>Syntax:</strong></p><pre>rsync -avz -e &quot;ssh -i &lt;key_path&gt;&quot; &lt;source&gt; &lt;destination&gt;</pre><p><strong>Common Flags:</strong></p><ul><li>-a: <strong>Archive</strong> mode (preserves permissions, timestamps, and symbolic links).</li><li>-v: <strong>Verbose</strong> (shows progress).</li><li>-z: <strong>Compress</strong> (compresses data during transfer to save bandwidth).</li><li>-e: Specifies the remote shell to use (necessary to pass the SSH key path).</li></ul><p><strong>1. Sync Local Folder to Remote:</strong></p><pre>rsync -avz -e &quot;ssh -i ~/.ssh/server_key_one&quot; ./local_website/ ubuntu@&lt;public ipv4&gt;:/var/www/html/</pre><ul><li><strong>Note on Trailing Slashes:</strong></li><li>./folder/ (with slash): Copies the <strong>contents</strong> inside the folder.</li><li>./folder (no slash): Copies the <strong>folder itself</strong>.</li></ul><p><strong>2. Resume a large interrupted download:</strong> Use the -P flag (Progress + Partial) to resume transfers if the connection drops.</p><pre>rsync -avzP -e &quot;ssh -i ~/.ssh/server_key_one&quot; ubuntu@&lt;public ipv4&gt;:/home/ubuntu/big_database.sql ./</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06e71298cfd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do SSH (remote-login) on EC2 instance]]></title>
            <link>https://medium.com/@aggarwalgunjan597/how-to-do-ssh-remote-login-on-ec2-instance-7feeea6dbe99?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/7feeea6dbe99</guid>
            <category><![CDATA[remotelogging]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[passwd]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 08:06:25 GMT</pubDate>
            <atom:updated>2025-12-27T08:06:58.213Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>lanch an instance (ubuntu)</li><li>set password: sudo passwd ubuntu</li><li>Enable Password Authentication <br>( run commands on remote server)<br> 1 .ls /etc/ssh/sshd_config.d/<br> you will see .conf file -&gt; copy the file <br>2 . sudo nano ls /etc/ssh/sshd_config.d/&lt;copied_file.conf&gt;<br>3 . Change PasswordAuthentication no to yes<br>4 . Ctrl O , enter and ctrl X</li><li>Restart SSH Service<br>sudo systemctl restart ssh</li><li>Connect from your Desktop</li><li>window powershell:<br>ssh ubuntu@&lt;public ipv4&gt;</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7feeea6dbe99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance Feature of TCP]]></title>
            <link>https://medium.com/@aggarwalgunjan597/advance-feature-of-tcp-a7371bcb223e?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7371bcb223e</guid>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[tcp-ip-model]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[tfo]]></category>
            <category><![CDATA[http3]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 06:35:05 GMT</pubDate>
            <atom:updated>2025-12-21T06:35:05.785Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>TCP Fast Open</strong></h3><p>it is an Advancement made in TCP protocol to reduce the overhead of “handshake” in TCP protocol that ensure the availability of Server and Client. if the distance between client and server is large that it result in performance overhead and latency for connection set-up.</p><p><em>Why it fails?</em></p><p><strong><em>1)Rigidity in Operating system</em></strong>:-<em>TCP Fast Open struggled because it requires deep, hard-to-update OS changes. Early adopters (like Windows and iOS) implemented a temporary “experimental” ID number (254). When the official standard later assigned a different permanent ID (34), it created a compatibility trap.</em></p><p><em>To avoid breaking connections with older devices, modern systems are forced to support </em><strong><em>both</em></strong><em> IDs, resulting in a messy and fragmented ecosystem that slowed widespread adoption.</em></p><p>2)<strong><em>Middleboxes</em></strong><em> (outdated firewalls and routers) frequently block TCP Fast Open packets because they interpret the new data format as a threat or error. This forces browsers to restart the connection using the old method, making the process significantly slower than if they hadn’t tried to use the “fast” method at all.</em></p><p>3)<strong><em>TCP Fast Open (TFO)</em></strong><em> uses a persistent digital token (cookie) to speed up connections. However, this token poses a severe privacy risk because it survives “Incognito” mode and network changes, allowing servers to track users even when they attempt to be anonymous or move to different physical locations.</em></p><p>4<em>)</em><strong><em>The HTTP/2 Shift (Diminishing Returns)</em></strong><em> When TFO was designed, the web ran on </em><strong><em>HTTP/1</em></strong><em>. Back then, browsers opened 6+ separate connections for a single webpage. TFO was valuable because it could speed up each of those 6 connections. However, the modern web runs on </em><strong><em>HTTP/2</em></strong><em>, which uses a single, long-lasting connection to send everything. TFO only helps with the very first handshake. Since we make fewer connections now, the total time saved by TFO is negligible.</em></p><h3><strong><em>Summary</em></strong></h3><p>Why TFO Lack Behind?</p><p><strong>TCP Fast Open (TFO)</strong> has largely been rendered unnecessary by modern protocols. <strong>HTTP/2</strong> reduced the number of connections needed (lowering TFO’s potential impact), while <strong>HTTP/3</strong> (using UDP) and <strong>TLS 1.3</strong> (using 0-RTT) deliver the same speed advantages as TFO without the technical flaws, privacy risks, or compatibility nightmares.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7371bcb223e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Server Side Event(SSE)?]]></title>
            <link>https://medium.com/@aggarwalgunjan597/what-is-server-side-event-sse-0a2826a58a0a?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a2826a58a0a</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[http1]]></category>
            <category><![CDATA[server-side-events]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sat, 20 Dec 2025 06:25:22 GMT</pubDate>
            <atom:updated>2025-12-20T06:25:22.025Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Server-Sent Events (SSE)</strong> is a technology that allows a server to push real-time updates to a web page over a single, long-lived HTTP connection.</p><p>While standard HTTP follows a “request-response” cycle (you ask, the server answers, then hangs up), SSE keeps the “phone line” open so the server can shout out updates whenever they happen.</p><p>Using SSE in your browser is remarkably simple because it is a built-in Web API.</p><h3>1. How It Works (The “Radio Broadcast” Model)</h3><p>Think of SSE like a <strong>radio station</strong>.</p><ol><li><strong>Tuning In:</strong> The client (browser) “tunes in” to a specific URL on the server using a JavaScript object called EventSource.</li><li><strong>Staying Connected:</strong> The server responds, but it doesn’t close the connection. It keeps it open.</li><li><strong>Streaming:</strong> Whenever the server has new info (a stock price change, a new chat message, a score update), it sends a “chunk” of data down that open pipe.</li><li><strong>Automatic Reconnect:</strong> If the connection drops (like driving through a tunnel), the browser automatically tries to reconnect to the “station.”</li></ol><h3>2. The Data Format (The “Wire” Protocol)</h3><p>The server must send the data in a very specific plain-text format. It must use the header Content-Type: text/event-stream.</p><p>A typical message from the server looks like this:</p><p>Plaintext</p><pre>event: user-login<br>data: {&quot;username&quot;: &quot;Alice&quot;, &quot;time&quot;: &quot;11:36&quot;}</pre><pre>data: This is a simple message without a custom event name.</pre><ul><li><strong>event:</strong> (Optional) Gives the message a specific name (like a &quot;channel&quot;).</li><li><strong>data:</strong> The actual content. If the message is long, you can use multiple data: lines.</li><li><strong>id:</strong> (Optional) A unique ID for the message. If the connection breaks, the browser sends the &quot;Last-Event-ID&quot; to the server so it can resume exactly where it left off.</li><li><strong>retry:</strong> (Optional) Tells the browser how many milliseconds to wait before trying to reconnect if the line drops.</li></ul><p>What is Difference between websockets and SSE?</p><ol><li>Communication flow — SSE is for server to client data communication where websockets is bi-directional used to real time communcation.</li><li>Protocol — SSE used HTTP standard protocol where websockets used specific ws:// protocol.</li><li>Reconnection- SSE automatic reconnect whereas websockets need manual reconnection.</li><li>Firewalls Passage — SSE can passe the firewalls whereas websocket sometime can be blocked</li></ol><h3>How SSE Work with HTTP/1.1 and HTTP/2?</h3><h4>1. The HTTP/1.1 Way: Separate Pipes</h4><p>In HTTP/1.1, a TCP connection can only handle <strong>one request/response at a time</strong>. Since SSE is a “hanging” request that never officially ends, it “clogs” that connection indefinitely.</p><ul><li>If you create 6 EventSource objects in your JS code, the browser opens <strong>6 separate TCP connections</strong>.</li><li>Because browsers have a hard limit of 6 connections per domain, your 7th request (whether it’s another SSE or just a simple image) will be <strong>blocked</strong> until one of the others is closed.</li></ul><h4>2. The HTTP/2 Way: One Pipe, Many Lanes</h4><p>HTTP/2 introduced a feature called <strong>Multiplexing</strong>. Instead of opening new TCP connections, it creates “Streams” inside a single, existing TCP connection.</p><ul><li><strong>Can you write 6 EventSources in JS?</strong> Yes! You can actually write 10, 20, or even 100.</li><li><strong>How it works:</strong> All those EventSource objects will travel through the <strong>same single TCP connection</strong>. They are assigned &quot;Stream IDs,&quot; allowing the browser to keep the data for EventSource_A separate from EventSource_B even though they are moving through the same &quot;pipe.&quot;</li></ul><blockquote><strong><em>Note:</em></strong><em> While HTTP/2 theoretically allows hundreds of streams, the server usually sets a limit (often </em><em>SETTINGS_MAX_CONCURRENT_STREAMS = 100). This is much higher than the old limit of 6.</em></blockquote><blockquote><strong>Browser Fail-safe:</strong> If for some reason the connection drops back to HTTP/1.1 (due to an old proxy, a corporate firewall, or a server misconfiguration), your app will suddenly break if it relies on more than 6 streams.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a2826a58a0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference Between HTTP versions?]]></title>
            <link>https://medium.com/@aggarwalgunjan597/difference-between-http-versions-ec83b41ae2f6?source=rss-a203de864c05------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec83b41ae2f6</guid>
            <category><![CDATA[how-internet-works]]></category>
            <category><![CDATA[osi-model]]></category>
            <category><![CDATA[application-layer]]></category>
            <category><![CDATA[http-version]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Aggarwalgunjan]]></dc:creator>
            <pubDate>Sat, 20 Dec 2025 05:56:23 GMT</pubDate>
            <atom:updated>2025-12-20T05:56:23.203Z</atom:updated>
            <content:encoded><![CDATA[<p>HTTP stand for hypertext tranfer protocol. It is a Application Layer protocol in OSI Layer Architecture.HTTP Protocol is used for communication and data exchange between Client (that is browser) and the Server(Web Server).</p><p><strong>Different Versions of HTTP</strong></p><ol><li><strong>HTTP/0.9</strong>- It is Earliest form of HTTP that is simple protcol supports only GET method with no header. It simple pass the plain header.</li><li><strong>HTTP/1.0</strong> - It is upgraded version of HTTP where header is included header and support multiple methods like POST, PUT etc with status code of response.Major drawback is it requires a new TCP connection for each request, leading to high latency.</li><li><strong>HTTP/1.1</strong>- In order to mitigate this flaw, HTTP/1.1 introduced <em>pipelining</em> (which proved difficult to implement) and <em>persistent connections</em>: the underlying TCP connection can be partially controlled using the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Connection">Connection</a> header. By allowing multiple requests and responses over a single connection, and improved caching, error handling, and content negotiation</li><li><strong>HTTP/2.0</strong> — It’s a binary protocol rather than a text protocol. It can’t be read and created manually. Despite this hurdle, it allows for the implementation of improved optimization techniques.</li></ol><ul><li>It’s a multiplexed protocol. Parallel requests can be made over the same connection, removing the constraints of the HTTP/1.x protocol.</li><li>It compresses headers. As these are often similar among a set of requests, this removes the duplication and overhead of data transmitted.</li></ul><p>5.<strong> HTTP/3.0-</strong> HTTP/3 keeps HTTP semantics the same but replaces TCP with QUIC to achieve faster and more reliable web communication.</p><p>Since 2005, more APIs have become available to web pages. Several of these APIs create extensions to the HTTP protocol for specific purposes:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events">Server-sent events</a>, where the server can push occasional messages to the browser.</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API">WebSocket</a>, a new protocol that can be set up by upgrading an existing HTTP connection.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec83b41ae2f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>