<?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 Mehul Jain on Medium]]></title>
        <description><![CDATA[Stories by Mehul Jain on Medium]]></description>
        <link>https://medium.com/@mehulofficial14?source=rss-fcafd3486c7d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cD3Exy5vuypi2UQ3vrfr3w.jpeg</url>
            <title>Stories by Mehul Jain on Medium</title>
            <link>https://medium.com/@mehulofficial14?source=rss-fcafd3486c7d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:17:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mehulofficial14/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[Data Structures and Algorithms (Part 1: About)]]></title>
            <link>https://medium.com/@mehulofficial14/data-structures-and-algorithms-part-1-b81768d2e232?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b81768d2e232</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Mon, 26 Feb 2024 18:18:10 GMT</pubDate>
            <atom:updated>2024-02-26T18:28:20.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*hpAQoR4S0e5gVkU1.jpg" /><figcaption>On your mark–get set–go!</figcaption></figure><ul><li><strong><em>Introduction</em></strong></li></ul><p>This series of blogs will be about the fundamentals of Data Structures and Algorithms. The focus will be mainly on cracking coding interviews.</p><p>Also, this series can be for anyone which means be it a beginner or an expert who wants to brush up on basics, this blog can be super useful.</p><p>The content will mainly revolve around design, implementation, tradeoffs, and analysis of all common Data Structures and Algorithms. Some traits that can help anyone stand out from the rest are solving efficiently, analysing problems carefully, discussing tradeoffs, and communicating any idea with others.</p><p>Hopefully, I can be a part of anyone’s success in any way possible!</p><ul><li><strong><em>References</em></strong></li></ul><p><a href="https://neetcode.io/">NeetCode</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b81768d2e232" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing categorical data (Part 03)]]></title>
            <link>https://medium.com/@mehulofficial14/analyzing-categorical-data-part-03-a593dbda9ad8?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a593dbda9ad8</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 18:24:43 GMT</pubDate>
            <atom:updated>2023-11-25T18:24:43.210Z</atom:updated>
            <content:encoded><![CDATA[<p>(References are linked at the end)</p><p><strong><em>Lesson 3: Distributions in two-way tables</em></strong></p><ul><li><em>Marginal and conditional distributions</em></li></ul><p>Marginal Distribution gives the percentage/frequency distribution of a complete row or a column as compared to the entire dataset. Conditional Distribution gives the percentage of a set from a given subset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_w3F81eGBCb2LzTTQzMGA.png" /><figcaption>The two-way distribution table or the joint distribution table</figcaption></figure><p>The marginal distribution of the joint distribution table is given above (row and column percentages). The conditional probability of the correct scores to be in the 80–100 bucket in the above dataset given that the time studied is 41–60 minutes is 18.6%.</p><p><strong><em>References</em></strong></p><ul><li><a href="https://www.khanacademy.org/math/statistics-probability">Khan Academy</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a593dbda9ad8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing categorical data (Part 02)]]></title>
            <link>https://medium.com/@mehulofficial14/statistics-and-probability-part-02-c4d098da63bf?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4d098da63bf</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 13:41:25 GMT</pubDate>
            <atom:updated>2023-11-25T13:43:04.777Z</atom:updated>
            <content:encoded><![CDATA[<p>(References are linked at the end)</p><p><strong><em>Lesson 2: Two-way tables</em></strong></p><ul><li><em>Two-way frequency tables and Venn diagrams</em></li></ul><p>A Venn diagram is a visual representation of the relationships between different sets of items. It often illustrates the similarities and differences between two or more sets.</p><p>A 2-way table, on the other hand, is a tabular representation of data that shows the relationship between two categorical variables.</p><p>Given a scenario where I have a total of 12 chocolates, there are 6 chocolates made out of butter only. 3 chocolates are made of butter and coconut. There is 1 chocolate made of coconut only. The rest are neither made of coconut nor butter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*PZ6FMWagx4Ylm5ipfYa8dQ.png" /><figcaption>Venn Diagram</figcaption></figure><p>The above is the Venn diagram for the given scenario.</p><pre>|                | Coconut | No Coconut | Row Total |<br>|----------------|---------|------------|-----------|<br>| Butter         |   3     |     3      |     6     |<br>| No Butter      |   1     |     5      |     6     |<br>| Column Total   |   4     |     8      |    12     |</pre><p>The above is the 2-way table for the given scenario.</p><ul><li><em>Two-way relative frequency tables</em></li></ul><p>The relative frequencies are calculated along which the total frequency equals 1. The frequency of the column, rows, or even the entire table can sum up to 1 based on which the relative frequency will be calculated.</p><ul><li><em>Interpreting two-way tables</em></li></ul><ol><li>The fraction can also be considered as the probability of an event occurring along the column whose total sum of fractions is 1.</li><li>The sum is generally taken along the dimension along which a claim is made to make any conclusions.</li><li>In two-way relative frequency tables, comparisons between likelihoods can be made but not in terms of absolute value.</li></ol><ul><li><em>Categorical data example</em></li></ul><p>The data that consists of categorical values uses the counting method to find the total counts for all cases. This gives the relative numbers for categorical data.</p><ul><li><em>Analysing trends in categorical data</em></li></ul><p>Given the two-way frequency table, the probability of the same can be found across the row, column, or the entire table. The percentages might not add up completely due to round-off errors. This error is called a round-off error.</p><p><strong><em>References</em></strong></p><ul><li><a href="https://www.khanacademy.org/math/statistics-probability">Khan Academy</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4d098da63bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing categorical data (Part 01)]]></title>
            <link>https://medium.com/@mehulofficial14/statistics-and-probability-part-01-2e6199dfe9a2?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e6199dfe9a2</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 11:09:31 GMT</pubDate>
            <atom:updated>2023-11-25T13:43:06.994Z</atom:updated>
            <content:encoded><![CDATA[<p>(References are linked at the end)</p><p><strong><em>Lesson 1: Analyzing one categorical variable</em></strong></p><ul><li><em>Identifying individuals, variables, and categorical variables in a data set</em></li></ul><p>Individuals in a dataset are generally those that help in uniquely identifying a row. It is an identifier and is not considered as a variable. The variables in this dataset that can take only discrete values are called categorical variables, while those with continuous values or quantitative values are called continuous variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnOu7fxafxwXfjJBTqOLMw.png" /><figcaption>Dataset</figcaption></figure><p>The individuals in the above dataset are represented by the “Drink” column which is the name of the drink. There are 4 variables in the dataset (“Type”, “Calories”, “Sugars (g)”, “Caffeine (mg)”). The categorical variable in the above dataset is “Type”. The rest of the 3 variables are called continuous variables.</p><ul><li><em>Reading pictographs</em></li></ul><p>The way of representing data in terms of pictures that is related to the data is called a pictograph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*iQa4HfCMS--4uJQ0z3pZ5w.png" /><figcaption>Pictograph</figcaption></figure><p>In the above pictograph, the number of people having an O+ve blood group is 8 x 8 = 64 meanwhile, the number of people having an O-ve blood group is 2 x 8 = 16. A single drop represents 8 people.</p><ul><li><em>Reading bar graphs</em></li></ul><p>The graph that shows data using levels of bars is known as a column bar graph (or “n-column” bar graph if there are “n” groups for each individual).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azEO9WJnXTchkhfhmPmXiA.png" /><figcaption>Bar Graph</figcaption></figure><p>In the above graph, the student named “Alejandra” has the highest improvement in scores from the Midterm to the Final term. This is by looking into the difference between each individual&#39;s blue and red bars.</p><ul><li><em>Reading bar graphs: Harry Potter</em></li></ul><p>Sometimes the graph labels in the X-axis can have aliases to show data since it can not accommodate along the axis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUYze3G2RzRp_h2XWNyg2Q.png" /><figcaption>Bar Graph with alias</figcaption></figure><p>The above graph shows how the names have aliases in the X-axis to show data of the individuals. The “H” stands for Hufflepuff and has a value of 3.</p><ul><li><em>Creating a bar graph</em></li></ul><p>To create a bar graph, observe the quantitative variables that need to be put in the Y-axis. The X-axis contains the individuals whose Y-axis variable values need to be measured.</p><ul><li><em>Reading bar charts: comparing two sets of data</em></li></ul><p>Multi-column group bar charts help in comparing at an individual level across a time frame.</p><ul><li><em>Reading bar charts: putting it together with central tendency</em></li></ul><p>The mean, also known as the average, is the sum of all values in a dataset divided by the total number of values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*0Jt2J6UURj2HLpSuXFrO0w.png" /><figcaption>Mean</figcaption></figure><p>The median is the middle value in a dataset when it is organized in numerical order. If the dataset has an odd number of observations, the median is the middle value. If the dataset has an even number of observations, the median is the average of the two middle values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*FN6TCnHLE_77m_s9b54R7A.png" /><figcaption>Median</figcaption></figure><p>The mode is the value(s) that appear most frequently in a dataset.</p><p>There can be:</p><ol><li>No mode: If no value is repeated.</li><li>Unimodal: If one value is repeated more than others.</li><li>Bimodal: If two values are repeated more than others.</li><li>Multimodal: If more than two values are repeated with similar frequency.</li></ol><p>The midrange is a measure of central tendency that is the average of the maximum and minimum values in a dataset. It provides a simple way to understand the overall range of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*oX3ncY65flo_jbz_kDl6KQ.png" /><figcaption>Midrange</figcaption></figure><p>The range in statistics represents the difference between the maximum and minimum values in a dataset. It provides a simple measure of the spread or dispersion of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*1Q7lMFYS2SL4Cx1ZWGXYUQ.png" /><figcaption>Range</figcaption></figure><p>Consider the below graph as a piece of sample data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*bCjAMsAGAjfz26szwn7FBA.png" /><figcaption>Bar Graph</figcaption></figure><p>The median for the above data for the final exam is 100. The final exam scores in order are 75, 80, 100, 100, and 100. The middlemost term (since it is an odd number of terms) is 100.</p><p>The maximum value of midterm scores is 100 and the minimum value of the scores is 60. The midrange is the average of these values which is 80.</p><p>The average score of all the students’ final exams is the sum of all the scores divided by the number of students. The sum is 100 + 100 + 100 + 75 + 80 = 455. Number of students is 5. The average is 91.</p><p>The mode of the final exam is the most frequently occurring score which is 100.</p><p>The range of the midterm scores is the difference between the maximum and minimum scores which is 100–60 = 40.</p><ul><li><em>Reading pie graphs (circle graphs)</em></li></ul><p>The pie chart is a visual representation of data that represents the contribution of different values in terms of the angles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*zNEY31i6ZNh4y1UdaLoxlw.png" /><figcaption>Pie Chart</figcaption></figure><p>The above data is a set of sales data and the contribution across different months. The best sales month is January (Highest angle in the pie chart) and the worst sales months are June and July (Lowest angle in the pie chart).</p><p><strong><em>References</em></strong></p><ul><li><a href="https://www.khanacademy.org/math/statistics-probability">Khan Academy</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e6199dfe9a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Complete Node.js Course (Part 01)]]></title>
            <link>https://medium.com/@mehulofficial14/the-complete-node-js-course-part-01-a2ef48385c1e?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ef48385c1e</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 04:57:36 GMT</pubDate>
            <atom:updated>2024-02-21T16:27:36.958Z</atom:updated>
            <content:encoded><![CDATA[<p>(References are linked at the end)</p><p><strong><em>Getting Started</em></strong></p><ul><li><em>Welcome</em></li></ul><p>This blog is to give deep insights into what NodeJS is, how it works, and many more. This blog aims to make anyone a backend expert using NodeJS.</p><ul><li><em>What is Node</em></li></ul><p>NodeJS (or Node) is an open-source, cross-platform, runtime environment for executing JavaScript code outside a browser. It is NOT a programming language or a framework but is generally used to build Application Programming Interfaces (or APIs) for backed services. NodeJS helps in building client applications like a web application (inside a web browser) or a mobile application (inside a mobile device) that a user interacts with. These applications need to talk with some backend services that can be on a server or in the cloud to perform different tasks like storing data, sending emails or push notifications, kick-off workflows, and many more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*tC3wwCf1bPX2meJwEuahIA.png" /><figcaption>Applications made using NodeJS and their workflow</figcaption></figure><p>NodeJS is used to make highly scalable, data-intensive, and real-time applications. It is great for prototyping and agile development, building superfast applications, and referencing as it has a large ecosystem of open-source libraries, and is easy to build for anyone who knows JavaScript which helps in making a cleaner and consistent codebase.</p><ul><li><em>Node Architecture</em></li></ul><p>JavaScript was initially used to make applications that would be executed only inside the browser. Every browser has a JavaScript engine that takes a JavaScript code and converts it to machine code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*HmTGD_WTIMcL55TMUmORwg.png" /><figcaption>JavaScript Engine and its function</figcaption></figure><p>Microsoft Edge’s Chakra, Firefox’s SpiderMonkey, and Chrome’s v8 (fastest engine) engines are a few JavaScript engines used inside the respective browsers that provide the runtime environment for the JavaScript code. Due to different engines, the code behaves differently in different browsers.</p><pre>document.getElementById(&#39;&#39;);</pre><p>Above is the “window” or the “document” object that provides the environment for the code that is executed but is not present in NodeJS. Ryan Dahl (the creator of Node) was the first to come up with the idea of executing a JavaScript code outside the browser. A JavaScript v8 engine embedded inside a C++ program to make Node.exe program is how NodeJS was first made. The objects used by the engines in the browser are different from those used in NodeJS.</p><pre>fs.readFile() // Used to work with the file system<br><br>http.createServer() // Used to listen to different ports to handle requests</pre><p>The above are just a few functions performed in NodeJS that can not be performed inside a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*sw22xjJO7TcLxTVAFZbX5A.png" /><figcaption>Node.exe and its components</figcaption></figure><p>Working with file systems and networks are just to name a few. The runtime environment provided by NodeJS is different from that provided by Chrome’s v8 engine for a particular JavaScript code.</p><ul><li><em>How Node Works</em></li></ul><p>NodeJS is used to create highly scalable applications. It is due to its asynchronous nature (non-blocking nature). A single thread is allocated to handle multiple requests, unlike the synchronous (blocking) architecture present in the architectures of ASP.net and Ruby on Rails. In the synchronous architecture, a single thread when allocated a request can not handle a new request. It will require another thread to handle any upcoming requests. If there are a large number of requests on a server, there is a possibility of running out of threads. This may require a new request to wait for the threads to be free or add more hardware to increase the number of threads. In contrast to this, asynchronous architecture in NodeJS handles using a single thread so there is no need for extra hardware. The single thread takes in a request and while the request is being handled, the thread moves on to handle other requests. The request that is then data-ready, will put a message in the Event Queue which is monitored by Node and is processed from there on. This architecture helps in handling network, file, or input-output (I/O) intensive tasks efficiently but can not be used for CPU-intensive applications like video-encoding or image-manipulation services. The CPU-intensive applications occupy the single thread for performing calculations that can keep the other requests on hold.</p><ul><li><em>Installing Node</em></li></ul><p>To check if Node is installed, run the following command.</p><pre>node --version</pre><p>The version number depends on when it was downloaded into a system. If the command is not found, go ahead and download it from <a href="https://nodejs.org/en/download">here</a>.</p><ul><li><em>Your First Node Program</em></li></ul><p>As the first step, create a folder (by the name “first-app” but can be anything else) by running the below command.</p><pre>mkdir first-app</pre><p>Create a file named “app.js” inside the newly created folder.</p><pre>function sayHello(name) {<br>    console.log(&#39;Hello &#39; + name);<br>}<br><br>sayHello(&#39;Mehul&#39;);</pre><p>This code will be given to the v8 engine of Node and will be executed there. To run the above code, run the following command.</p><pre>node app.js</pre><p>Some objects like window and document that are present in the browser, may not be work for a Node application as these are present in the run time environment. Running the following code (replace the below code in app.js and run it using the command as used before) will give a “ReferenceError”.</p><pre>console.log(window);</pre><ul><li><em>Blog Structure</em></li></ul><p>Next section is about the Node Module Structure which is the fundamental concepts of Node. It is going to be about making a module from scratch that will use the operating system and networking concepts as well. This is followed by RESTful APIs using Express under the “Node Package Manager“ (NPM) section that requires the knowledge of asynchronous functions in JavaScript as this will be later used to store data in MongoDB. This is followed by learning about authentication and authorization including role management using JSON web-tokens. Coming to building real-worl applications, it is important to know about handling and logging errors. Unit-testing and integration and Test-driven Development (TDC) helps build new features which is followed by deployment.</p><ul><li><em>Recap</em></li></ul><p>So, in this section, you learned that:</p><ol><li>Node is a runtime environment for executing JS code.</li><li>Essentially, Node is a C++ program that embeds Chrome’s v8 engine, the fastest JS engine in the world.</li><li>We use Node to build fast and scalable networking applications. It’s a perfect choice for building RESTful services.</li><li>Node applications are single-threaded. That means a single thread is used to serve all clients.</li><li>Node applications are asynchronous or non-blocking by default. That means when the application involves I/O operations (eg accessing the file system or the network), the thread doesn’t wait (or block) for the result of the operation. It is released to serve other clients.</li><li>This architecture makes Node ideal for building I/O-intensive applications.</li><li>You should avoid using Node for CPU-intensive applications, such as a video encoding service. Because while executing these operations, other clients have to wait for the single thread to finish its job and be ready to serve them.</li><li>In Node, we don’t have browser environment objects such as window or the document object. Instead, we have other objects that are not available in browsers, such as objects for working with the file system, network, operating system, etc.</li></ol><ul><li><em>My profile</em></li></ul><ol><li><a href="https://medium.com/@mehulofficial14">Medium</a></li><li><a href="https://www.linkedin.com/in/mehul-jain-88a379241/">LinkedIn</a></li></ol><ul><li><em>Learning Paths</em></li></ul><p>Do let me know in the comments for more!</p><p><strong><em>References</em></strong></p><ul><li><a href="https://codewithmosh.com/p/the-complete-node-js-course">Code with Mosh</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ef48385c1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design for Beginners]]></title>
            <link>https://medium.com/@mehulofficial14/system-design-for-beginners-e684dfac8fe0?source=rss-fcafd3486c7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e684dfac8fe0</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Mehul Jain]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 07:14:56 GMT</pubDate>
            <atom:updated>2023-10-08T03:57:43.304Z</atom:updated>
            <content:encoded><![CDATA[<p>(References are linked at the end)</p><p><strong><em>Computer Architecture</em></strong></p><p>Knowing how a computer is designed is essential to understanding how a distributed system works (at least at a high level!) and so is an idea of the components from a software perspective. For now, let us assume that the files we have are just a set of codes in different languages.</p><ul><li><em>Disk</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*5rGfmnjzlqBmOBFuDaoAUQ.png" /><figcaption>Disk in a computer</figcaption></figure><p>The disk is also known as the storage or the Hard Disk Drive (HDD). In recent times, it has been replaced by Solid State Drive (SSD) which is faster than the HDD. The disk stores all the data saved and is persistent (code that we are executing even after a malfunction like a system crash is present if saved). The scale of storage is generally in Terabytes (TB) and the time taken for a read-write operation is in the scale of milliseconds (if it is not an SSD).</p><ul><li><em>Memory</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*Kp3Vu_ZZIgY1PR_rrBzuFA.png" /><figcaption>Memory in a computer</figcaption></figure><p>The memory is also known as the Random Access Memory (RAM). It is also used to store information but is smaller than the disk. The scale of storage is generally in Gigabytes (GB) and the time taken for a read-write operation is in the scale of microseconds. RAM is generally more expensive than the disk but faster as it is smaller in size.</p><ul><li><em>CPU</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*zMs2DdVclE--GG44P5J0Cg.png" /><figcaption>CPU in a computer</figcaption></figure><p>The CPU or the Central Processing Unit is also known as the “Brain of the Computer”. The RAM and the disk can not communicate with each other directly. The CPU comes into the picture here. The CPU performs the read-write operations and different computations to and from the RAM and the disk. The RAM converts (known as compiling) the code to machine-readable instructions that are read (also known as interpreting) by the CPU. The CPU executes the code that has been read from the RAM and it also performs different functions to manipulate the data present in the variables inside the RAM. It then writes back into the disk or the RAM after different computations have been performed.</p><ul><li><em>Cache</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*P5J5exOYnvobJduB0-Relw.png" /><figcaption>Cache in a computer</figcaption></figure><p>The cache is generally present inside a CPU. It is used to improve the speed of the read-write operations. It is much smaller in size than the RAM and the disk. It is in the scale of Megabytes (MB) and the time taken for a read-write operation is in the scale of nanoseconds but is a lot more expensive than a RAM or a disk. It is generally used as a substitute for the RAM. CPU assigns certain sections in the RAM on which the cache can fit to perform different read-write operations. The sections are chosen based on the frequency of the read-write operations by the CPU on the RAM. If a section is frequently used, that section of the RAM is chosen by the CPU to be put in the cache. The CPU first checks the presence of the section inside the cache and if it isn’t found, it checks in the RAM. This way, it improves the performance of the entire system.</p><p>Data is not persistent inside the cache and the RAM so if there is some data or code present in the cache or RAM and the system malfunctions, it will not be present anymore until it is saved before the malfunction.</p><p><strong><em>The need for multiple systems and the importance of their design</em></strong></p><p>The computer architecture is very similar to what the design of a distributed system would look like. It helps solve complex problems by combining multiple systems.</p><p>Moore’s law helps us understand that the number of transistors doubles every two years and this increases the speed by a factor of 2. But over the last few years, the speed has flattened (become linear from exponential) and that is because of the capability a single CPU can perform up to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*AVJMRwC9ZKtMG_Ya5Terxg.png" /><figcaption>Moore’s Law</figcaption></figure><p>Hence, there is a need to use multiple systems to cater to the needs. This is one of the reasons to know the system design principles.</p><p><strong><em>Application Architecture</em></strong></p><p>Knowing the high-level architecture of an application is essential for a developer.</p><p><strong><em>Developer Perspective</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*obn0S-dwn7bWN4BIPcRkTg.png" /><figcaption>Initial Developer Perspective in an Application Architecture</figcaption></figure><p>Developers build and deploy code to make an application which is then sent to the servers where the application will run. The server serves the users by handling requests. The code written by the developer that is built and deployed can be on the user’s system or it can be on a Continuous Integration Continuous Deployment (CICD) server (more professional).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwSLBbM1lzEBijZKqFUEcQ.png" /><figcaption>Storage in an Application Architecture</figcaption></figure><p>The server has data that needs to be stored in a storage that can be either external (like an external system being the database that makes a distributed storage mechanism combining with the server connected via a network) or a part of the server’s system (server system’s disk) itself but there are limitations with the server system’s disk as it can not solve the purpose of a large user base.</p><ul><li><em>Logging System</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fowVSVIxEY0AUi9JeRdG5w.png" /><figcaption>Logging System in Application Architecture</figcaption></figure><p>Developers have the responsibility to look for any errors. On a personal system, simple log statements work to find errors but for a server running the application log statements would not work as it is a different system. The log statements don’t need to be stored on the server as it won’t be interacting with it. For developers to deal with logs, an external logging system can be connected to the server. This helps the developers debug any errors occurring in the server. The logs store both the successful and failed status of the requests by users. There is no user interaction with the logging system.</p><ul><li><em>Metrics System</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dITiS074J5mWNhjbIT8_4Q.png" /><figcaption>Metrics System in Application Architecture</figcaption></figure><p>There can be cases where the logging system can not provide the complete information (like a CPU shutdown in a server, a faulty CPU, RAM taking up space, or storage being full). To know the complete status of the resources like RAM, CPU utilization, or even the status of the application (like if requests are failing and what kind of requests are failing), a metrics system is used. Some metrics come from the logging system itself which is called the log-based metrics. The success or failure logs can create different metrics as the logging system records all types of logs. Metrics are usually displayed as a time series across a time span (like the trend of CPU utilization, RAM occupancy, application status, or request status as they have a timestamp associated with it).</p><ul><li><em>Alerting System</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyS1TC2c9QsERE-hbsl7wg.png" /><figcaption>Alerting System in Application Architecture</figcaption></figure><p>As a developer, it is feasible to understand the logs in the logging system and the metrics system. But to manually check if there is an error in the application, is not always possible for a developer. Sometimes a user using the application can inform the developer (as they are using the application constantly). To get the latest updates, a push notification is sent from the metrics system to the developer when an error occurs. This is done by the metrics system feeding its status data into an alerting system. The notification can be sent when the threshold of any metric has reached a certain limit (like a CPU or RAM being used up to a certain level, storage exceeding a level, or even the percentage of successful requests raised by users dropping below a certain value, say 95% from a 100%). This is one of the fastest methods of being notified about the application.</p><p><strong><em>User Perspective</em></strong></p><p>Knowing the usage of an application is essential for a user who communicates with the application via different requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtaELNegekWsUMvq8QHWxw.png" /><figcaption>User raising a request on a frontend-based Application</figcaption></figure><p>A user raises a request to the server to use the application running there. The application can be a frontend-based application where the response can be of a JavaScript/HTML type after a request from the user (mostly via a browser).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vG1Qpe-C3jCxz3cmDdub2w.png" /><figcaption>User raising a request on a backend-based Application</figcaption></figure><p>The application can also be a backend-based application where the response can be of a JSON type containing data after a request from the user (mostly an API call via the browser).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H3dsFUpKepEulwSJVCc4Gw.png" /><figcaption>External services used by the server on user requests</figcaption></figure><p>Sometimes there is a necessity for external services (like payment gateway APIs for an e-commerce website) to handle different user requests.</p><p><strong><em>Different strategies to improve performance</em></strong></p><p>There may be cases where there are many users raising a request at the same time to the server. A single server can not handle many requests at one point in time. Determining the root cause is important.</p><ul><li><em>Vertical Scaling</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUQMN4EveT4cjFWdq8peaA.png" /><figcaption>Vertical Scaling</figcaption></figure><p>Maybe the CPU is slowing down the response time so getting a better CPU is one such solution. High RAM occupancy can also be a significant reason so getting more RAM for the existing server is also a solution. These are some hardware limitations with a single server that on upgradation can improve the performance. This is called vertical scaling.</p><ul><li><em>Horizontal Scaling</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BE_4CpiQDMB3hO6L8H7QUg.png" /><figcaption>Horizontal Scaling</figcaption></figure><p>There is always a drawback regarding hardware upgradation because it can be scaled up to a certain limit. So the alternate strategy is to increase the number of systems by creating copies that together become a server. This is called horizontal scaling. The user can request any server that is not occupied. The load balancer is responsible for distributing requests efficiently (a balanced amount depends on each server system’s capability) across all the connected servers. It generally diverts the incoming request to a server having lesser traffic. This helps in handling many requests at the same time.</p><p><strong><em>The need for different design concepts</em></strong></p><p>The actual and practically designed systems can be much more complicated than the theoretical ones. Networking is an important aspect as communication is key between different components not in the same system. The knowledge of the basics of each component and their respective workflow is gold for designing large-scale applications!</p><p><strong><em>Design Requirements</em></strong></p><p>The basics of designing large systems help to solve big problems. In the focus of system design interviews, it is not expected to know every detail of every component. Memorizing facts will not help but the thought process is going to lead the way. Weighing the tradeoffs to get the most effective solution is the ultimate goal as no design is perfect. Analyze each approach, the advantages, and the sacrifices.</p><p><strong><em>High-Level Data Path</em></strong></p><ul><li><em>Move Data</em></li></ul><p>Data is moved between different systems (not necessarily in the same system but can be in different places like different data centers in different locations). Services like YouTube have videos and comments that are moved across. This is done using networks present between systems.</p><ul><li><em>Store Data</em></li></ul><p>Every type of data storage has its own tradeoffs and advantages. Discrete data storage concepts can be advantageous in different situations. Data is stored in databases, blob structures, file systems, distributed file systems, and many more. Each of these is unique and efficient in different situations. The amount of data is what makes it challenging to move, store, and transform data as the chosen method needs to be unique at every stage in the path. The data to be stored can include comments and videos for services like YouTube.</p><ul><li><em>Transform Data</em></li></ul><p>Transforming data helps in manipulating the data that was previously moved and stored. Data can include log data from applications that are aggregated and transformed to get the percentage of successful requests or it can be server response log data that are aggregated and transformed to get the percentage of successful requests and failed requests. Transforming data to get useful data helps in better insights (like encoding videos, aggregating views, comments, and many other metrics for services like YouTube).</p><p>It is very important to be careful in designing a complex system. A bad design can lead to unnecessary expense, time, and other resources. It is difficult to migrate and correct once a design is generally under development.</p><p><strong><em>References</em></strong></p><ul><li><a href="https://neetcode.io/courses/system-design-for-beginners/0">NeetCode</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e684dfac8fe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>