<?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"><channel><title><![CDATA[Anubhav Dixit]]></title><description><![CDATA[Software Engineer]]></description><link>https://blog.anubhavdxt.tech</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 08:41:50 GMT</lastBuildDate><atom:link href="https://blog.anubhavdxt.tech/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Designing a single-threaded, asynchronous, and highly concurrent engine]]></title><description><![CDATA[I got this question while interviewing for the MTS (Member of Technical Staff) position at a reputed startup. They asked me to write the theoretical architecture implementation of a single-threaded, asynchronous, and highly concurrent engine.
Below i...]]></description><link>https://blog.anubhavdxt.tech/single-thread-asynchronous-concurrent-engine</link><guid isPermaLink="true">https://blog.anubhavdxt.tech/single-thread-asynchronous-concurrent-engine</guid><category><![CDATA[System Architecture]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Event Loop]]></category><category><![CDATA[callstack]]></category><category><![CDATA[garbagecollection]]></category><dc:creator><![CDATA[Anubhav Dixit]]></dc:creator><pubDate>Sun, 12 Feb 2023 06:18:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676181252059/d09edfa4-4545-4c53-b863-50e972ce5c0b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I got this question while interviewing for the MTS (Member of Technical Staff) position at a reputed startup. They asked me to write the theoretical architecture implementation of a single-threaded, asynchronous, and highly concurrent engine.</p>
<p>Below is the explanation and procedure that I followed.</p>
<h2 id="heading-flow-of-code">Flow of code</h2>
<p>First of all, we need to understand the flow of execution of the code and the intermediate steps involved in it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675757080060/cf5a3241-10d2-4d31-88b1-af6e1598bb98.png" alt class="image--center mx-auto" /></p>
<p>There will be three steps involved majorly:</p>
<ol>
<li><p>The source code will be first broken into tokens and parsed into an AST with the help of a <em>syntax parser</em>. The code will now be in the form of an <em>Abstract Syntax Tree</em>.</p>
</li>
<li><p>After that, this AST will go to the <em>interpreter</em> for compilation. It will get converted into <em>bytecode</em> for further processing.</p>
</li>
<li><p>The bytecode generated above will be sent to the <em>main thread</em> for execution and executed inside the <em>call stack</em>.</p>
</li>
</ol>
<h2 id="heading-single-threaded-concurrency-model">Single-threaded Concurrency model</h2>
<p>Since our motive here is to make the engine single-threaded, we will have only one thread for the execution of the tasks. We won't be able to run multiple tasks parallelly. If any CPU-intensive task is there, it will block the execution of further tasks causing the system to collapse or hang. So we need to keep the architecture such that it becomes non-blocking.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675760639324/47ef538f-4034-404b-9cf2-851622d77731.png" alt class="image--center mx-auto" /></p>
<p>The concurrency model shown in the figure above has three significant components.</p>
<ol>
<li><p><strong>Call Stack</strong></p>
<p> The frames of the function calls form a stack. At the start of the program, Global Execution Context is created. After that, according to the function calls, a new frame is created to execute it. Being a stack, it supports <em>LIFO</em> (Last in, first out).</p>
</li>
<li><p><strong>Memory Heap</strong></p>
<p> Inside the memory heap, memory is allocated to the objects and variables present inside the code. The memory is allocated randomly to every object in a heap.</p>
</li>
<li><p><strong>Task Queue</strong></p>
<p> The primary purpose of the task queue is to queue the tasks while the call stack executes the previous ones. Since it is a queue, the operations performed here will be <em>FIFO</em> (First in, first out).</p>
</li>
</ol>
<p><em>But now the question arises, how does the task queue be able to queue the tasks beforehand?</em></p>
<h2 id="heading-asynchronous-operations">Asynchronous operations</h2>
<p>To make the engine asynchronous, we can use an <em>event loop.</em> It helps us in making the engine asynchronous. We will also use the OS kernel and OS as well as web APIs. These are also very helpful in making the system asynchronous.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675762269074/01465666-d149-46e4-82df-54d90992d07c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-components-of-the-asynchronous-model">Components of the asynchronous model</h3>
<ol>
<li><p><strong>Event Loop</strong></p>
<p> The primary work of the event loop is to monitor the call stack continuously and push a task from the task queue to the call stack when it gets empty.</p>
</li>
<li><p><strong>OS Kernel &amp; APIs</strong></p>
<p> We can use the OS Kernel for offloading the main thread from Input/Output operations, making the system asynchronous.</p>
</li>
</ol>
<h3 id="heading-engine-model-and-execution-process">Engine model and execution process</h3>
<p>Since we have outlined the architecture, we will try to understand the implementation and execution of the above model.</p>
<p>At the start of the code, a global execution context will be created in the call stack. Then the memory will be allocated to the objects and variables inside the memory heap. Then the code execution will start line by line.</p>
<p>Now, to make the system non-blocking, we will use the OS Kernel and APIs, e.g., Web APIs like <code>setTimeOut()</code>, <code>localeStorage()</code> And file read and write with the help of OS Kernel. When these types of tasks are inside the code, the main thread will send them to the OS environment, and the control will go to the following line of code. Since the control moves ahead instead of waiting for these operations to complete, these tasks will be queued in the task queue on completion from the OS environment.</p>
<p>Here the work of the event loop starts. An event loop is a process in which the call stack searches for the pending tasks in the task queue when nothing is to be executed inside the call stack. The event loop starts functioning only when all the frames inside the call stack are popped out. The task that was pushed inside the queue first will be pushed to the call stack first until all the queued tasks are executed.</p>
<p>This way, all the code will be executed, and all the tasks will be handled concurrently without blocking the main thread. This system takes help from the OS Kernel and APIs for handling I/O operations, allowing it to execute all the tasks on a single thread concurrently and asynchronously without blocking the thread.</p>
<h3 id="heading-garbage-collection-and-freeing-up-the-memory">Garbage collection and freeing up the memory</h3>
<p>After the execution of the code, the memory from the heap needs to be freed up. Otherwise, it may cause system storage issues and slow it down. For this purpose, we need to use a garbage collector (GC). After doing some research, I thought of including the Mark and Sweep garbage collection algorithm for the implementation of the Garbage Collector of this engine. This algorithm works on the concept of 'an object is unreachable'. It points out the root object of the whole code - for example, the Global or Window object in our web browsers. After getting the root objects, it will search all the objects reachable from the root object, then all the objects reachable from those objects, and so on. After pointing out all the reachable objects, it sweeps all the unreachable objects.</p>
<h2 id="heading-further-optimization-techniques">Further optimization techniques</h2>
<p>We also need to focus on some optimization techniques to make our engine more optimal and fast.</p>
<ol>
<li><p><strong>Inlining</strong></p>
<p> At the start, we can inline all the source code, saving a lot of time that might be wasted in parsing the blank lines.</p>
</li>
<li><p><strong>Inline caching</strong></p>
<p> We can use the inline caching method to cache the simultaneous calls of the same function with the same arguments. It will cache those results, and the next time the same call happens, it won't need to execute the code instead, it will directly provide the output.</p>
</li>
</ol>
<h2 id="heading-outro">Outro</h2>
<p>So it was all about the high-level architecture of a single-threaded, asynchronous, and highly concurrent engine. If you want to learn more of it, you can check out the links in the references section below.</p>
<p>Also, if you like my content, you can support me with a 👍 and catch me on <a target="_blank" href="https://twitter.com/anubhavdxtdev"><strong>Twitter</strong></a> <strong>and LinkedIn</strong>. If you also like to host your repositories on GitHub, like me, you can find me there also <a target="_blank" href="https://github.com/anubhavdxt"><strong>GitHub</strong></a>.</p>
<p>Feedbacks are most welcome.</p>
<h2 id="heading-references">References</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop">https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop</a></p>
<p><a target="_blank" href="https://v8.dev/">https://v8.dev/</a></p>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection</a></p>
]]></content:encoded></item><item><title><![CDATA[How does the Internet works?]]></title><description><![CDATA[How does the Internet works?
Nowadays, Internet has become an essential part of our lives, and we need the Internet for daily purposes. Whether searching for resources to study or watching a movie on any OTT platform, we need the Internet.
In this ar...]]></description><link>https://blog.anubhavdxt.tech/how-does-the-internet-works</link><guid isPermaLink="true">https://blog.anubhavdxt.tech/how-does-the-internet-works</guid><category><![CDATA[internet]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Web Design]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Anubhav Dixit]]></dc:creator><pubDate>Mon, 10 Jan 2022 06:44:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1641796935848/894hLEtAR.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-how-does-the-internet-works">How does the Internet works?</h1>
<p>Nowadays, Internet has become an essential part of our lives, and we need the Internet for daily purposes. Whether searching for resources to study or watching a movie on any OTT platform, we need the Internet.</p>
<p>In this article, we will try to understand the functioning and basics of the Internet and how it gets to us.</p>
<p>But, before we proceed further, you need to understand some general terms, they may not make much sense to you now, but we will understand them more clearly in our further reading.</p>
<h2 id="heading-technical-terminology">Technical terminology</h2>
<h4 id="heading-network">Network</h4>
<p>A network is a connection of two or more computers connected with the help of an ethernet cable or wirelessly with wi-fi or Bluetooth.</p>
<h4 id="heading-switch">Switch</h4>
<p>The switch is a device used to connect the devices to communicate. It has ethernet ports, and all the devices are associated with an ethernet cable. We need a switch device to make a wired network by connecting two or more computers with an ethernet cable.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641720865181/72KZHDHbw.jpeg" alt="Switch.jpg" /></p>
<h4 id="heading-lan">LAN</h4>
<p>Local Area Network is a network connecting the computers of a small area with a switch to make them communicate with each other.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641725526547/VbKJd4V3n.png" alt="internet-schema-3.png" /></p>
<h4 id="heading-router">Router</h4>
<p>A router is a device used to connect a LAN to the Internet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641720800423/xMkoH5ikN.jpeg" alt="Router.jpg" /></p>
<h4 id="heading-modem">Modem</h4>
<p>A modem is equipment that connects our network to the telephone infrastructure. This modem turns the information from our network into information manageable by the telephone infrastructure and vice versa.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641725447560/nw3yokxf6.jpeg" alt="Motorola-MB7621_20210211-233252_full.jpeg" /></p>
<h4 id="heading-wan">WAN</h4>
<p>Wide Area Network extends over an extensive geographical area, comprising countries to continents. It is a network of Local Area Networks.</p>
<h4 id="heading-ispinternet-service-provider">ISP(Internet Service Provider)</h4>
<p>An ISP is a company that manages some special routers linked together and can also access other ISPs' routers. So the message from our network is carried through the network of ISP networks to the destination network. The Internet consists of this whole infrastructure of networks.</p>
<h4 id="heading-packets">Packets</h4>
<p>In networking, the packets are a smaller chunk of the more extensive information containing both data and information about itself. Information stored inside it is known as 'header,' which tells a computer what to do with its data.</p>
<h4 id="heading-protocols">Protocols</h4>
<p>In networking, a protocol is a standardized way of doing specific actions and formatting data so that two or more devices can communicate with and understand each other. The protocol is needed because we need a common language for the devices with different hardware and software to communicate over the Internet.</p>
<p><em>Now, as we are familiar with the above terminology, we'll move forward to our main topic.</em></p>
<h2 id="heading-why-is-distributed-networking-important-for-the-internet">Why is distributed networking important for the Internet?</h2>
<p>There is no control centre for the Internet. Instead, it is a distributed networking system, not dependent on any individual machine. Any computer or hardware that can send and receive data accurately (e.g., using the correct networking protocols) can be part of the Internet.</p>
<p>The Internet is resilient due to its distributed nature. Computers, servers, and other pieces of networking hardware connect and disconnect from the Internet all the time without impacting how the Internet functions — unlike a computer, which may not function at all if it is missing a component.</p>
<h2 id="heading-connecting-to-the-internet-a-network-of-networks">Connecting to the Internet (A network of networks)</h2>
<p>A small number of computers are connected to transmit information in a local area network. But when we need to communicate to a computer outside our network, we need to connect to another local area network.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641725277456/TzioABg5c.png" alt="internet-schema-2.png" /></p>
<p>But it's not possible to set cables up between your house and the rest of the world, so how can you handle this? Well, there are already cables linked to your home, for example, electric power and telephone. The telephone infrastructure already connects your house with anyone in the world, so it is the perfect wire we need.
We connect our network to the telephone infrastructure with a modem.</p>
<p>The next step is to send the messages from our network to the network we want to reach. To do that, we will connect our network to an Internet Service Provider (ISP).
An Internet connection and a router are needed to connect to the Internet. The router allows a local area network to communicate with the Internet and send messages outside a network.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641725584547/iG8SQXYF7.png" alt="internet-schema-7.png" /></p>
<p>Whenever a message is sent to a device outside of a local area network over the Internet, it first goes to the router; the router checks the message's destination and sends it to the other router. This process continues until the message reaches its destination.</p>
<h2 id="heading-intranet-andamp-extranet">Intranet &amp; Extranet</h2>
<p>Intranet is a private network owned by a single organization and is a tool for sharing information throughout the organization. Since the intranet is a private network, no one can use the intranet without a valid username and password.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641795870392/HmzZdh7sc.png" alt="internet-schema-8.png" /></p>
<p>The extranet is also a private network like an intranet owned by either a single or many organizations. It is managed on a contractual basis between organizations and facilitates sharing of information between internal and external members.</p>
<h2 id="heading-future-of-internet">Future of Internet</h2>
<p>In the coming time, the Internet will take over our lives, from streaming music to turning off the light of our bedroom, and we will be doing everything with the help of the Internet. It has already made our lives very simple. We use the Internet for our day-to-day tasks, from searching for our assignment questions to searching for a particular recipe. We use it for almost everything.</p>
<h2 id="heading-building-a-better-and-safer-internet">Building a better and safer Internet</h2>
<p>The invention of the Internet is a significant achievement on its own, but it doesn't always work as expected. Networking issues and malicious activity can slow down Internet access or block it together.</p>
<p>Third parties can spy on user activities, leading to abuse and, in some cases, government repression. Internet protocols and processes were not designed with security and privacy in mind since the people who first designed and built the Internet were more concerned with getting it to work than making it perfect.</p>
<p>However, we as a developer should work on building the Internet safer by contributing to the development of new, more fast, and secure protocols and educating users about the working of Internet technology, etc.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>So this is a brief idea about how the Internet works. If you want to know more about its working and deep dive to understand everything, you can refer to the links below in the resources section.</p>
<p>Also, if you like my content, you can support me with a 👍 and you can catch me on <a target="_blank" href="https://twitter.com/anubhavdxtdev">Twitter</a>, <a target="_blank" href="https://instagram.com/anubhavdxtdev">Instagram</a>, <a target="_blank" href="https://www.linkedin.com/in/anubhavdxt">LinkedIn</a> and if you also like to host your repositories on GitHub like me, you can find me there also <a target="_blank" href="https://github.com/anubhavdxt">GitHub</a>.</p>
<p>Feedbacks are most welcome.</p>
<h2 id="heading-resources">Resources</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/How_does_the_Internet_work">MDN Web Docs</a><br /><a target="_blank" href="https://www.cloudflare.com/en-in/learning/network-layer/how-does-the-internet-work/">Cloudflare</a><br /><a target="_blank" href="https://www.hp.com/us-en/shop/tech-takes/how-does-the-internet-work">HP</a></p>
<h2 id="heading-credit">Credit</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US">MDN Web Docs</a><br /><a target="_blank" href="https://icons8.com">Icons8</a><br /><a target="_blank" href="https://www.cloudflare.com/en-in/learning">Cloudflare</a></p>
<h2 id="heading-read-more">Read more</h2>
<p><a target="_blank" href="https://anubhavdixit.me/how-does-the-web-works">How does the Web works?</a></p>
]]></content:encoded></item><item><title><![CDATA[How does the Web works?]]></title><description><![CDATA[How does the Web work?
We use the web for our day-to-day tasks, such as information, education, or entertainment.
But have you ever wondered how these websites get to your screen?
How do all those websites get to load within a fraction of seconds and...]]></description><link>https://blog.anubhavdxt.tech/how-does-the-web-works</link><guid isPermaLink="true">https://blog.anubhavdxt.tech/how-does-the-web-works</guid><category><![CDATA[web]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[website]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[Anubhav Dixit]]></dc:creator><pubDate>Fri, 07 Jan 2022 17:07:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1641572208728/LPZRA-MeFN.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-how-does-the-web-work">How does the Web work?</h1>
<p>We use the web for our day-to-day tasks, such as information, education, or entertainment.</p>
<p>But have you ever wondered how these websites get to your screen?</p>
<p>How do all those websites get to load within a fraction of seconds and become alive?</p>
<p>A lot is happening between you clicking the search button and the websites loads.</p>
<p>In this article, we will deep dive into the functioning of what happens behind the scenes after we click that search button inside our web browser.</p>
<h2 id="heading-technical-terminology">Technical terminology</h2>
<p>Before we move further, it is good to understand some technical terms.</p>
<p>You may not understand them, but you will see them making more sense in this article later.</p>
<p>I'll try my best to explain them in the simplest way possible for your understanding so that we can move further.</p>
<h4 id="heading-url">URL</h4>
<p>Uniform Resource Locator is a form of text that we use to tell the browser exactly what we want. Ex- <code>https://google.com</code></p>
<h4 id="heading-clients">Clients</h4>
<p>It is your computer connected to the internet, from which you request some information.</p>
<h4 id="heading-servers">Servers</h4>
<p>A server is a computer that stores all the data, including web pages, sites, apps, etc.</p>
<h4 id="heading-internet">Internet</h4>
<p>It is a network of all the world's computers that allows you to send and receive data on the web.</p>
<h4 id="heading-protocols">Protocols</h4>
<p>Protocols are rules that clients and servers must follow to communicate.</p>
<h4 id="heading-tcpip">TCP/IP</h4>
<p>Transmission Control Protocol and Internet Protocol are communication protocols that define how data should travel across the internet. </p>
<h4 id="heading-ip-address">IP Address</h4>
<p>Internet Protocol Address is a unique address given to each device across the internet. It is in the form <strong>192.158.11.38</strong>, each number ranging from <strong>0-255</strong>.</p>
<h4 id="heading-dns">DNS</h4>
<p>Domain Name Servers are like the phone address book for websites containing the IP address of all the websites in it.</p>
<h4 id="heading-http">HTTP</h4>
<p>Hypertext Transfer Protocol is an application protocol that defines a language for clients and servers to speak. It is the first part of the URL.</p>
<h4 id="heading-isp">ISP</h4>
<p>Internet Service Provider is a company that provides web access to consumers.</p>
<p><em>Now, as we are familiar with the above terminology, we'll move forward to our main topic.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641574467782/1yuj4FEgI.png" alt="Group 5.png" /></p>
<h2 id="heading-the-whole-story">The whole story</h2>
<p>When you request a website from the web, you type something in the browser and click the search button.</p>
<ol>
<li>The browser communicates with the DNS server and searches for the website's actual address you are requesting.</li>
<li>After the browser gets the website's actual address, it requests the server to send a copy of the website to you. This request made by the browser is known as an HTTP request. TCP/IP creates message requests and other data transfers between the client and the server.</li>
<li>If the server approves the client's request, the server sends the client a <strong>200 OK</strong> message which means <em>You can get a copy of the website</em> and starts sending the website's files to the browser in the form of small chunks called data packets.</li>
<li>The browser then assembles the data packets into a complete web page and displays them onto the screen.</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>So this is a brief idea about how the web works behind the scenes. If you want to know more about its working and deep dive to understand everything, you can refer to the links below in the resources section.</p>
<p>Also, if you like my content, you can support me with a 👍 and you can catch me on  <a target="_blank" href="https://twitter.com/anubhavdxtdev">Twitter</a>, <a target="_blank" href="https://instagram.com/anubhavdxtdev">Instagram</a>, <a target="_blank" href="https://www.linkedin.com/in/anubhavdxt">LinkedIn</a> and if you also like to host your repositories on GitHub like me, you can find me there also <a target="_blank" href="https://github.com/anubhavdxt">GitHub</a>.</p>
<p>Feedbacks are most welcome.</p>
<h2 id="heading-resources">Resources</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works">MDN Web Docs</a><br /><a target="_blank" href="https://ipinfo.info/html/ip_checker.php">IP Address Checker</a><br /><a target="_blank" href="https://www.youtube.com/watch?v=hJHvdBlSxug">Video</a></p>
<h2 id="heading-credit">Credit</h2>
<p><a target="_blank" href="https://developer.mozilla.org/en-US">MDN Web Docs</a><br /><a target="_blank" href="https://dev.to/rohitrana/how-the-web-works-1hd7">Rohit Rana (dev.to)</a></p>
]]></content:encoded></item></channel></rss>