<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5795907029429874864</id><updated>2024-11-08T21:07:44.120+05:30</updated><category term="tech"/><category term="books"/><title type='text'>ReadsNGeeks : Get latest articles on Software Development and Coding Best Practices</title><subtitle type='html'>A blog on web design and development guides, programming languages, competitive coding, and many other technical stuff. Also, covering book-related reviews, information, and recommendations. </subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-219604457268250974</id><published>2020-08-21T11:01:00.005+05:30</published><updated>2020-08-21T11:01:52.451+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>NodeJS Application with Docker</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In the last article, we went through the basics of Docker. Like what is a Docker Image, what are containers and how we run a docker image on our system. In this article, we will create a NodeJS application, wrap it inside a Docker container, and run that application on our local machine. We won&#39;t be creating any complex application, we are just focused on getting NodeJS work inside a Docker Container.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAY0XJd14ciXH-AZwrl0ffjm4YiQMKGX9wQjmzaKge7x41OKuqNck43Xm7LbK2YSiyUFS6LQ364WNd53Jmrdbigo7UlKv_L2fZOf9te5gPLQ15N1Ow7sL1yPOnHJXh7y6UTYuyPjW4viiJ/s288/node-docker.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;286&quot; data-original-width=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAY0XJd14ciXH-AZwrl0ffjm4YiQMKGX9wQjmzaKge7x41OKuqNck43Xm7LbK2YSiyUFS6LQ364WNd53Jmrdbigo7UlKv_L2fZOf9te5gPLQ15N1Ow7sL1yPOnHJXh7y6UTYuyPjW4viiJ/s0/node-docker.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;To begin with, let&#39;s set up a NodeJS project first. For that, we need to create a folder. Then inside that folder, we need to create a&amp;nbsp;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt; &lt;span style=&quot;font-family: courier;&quot;&gt;package.json&lt;/span&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/span&gt; file that will contain all the dependencies of our project. Inside&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; package.json&amp;nbsp;&lt;/span&gt; we will put the following:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;span face=&quot;&quot; style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;dependencies&quot;:{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;express&quot;:&quot;*&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;scripts&quot;:{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;start&quot;:&quot;node index.js&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now create an&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; index.js&amp;nbsp;&lt;/span&gt; file which will contain our main server startup and API code. Inside index.js we put the following lines of code:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span face=&quot;&quot; style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;p&gt;const express = require(&#39;express&#39;)&lt;br /&gt;const app = express()&lt;br /&gt;&lt;br /&gt;app.get(&#39;/cube&#39;,(req,res)=&amp;gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var number = req.query.number&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return res.json({&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value: Math.pow(number,3)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;})&lt;br /&gt;app.listen(8080,()=&amp;gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(&#39;Listening on port 8080&#39;)&lt;br /&gt;})&lt;/p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here we are using the express framework, we stated that as dependency is our&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; package.json &lt;/span&gt;. In&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; &lt;/span&gt;&lt;/span&gt;index.js&amp;nbsp;&lt;/span&gt; we are importing the express library and creating an app instance of it. Then we create an api&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; /cube&amp;nbsp; &lt;/span&gt;which will take a number as input and return the cube root of that number. Finally, we specify the server to run on port 8080.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Next step is to create a Dockerfile. A Dockerfile is basically a text file that contains some settings&amp;nbsp; and commands that are needed to be executed in order to create a docker image of our project. We just need to create&amp;nbsp; a file named&amp;nbsp;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;Dockerfile&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;and put the following content inside it.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span face=&quot;&quot; style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#Specifiy a base image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;FROM node:alpine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#Copy all project files inside container&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;COPY ./ ./&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#Install dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;RUN npm install&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#Start Up command&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;CMD [&quot;npm&quot;,&quot;start&quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let&#39;s understand each of these commands one by one. First, we need to specify a base image. The container inside&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: verdana; font-size: small;&quot;&gt; which the image will is in total isolation and doesn&#39;t have node or npm installed. So we use a&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; node:alpine&amp;nbsp;&lt;/span&gt; which is a lightweight node environment already available in docker hub. This will give us the node environment to run our project. Next using the COPY ./ ./ command we copy our project files and folders into the container. Then npm install will install all the dependencies inside&amp;nbsp;&amp;nbsp; &lt;span style=&quot;background-color: #eeeeee;&quot;&gt;package.json&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;inside the container. And in the end, we specify the command which will start our server.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: verdana; font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we need to build our image. For this, we open up the terminal inside our project folder and run the command&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; docker build .&amp;nbsp;&lt;/span&gt; , it will start up the build process and on successful build, we will get an image id.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPnwBmn2HMJbrr3ZuK9tNIPTuHvm3aEJRCIKX_run3M4C3wQoXqtqqO9iU8aPdfgGykcGt_I78NXf_YsqoJ4b1b5t8dwLEs-n7TD_EKeQJJJHtHgcDukB7UwzBW2dmtVZKIUJlTGlJH8N9/s804/Screenshot+2020-08-19+at+12.34.23+AM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;443&quot; data-original-width=&quot;804&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPnwBmn2HMJbrr3ZuK9tNIPTuHvm3aEJRCIKX_run3M4C3wQoXqtqqO9iU8aPdfgGykcGt_I78NXf_YsqoJ4b1b5t8dwLEs-n7TD_EKeQJJJHtHgcDukB7UwzBW2dmtVZKIUJlTGlJH8N9/s640/Screenshot+2020-08-19+at+12.34.23+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now to run the image we have to run the command&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; docker run &amp;lt;build_id&amp;gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;. The node server will start up on the specified port.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnVpLo4HuJ0nRf5nSul-70TkLMVb4rfGhBnpFz6z3Fcu-UFzmuLFZvmltfZA2R6gd8vDpaL0POyY3OrzQpIZj1PUR3QyCzU7EvIPXoKhrb5lGlUT1QElGYyJnifuNzubpG6TzHDzmctlP5/s736/Screenshot+2020-08-19+at+12.34.33+AM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;117&quot; data-original-width=&quot;736&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnVpLo4HuJ0nRf5nSul-70TkLMVb4rfGhBnpFz6z3Fcu-UFzmuLFZvmltfZA2R6gd8vDpaL0POyY3OrzQpIZj1PUR3QyCzU7EvIPXoKhrb5lGlUT1QElGYyJnifuNzubpG6TzHDzmctlP5/s640/Screenshot+2020-08-19+at+12.34.33+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;There is one more thing to be taken care of. We can see the server running on port 8080 on our local machine, but if we try to access localhost:8080 we won&#39;t be able to do so. The reason for this is the server is running on the container&#39;s port number 8080, not on our machine&#39;s port 8080. To access this via our machine&#39;s port 8080 we need to set up a port mapping. The way we do this is specifying some extra parameters in the docker run command. We run the following command:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUguE5JtGv4LmtPsp2PRdREKI7bzTeuPFZoN3xI0gsAfxyh8li74iI-rEmEEJqTs8xfuiByuzs13Z2GPf5IJwCs1Q4XsLXbX3Gh2gKhXbggVuOCz84inp2S7ykgAr9rAzcR9nVxHviw6Y/s331/docker-port.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;121&quot; data-original-width=&quot;331&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUguE5JtGv4LmtPsp2PRdREKI7bzTeuPFZoN3xI0gsAfxyh8li74iI-rEmEEJqTs8xfuiByuzs13Z2GPf5IJwCs1Q4XsLXbX3Gh2gKhXbggVuOCz84inp2S7ykgAr9rAzcR9nVxHviw6Y/d/docker-port.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, after executing this command we will be able to access the NodeJS application from localhost:8080.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOdFFwK51MEkfXjvRMSgcNx_D2VYowygD8a2BTzTg119RVVlSs1UPAhiCCLHKhgbdWqIuQSdqWTdFd9dygWXAIYIblBoCzhp0BYsvTZ-vCeJV5x4tJtEZyKrpQAucRySGRG2jSMWxXLsoK/s373/Screenshot+2020-08-20+at+12.38.51+AM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;195&quot; data-original-width=&quot;373&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOdFFwK51MEkfXjvRMSgcNx_D2VYowygD8a2BTzTg119RVVlSs1UPAhiCCLHKhgbdWqIuQSdqWTdFd9dygWXAIYIblBoCzhp0BYsvTZ-vCeJV5x4tJtEZyKrpQAucRySGRG2jSMWxXLsoK/s0/Screenshot+2020-08-20+at+12.38.51+AM.png&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, using docker we have containerized a NodeJS application. By this method, we can even develop NodeJS application without NodeJS being installed on the system. &lt;br /&gt;Hope this article has helped you to get an understanding of how NodeJS and Docker work together. If you have any feedback and doubts do mention them in the comments. Stay Safe and Happy Coding!&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/219604457268250974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/nodejs-application-with-docker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/219604457268250974'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/219604457268250974'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/nodejs-application-with-docker.html' title='NodeJS Application with Docker'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAY0XJd14ciXH-AZwrl0ffjm4YiQMKGX9wQjmzaKge7x41OKuqNck43Xm7LbK2YSiyUFS6LQ364WNd53Jmrdbigo7UlKv_L2fZOf9te5gPLQ15N1Ow7sL1yPOnHJXh7y6UTYuyPjW4viiJ/s72-c/node-docker.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-4843419254421014337</id><published>2020-08-09T22:20:00.002+05:30</published><updated>2020-08-11T10:18:35.891+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>All about Docker -  Beginner&#39;s Insight</title><content type='html'>&lt;div&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Before diving into what Docker is and the details of it, let us first try to understand why to use Docker and what problem does it solve.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-o0ls6vgxEeIR3J1iBZCzGWOBh0gWr8b3qEqeOW9t7-B5clGihmYjZWSgEfBdaWBGEE58fJb_APLo4bY6px6ot-xWlrnwRyGOUfZYGfqNUJslxt132J5e60KuvNH5QPDqANKX9NMcbOzW/s2048/docker-logo-png-transparent.png&quot; style=&quot;display: block; margin-left: auto; margin-right: auto; padding: 1em 0px;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1720&quot; data-original-width=&quot;2048&quot; height=&quot;269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-o0ls6vgxEeIR3J1iBZCzGWOBh0gWr8b3qEqeOW9t7-B5clGihmYjZWSgEfBdaWBGEE58fJb_APLo4bY6px6ot-xWlrnwRyGOUfZYGfqNUJslxt132J5e60KuvNH5QPDqANKX9NMcbOzW/w320-h269/docker-logo-png-transparent.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Suppose, you are installing a software on your machine. So the steps we follow are downloading a software and installing it. During installation, we often get errors due to some other setup and dependencies. We then try to troubleshoot it and continue our installation. Like this, we might get many errors and keep on troubleshooting the issues. This is where Docker can help.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker&lt;/b&gt; makes it easy to install a software without getting into any kind of setup or dependency issue.&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Using Docker we can install any software using just one command and then start using that software. At the end of this article, there is a basic video tutorial of how to install docker and how to install and run an application using Docker.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, &lt;b&gt;what is &lt;i&gt;Docker&lt;/i&gt;?&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Going by definition:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Docker is a platform, that uses OS-level virtualization to enable developers to install and run any application as a lightweight, portable package known as container.&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now, to understand this definition in depth we first need to know about different components in the&lt;b&gt; Docker Ecosystem&lt;/b&gt; and then about &lt;b&gt;Containers&lt;/b&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Docker Ecosystem is basically a collection of different projects and tools that helps in installing and running any application via Docker.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXrTksiHlHcU_6ZYuXSEYB9mAJyuVDwkazQSRnZ1cNjHtBf8hTjwrOjsh5vUxe9okgvr8v3ajG1B7TgxUqt2UShr0yFsLSVNJnLskYuHawlo9W6UctqP5JFNzJd39m0r42KcLDH0Cigsig/s362/docker-eco.png&quot; style=&quot;display: block; margin-left: auto; margin-right: auto; padding: 1em 0px;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;362&quot; data-original-width=&quot;341&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXrTksiHlHcU_6ZYuXSEYB9mAJyuVDwkazQSRnZ1cNjHtBf8hTjwrOjsh5vUxe9okgvr8v3ajG1B7TgxUqt2UShr0yFsLSVNJnLskYuHawlo9W6UctqP5JFNzJd39m0r42KcLDH0Cigsig/s0/docker-eco.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, here we can say six different tools in the docker ecosystem. Let&#39;s get a brief idea on each of them.&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Client: &lt;/b&gt;When we install docker on our system, we generally use the CLI to interact with other docker tools from our system. So, the CLI in our system becomes a Docker Client.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Server: &lt;/b&gt;A docker server is the one that handles all the requests from the client like when a client requests to install an application, it requests the docker server, the docker server then fetches the image of that application from the docker hub.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Hub:&lt;/b&gt; It is a place where the images of each application is stored. It is like an online repository of applications from where docker fetches and installs any application on our system.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Image:&lt;/b&gt; In some of the points above, we mentioned about images of an application. What are we referring to as image is basically a docker image. A Docker Image of an application is a single file with all the dependencies and configuration required to run that application.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Compose:&lt;/b&gt; In the next section we will see what are containers. Docker Compose is a tool that allows us to run multiple containers and provides a way to interact between them.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Docker Machine:&lt;/b&gt;Docker Machine is a tool that allows us to run Docker in a variety of environments, like on a virtual environment or on a cloud system&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;What is a &lt;i&gt;Container&lt;/i&gt;?&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;In the previous section learned what a Docker Image is. So the image of an application is a single file containing all configurations and dependencies needed to run that application. Now when we install any application using Docker, the image of the application gets downloaded. To run this image we need hardware resources like memory, network drivers and hard disk space. Now, we don&#39;t run these images directly on our system, instead these images are run using Containers. A container is a sort of virtual environment which is totally independent and has its own set of hardware resources.&amp;nbsp; Inside a container, we have an instance of the image of an application and the application runs inside the container using its hardware resources. We can create as many containers on our system and use them to run the same image, but each of these containers will run in complete isolation, i.e an application running in one container won&#39;t affect the application in another container.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo1GFevuZ3gx_rvxEBIcLolA05KdS_kTPCDUs2OnEPp-aAKuLP1dGJEos_F79PlMlVR32HJLhdbHTD-cy8Aoq8TwdkCJnVmqoXTfOrWrnFW1aFRbbkaFFvVJautGQnsAE7bjhyphenhyphenkQ_41tOE/s581/images-basic.png&quot; style=&quot;display: block; padding: 1em 0px;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;272&quot; data-original-width=&quot;581&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo1GFevuZ3gx_rvxEBIcLolA05KdS_kTPCDUs2OnEPp-aAKuLP1dGJEos_F79PlMlVR32HJLhdbHTD-cy8Aoq8TwdkCJnVmqoXTfOrWrnFW1aFRbbkaFFvVJautGQnsAE7bjhyphenhyphenkQ_41tOE/w640-h300/images-basic.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let&#39;s dig a bit deep and see how containers work.&lt;br /&gt;To have a better understanding of how containers work, one should have a brief idea of an OS kernel. The OS kernel is a software process that governs access between all the application programs running on a system and all the physical hardware like CPU, Memory, etc. Any application process like Chrome or NodeJS cannot access the hardware directly, instead they make system calls to the kernel and kernel assigns the hardware resources to them.&lt;br /&gt;Now, when we install docker on our system a Linux virtual environment is created with its own kernel. Now to when we try to run a docker image, this kernel separates a portion of hardware resources like CPU, Hard Disk, Memory, etc. These portion of hardware resources are totally isolated and only available to the running application. This basically becomes a container. Now, the instance of docker image is loaded into the container&#39;s memory and it is started using the docker image&#39;s startup command. Have a look at this diagram to get a better understanding.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9BQ90zFdn30Tauj7RD5Rvk6zTHNo6fOPtd5jHmcNm57VzAQ-2CHwUwdIcVhyUOQssH3ifn1kYqRc6y-GQmehLQkaa-nZbOxAfZL897dyREgx_UFantkS0Y4PZtCK2DHRMrVSQJXGxyI_-/s621/images-main.png&quot; style=&quot;display: block; padding: 1em 0px;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;292&quot; data-original-width=&quot;621&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9BQ90zFdn30Tauj7RD5Rvk6zTHNo6fOPtd5jHmcNm57VzAQ-2CHwUwdIcVhyUOQssH3ifn1kYqRc6y-GQmehLQkaa-nZbOxAfZL897dyREgx_UFantkS0Y4PZtCK2DHRMrVSQJXGxyI_-/s0/images-main.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here is a video demonstration of installing docker and running an application using docker.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;630&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dxzvg25xptQQwphmgSuSN_Kai3sFuvWxgVF06fqoQCGw3nXVcNQUSJoRqvANdcbNDo40Aj2MVBIdlA5grZK_g&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Hope after reading this you get a basic understanding of what docker is and how it works. Although there is no hands-on example on how to use docker, but these concepts are necessary before you get started. In the next article, we will build a NodeJS application using Docker, so don&#39;t forget to subscribe. Stay Safe and Happy Coding!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/4843419254421014337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/docker-beginner.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/4843419254421014337'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/4843419254421014337'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/docker-beginner.html' title='All about Docker -  Beginner&#39;s Insight'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-o0ls6vgxEeIR3J1iBZCzGWOBh0gWr8b3qEqeOW9t7-B5clGihmYjZWSgEfBdaWBGEE58fJb_APLo4bY6px6ot-xWlrnwRyGOUfZYGfqNUJslxt132J5e60KuvNH5QPDqANKX9NMcbOzW/s72-w320-h269-c/docker-logo-png-transparent.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-5811691387974166314</id><published>2020-08-01T10:22:00.001+05:30</published><updated>2020-08-01T10:22:28.944+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>Creating and Publishing an NPM package </title><content type='html'>&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;6&quot;&gt;W&lt;/font&gt;hat is NPM?&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font face=&quot;verdana&quot; size=&quot;3&quot;&gt;If you are a JavaScript developer, you most probably know what NPM is. NPM (Node Package Manager) is an open-source online repository where JavaScript developers create and publish different JS packages to be used by other JS developers. It consists of public as well as paid-for private packages.&lt;/font&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In this article, we will see how to create a node package and publish it to npm. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRwt26V065uD2YQGN03i3iR68K9eAQvd7cZoX5RCHIfJF7QaI0Zx8uiAPwITzMRr_Od69v7u1f9KSy_l-MOU2PzWNVBBkU25jM194gGf9i9ooyM1ciaiO52RCrAUxuNhNZxABeAnrV7Ad1/s540/npm.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;210&quot; data-original-width=&quot;540&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRwt26V065uD2YQGN03i3iR68K9eAQvd7cZoX5RCHIfJF7QaI0Zx8uiAPwITzMRr_Od69v7u1f9KSy_l-MOU2PzWNVBBkU25jM194gGf9i9ooyM1ciaiO52RCrAUxuNhNZxABeAnrV7Ad1/s0/npm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;What will we build?&lt;/font&gt;&lt;br /&gt;&lt;font size=&quot;3&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Here, 
we are mainly focused on the steps to create and publish an npm package, 
so we won&#39;t be building anything that does some complex stuff. We will 
try to build a Counter, which will take an array or a string as input 
and will return how many times each unique element occurs in the array 
or string. It will return a JSON object where each element will be a key
 and the value for each key will be the number of occurrences of that 
element.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;For example:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;Input:&lt;/b&gt; [&#39;a&#39;,&#39;b&#39;,&#39;a&#39;,&#39;c&#39;,&#39;d&#39;,&#39;b&#39;,&#39;c&#39;,&#39;a&#39;]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;Output:&lt;/b&gt;{&#39;a&#39;:3, &#39;b&#39;:2, &#39;c&#39;:2, &#39;d&#39;:1}&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;Before we get started we need to make sure that node and npm are installed on our system. To check, open the terminal and type &lt;i&gt;npm -v&lt;/i&gt; and &lt;i&gt;node -v&lt;/i&gt;. For each of them, the system will show the version that is installed and if it is not installed it will throw an error stating &lt;i&gt;command not found.&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;3&quot;&gt; &lt;font face=&quot;verdana&quot;&gt;If not installed we can install using this &lt;a href=&quot;https://docs.npmjs.com/downloading-and-installing-node-js-and-npm&quot; target=&quot;_blank&quot;&gt;guide&lt;/a&gt;.&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;- Create and Initialize the repository:&lt;/b&gt; First of all, make a folder and initialize it as an npm project by running npm init. After running npm init, you will be prompted to input certain configuration values like this:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_XnCDIX6r1kVeMZlBjm-A-a5AD2_BBZym1JTnR9sRXhtUALJXhN1ik4SHRsY6M9cLotUBB-xVjufmmdS4O2tR23HpA_ce_CAos9Oki8z9SycrS0ZZLWLTq7YyfIod5yVlwDbhsBpTbBo7/s1063/Screenshot+2020-07-29+at+7.36.43+PM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;442&quot; data-original-width=&quot;1063&quot; height=&quot;266&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_XnCDIX6r1kVeMZlBjm-A-a5AD2_BBZym1JTnR9sRXhtUALJXhN1ik4SHRsY6M9cLotUBB-xVjufmmdS4O2tR23HpA_ce_CAos9Oki8z9SycrS0ZZLWLTq7YyfIod5yVlwDbhsBpTbBo7/w640-h266/Screenshot+2020-07-29+at+7.36.43+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;We can either input these values as per our requirement or keep on pressing enter for default values.&lt;/font&gt; &lt;font face=&quot;verdana&quot;&gt;Then a prompt will come up asking whether the above-entered details are correct. Type &lt;i&gt;yes&lt;/i&gt; and press enter.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeoQQ85o_ouWhILLvhxLh53a-oLYMUNtkxxWlGYWsoGLsxi2ijb3yzOUmMxpOKb8UciiWeyaNcPZqNa1g18WeGaMOanoijknu8d9Num135-Hzr8vrweN3R3nBxsBFRBQ09JWeKrlDhGu80/s1063/Screenshot+2020-07-29+at+7.37.15+PM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;329&quot; data-original-width=&quot;1063&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeoQQ85o_ouWhILLvhxLh53a-oLYMUNtkxxWlGYWsoGLsxi2ijb3yzOUmMxpOKb8UciiWeyaNcPZqNa1g18WeGaMOanoijknu8d9Num135-Hzr8vrweN3R3nBxsBFRBQ09JWeKrlDhGu80/w640-h198/Screenshot+2020-07-29+at+7.37.15+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;- Write the project code: &lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;After this open up the project folder in a code editor. Inside it there will be a file called package.json which contains the configurations which we mentioned during npm init. Something like this:&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;a name=&quot;line-2&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;js-counter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;a name=&quot;line-3&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1.0.0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;a name=&quot;line-4&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;A module which will take an array or a string as input and will return how many times each unique element occurs in the array or string&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;a name=&quot;line-5&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;main&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;index.js&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;a name=&quot;line-6&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;a name=&quot;line-7&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;echo \&quot;Error: no test specified\&quot; &amp;amp;&amp;amp; exit 1&quot;&lt;/span&gt;
&lt;a name=&quot;line-8&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;a name=&quot;line-9&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Saptarshi Dey&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;a name=&quot;line-10&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MIT&quot;&lt;/span&gt;
&lt;a name=&quot;line-11&quot;&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Now create a file named index.js. This will be our main file and here we will write the function which will perform our required task. Below is the code as per our requirement:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span class=&quot;kd&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;a name=&quot;line-2&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
&lt;a name=&quot;line-3&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;nx&quot;&gt;len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;
&lt;a name=&quot;line-4&quot;&gt;&lt;/a&gt;    
&lt;a name=&quot;line-5&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
&lt;a name=&quot;line-6&quot;&gt;&lt;/a&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]){&lt;/span&gt;
&lt;a name=&quot;line-7&quot;&gt;&lt;/a&gt;            &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;a name=&quot;line-8&quot;&gt;&lt;/a&gt;        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;a name=&quot;line-9&quot;&gt;&lt;/a&gt;            &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;a name=&quot;line-10&quot;&gt;&lt;/a&gt;        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;a name=&quot;line-11&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;a name=&quot;line-12&quot;&gt;&lt;/a&gt;   
&lt;a name=&quot;line-13&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;
&lt;a name=&quot;line-14&quot;&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;a name=&quot;line-15&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;- Publishing the package: &lt;/b&gt;To publish the package we first need to authenticate. For that go to the terminal and type &lt;i&gt;npm login.&lt;/i&gt; Then enter your username and password when prompted. If you do not have an npm account, you can create it &lt;a href=&quot;https://www.npmjs.com/signup&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;Now after logging in we can publish the package. One thing to watch out for is the name of the package. The name of the package is mentioned in package.json and if any package with the same name already exists in the npm registry we cannot publish our package. &lt;a href=&quot;https://docs.npmjs.com/package-name-guidelines&quot; target=&quot;_blank&quot;&gt;Here&lt;/a&gt; are the package name guidelines. If the name is unique we can publish the package just by running &lt;i&gt;npm publish&lt;/i&gt;. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;After publishing is successful&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;, you can visit your account in the NPM registry to see the package.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;- Testing: &lt;/b&gt;To test the package we have to install the package. First, create a repository and install the package.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;table class=&quot;highlighttable&quot; style=&quot;height: 1px; width: 1px;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;linenos&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;repository&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;navigate&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;inside&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;it&lt;/span&gt;
&lt;a name=&quot;line-2&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;package&lt;/span&gt;
&lt;a name=&quot;line-3&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;package&lt;/span&gt;
&lt;a name=&quot;line-4&quot;&gt;&lt;/a&gt;
&lt;a name=&quot;line-5&quot;&gt;&lt;/a&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;package&lt;/span&gt;
&lt;a name=&quot;line-6&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;counter&lt;/span&gt;
&lt;a name=&quot;line-7&quot;&gt;&lt;/a&gt;
&lt;a name=&quot;line-8&quot;&gt;&lt;/a&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;file&lt;/span&gt;
&lt;a name=&quot;line-9&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;touch&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Then inside the &lt;i&gt;index.js&lt;/i&gt; you can write the following code to test out your package:&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span class=&quot;kr&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;js-element-counter&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;a name=&quot;line-2&quot;&gt;&lt;/a&gt;&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;You will get the output as:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;1&#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;2&#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;3&#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;4&#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span class=&quot;p&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;This was a basic step to create an npm package. To this, you can add a proper README file stating the usage of the package with some examples.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;Here is a detailed video of the steps mentioned above:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dwjeUG4f6nifM-xfHwLEu8OLyyrsDUzvpo02_GRO4FtMcaWOEGBFxL8NP7p_VRb5P6J1-enPqOH-560MW2wew&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now as you know to create and publish your own npm package, dive in to create some cool packages and publish them, who knows your package might become helpful for some other developer out there!&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/5811691387974166314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/npm-module-publish.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5811691387974166314'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5811691387974166314'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/08/npm-module-publish.html' title='Creating and Publishing an NPM package '/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRwt26V065uD2YQGN03i3iR68K9eAQvd7cZoX5RCHIfJF7QaI0Zx8uiAPwITzMRr_Od69v7u1f9KSy_l-MOU2PzWNVBBkU25jM194gGf9i9ooyM1ciaiO52RCrAUxuNhNZxABeAnrV7Ad1/s72-c/npm.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-2950204435688443775</id><published>2020-07-24T10:22:00.006+05:30</published><updated>2020-07-24T10:26:15.474+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>API Security - Securing API with Tokens and JWT</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;API security is one of the most important aspects of designing and implementing REST APIs. Without adequate security, it does not really matter what other design principles have been taken care of. In this article, we will see about the different types of functional attacks possible on the API path length and how to authenticate REST APIs using Tokens. We will also implement this by creating a NodeJs API and integrating JsonWebToken (JWT) in it.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihkN_4Ri5L_H-1MG1yogypTYqBxdBAOzmDpxdpbEMK4S3X4dWF1FZtVXTLulI41R39ZKQKFXOvIvcdit_uPuZGaS3lTz5TC5fiUvWzmI9D_H6nORk4-rNLzqnrovAY3bnRjRDV70XvSKte/s221/api-security.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;221&quot; data-original-width=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihkN_4Ri5L_H-1MG1yogypTYqBxdBAOzmDpxdpbEMK4S3X4dWF1FZtVXTLulI41R39ZKQKFXOvIvcdit_uPuZGaS3lTz5TC5fiUvWzmI9D_H6nORk4-rNLzqnrovAY3bnRjRDV70XvSKte/s0/api-security.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Before we get started, let us see the basic difference between Authentication and Authorization. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Authentication:&lt;/b&gt; It is the process to verify that you are really who you claim to be. With authentication, APIs verify that the request is coming from its trusted list of sources.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Authorization:&lt;/b&gt; It is the process of checking whether you have access to a certain resource. Like a client can be a trusted source for an API but that particular client might not be authorized to view some confidential data.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;At what points attacks might happen?&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVA3MRcSs8x66365jlV3t8VbveDfH3__uW1x48omapb4kZyiKgzMaaqJbA0nQ_BO8XsNF0YBUE3B1Aq1nwPYq3dUEj8E7QVT5BbfD-vPcqDAiu8Fd3hoRj2DBZHG9AdX2nJyWvMwar1iv/s737/security.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;438&quot; data-original-width=&quot;737&quot; height=&quot;380&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVA3MRcSs8x66365jlV3t8VbveDfH3__uW1x48omapb4kZyiKgzMaaqJbA0nQ_BO8XsNF0YBUE3B1Aq1nwPYq3dUEj8E7QVT5BbfD-vPcqDAiu8Fd3hoRj2DBZHG9AdX2nJyWvMwar1iv/w640-h380/security.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Attacks can happen at multiple points on the API path length. Like a hacker can attack directly the client and intercept the data, also the hacker can exploit any vulnerability on the API gateway and he can also breach the firewall to attack the application server directly or the database. &lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;Types of functional Attacks:&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Data Theft:&lt;/b&gt; Here the attacker breaks into the system to steal confidential data like bank details of a person, credit card details, etc.&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Data Manipulation:&lt;/b&gt; Here the attacker tries to change/alter the data that is being transferred.&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Identity Theft:&lt;/b&gt; In identity theft the attacker gains personal information of a victim by deception and misuse that information in the victim&#39;s name &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;DOS Attack:&lt;/b&gt; Denial Of Service(DoS) is an attack where the attacker tries to stop genuine clients from accessing the server by flooding the application server with traffic or sending requests that causes the server to crash&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;API Authentication is one of the ways to prevent these types of attacks. Next, we will look into Token Based Authentication which is being widely used now-a-days.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;Token Based Authentication&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;Token based authentication requires the client to request a token from the server. The server after receiving the request verifies the client and sends back a token to the client. The client on each subsequent request to the server should send the token else the request will be rejected. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMWXhV2rkGHCEOya2_pGHLZyoGghCVqGg8y5ha1AC98eQQ54FvqUihTvAPZsuLP4R7SndBvH5OzAyUmOuqLCn9lIaQ1C8ZxewrdnJoMUmFXkJ48_XS5nMlfMjjR9hEaDILuSCTrCbEPNe4/s601/token.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;211&quot; data-original-width=&quot;601&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMWXhV2rkGHCEOya2_pGHLZyoGghCVqGg8y5ha1AC98eQQ54FvqUihTvAPZsuLP4R7SndBvH5OzAyUmOuqLCn9lIaQ1C8ZxewrdnJoMUmFXkJ48_XS5nMlfMjjR9hEaDILuSCTrCbEPNe4/w640-h224/token.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;JSON Web Tokens:&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;A JSON Web Token is an open standard for securely transmitting data between two parties as a JSON object. It is self-contained, means all the information required to verify a client is contained in the token itself.&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;This is how a JSON Web Token looks like:&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyd9Edtv08jSCvxMROLC_POzrAk_U_kdQ1ugS5Lq-kchDseTetkqTD7zSHeGudI0vrz-dc_RJJq0UymCtNPmrJuTDaQK0zhVnS_tk_pp_U4kEcMnUs3v7Qc32IW_RkFMm3-4VZ5jUQBNdP/s1018/jwt.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;91&quot; data-original-width=&quot;1018&quot; height=&quot;58&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyd9Edtv08jSCvxMROLC_POzrAk_U_kdQ1ugS5Lq-kchDseTetkqTD7zSHeGudI0vrz-dc_RJJq0UymCtNPmrJuTDaQK0zhVnS_tk_pp_U4kEcMnUs3v7Qc32IW_RkFMm3-4VZ5jUQBNdP/w640-h58/jwt.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/font&gt;&lt;/font&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&amp;nbsp; As we see a JSON Web Token contains three parts:&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Header:&lt;/b&gt; This contains metadata which is hashed using any algorithm like HMAC and is base64 encoded&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Payload: &lt;/b&gt;This contains the claims, which is some set of data like who is the issuer, expiry timestamp of the token, etc. This is also hashed and base64 encoded&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Signature: &lt;/b&gt;This is the combined hashed value of header and payload and is also encrypted using a secret key &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here is a basic example of integrating JWT authentication in NodeJS. For this, we have used the npm package &lt;a href=&quot;https://www.npmjs.com/package/jsonwebtoken&quot;&gt;jsonwebtoken&lt;/a&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1qLaQTmVIajyZXoRPJ7z_mwst28Xwq2GgQTXnRZGRUfsbcY5R4Xkdtl3lV-thfhjbyjXCDTuL319EmEkWpX6_IKPMIPvDsB8P-GHuYikdsI4CHGy0tlY9lncO4uP03ja6HvBzYG_xrnW/s844/Screenshot+2020-07-23+at+8.07.24+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;694&quot; data-original-width=&quot;844&quot; height=&quot;526&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1qLaQTmVIajyZXoRPJ7z_mwst28Xwq2GgQTXnRZGRUfsbcY5R4Xkdtl3lV-thfhjbyjXCDTuL319EmEkWpX6_IKPMIPvDsB8P-GHuYikdsI4CHGy0tlY9lncO4uP03ja6HvBzYG_xrnW/w640-h526/Screenshot+2020-07-23+at+8.07.24+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;NodeJS code for JWT integration&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here we have created a /token endpoint which takes id and password and validates it with a static user credential. If the id and password matches then we create a token using a private key. Here we have hard-coded the private key but generally it should be read from a separate file or environment variable. Then we return the created token to the client. If the credentials do not match we send an unauthorized response.&lt;br /&gt;Then we have an authentication middleware, which extracts the value from each subsequent request header and verifies it. If success then we send back a message stating the client is verified else if it fails in the auth middleware then we send an unauthorized response.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here is a working demo of the above code. We have used Postman here for trying out the APIs.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;322&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dw96qCTSVyl5nx68tXxKMNGESy7iE0-UJGqaBs9PTL913O6ubZS7WpCXvH1Lxhct98yBm1PJsHEKXnlWsIg5g&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Hope this article has given a clear concept on API security and about JWT authentication. You can get the above code in this link. Do mention your thoughts and views in the comments. Stay Safe and Happy Coding!&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/2950204435688443775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/api-security-jwt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/2950204435688443775'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/2950204435688443775'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/api-security-jwt.html' title='API Security - Securing API with Tokens and JWT'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihkN_4Ri5L_H-1MG1yogypTYqBxdBAOzmDpxdpbEMK4S3X4dWF1FZtVXTLulI41R39ZKQKFXOvIvcdit_uPuZGaS3lTz5TC5fiUvWzmI9D_H6nORk4-rNLzqnrovAY3bnRjRDV70XvSKte/s72-c/api-security.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-1284556948589976441</id><published>2020-07-14T11:12:00.000+05:30</published><updated>2020-07-14T11:12:36.291+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>API Caching - Reducing Network Calls</title><content type='html'>&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;6&quot;&gt;W&lt;/font&gt;hat is Caching?&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b id=&quot;docs-internal-guid-e80fa7e5-7fff-9565-d4e9-9be1a9f79cc1&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;Caching&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; is the ability to store copies of frequently accessed data in several places along the request-response path.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In terms of REST APIs, caching is storing the response of APIs having relatively high response time in an in-memory or distributed system, so that the response can be fetched from the stored system within a short amount of time. &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6bUVRrsRe75iDjnwDGUfqSyBf3V4Mlnq9ZidILWbZ6YGUKmQQBfgtNBInSW3gJc1kJ_x9gph5_6V_9EjJ8xJVLUPj_ellAlFr7Dm8NwVpdDEczWwOUPKqXF8LlZUMd7GxTLd_XPfaKhEt/s617/caching.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;351&quot; data-original-width=&quot;617&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6bUVRrsRe75iDjnwDGUfqSyBf3V4Mlnq9ZidILWbZ6YGUKmQQBfgtNBInSW3gJc1kJ_x9gph5_6V_9EjJ8xJVLUPj_ellAlFr7Dm8NwVpdDEczWwOUPKqXF8LlZUMd7GxTLd_XPfaKhEt/w640-h364/caching.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b id=&quot;docs-internal-guid-e80fa7e5-7fff-9565-d4e9-9be1a9f79cc1&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b id=&quot;docs-internal-guid-e80fa7e5-7fff-9565-d4e9-9be1a9f79cc1&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;Why implement caching?&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/font&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;There are generally two basic reasons for which REST API developers implement caching:&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Reduce Network Calls:&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;
 Most API operations are read operations, so when data doesn&#39;t change 
then there is no need to fetch data again and again from a database. For
 this, we can have an in-memory cache where we can save the data as 
key-value pair and fetch the data from the cache. As a result of this 
network calls will be reduced significantly.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Reduce Load on Database:&lt;/b&gt; When we are using a cache, then for most of the time we will be fetching data from the cache and won&#39;t be querying the database much. So, as a result, database query/computational costs are decreased and so the concurrency of the database increases.&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;Types of Caching&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;API Caching can be sub-divided into &lt;b&gt;in-memory&lt;/b&gt; caching and &lt;b&gt;distributed&lt;/b&gt; caching based on where data is being stored.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;In-Memory Caching:&lt;/b&gt; In memory caching stores data inside the application server itself. A certain portion of the memory in the application server is allotted for caching. It is not distributed and neither scalable.&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Distributed Caching:&lt;/b&gt; A distributed cache is a cache maintained by multiple servers, typically maintained as an external service which the application server can access. Distributive Caching is useful when we have to store lots of data in the cache. It can improve performance by scaling horizontally.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;How much improvement is possible?&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Let us take an example here. Suppose we have an API that fetches the transaction data for any user in an online shopping site. Let&#39;s assume the Database Access Time = 30ms,&amp;nbsp; Cache Access Time = 8ms and Computational Buffer = 5ms. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Now if a user makes the API call 10 times, then without using cache the total time taken will be = &lt;b&gt;(30+5)*10 = 350ms&lt;/b&gt;&lt;br /&gt;If caching is there, then 1st request won&#39;t get any data from cache, so the API will query the database for the first time, after that the result will be stored in the cache and from the subsequent requests data will be fetched and returned from the cache.&lt;br /&gt;So, using cache total time taken will be = &lt;b&gt;(30+8+5)*1 + (8+5)*9 =&amp;nbsp; 160ms&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Here we see that for 10 API calls, the total response time has reduced by almost 54%. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;The problem - Cache Invalidation&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;blockquote&gt;There are only two hard things in Computer Science: Cache Invalidation and naming things&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;- Phil Karlton&lt;/span&gt;&lt;/blockquote&gt;&lt;span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Caching is a great solution for reducing network and calls and improving the performance of our APIs. For a low response time, we want to cache our content for a longer period of time. But at the same time, we should be able to return fresh data whenever there is an update in our main database. Cache Invalidation is the process in which the content stored &lt;/font&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;inside a cache replaced or removed as the data it contained is now no longer useful&lt;/span&gt;&lt;/font&gt;. &lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;For example, there is a cache which contains the basic information of an user. An API fetches user&amp;nbsp; info from this cache and returns it to the client. Now suppose the user changes his phone number and the update happens in our main database. So for this, either the cache has to be updated with the new data or the cache has to be removed so that the API directly goes and fetches from the main database.&lt;br /&gt;Now, when and how to invalidate a cache depends mostly on the business requirements, like whether the updated data has to be instantly visible to the client or it will be available after a certain interval of time, &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;whether comprising on response time is possible or not, etc. For this there are these 3 techniques:&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Write-through cache: &lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Here, data is updated in the database and cache at the same time. This won&#39;t compromise with the response time and updated data will be available instantly but the write operations will take much more time.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Write-around cache:&lt;/b&gt; Here, data is directly written to database bypassing the cache. This reduces the write operation costs but the response time for read requests will be high.&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Write-back cache:&lt;/b&gt; In this case, data is directly written to cache only and success message is sent to client. Then at specified intervals the data update is done on main database by automated scripts. Here also &lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;updated data will be available instantly but there is risk of data loss if cache fails.&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Well, that is pretty much about the basics of API caching. In this article, we covered what is caching and the different ways it can be implemented, also how it can drastically improve API performance. In the end we discussed about cache invalidation and it&#39;s techniques. If you have any doubts or suggestions to improve this article do mention them in the comments. Stay Safe and Happy Coding!&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/1284556948589976441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/api-caching-reducing-network-calls.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/1284556948589976441'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/1284556948589976441'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/api-caching-reducing-network-calls.html' title='API Caching - Reducing Network Calls'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6bUVRrsRe75iDjnwDGUfqSyBf3V4Mlnq9ZidILWbZ6YGUKmQQBfgtNBInSW3gJc1kJ_x9gph5_6V_9EjJ8xJVLUPj_ellAlFr7Dm8NwVpdDEczWwOUPKqXF8LlZUMd7GxTLd_XPfaKhEt/s72-w640-h364-c/caching.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-910279010798892723</id><published>2020-07-07T19:34:00.000+05:30</published><updated>2020-07-07T19:34:25.619+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>5 Topics For a NodeJS Interview</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Before starting let us look at some statistics on NodeJs. According to StackOverflow&#39;s &lt;a href=&quot;https://insights.stackoverflow.com/survey/2020#technology-other-frameworks-libraries-and-tools-professional-developers3&quot; target=&quot;_blank&quot;&gt;developers survey&lt;/a&gt;, 51.9% of Professional Developers use NodeJs, and according to a survey by &lt;a href=&quot;https://nodejs.org/en/user-survey-report/&quot; target=&quot;_blank&quot;&gt;nodejs.org&lt;/a&gt; about 26% companies in the US and 21% in India use NodeJs for their Backend. &lt;br /&gt;NodeJS has been the most widely used technology for API development in the past few years. I have been a NodeJS developer for 3+ years and have given over 20+ interviews for NodeJS developer roles in many companies. I have also interviewed over 30+ candidates for NodeJs developer roles. In this article, I will list down and briefly explain 5 topics on NodeJs. The most frequent questions that I have faced in an interview or asked a candidate as an interviewer is based on these topics. &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjzufgN6lLN_DPwwwt8P3CHBQTdC9BVncYEjI6dB59GRIVRkvGZvuvgK_3n7dWDh0jcQQ29llK4ys9STSyWkE6VqflaXhSDMWImlCvJvZblrjWXp6amEnAo40woWTCi1nJCpDN8oU8Cr7/s401/node-interview.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;381&quot; data-original-width=&quot;401&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjzufgN6lLN_DPwwwt8P3CHBQTdC9BVncYEjI6dB59GRIVRkvGZvuvgK_3n7dWDh0jcQQ29llK4ys9STSyWkE6VqflaXhSDMWImlCvJvZblrjWXp6amEnAo40woWTCi1nJCpDN8oU8Cr7/s320/node-interview.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Now, let&#39;s begin&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;1) NodeJS is single-threaded&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;So, what is NodeJs? A google search of this will give you some results, and the answer we get is mostly like this:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;blockquote&gt;Node Js is a single-threaded, asynchronous non-blocking I/O model that executes JavaScript on the server-side&lt;/blockquote&gt;&lt;div&gt;NodeJS is single-threaded. What is means is the code we write is executed on a single thread, which is also known as the main thread. Being single-threaded means it has a single call stack and it can do only one thing at a time. But now a question arises - If NodeJS is single-threaded then how does it perform &lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;asynchronous non-blocking I/O operations simultaneously. The answer to the question is the Event Loop.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;2) NodeJS Event Loop&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;NodeJS event loop is the heart of the asynchronous nature of NodeJS. The V8 engine runtime, on which NodeJS is built, consists of a heap memory and a call stack, and the NodeJS environment consists of a callback queue, some other APIs, and the Event Loop. All these work together to achieve the asynchronous non-blocking nature of NodeJS. The event loop&#39;s main function is to dispatch all the callbacks of various &lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;asynchronous&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; functions that have been accumulated in the callback queue. The code execution happens on the main thread while executing when an &lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;asynchronous functional call is encountered it is shifted from the main thread and executed separately and when the function completes execution the callback of that function is added to the callback queue and the event loop dispatches it accordingly. To know in detail about how NodeJS works, refer to &lt;a href=&quot;https://medium.com/@dey7.kol/nodejs-its-async-nature-and-the-event-loop-756fad08c79b&quot; target=&quot;_blank&quot;&gt;this article&lt;/a&gt;, which we posted on medium. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4XWu4Y7uTvN-muYhAPtcess8tCrXjdS3MQzNKm5uWk-a8sknWOcdZ7PsHPyyMUX3sK-ImpjYBwhSj_PDQFgUyZVUayDnyABe8ZoFB8qjn57YuVK0zwr6W7qvl-uFDJIyH8fe9arIWlIwi/s911/node-arch.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;493&quot; data-original-width=&quot;911&quot; height=&quot;346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4XWu4Y7uTvN-muYhAPtcess8tCrXjdS3MQzNKm5uWk-a8sknWOcdZ7PsHPyyMUX3sK-ImpjYBwhSj_PDQFgUyZVUayDnyABe8ZoFB8qjn57YuVK0zwr6W7qvl-uFDJIyH8fe9arIWlIwi/w640-h346/node-arch.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;3) NodeJS Event Emmiter&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;There are many objects in NodeJS which emit events like fs.readStream emits an event when the specified file is opened. There is a NodeJS module &lt;b&gt;events&lt;/b&gt; and all objects which emit events are instances of events.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;EventEmitter. These objects contain a &lt;b&gt;.on()&lt;/b&gt; function by which we can attach an event to it along with the callback for that event. Then using &lt;b&gt;.emit()&lt;/b&gt; function,the particular event can be triggered. Have a look at the following code snippet to understand how &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;EventEmitter is used in NodeJS.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUP8kZEZi_g_4boK8jpqAgwKmIecL7iSd0aS3mt08Yqu9jtT4XAkJ_0MAyqRqMjKJuzP4hp51J3SNnBYI63f7gaOM6jelSGe4HRocBqUJVr-uxCaNhpH98kUSs735Nx7x0owuA4pUDnxht/s575/Screenshot+2020-07-05+at+11.57.38+AM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;388&quot; data-original-width=&quot;575&quot; height=&quot;432&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUP8kZEZi_g_4boK8jpqAgwKmIecL7iSd0aS3mt08Yqu9jtT4XAkJ_0MAyqRqMjKJuzP4hp51J3SNnBYI63f7gaOM6jelSGe4HRocBqUJVr-uxCaNhpH98kUSs735Nx7x0owuA4pUDnxht/w640-h432/Screenshot+2020-07-05+at+11.57.38+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;4) NodeJS Middlewares&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Middlewares in NodeJS are functions that get executed in the middle of the request and response cycle. A middleware has access to the request object, the response object, and to the next middleware function (if any). The code inside a middleware function gets executed before the callback for a particular request is executed. Generally, middlewares are used to change request and response objects, perform authentication, request data verification, etc. To know more about middlewares checkout this &lt;a href=&quot;https://expressjs.com/en/guide/writing-middleware.html&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;b&gt;5) NodeJS Promises vs Callbacks&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;This concept is not particularly of NodeJS, it is related to native JavaScript. But still while developing APIs using NodeJS, it is required that one should have a clear knowledge about this. So this topic is common NodeJS interviews also. Now as we all know callbacks are functions that we pass as an argument to another function which is asynchronous in nature. This callback function gets executed when after the parent functions completes its execution. Promises are enhancements to callbacks. For this, we generally write a function that returns a promise object.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt; Promises notify whether the request is fulfilled or rejected. Callbacks can be registered with the &lt;b&gt;.then()&lt;/b&gt; to handle fulfillment and&lt;b&gt; .catch()&lt;/b&gt; to handle&amp;nbsp; rejection. One problem of callbacks is that nesting of multiple callback functions can lead to something known as callback hell, which decreased code readability, and code management becomes harder. Using Promises, this issue can be solved using&amp;nbsp; promise chaining.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here we have briefly explained these 5 important topics which are important for a NodeJS interview. Also, it is better if one can get a detailed understanding of these topics. Before we end, a request to anyone who has attended NodeJS&amp;nbsp; interviews in the recent past and has come across important questions, then feel free to comment here, it will be beneficial for others. Also, if you have liked this article do subscribe to get this kind of interview tips directly delivered to your inbox. &lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/910279010798892723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/5-topics-for-nodejs-interview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/910279010798892723'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/910279010798892723'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/5-topics-for-nodejs-interview.html' title='5 Topics For a NodeJS Interview'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjzufgN6lLN_DPwwwt8P3CHBQTdC9BVncYEjI6dB59GRIVRkvGZvuvgK_3n7dWDh0jcQQ29llK4ys9STSyWkE6VqflaXhSDMWImlCvJvZblrjWXp6amEnAo40woWTCi1nJCpDN8oU8Cr7/s72-c/node-interview.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-8275253559360364758</id><published>2020-07-01T20:00:00.001+05:30</published><updated>2020-07-02T11:55:37.236+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>System Design - Load Balancing</title><content type='html'>&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;6&quot;&gt;W&lt;/font&gt;hat is Load Balancing?&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;Load Balancing is a technique to efficiently and uniformly distribute &lt;/font&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;network traffic across multiple servers. When we are horizontally scaling our application then we add multiple servers to handle a large amount of network traffic. Here load balancing ensures that no single server receives too many requests and the network traffic is evenly distributed. This improves the whole application responsiveness. &lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfJaA_mHND9cHioXeh4lsFbRhrSJGCE8SCkyNQanPneLvgRToa_AQA8v2qbp-lui1c351jSac6hYn0N4MMwNMcqTu8jL1IyQ20crU2i-vicTjUVhww1LWpss9EeBdKJBrJSsRMmiLoj3pL/s742/lb.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;474&quot; data-original-width=&quot;742&quot; height=&quot;408&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfJaA_mHND9cHioXeh4lsFbRhrSJGCE8SCkyNQanPneLvgRToa_AQA8v2qbp-lui1c351jSac6hYn0N4MMwNMcqTu8jL1IyQ20crU2i-vicTjUVhww1LWpss9EeBdKJBrJSsRMmiLoj3pL/w640-h408/lb.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;5&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;&lt;font size=&quot;3&quot;&gt;Load Balancing By Normal Hashing:&lt;/font&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;A Hash map is a data structure that&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt; is used to map a given value with a particular key for faster access of elements, and hashing is the technique to map a value to a particular key using a special function. This special function is called a hash function. &lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;To know more about hashing and collision resolution techniques, check this &lt;a href=&quot;https://www.geeksforgeeks.org/hashing-in-distributed-systems/&quot; target=&quot;_blank&quot;&gt;article&lt;/a&gt;.&lt;/span&gt; Now how this hashing is used for Load Balancing?&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Each request that a client makes contains a unique request id. Also, each of the multiple servers in the application is numbered. So the technique is to use a hash function which will take in the request ID of the server and generates a key that represents the server number to which this request will be redirected. Let&#39;s understand this with the help of an example.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Suppose we have four servers numbered 0-3. Our hash function is defined as h(x) = x % m, where x is the request ID and m is the no. of servers. The below table represents how three requests with request IDs 1000, 1010 and 1027 are mapped.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;
&lt;table class=&quot;table-resp table-hover&quot;&gt;
    &lt;thead style=&quot;background-color: #e0dfdc;&quot;&gt;
      &lt;tr&gt;
        &lt;th&gt;Request ID&lt;/th&gt;
        &lt;th&gt;Hash Function&lt;/th&gt;
        &lt;th&gt;Key/Server No. &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1000&lt;/td&gt;
        &lt;td&gt;h(1000) = 1000%4&lt;/td&gt;
        &lt;td&gt; 0 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1010&lt;/td&gt;
        &lt;td&gt;h(1010) = 1010%4&lt;/td&gt;
        &lt;td&gt; 2 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1027&lt;/td&gt;
        &lt;td&gt;h(1027) = 1027%4&lt;/td&gt;
        &lt;td&gt; 3 &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;  
&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;So, like this each request will be processed by the server to which it gets mapped after hashing its request ID value.&lt;/font&gt; &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;Drawbacks of using normal hashing:&lt;/b&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;The above-mentioned method works fine if the number of servers is fixed. But suppose now the total incoming traffic to the application increases over time and we have to scale up our application more. For that reason suppose one more server gets added in our above example. Now we have 5 servers. So now 1000,1010 both will be mapped to server 0 and 1027 to server 2. So now all the requests are being completely being mapped to different servers. So, what is the issue here?&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;First of all the request Id are not random, they usually contain some client/user information within it. Like here if we assume requests having 100 in the beginning is from a user having user id as U0, then requests having request starting with 101 is from user U1 and requests staring with 102 is from user U2. Now each server has a local cache in which it can store the response of a request for a particular user. All the time the server doesn&#39;t fetch from the database, if the request is from the same user within a specific interval of time it returns data from the cache, this improves the response time. Now initially when there were four servers the data of user U1 and U2 were being stored in local cache of server 2 and server 3 respectively. Now after adding another server, the requests from these users are going to different servers which does not have the cached data for these users. So all the cached data stored for all the users at different servers are lost. This operation can reduce the overall speed of the application when there are large no. of requests coming in and also the number of servers are much more.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;This can be solved by a concept known as &lt;i&gt;&lt;b&gt;Consistent Hashing&lt;/b&gt;&lt;/i&gt;.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;&lt;font size=&quot;3&quot;&gt;Load Balancing By Consistent Hashing:&lt;/font&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;The main difference between normal hashing and consistent hashing is the data structure that is being used. In normal hashing, the data structure is generally a linear array or an object with key-value pair. In the case of consistent hashing, we use a circular array data structure which is also known as &lt;i&gt;consistent hash ring&lt;/i&gt;. &lt;br /&gt;Also for &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;consistent&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt; hashing we have a pre-defined search space. Let us denote it by N. Here the servers are also hashed into the hash ring. Each server has a unique id too. We can use those server IDs to hash the servers. Let us take our previous example with 4 servers and hash function as &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;h(x) = x % N, here X will be ID of server and N = 100&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;
&lt;table class=&quot;table-resp table-hover&quot;&gt;
    &lt;thead style=&quot;background-color: #e0dfdc;&quot;&gt;
      &lt;tr&gt;
        &lt;th&gt;Server ID&lt;/th&gt;
        &lt;th&gt;Hash Function&lt;/th&gt;
        &lt;th&gt;Position &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1024(S1)&lt;/td&gt;
        &lt;td&gt;h(1024) = 1024%100&lt;/td&gt;
        &lt;td&gt; 24 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1049(S2)&lt;/td&gt;
        &lt;td&gt;h(1049) = 1049%100&lt;/td&gt;
        &lt;td&gt; 49 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1074(S3)&lt;/td&gt;
        &lt;td&gt;h(1074) = 1027%100&lt;/td&gt;
        &lt;td&gt; 74 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1099(S4)&lt;/td&gt;
        &lt;td&gt;h(1099) = 1099%100&lt;/td&gt;
        &lt;td&gt; 99 &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;   
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;Now lets assume there are these 4 requests with IDs 1023(R1), 1145(R2), 1270(R3) and 1375(R4). These 4 request will also be hashed and mapped on the circular hash ring. &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz3rHLQaNIEK5Qhp-fO61e5R8Y380E8g09Bf6RSU-ZhiDl3QDbA1R468ImtAdXtZOCUb8x7gyUigk_n2NHBv0wmN3zqElJKveGg9ihsqAAjnQqtalpdooOjb6bg8sOj50hQqrHH4hDmF2p/s761/chash.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;108&quot; data-original-width=&quot;761&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz3rHLQaNIEK5Qhp-fO61e5R8Y380E8g09Bf6RSU-ZhiDl3QDbA1R468ImtAdXtZOCUb8x7gyUigk_n2NHBv0wmN3zqElJKveGg9ihsqAAjnQqtalpdooOjb6bg8sOj50hQqrHH4hDmF2p/w640-h90/chash.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The diagram shows how each server and request is mapped to the hash ring. The idea here is that each request here will be served by the nearest server to the right of it. Like R1 will be served by S1, R2 by S2, like this. Now as the requests and servers are hashed uniformly over the hash ring so the distribution of traffic will also be uniform.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Now if we add a new server here with a server ID 1080, it will hash to the position 1080%100 = 80 in the hash ring. The hash ring after adding this server will look like this:&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyRBn-1cyB6NBqNRMmNYHjQ_j6l0IwxitCmepb0lrDHBfi65FgfzxP3pLu23mnpikckt6_GbOLvJPCF3cL3rb-SQf54zPzWPIPVvwgQb18FJmgtc5Ijv86gP3vBavri4LG6LWCl9wwFvS0/s801/chahsmap.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;108&quot; data-original-width=&quot;801&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyRBn-1cyB6NBqNRMmNYHjQ_j6l0IwxitCmepb0lrDHBfi65FgfzxP3pLu23mnpikckt6_GbOLvJPCF3cL3rb-SQf54zPzWPIPVvwgQb18FJmgtc5Ijv86gP3vBavri4LG6LWCl9wwFvS0/w640-h86/chahsmap.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here unlike normal hashing, all the requests are not being re-mapped to different servers. The requests R1,R2 and R3 will be still be processed by the same server. Only R4 will now be served by S5 instead of S4&lt;/span&gt;&lt;/font&gt;. &lt;font size=&quot;2&quot;&gt;In the case of normal hashing, whenever a new server was added then each request was re-mapped to different servers and as a result, every useful information stored on local cache of servers was lost. Here that is reduced as only one server is being re-mapped. So, consistent hashing is more efficient.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;One drawback of consistent hashing is that choosing an improper hash function might result in a skewed distribution of the servers over the hash map and that results in a particular server handling more load as compared to other servers. But still, with large no. of servers and a relatively large search space, consistent hashing is way more efficient than normal hashing.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;Hope this article has given enough idea on Load Balancing and how normal hashing and &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font size=&quot;5&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;verdana&quot;&gt;consistent hashing works. Do mention in the comments your views on this article or any suggestions for improvement. Stay Safe and Happy coding!&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/8275253559360364758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/system-design-load-balancing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/8275253559360364758'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/8275253559360364758'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/07/system-design-load-balancing.html' title='System Design - Load Balancing'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfJaA_mHND9cHioXeh4lsFbRhrSJGCE8SCkyNQanPneLvgRToa_AQA8v2qbp-lui1c351jSac6hYn0N4MMwNMcqTu8jL1IyQ20crU2i-vicTjUVhww1LWpss9EeBdKJBrJSsRMmiLoj3pL/s72-w640-h408-c/lb.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-3750228836392067315</id><published>2020-06-24T22:18:00.000+05:30</published><updated>2020-06-24T22:18:54.873+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>Version Control - Basics</title><content type='html'>&lt;div&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;trebuchet&amp;quot;;&quot;&gt;&lt;font size=&quot;6&quot;&gt;W&lt;/font&gt;hat is Version Control?&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;3&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Version Control can be described as a system that helps us to manage the changes that are made to files over time, including code, binary or digital files. It helps by recording and keeping a track of the modifications done to a file or to a set of files so that at a later point of time we can recall a specific version of the files(s) if required.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Another benefit of using a version control system is that it makes collaboration among software engineers working on a particular project easy and also provides some insights on what everyone is doing on the project. In this article, we will understand version control in detail and&amp;nbsp; for that we will be talking about Git and GitHub.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Git &lt;/b&gt;is a distributed version-control system that tracks the changes of file(s), whereas &lt;b&gt;GitHub&lt;/b&gt; is a cloud-based hosting service that is built around the Git tool. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIES5gwEaeqAsjGzduk2wyQmVocXN-o7iKN_N3xkZhYtczQaMRQFTrp_jqDSTGWWJAo9NVcwfYFCualplF_jA9JnkmBlPiKKrdAwy3qlruMrdPziLU1XV_le3Dy_cZesZhm80vm8zm8LFm/s479/blog-cp.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;126&quot; data-original-width=&quot;479&quot; height=&quot;105&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIES5gwEaeqAsjGzduk2wyQmVocXN-o7iKN_N3xkZhYtczQaMRQFTrp_jqDSTGWWJAo9NVcwfYFCualplF_jA9JnkmBlPiKKrdAwy3qlruMrdPziLU1XV_le3Dy_cZesZhm80vm8zm8LFm/w400-h105/blog-cp.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Remote Repository vs Local Repository:&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Suppose you are part of a team whose task is to build a chat app. Now your responsibility is to set up the working repository. So for that, you create a folder in your local system. After creating the folder, it has to be initialized as a git repository using the command&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; &lt;/span&gt;&lt;i&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;git init &lt;/span&gt;&lt;/i&gt;. After this, the project folder residing in your system becomes a &lt;b&gt;local git repository&lt;/b&gt;. Then you add your initial project files and commit those changes locally. Now for the whole team to contribute, your local repository has to be available somewhere on the cloud. This is where GitHub comes into the picture. A repository, ideally with the same name as your local folder, needs to be created on GitHub. Now using the URL of this repository you can push the contents of your local repository to the one on GitHub. So this becomes the &lt;b&gt;remote repository&lt;/b&gt;. Now other members can clone this repository on GitHub and all the initial project setup will be available to them. &lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZzlIz7nGJQoNo-kEvYIWx0U3Kbv1VCtWmUpm7QDAH-OAmXy1ttbv3Yu9g5TtFbJ_Xc8haNdlVY5GJWBgohEG5R0xO06Gq-E5iRdsS3RBsZewXfEa8jLpgOByH1f7CBaIHmJa37c0afYtw/s609/Screenshot+2020-06-23+at+4.27.41+PM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;107&quot; data-original-width=&quot;609&quot; height=&quot;107&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZzlIz7nGJQoNo-kEvYIWx0U3Kbv1VCtWmUpm7QDAH-OAmXy1ttbv3Yu9g5TtFbJ_Xc8haNdlVY5GJWBgohEG5R0xO06Gq-E5iRdsS3RBsZewXfEa8jLpgOByH1f7CBaIHmJa37c0afYtw/d/Screenshot+2020-06-23+at+4.27.41+PM.png&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Create a folder for the project in your system. Then initialize it using git init. It becomes the local repository&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuZNqCMBRGoxayHdyik0al7SWXRcsO8FK354h3IHaHHfnUmucPswoFke9kAp20dJbGs2yve1M4f9Jdjj8epDYORiNhsvHyAUudVSnFg7gbnQp4FHnSID5I3dPywrLlQFA0GBisIzfsReXV/s1004/Screenshot+2020-06-23+at+4.39.44+PM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;261&quot; data-original-width=&quot;1004&quot; height=&quot;219&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuZNqCMBRGoxayHdyik0al7SWXRcsO8FK354h3IHaHHfnUmucPswoFke9kAp20dJbGs2yve1M4f9Jdjj8epDYORiNhsvHyAUudVSnFg7gbnQp4FHnSID5I3dPywrLlQFA0GBisIzfsReXV/d/Screenshot+2020-06-23+at+4.39.44+PM.png&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Now go to github.com and create a repository with the same name. This becomes the remote repository&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_fC1nz2cUjJJC0KwaUy5N7eoeG2zG8KZ4nrnXPb9V95r22Us4MJ513O5a1mQWMwesRQZVHy778eC_zgvLRb1vFLukvYbcbbDGM7G7u6t3RZIIZZtznwe39CyK_beOZUTNzD7XsWzpC6Qq/s774/Screenshot+2020-06-23+at+4.49.48+PM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;115&quot; data-original-width=&quot;774&quot; height=&quot;115&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_fC1nz2cUjJJC0KwaUy5N7eoeG2zG8KZ4nrnXPb9V95r22Us4MJ513O5a1mQWMwesRQZVHy778eC_zgvLRb1vFLukvYbcbbDGM7G7u6t3RZIIZZtznwe39CyK_beOZUTNzD7XsWzpC6Qq/d/Screenshot+2020-06-23+at+4.49.48+PM.png&quot; width=&quot;589&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Now using the url of the remote repository, connect your local repository to the remote one &lt;/font&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9VMDtg89lGs6_jk3hjH4ZEOPrpfSQfVlvz0eWJaCMBZtTdSPnKltNxmUEPO_PvuzHZfy1nVleAdXgYQDrOC4ZleQRHUaYPDR4IRkahBZSQinvKO5JO6MYJJkW28dFWdDnT7oWUqKT4wYZ/s667/Screenshot+2020-06-23+at+5.02.29+PM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;254&quot; data-original-width=&quot;667&quot; height=&quot;153&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9VMDtg89lGs6_jk3hjH4ZEOPrpfSQfVlvz0eWJaCMBZtTdSPnKltNxmUEPO_PvuzHZfy1nVleAdXgYQDrOC4ZleQRHUaYPDR4IRkahBZSQinvKO5JO6MYJJkW28dFWdDnT7oWUqKT4wYZ/d/Screenshot+2020-06-23+at+5.02.29+PM.png&quot; width=&quot;575&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgodOoK-X0Mtcj_oRoGDvhMMeJVLrYmUVibFAkLOoHGbOnaqYJYu-EY_WVQwlJEpMXFxBXgrWEYn9w3qo6e957aW7UsHE12hVZSusFuBJv9fQSC6jKaOHnjrAL3_Hx799pe3_LW8zQVqopo/s997/Screenshot+2020-06-23+at+5.03.51+PM.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;370&quot; data-original-width=&quot;997&quot; height=&quot;149&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgodOoK-X0Mtcj_oRoGDvhMMeJVLrYmUVibFAkLOoHGbOnaqYJYu-EY_WVQwlJEpMXFxBXgrWEYn9w3qo6e957aW7UsHE12hVZSusFuBJv9fQSC6jKaOHnjrAL3_Hx799pe3_LW8zQVqopo/w400-h149/Screenshot+2020-06-23+at+5.03.51+PM.png&quot; width=&quot;591&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;Now after adding your code files, when you push your code it gets pushed all the way back to the remote repo&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3 Areas of a Git Repository:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Inside a Git repository we have three logical areas in which we work with our files - The Working Tree, The Staging Area and The Git History.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOp0ElqMaSus9qD24UlUhN61wXaJv4Vsr3FzdNc6imWmVF0CU_DHvMX955xF8yDnFhXPhKhf5sRh0YKTlFfTdlNEvkEf8QSPNIf_3nykgj5ygEyXDPFxu8HyxAYO26xH-Rv9MkFkWXq6r3/s641/git-areas.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;281&quot; data-original-width=&quot;641&quot; height=&quot;280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOp0ElqMaSus9qD24UlUhN61wXaJv4Vsr3FzdNc6imWmVF0CU_DHvMX955xF8yDnFhXPhKhf5sRh0YKTlFfTdlNEvkEf8QSPNIf_3nykgj5ygEyXDPFxu8HyxAYO26xH-Rv9MkFkWXq6r3/w640-h280/git-areas.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The working tree is what we see in our local system, where we add, edit or delete files&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;When we make changes to our files, Git gives us the full freedom to choose which files to add/include in the next commit. After adding a file using the&amp;nbsp;&lt;i&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; git add&amp;nbsp;&lt;/span&gt;&lt;/i&gt; command it goes into the staging area&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The Git History may be defined as a hierarchical structure, which contains a list of all the commits done on that repository over time.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Git Branching:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Branches allow us to work on the same file in parallel. When we initialize a repository there is a basic branch by default which is the master branch. Now when&lt;b&gt; &lt;/b&gt;we create a branch, a different copy of the whole working tree is created. Like suppose we create a branch named &lt;i&gt;chat-room &lt;/i&gt;from the branch master, then in the newly created branch we will have the exact copy of all the files that were in master. We can add, edit or delete files in this branch independently. This will not affect the master branch. The branching feature is used by developers who are working on the same project but on different features. From the main branch, different feature branches can be created where different developers can work independently. &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;When a branch is stable and tested then that branch can be merged with the main branch.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The command&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; &lt;i&gt;git branch &amp;lt;branch-name&amp;gt;&lt;/i&gt;&amp;nbsp;&lt;/span&gt; is used to create a branch. Then we can go to that branch using&amp;nbsp;&lt;i&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; git checkout &amp;lt;branch-name&amp;gt; &lt;/span&gt;&lt;/i&gt;. For merging, generally a pull request is required to be raised in the remote repository, i.e on Github and a reviewer will review your changes and merge the branch with the main branch, or for a local merge we can just go back to the main branch and use&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; &lt;i&gt;git merge &amp;lt;branch_name&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeka1ECwAdl9KX1n-NQ-x8a_aa4JDoDQyoJNrKeBZG7bO6KK6SvV1ikK_1NEDsczgDc7i7cPfGXvGDkciL4MLV7wBqB4JNMz-gX14YV-QkuMRz6esimREOs7scEsM40bcZmozu9JxDgKXZ/s913/Screenshot+2020-06-24+at+10.30.19+AM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;469&quot; data-original-width=&quot;913&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeka1ECwAdl9KX1n-NQ-x8a_aa4JDoDQyoJNrKeBZG7bO6KK6SvV1ikK_1NEDsczgDc7i7cPfGXvGDkciL4MLV7wBqB4JNMz-gX14YV-QkuMRz6esimREOs7scEsM40bcZmozu9JxDgKXZ/w640-h328/Screenshot+2020-06-24+at+10.30.19+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Create and checkout to a new branch. After adding /editing files commit and push the contents of this branch&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilndP3Oo7g6ie8g81eUi5fe5HCgT1CANJ3YlkOYBnvmnqJiaDZ4jzRRWbG1CNA4jrMp4OtCdxU9oleC8nMw2k-HE8yDs39g5sh8fJIxjhnbPzNm135x31Tjtdd8ZUpKVMU8MhM71Qpkx3w/s1003/Screenshot+2020-06-24+at+10.40.14+AM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;508&quot; data-original-width=&quot;1003&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilndP3Oo7g6ie8g81eUi5fe5HCgT1CANJ3YlkOYBnvmnqJiaDZ4jzRRWbG1CNA4jrMp4OtCdxU9oleC8nMw2k-HE8yDs39g5sh8fJIxjhnbPzNm135x31Tjtdd8ZUpKVMU8MhM71Qpkx3w/w640-h324/Screenshot+2020-06-24+at+10.40.14+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;When we push the code, in the remote repository the new branch gets created&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgipB9_gvmqTHnEMXggByYtV3QeMZ5HJGuiiZ6Jv9wGjdqS1oWrYCXXH1Y_Ha5D0fGX16ZcZdAD7sZtXlSwWby7yncD4UPzek5QqnkZ0g4-gPRdxn53L3dzP2gBPglOEZOc5lEgM8FKekNG/s838/Screenshot+2020-06-24+at+11.05.24+AM.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;327&quot; data-original-width=&quot;838&quot; height=&quot;250&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgipB9_gvmqTHnEMXggByYtV3QeMZ5HJGuiiZ6Jv9wGjdqS1oWrYCXXH1Y_Ha5D0fGX16ZcZdAD7sZtXlSwWby7yncD4UPzek5QqnkZ0g4-gPRdxn53L3dzP2gBPglOEZOc5lEgM8FKekNG/w640-h250/Screenshot+2020-06-24+at+11.05.24+AM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;To merge with the master, checkout to master and merge the branch using git merge command.&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;Git Logs:&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;All the commits made in a repository can be viewed using the git log command. Each of the commits has a unique hash value. Using that unique value we can restore back our files at that particular commit. We can move to a particular commit using the command&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt; &lt;i&gt;git checkout &amp;lt;commit_hash&amp;gt; &lt;/i&gt;&lt;/span&gt;. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh4ClUGqPHvewwcdAK8y0bcSiJPFdDwvTjLkPUX7bJdo1XL2l3kPxVzcSMmETd2R7UdYdOKjFTKmzIJgJLS5zekjfeclOEhuTF9JdYTU2ejXflrmhJJBONSN_ribnr-BqB8QPEQwIOWaMI/s1073/logs.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;521&quot; data-original-width=&quot;1073&quot; height=&quot;310&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh4ClUGqPHvewwcdAK8y0bcSiJPFdDwvTjLkPUX7bJdo1XL2l3kPxVzcSMmETd2R7UdYdOKjFTKmzIJgJLS5zekjfeclOEhuTF9JdYTU2ejXflrmhJJBONSN_ribnr-BqB8QPEQwIOWaMI/w640-h310/logs.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The git log command gives list of all commits and the unique hash value, using which we can checkout to that commit.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Hope after reading this article you get a basic idea of what version controlling is and also some understanding of git. There are more advanced stuffs related to version controlling and Git which I will be posting in my upcoming articles. Do comment out your views on version controlling. Stay Safe and Happy Coding!&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/3750228836392067315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/version-control-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3750228836392067315'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3750228836392067315'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/version-control-basics.html' title='Version Control - Basics'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIES5gwEaeqAsjGzduk2wyQmVocXN-o7iKN_N3xkZhYtczQaMRQFTrp_jqDSTGWWJAo9NVcwfYFCualplF_jA9JnkmBlPiKKrdAwy3qlruMrdPziLU1XV_le3Dy_cZesZhm80vm8zm8LFm/s72-w400-h105-c/blog-cp.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-4621407804549934223</id><published>2020-06-17T13:06:00.001+05:30</published><updated>2020-06-18T12:31:52.774+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>Backend Engineering</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;trebuchet&amp;quot;;&quot;&gt;&lt;font size=&quot;6&quot;&gt;W&lt;/font&gt;hat is Backend Engineering?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Suppose you open Facebook and enter your username and password then click login. You get back a page showing data that is personalized for you. Or suppose you open your Amazon app and typed a particular product name and then you get all the products listed with an image and description. So all the stuff that happens behind the scenes after you click the login or search button till you get back the requested data&amp;nbsp; is what we call as the backend. So, backend engineering deals with creating the most effective and efficient solution to fetch data and return formatted data to the frontend, which can be a web page or a mobile application. &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrp0P1pU71x4uiI4OHBhtlu8Z0S0mEp9e0WzPCjtPWO69EAi8DW-4ErG2A8pSMPK27xFDHIUpog8LL-2KhWXbru379KZzQ9GIzhObOB63uvHE50IoJXhjJzMahUnllRq98VlLczuFYuvql/s619/backend.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;501&quot; data-original-width=&quot;619&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrp0P1pU71x4uiI4OHBhtlu8Z0S0mEp9e0WzPCjtPWO69EAi8DW-4ErG2A8pSMPK27xFDHIUpog8LL-2KhWXbru379KZzQ9GIzhObOB63uvHE50IoJXhjJzMahUnllRq98VlLczuFYuvql/w400-h324/backend.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;In this article, we are going to talk in-depth about Backend Engineering, like what is it exactly, what things a backend engineer is specifically required to do and in the end, we will see some statistics on backend engineering like percentage of developers choosing backend engineering, the average salary of a backend engineer, etc.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot;;&quot;&gt;Backend Engineering is about developing API endpoints along with that handling databases, designing database schema and also handling integration of third-party services&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The tasks involved in backend engineering are:&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;API Design/Development&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Database Design&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Third-party Service Integration&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;DevOps Tasks&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;API Design/Development:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;API design/development is the main task of a backend engineer. What is an API and how does it work? All these I explained in one of my previous blogs. &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;API Design is what needs to be done before the development begins. API design is very much related to the overall user-experience of the application. It involves the type of endpoints that are being exposed, the parameters the APIs will accept from the frontend and the structure of the data that the APIs will return in response. All these things impact the overall application that is being developed.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;API Development is basically writing the code to implement the business logic in accordance with the API designs that were primarily finalized. API development deals with querying database for the data, manipulating the data, integrating security features like authentication and authorization, etc.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Database Design:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Another essential task involved in backend engineering is database designing. It includes picking the type of Database, i.e RDMS/NoSQL/Graph DB for the application, defining the schema of the entities that are going to be stored in the database and other tasks like how much normalized the relations will be and what constraints will be there. Proper database design is essential because without it data fetching and insertion operations become more complex. &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Third-party Service Integration:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;While developing the backend for an application, most of the time it is required to integrate many third-party services like caching, queuing, authentication services, etc. So all of these require reading a lot of documentation, understanding the code and the guidelines. For example, integrating a Caching service to reduce the network traffic or integrating an OAuth service like Google/Facebook for user authentication are some third-party services that are commonly used.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;DevOps Tasks:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;DevOps tasks involve deploying code to cloud instances, creating pipelines for Continuous Integration and Continuous Deployment and many more things related to handling&amp;nbsp; server configurations and environment be it test or production. Well, this is not the entire responsibility of a backend engineer. Some organizations have a separate DevOps team to handle these tasks while in some organizations these tasks are handled by backend engineers.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;According to &lt;a href=&quot;https://insights.stackoverflow.com/survey/2020#technology-platforms-professional-developers5&quot; target=&quot;_blank&quot;&gt;Stack-overflow Developer Survey&lt;/a&gt;, most of the developers (around 55.2%) are pursuing a career in backend engineering.&amp;nbsp; As per &lt;a href=&quot;https://www.indeed.com/career/back-end-developer/salaries?from=top_sb&quot; target=&quot;_blank&quot;&gt;indeed.com &lt;/a&gt;the average salary of a backend engineer is &lt;b&gt;$128k&lt;/b&gt; in the US and in India, it is around &lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;strong class=&quot;cmp-salary-amount&quot;&gt;₹ 400k&lt;/strong&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;. Coming to backend technologies, NodeJs is mostly being used now-a-days. Python and Ruby on Rails are also in demand. Coming to databases, MySQL and &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;PostgreSQL &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;are widely used as RDBMS and MongoDB as NoSQL. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;If you are someone who doesn&#39;t like anything related to UX or UI development and instead like orchestrating behind the scenes of an application then backend engineering might be suitable for you.&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;cmp-salary-amount&quot;&gt;If you are thinking of getting into backend engineering, hope this article has given you enough insights about it. If you are already into backend engineering, do comment out your views on it. Stay Safe and Happy Coding!&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/4621407804549934223/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/backend-engineering.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/4621407804549934223'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/4621407804549934223'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/backend-engineering.html' title='Backend Engineering'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrp0P1pU71x4uiI4OHBhtlu8Z0S0mEp9e0WzPCjtPWO69EAi8DW-4ErG2A8pSMPK27xFDHIUpog8LL-2KhWXbru379KZzQ9GIzhObOB63uvHE50IoJXhjJzMahUnllRq98VlLczuFYuvql/s72-w400-h324-c/backend.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-3215304492266300204</id><published>2020-06-11T15:00:00.002+05:30</published><updated>2020-06-11T15:00:40.860+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>Monolithic Vs Microservices Architecture</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;A topic that is profoundly discussed in software engineering or system design domain is whether to choose a &lt;b&gt;Monolithic &lt;/b&gt;or a&lt;b&gt; Microservice architecture&lt;/b&gt; while developing and deploying a server-side application. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_E1a4gABAoTiS6gUnkiQ4UiTTCt4BdgcyYDnMA4T4gT2Wh01xgFL0Dc4y_wZXBQvXQyz_BrZVZYfS_xTp42MpjSxAwOpwVYfz0eXLKVbv7pAyjrV9rb8J7shbRNHtQVNeWwMgrg8er-Yk/s602/micro-vs-mono.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;363&quot; data-original-width=&quot;602&quot; height=&quot;241&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_E1a4gABAoTiS6gUnkiQ4UiTTCt4BdgcyYDnMA4T4gT2Wh01xgFL0Dc4y_wZXBQvXQyz_BrZVZYfS_xTp42MpjSxAwOpwVYfz0eXLKVbv7pAyjrV9rb8J7shbRNHtQVNeWwMgrg8er-Yk/w400-h241/micro-vs-mono.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In this article, we are going to discuss in detail about Monolithic and Microservice architecture, advantages and disadvantages of&amp;nbsp; each and in the end will see which architecture to choose based on the system&#39;s requirements.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;i&gt;&lt;b&gt;Monolithic Architecture:&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Generally, when we develop a server-side application we do it as a layered architecture which contains the following layers:&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The presentation layer in which HTTP requests are handled and responds with data as JSON/XML&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The business layer where the application&#39;s business logic is written&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The third-party layer, which contains the code to handle third-party services like caching, queuing&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The Database Access layer, which is responsible for performing read/write/delete operations on the database&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Despite having a layered architecture, while deploying all the code is packed together and deployed as a single-tier application. This is what a Monolithic Architecture is. &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQv_XEFRzsYR_xuCRKg3AQtkoMU75SBmQ0QB-Jiu1__VwXbB8eNEGQGCmVa5cIBW17bfpockOWceR2tP1lKyXU44RMbqloeqQcKx9CmF8smcj2_5rIY7AD0k2SN0NTW1EjWuemgYM4iIzz/s693/monolith.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;408&quot; data-original-width=&quot;693&quot; height=&quot;377&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQv_XEFRzsYR_xuCRKg3AQtkoMU75SBmQ0QB-Jiu1__VwXbB8eNEGQGCmVa5cIBW17bfpockOWceR2tP1lKyXU44RMbqloeqQcKx9CmF8smcj2_5rIY7AD0k2SN0NTW1EjWuemgYM4iIzz/w640-h377/monolith.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;font size=&quot;2&quot;&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Advantages of using Monolithic Architecture:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;I&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;t is simple to develop. Time and Resource required for a monolithic architecture is comparatively less&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Deployments are easy when we are using monolithic architecture, we just have to pack our codebase together and copy it to the server&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;As all the services are on the same server so problems of network latency and security are less&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Disadvantages of using Monolithic Architecture:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;For any new developer, it is difficult because he/she has to understand the functionality of the whole application, even if his/her work is related to a particular functionality&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;The whole application has to be redeployed on each update&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Reliability is an issue here. A bug in a certain feature of the application can bring down the whole application&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;If a single part/feature of the application is getting high traffic, then we need to scale up the whole application. This is inefficient and might lead to unnecessary allocation of resources&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Adapting to a new technology is difficult as because the whole application might get affected due to it&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;i&gt;&lt;b&gt;Microservice Architecture:&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In a microservice architecture, the idea is to split the whole application into a number of smaller services instead of building a single monolith application. These smaller services are called microservices. Each microservice is a small-application on its own having all the layers, i.e presentation layer, business layer, third-party layer and data-access layer and is deployed separately. These microservices communicate with each other via RPC or any message-based API.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In a Microservice architecture, instead of having a single database each service can have its own database. Although it might result in duplication of data but having a database per schema is needed if we want to benefit from microservice architecture. Another advantage of this is that a microservice can use the type of database that best suits its needs.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Have a look at the diagram below:&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP-dZOeHYTzVfTVwnTXg_JQgya2BYcLjORzjMzp6-TCd_whKTZznkjCU6NDhRSs1q8uUl8mCL3eJF63fpvP-otXG85pWqHMtuoGh25FWdPlehyI1Lsjpb71IAxA9r9K8Zom7wFK8x-6VCs/s625/micro.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;475&quot; data-original-width=&quot;625&quot; height=&quot;486&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP-dZOeHYTzVfTVwnTXg_JQgya2BYcLjORzjMzp6-TCd_whKTZznkjCU6NDhRSs1q8uUl8mCL3eJF63fpvP-otXG85pWqHMtuoGh25FWdPlehyI1Lsjpb71IAxA9r9K8Zom7wFK8x-6VCs/w640-h486/micro.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Here, an application is divided into four microservices - User Profile, Chat Service, Payment Service and Analytics. The Analytics and Payment services have a database of their own and the Chat and User Profile &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;services are using a shared database. Each of the microservices communicates with each other as per requirement. The clients access the microservices via an intermediary known as the API Gateway which is responsible for handling tasks like load balancing, caching, monitoring, etc.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Advantages of using Microservice Architecture:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;If we update any particular service, only that service needs to be redeployed instead of the whole application&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;For a new developer, it is easy because here he/she has to focus only on the particular service in which he/she will work. The working knowledge of the whole application is not necessary&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Microservices are fault-tolerant. If any particular service is down then also the other services continue to function&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Every microservice can be developed using technologies that best suits its needs. Like Analytics service can be built using Python and the Payment service can be built using Java&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;In a microservice architecture, the services can be scaled independently. If any particular service is receiving high traffic, only that particular service needs to be scaled up &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Disadvantages of using Monolithic Architecture:&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;As the no. of microservices increases the system becomes more complex. So, it becomes difficult to handle than a simple monolith application&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;In terms of network usage, it is costly as because each service continuously communicates with each other over the network via RPC&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;As there are inter-service communications, microservices are comparatively less secure than monolith applications&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Debugging in microservice applications is kind of challenging as because the flow of control may be over multiple services and it is difficult to find where the error actually occurred&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;i&gt;&lt;b&gt;When to choose what?&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;A Monolithic Application is best suited for applications that are simple and lightweight. If it has only a few functionalities and there is&amp;nbsp; not much prospect of the application evolving then using microservices might be overhead. Also when the development team is small and cohesive it is better to go with monolithic architecture.&lt;/span&gt;&lt;/font&gt; &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;On the other hand, if the application is an evolving application with lots of features and functionalities then Microservice architecture will help. When the team is large and diverse, then also adopting to microservice architecture is a good option.&lt;/font&gt;&lt;/span&gt; &lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;So, I hope after reading this article you can now understand the difference between monolithic and microservice architecture. We saw with detailed examples of how these two work and the advantages and disadvantages of each. Also, in the end, we discussed the scenarios about where to choose monolith and where to choose microservices. Do mention your thoughts and views in the comments. Stay safe and Happy Coding!&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font size=&quot;4&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/3215304492266300204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/monolithic-vs-microservices.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3215304492266300204'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3215304492266300204'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/monolithic-vs-microservices.html' title='Monolithic Vs Microservices Architecture'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_E1a4gABAoTiS6gUnkiQ4UiTTCt4BdgcyYDnMA4T4gT2Wh01xgFL0Dc4y_wZXBQvXQyz_BrZVZYfS_xTp42MpjSxAwOpwVYfz0eXLKVbv7pAyjrV9rb8J7shbRNHtQVNeWwMgrg8er-Yk/s72-w400-h241-c/micro-vs-mono.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-2596414096221626388</id><published>2020-06-05T13:01:00.001+05:30</published><updated>2020-06-07T21:32:00.572+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>A Beginner&#39;s Guide to Competitive Coding</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Want to start &lt;i&gt;&lt;b&gt;competitive coding&lt;/b&gt;&lt;/i&gt;? But not exactly sure where to start and how to progress? &lt;br /&gt;In this article, I will share some information and tips to help you get started with competitive coding. I have been into competitive coding for around 5 years now, have participated and ranked in many competitive coding contents like TCS Codevita, ACM ICPC, etc. The things I am going to share are mostly from my experience, which also includes some valuable tips which I have gained from other professional coders. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UqPbIQKiytv9k7HOtXqx3ALSZKEgMp0JNRJGNUeoRvPp79Urd3UGmhuuzfFpxP45M-vWbmqjAtbfaWiIy1T3bn3VLoSQ62vOun2EkVcCSU2R3gi36ygdhvEb-9CG0UVvlXmHlHucTBjj/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;445&quot; data-original-width=&quot;531&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UqPbIQKiytv9k7HOtXqx3ALSZKEgMp0JNRJGNUeoRvPp79Urd3UGmhuuzfFpxP45M-vWbmqjAtbfaWiIy1T3bn3VLoSQ62vOun2EkVcCSU2R3gi36ygdhvEb-9CG0UVvlXmHlHucTBjj/s320/cc.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Why to engage in competitive coding?&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Competitive Coding &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;is basically a mind sport where one needs to quickly implement solutions for some math puzzles or some task problems. You get a problem statement, you read that and then logically think of a way to solve the problem and then implement that logic by writing some lines of code.&lt;/span&gt;&lt;/font&gt; &lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;This helps you to develop your problem-solving skills and also increases your thinking capability. If you are into Competitive Coding it will surely help you in your career whether you are a Software Developer, Data Scientist or, a Network Security Engineer. Most companies hiring freshers from campus placements have a round where they test the student&#39;s coding skills, also for top product-based companies one has to go through an initial round of competitive coding.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Data-structure and Algorithms, why they are important?&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Well, if you want to excel in Competitive Coding then a proper understanding of Data-structure and Algorithms are must. Time constraint is an important factor while solving coding problems. By using a proper data-structure and implementing the best algorithm you can bring down the time complexity value of your solution(if you are not aware about time complexity, you can read about it &lt;a href=&quot;https://www.geeksforgeeks.org/understanding-time-complexity-simple-examples/&quot;&gt;here&lt;/a&gt;). Lets see an example of this.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Suppose we have a problem statement like this: &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;i&gt;We are given an array and a target number. We need to find two numbers in the array that sum up to the target number provided.&lt;/i&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;Example&lt;/b&gt;&lt;i&gt;&lt;b&gt;:&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;Array&lt;i&gt;: &lt;/i&gt;[1, 2, 3, 4, 5, 6, 7, 8, 9, 15] &lt;i&gt;, &lt;/i&gt;target-number&lt;i&gt;: 18&lt;/i&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Output&lt;/font&gt;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;: &lt;/font&gt;&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;[3,15]&lt;/font&gt;&lt;/span&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;b&gt;Solution 1:&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;pre style=&quot;overflow-x: scroll;&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getTwoValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;##driver main&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;__main__&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getTwoValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Here
 we can see in the getTwoValue() function one for-loop is running inside
 another for-loop. This will result in a time-complexity of &lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;O(n&lt;sup&gt;^&lt;/sup&gt;2)&lt;/b&gt;.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;b&gt;Solution 2:&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre style=&quot;overflow-x: scroll;&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;collections&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defaultdict&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getTwoValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tempDict&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defaultdict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;tempDict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tempDict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;remain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
     &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;p&quot;&gt;&lt;span class=&quot;c&quot;&gt;##driver main&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;__main__&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getTwoValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;targetSum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Here we can see in the getTwoValue() function we are using a hash-map. the variable tempDict is the hash-map being used here. Here, we can see there are two for-loops but they are independent of each other, i.e not nested inside one another, so as a result time-complexity here is O(n).&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;So, here we saw how using a proper Data Structure and implementing a different algorithm we reduced the time complexity of the problem from O(n^2) to O(n). So before just diving into competitive coding gain some knowledge on Data-Structures and Algorithm, it will surely help.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Which programming language should be used?&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Generally, if your concepts are clear, language doesn&#39;t matter for competitive coding. Most of the competitive coding platforms allows you to write code in any programming language you want. So, language is not a bottleneck.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Still many developers prefer languages which has a simple syntax and concepts like OOP can be implemented easily. Based on survey results from top coding platforms the top 3 languages used for competitive coding were &lt;b&gt;C++&lt;/b&gt;, &lt;b&gt;Java&lt;/b&gt; and &lt;b&gt;Python&lt;/b&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Platforms where one can practice competitive coding:&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;I will mention top 5 platforms which are mostly used my competitive coders:&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://leetcode.com/&quot;&gt;LeetCode&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;geeksforgeeks.org/&quot;&gt;GeeksForGeeks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;www.hackerrank.com&quot;&gt;Hackerrank&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.hackerearth.com/&quot;&gt;Hackerearth&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.codechef.com/&quot;&gt;CodeChef&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The information shared here in this article, I feel is enough to get you started with competitive coding. If you still haven&#39;t started it, do ASAP. It is fun and you will surely enjoy it. Stay safe and happy coding!!&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/2596414096221626388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/a-beginners-guide-to-competitive-coding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/2596414096221626388'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/2596414096221626388'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/06/a-beginners-guide-to-competitive-coding.html' title='A Beginner&#39;s Guide to Competitive Coding'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UqPbIQKiytv9k7HOtXqx3ALSZKEgMp0JNRJGNUeoRvPp79Urd3UGmhuuzfFpxP45M-vWbmqjAtbfaWiIy1T3bn3VLoSQ62vOun2EkVcCSU2R3gi36ygdhvEb-9CG0UVvlXmHlHucTBjj/s72-c/cc.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-3561155743242345903</id><published>2020-06-03T18:32:00.000+05:30</published><updated>2020-06-03T18:32:16.321+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>SOAP vs REST vs GraphQL : A Detailed Comparison</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;i&gt;&lt;b&gt;SOAP vs REST&lt;/b&gt;&lt;/i&gt; has been quite an issue for some time now. And now with Graphql gaining popularity, people have started to converse about &lt;i&gt;&lt;b&gt;REST vs GraphQL&lt;/b&gt;&lt;/i&gt;. In this article, we will do a comparison of SOAP vs REST and REST vs GraphQL. We will see the advantages and disadvantages of all three and when to choose what.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoVIBX0OWQJs0s8ZKq-GsY9CcuJ8evCVzZdt8THxi7J-Ty0NhnQsM5cgOT7DyuLbQKI_QOeSrnmDsQ0NYt9Kf6ePHFOZ1iuYC7t9ulKVUh-yGxE2Pen1Xbxfh5CRUsgP85IFcyAmfwCiIz/s1600/soap-rest-graphql.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;196&quot; data-original-width=&quot;628&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoVIBX0OWQJs0s8ZKq-GsY9CcuJ8evCVzZdt8THxi7J-Ty0NhnQsM5cgOT7DyuLbQKI_QOeSrnmDsQ0NYt9Kf6ePHFOZ1iuYC7t9ulKVUh-yGxE2Pen1Xbxfh5CRUsgP85IFcyAmfwCiIz/s1600/soap-rest-graphql.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
SOAP vs REST&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;About SOAP:&lt;/span&gt; &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;SOAP stands for Simple Object Access Protocol. It is basically a messaging protocol that was developed by Microsoft. It relies on XML heavily and defines a very strongly typed messaging framework. It is used for data exchange in a distributed environment. SOAP works with any of the application-level protocols like HTTP, TCP, SMTP, etc. The data which is returned is always in XML format. The structure of the XML of the request and response are explicitly defined. All of the SOAP specifications and definitions are developed and maintained by &lt;a href=&quot;https://www.w3.org/TR/soap12/&quot; target=&quot;_blank&quot;&gt;W3C (World Wide Web Consortium)&lt;/a&gt;. SOAP has strict rules and built-in comprehensive features in the form of security, transactions, and ACID (Atomicity, Consistency, Isolation ad Durability). For all these the complexity is higher and it requires more bandwidth and resources for processing.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;This is the XML structure of a SOAP response message from w3.org.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;overflow-x: scroll;&quot;&gt;&amp;lt;env:Envelope xmlns:env=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&amp;gt;
 &amp;lt;env:Header&amp;gt;
  &amp;lt;n:alertcontrol xmlns:n=&quot;http://example.org/alertcontrol&quot;&amp;gt;
   &amp;lt;n:priority&amp;gt;1&amp;lt;/n:priority&amp;gt;
   &amp;lt;n:expires&amp;gt;2001-06-22T14:00:00-05:00&amp;lt;/n:expires&amp;gt;
  &amp;lt;/n:alertcontrol&amp;gt;
 &amp;lt;/env:Header&amp;gt;
 &amp;lt;env:Body&amp;gt;
  &amp;lt;m:alert xmlns:m=&quot;http://example.org/alert&quot;&amp;gt;
   &amp;lt;m:msg&amp;gt;Pick up Mary at school at 2pm&amp;lt;/m:msg&amp;gt;
  &amp;lt;/m:alert&amp;gt;
 &amp;lt;/env:Body&amp;gt;
&amp;lt;/env:Envelope&amp;gt;&lt;/pre&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Envelop:&lt;/b&gt; It is the starting and ending tag of the whole message&lt;/li&gt;&lt;li&gt;&lt;b&gt;Header: &lt;/b&gt;It contains optional attributes, like meta-data, expiration date,etc.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Body:&lt;/b&gt; It contains the actual response data that is to be sent&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;Advantages:&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;SOAP has built-in security and error handling&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;Successful/Retry logic for message functionality&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;SOAP is transport-independent (can work with HTTP or TCP or UDP or SMTP)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;SOAP has built-in ACID compliance&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;

&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;Disadvantages:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;SOAP relies mainly on XML. XML parsing is a heavy operation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;It consumes more bandwidth and requires more computing power. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;h4&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span id=&quot;about-rest&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;About REST:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;
&lt;/ul&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;REST stands for Representational State Transfer. Unlike SOAP, REST is an architectural style to design &lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;APIs. We discussed the details of REST Architectural Constraints on our previous &lt;a href=&quot;https://readsngeeks.blogspot.com/2020/05/restful-api-architectural-constraints.html&quot; target=&quot;_blank&quot;&gt;article&lt;/a&gt;. We can say REST is a light-weight alternative to SOAP. Developers found SOAP to be inconvenient in some scenarios. Like, suppose someone writing code in JavaScript has to write lots of extra code to do a simple task because it is always required to create the standard XML structure. REST APIs are based on URI (Uniform Resource Identifier) and can use any data format like JSON, XML, TXT, etc., although JSON is most commonly used. REST APIs are simple and easy to scale. REST does not provide any built-in security or error handling. All these things have to be implemented additionally as per requirement by the developer. The objective of REST is to make data available as a resource by making API calls that use the well-known HTTP verbs like GET, POST, PUT, DELETE, etc.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;Below is a sample REST API response. This is one of Github&#39;s public API&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijOAR_Q6zftIMDdTfllaOv5CaNUgY1LZBPS0h_cp-M0JYArfSRWovH0rM_ac24rd4AfcxWmgWam9Zkebjh7Ol7F1kQPefQPqgnohiEKOInfhI9O21FbFvRZMjx-Jvfbd24-0yHqdJfRHLo/&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;830&quot; data-original-width=&quot;1197&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijOAR_Q6zftIMDdTfllaOv5CaNUgY1LZBPS0h_cp-M0JYArfSRWovH0rM_ac24rd4AfcxWmgWam9Zkebjh7Ol7F1kQPefQPqgnohiEKOInfhI9O21FbFvRZMjx-Jvfbd24-0yHqdJfRHLo/d/Screenshot+2020-05-30+at+6.29.35+PM.png&quot; title=&quot;A sample REST API response&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;Advantages:&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;REST is light-weight, flexible and scalable&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;REST supports all data types be it XML, JSON or TXT&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;REST APIs use a single uniform interface&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;In terms of design, REST is much closer to other web technologies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;Disadvantages:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;REST does not have any in-built features for security and error handling&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;REST is not suitable for distributed environments&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;br id=&quot;docs-internal-guid-d6612207-7fff-20a3-d3c7-a2e2f7c6c24d&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div align=&quot;left&quot; dir=&quot;ltr&quot; style=&quot;margin-left: 0pt;&quot;&gt;&lt;table class=&quot;table-resp table-hover&quot;&gt;
    &lt;thead style=&quot;background-color: #e0dfdc;&quot;&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;br /&gt;&lt;/th&gt;
        &lt;th&gt;SOAP&lt;/th&gt;
        &lt;th&gt;REST&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Design&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;It is a standardized protocol with well-defined rules&lt;/td&gt;
        &lt;td&gt;  It is an architectural style with certain constraints&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Functionality&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Function-driven (Data available through functional services)&lt;/td&gt;
        &lt;td&gt;Data-Driven (Data available as a resource)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Data Format&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;XML&lt;/td&gt;
        &lt;td&gt;XML, JSON, TXT, etc.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Caching&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Cannot be cached&lt;/td&gt;
        &lt;td&gt;Caching available&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Security&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;It has WS-Security with SSL support&lt;/td&gt;
        &lt;td&gt;SSL support and HTTPS&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Performance&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Requires more bandwidth and resources&lt;/td&gt;
        &lt;td&gt;It is lightweight and requires fewer resources&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Transfer Protocol(s)&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;HTTP, TCP, UDP or SMTP&lt;/td&gt;
        &lt;td&gt;HTTP&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;ACID Compliance&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Has in-built ACID Compliance&lt;/td&gt;
        &lt;td&gt;Does not have ACID compliance&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;h3&gt;REST Vs GraphQL&lt;/h3&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In the previous &lt;a href=&quot;#about-rest&quot;&gt;section&lt;/a&gt; we discussed about REST in detail, so now lets focus on GraphQL.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;b&gt;About GraphQL:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;GraphQL is a relatively new technology that has made a lot of buzz. It is a modern way of developing and querying APIs. GraphQL is developed and maintained by Facebook which made its stable release in 2018. GraphQL was developed to overcome some of the shortcomings of REST. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;One thing about REST is that we end up creating multiple endpoints to fetch data that are structurally different but are relatable. Sometimes we end up over-fetching or under-fetching the data. Let us understand this by an example. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Here, we will have a look at GitHub&#39;s public API V3.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;2&quot;&gt;One end-point is&lt;/font&gt;&lt;/span&gt; &lt;/span&gt;&lt;font size=&quot;4&quot;&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;code&gt;GET /search/users&lt;/code&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;4&quot;&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;code&gt;?q=John&lt;/code&gt;&lt;/span&gt;&lt;/font&gt;. &lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;This end-point returns us a list of users with a unique username attribute for each user with the name &#39;John&#39;. Now suppose we want to get the repositories of that user. For that, there is another end-point&lt;/span&gt;&lt;/font&gt;&lt;code&gt; &lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;font size=&quot;4&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;GET /users/:username/repos&lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;. &lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;So, here we have two different end-points. Also, like for the first end-point we will get all the attributes of that user like name, email, location along with the username. But we were interested in getting only username. So this is kind of over-fetch.&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;With GraphQL the client is able to fetch all the required information with a single call, rather to make multiple REST requests to fetch the same. While requesting the client can specify the data he wants and GraphQL will return only that data. Also, there is only one end-point. The GraphQL server will first check the data the client has specifically requested for and then query it out accordingly. &lt;br /&gt;See this example:&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;{
 query getUserAndRepo{
   getUser(name: &quot;John&quot;){
   username
    repos(){
     id
     title
    }
   }
 }
}&lt;/pre&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;In GraphQL, with such similar query we can get the id and title of repositories of the user named &quot;John&quot;. This can be achieved with a single call, also there will be no data over-fetch or under-fetch. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Now, all these doesn&#39;t mean that REST will become obsolete and GraphQL will be used everywhere. We should keep in mind that whenever any new technology comes up it too has its own pros and cons.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;

&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;Advantages:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;GraphQL allows us Declarative Data fetching, i.e client can specify the data it needs along with specific entities and attributes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;No data over-fetching or under-fetching in GraphQL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;GraphQL is a strongly typed query language. Being strongly typed, it is less error prone &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;GraphQL is version free, the structure of the response data is determined entirely by the clients query. Any change/modification on server code does not affect the structure of the response data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;, sans-serif;&quot;&gt;&lt;b&gt;Disadvantages:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;A GraphQL query can face performance issues if a client asks for too many fields at once&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;GraphQL cannot cache response data. To implement caching certain libraries like Apollo-Client are required&lt;/span&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
  
  &lt;table class=&quot;table-resp table-hover&quot;&gt;
  &lt;thead style=&quot;background-color: #e0dfdc;&quot;&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;br /&gt;&lt;/th&gt;
        &lt;th&gt;REST&lt;/th&gt;
        &lt;th&gt;GraphQL&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Type&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;  It is an architectural style with certain constraints&lt;/td&gt;
        &lt;td&gt;It is a specification, which can be implemented by a language&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Endpoint&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Multiple endpoints for multiple resources&lt;/td&gt;
        &lt;td&gt;Only a single endpoint&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;HTTP Methods&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;GET, POST, PUT and DELETE all can be used&lt;/td&gt;
        &lt;td&gt;Only POST is used here&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Caching&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Caching available&lt;/td&gt;
        &lt;td&gt;Normally not available. Can be made available via libraries on top&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Data Fetching&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;Specific Data on a single API call&lt;/td&gt;
        &lt;td&gt;Fixed Data with multiple API calls&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  
  &lt;/table&gt;
  &lt;div&gt;&lt;h2&gt;&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/h2&gt;&lt;h2&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;font size=&quot;4&quot;&gt;Where to use what?&lt;/font&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;The answer to this question is based on what use-case do you have. All SOAP , REST and GraphQL have its pros and cons. &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;SOAP is mostly used for enterprise level application which require high security and complex transactions are involved. API for payment gateways, financial applications, CRM applications, etc. mostly use SOAP.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;REST on the other hand provides point to point communication. Most public APIs provided by organizations are REST APIs. When flexibility and scalability is desired then REST API is a good choice.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;GraphQL as we mentioned makes querying simpler and helps the client to get the data as per its needs. But GraphQL does not give any significant advantage over REST performance wise, unless the application is executing like a millions of queries per second.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;Hope after reading this article you get a clear picture on the difference between SOAP, REST and GraphQL and also get a understanding about the pros and cons of each of them. Do mention your thoughts in the comments. If you like it do subscribe for more articles on software development stuffs. Also, I&#39;d like to grow my readership, if you enjoyed this article, share it with a friend! Stay safe and Happy Coding!&lt;/span&gt; &lt;/font&gt;&lt;br /&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;code&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;font size=&quot;4&quot;&gt;&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/3561155743242345903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/soap-vs-rest-vs-graphql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3561155743242345903'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/3561155743242345903'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/soap-vs-rest-vs-graphql.html' title='SOAP vs REST vs GraphQL : A Detailed Comparison'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoVIBX0OWQJs0s8ZKq-GsY9CcuJ8evCVzZdt8THxi7J-Ty0NhnQsM5cgOT7DyuLbQKI_QOeSrnmDsQ0NYt9Kf6ePHFOZ1iuYC7t9ulKVUh-yGxE2Pen1Xbxfh5CRUsgP85IFcyAmfwCiIz/s72-c/soap-rest-graphql.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-834065097905127509</id><published>2020-05-28T19:33:00.000+05:30</published><updated>2020-05-28T21:41:03.419+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="books"/><title type='text'>Elon Musk : A biography by Ashlee Vance</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div id=&quot;docs-internal-guid-8bda5dd3-7fff-8765-bea1-c9d6072a6f0a&quot; style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The book &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Elon Musk&#39;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;is an authorized biography of one of the most interesting and innovative entrepreneurs of our generation.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCIbQQ1FtXF3LI7L7IO55X2UKo3PngzOQ1ciJCb0QuCF2_3lU2yXB5ptnDaFHXtmphoxFE-ATdFD0Bhjl5OSQwQlHy4KIEZJRIOf9t0ez0uIzAe8VoJaIul3NSN3pLD4nN8BXn7_syYKo3/s1600/elonMain.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;803&quot; data-original-width=&quot;602&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCIbQQ1FtXF3LI7L7IO55X2UKo3PngzOQ1ciJCb0QuCF2_3lU2yXB5ptnDaFHXtmphoxFE-ATdFD0Bhjl5OSQwQlHy4KIEZJRIOf9t0ez0uIzAe8VoJaIul3NSN3pLD4nN8BXn7_syYKo3/s320/elonMain.jpg&quot; width=&quot;239&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span id=&quot;goog_328820038&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_328820039&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This book gives the interesting and inspiring story of Musk&#39;s life, from his childhood to the part where he spent significant time in &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Zip2&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Paypal &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;and then onto &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Tesla&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;SpaceX&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, and &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Solar City&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. The author, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Ashlee Vance&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, an American business columnist and author had to put up quite an effort and time to gather all the content that is presented in this book. He interviewed mostly employees of SpaceX and Tesla, also Elon&#39;s mother, and at the end Elon himself.&amp;nbsp; The first edition of the book was published in May 2015.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The book takes us back to his days in South Africa. Born in 1971, he grew up in Pretoria. From childhood itself, young Elon had a keen interest in technology and used to fantasize about Space and battles between Evil and Good. He was into it so much that at the age of 12 he developed a game called &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Blaster &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;on his own&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The game&#39;s objective was to fight and destroy an alien space freighter with bombs and beam machines. In 1984, the public first met Elon Musk, courtesy of this video game, when a South African Trade publication published the source code of the game. The book tells us in detail about Maye Musk, his mother and his father Errol Musk, and gives a brief family history of both of them. It takes us through Elon&#39;s childhood in Africa about his High School experiences and growing up with his brother Kimbal Musk. After this at the age of seventeen, Elon left South Africa for Canada.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;While reading you will get to know why this escape to Canada was not a well-thought plan for Elon. He had a long Canadian ancestry from his mother&#39;s side. His mother had family all across Canada. As the book progresses we get to know how Elon ended up with one of his cousins and how he took up different kinds of jobs for survival. Elon then ended up rolling at Queen&#39;s University in Kingston. During this time his brother Kimbal also went to Canada. Elon after two years Queen&#39;s University went to the University of Pennsylvania. He went in the pursuit of a dual degree, an economics degree from Wharton School, and then a bachelor&#39;s degree in Physics from the University of Pennsylvania. As the book progress, you will see how always had a desire to do something that would have an effect on the world. At each and every step and action mentioned in the book, you will get to know the vision that Elon Musk always had. At a point in time, Elon considered getting into video game business but later backed off because he thought by getting into video games would not help him to create a big effect on the world.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div id=&quot;docs-internal-guid-abd177c7-7fff-d995-5f43-8fa19fb81d69&quot; style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span id=&quot;docs-internal-guid-98f66c82-7fff-9b2c-b8e6-611abd24aa74&quot; style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The book then guides us to Elon&#39;s first startup, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Zip2, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;which was founded by him and Kimbal. Zip2 was basically a searchable directory of businesses plotted on a digital map. The story behind Zip2 coming into existence is a pretty interesting one that the books present to us in a pleasant format. For the initial phase, they borrowed $28k from their father. They worked day and night to make Zip2 a success. Musk did the original coding behind the service and Kimbal managed the sales operation. Over the years Zip2 achieved remarkable success. In 1999, the PC maker company acquired Zip2 for an amount of $307 million. Musk made $22m from the sale of Zip2. With that Musk founded &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;X.com&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; in March 1999, which was an online financial services and e-mail payment company.&amp;nbsp; After a year X.com merged with &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Confinity &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;and the merger was renamed to &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;PayPal&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; in 2001. Elon had an interesting journey while being the &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;CEO of PayPal. But due to disagreements with other company executives Musk was removed from the CEO position, but he remained on board. Later PayPal was acquired by &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;eBay&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; $1.5b and Musk made $165m from the deal.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span id=&quot;docs-internal-guid-dd2527a3-7fff-3a40-7ec2-c417a9d72586&quot; style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;After this, the book presents to us Elon&#39;s journey in building &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;SpaceX. &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In 2001 Elon took up a project called Mars Oasis, whose purpose was growing food crops on Martian regolith. For that, he contacted Russian Companies to buy rockets. After many dealings, a Russian Company offered one rocket for $8m. Elon thought it was too much and called off the deal. Then an idea stuck, he could start a company that could build the affordable rockets he needed. With $100m from his early ventures, Elon founded SpaceX in May 2002. Elon believed the key to making space travel affordable was to make rockets reusable. As you read you will get to know the dedication and hard work he put in order to make his vision a reality. After many failed attempts to launch their first rocket, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Falcon 1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, SpaceX made its successful launch at its fifth try. After that SpaceX launched its Falcon 9 rocket and &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Dragon&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, its first spacecraft&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8aKIYeRRTsjNI-9SaylzL9HC4M5ZOrDw0001BKPMTjG_8ca4gLNs-ZEu_Wlc_N9Ukh_Y_SIF5N10WoeFgAeeV7Edv3HVZM9ZvMgdVaafnGpIBbw3L4tuMNP_BuQwVsK-uwd7tbiwpfPW-/s1600/musk1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;1104&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8aKIYeRRTsjNI-9SaylzL9HC4M5ZOrDw0001BKPMTjG_8ca4gLNs-ZEu_Wlc_N9Ukh_Y_SIF5N10WoeFgAeeV7Edv3HVZM9ZvMgdVaafnGpIBbw3L4tuMNP_BuQwVsK-uwd7tbiwpfPW-/s320/musk1.jpg&quot; width=&quot;220&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: justify;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;docs-internal-guid-abd177c7-7fff-d995-5f43-8fa19fb81d69&quot; style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;After this, the book leads us to Elon&#39;s next big venture &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Tesla&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. Unlike SpaceX, Elon was not the founder of Tesla. Originally Tesla Motors was started in July 2003 by Martin Eberhard and Marc Tarpenning. Elon lead Series A round of investment in Tesla and joined Tesla&#39;s board of directors. After a few issues and a financial crisis, Eberhard, the then CEO had to leave the company after that Elon assumed the role of CEO in 2008. Elon&#39;s plan was to make money by first building and selling an electric sports car and then use that money to build affordable cars. The book takes you through the whole development journey of Tesla&#39;s first sports car, the Tesla Roadster in 2008. After that Tesla bought its four-door Model S sedan into the Market in 2012. In a few years, the sale of Tesla increased so much that they decided to open up a network of supercharger stations all across the US. While reading through this part of the book, you get to see how Elon managed his time being CEO of two giant companies. Tesla&#39;s innovation was on a different level. They kept on adding/upgrading features to its cars be it a functional feature or a more advanced technical feature, and one of the main things that kept Tesla going was Elon&#39;s vision and determination.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: justify;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;docs-internal-guid-4991870b-7fff-7f94-707f-9fed5b1beb2e&quot; style=&quot;line-height: 1.38; margin-bottom: 12pt; margin-top: 12pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;We have seen many global entrepreneurs and industrialists, but none like Elon Musk have touched upon multiple domains and have achieved success in all. Personally, what I like most about Elon Musk is his never give up attitude, if he figures out something is possible he doesn&#39;t let go until that is achieved. The author did a great job in bringing out this inspirational story of Elon Musk and also has touched upon his personal life too. This book is a must-read for those who are into the early stages of entrepreneurship. Also, if anyone wants to know the man behind Tesla, SpaceX and SolarCity this book is the best resource for you. My main take away from the book can be expressed by the following quote by Elon himself.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: Times, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;Failure is an option here. If things are not failing, then you are not innovating enough.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-family: Times, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp; - Elon Musk&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: justify;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;st&quot;&gt;&lt;span class=&quot;st&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: nowrap;&quot;&gt;&lt;span class=&quot;st&quot;&gt;&lt;span class=&quot;st&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: nowrap;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span id=&quot;docs-internal-guid-3482d526-7fff-04de-3665-71d880e71509&quot; style=&quot;background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Do give this book a read and mention how was your experience. Anyone who has already read this, comment out your views as well. Till then, Happy Reading!!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/834065097905127509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/elon-musk-biography.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/834065097905127509'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/834065097905127509'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/elon-musk-biography.html' title='Elon Musk : A biography by Ashlee Vance'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCIbQQ1FtXF3LI7L7IO55X2UKo3PngzOQ1ciJCb0QuCF2_3lU2yXB5ptnDaFHXtmphoxFE-ATdFD0Bhjl5OSQwQlHy4KIEZJRIOf9t0ez0uIzAe8VoJaIul3NSN3pLD4nN8BXn7_syYKo3/s72-c/elonMain.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-5771201653467393345</id><published>2020-05-24T10:51:00.001+05:30</published><updated>2020-05-25T01:15:29.530+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>RESTful API - Architectural Constraints</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;In my last article, I wrote about the basics of REST API. Like what is a RESTful API and reasons behind naming it so. If you have missed that, check it out &lt;a href=&quot;https://readsngeeks.blogspot.com/2020/05/rest-api-basics.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. I mentioned the following line in my last post:&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;b&gt;REST&lt;/b&gt; is not any standard or technology rather it is an architectural style for developing API  based on a standard set of principles.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXHJpnJQtk22pqtICiSBbYOgA62xDhRADmSMUjxWV5njk7o0iyZCdzBYQwt1YOXmlrbQ1i4uy_oMgoj2wEqGD6RRNTJmjOiUHzdFlQuKcnwI4SM7rO0iGqTCfclT648NqqAXYTc8sNyCuV/s1600/rest.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;300&quot; data-original-width=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXHJpnJQtk22pqtICiSBbYOgA62xDhRADmSMUjxWV5njk7o0iyZCdzBYQwt1YOXmlrbQ1i4uy_oMgoj2wEqGD6RRNTJmjOiUHzdFlQuKcnwI4SM7rO0iGqTCfclT648NqqAXYTc8sNyCuV/s1600/rest.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;So in this article, let&#39;s see what are those architectural constraints and principles that make an API RESTful.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;There are 6 design principles, also known as REST Architectural constraints. These principles were described by Roy Fielding in his dissertation &lt;a href=&quot;https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm&quot; target=&quot;_blank&quot;&gt;paper&lt;/a&gt;, which was published in 2000. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;These following 6 architectural constraints makes any API service RESTful:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;#uniform&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Uniform Interface&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;#client-server&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Client-Server&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;#stateless&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Statelessness&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;#caching&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Caching&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#layered&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;b&gt;Layered System&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#ondemand&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;b&gt;Code on Demand&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;/span&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span id=&quot;uniform&quot; style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;b&gt;Uniform Interface&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkv1V0rfY4lAcfyqSaNSpE-xNPzxpwB2jc58lqkl1ZeOoFhMYD1aT1gZyg5mbymr9y5JiusF7YRjFEihkpzVH6Xt5np2t3KOM0WRQuH7n5ZYWnw68uo2pCwqFnt1D2GnmPNqecbq0aKty7/s1600/interface.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;273&quot; data-original-width=&quot;231&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkv1V0rfY4lAcfyqSaNSpE-xNPzxpwB2jc58lqkl1ZeOoFhMYD1aT1gZyg5mbymr9y5JiusF7YRjFEihkpzVH6Xt5np2t3KOM0WRQuH7n5ZYWnw68uo2pCwqFnt1D2GnmPNqecbq0aKty7/s1600/interface.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Here
 interface refers to a contract for communication between the API 
provider and the consumer. The API provider and consumer here share a 
common technical interface, which is well-defined using HTTP methods and
 media types.&lt;br /&gt;This interface states that inside the system there are 
resources and to get the state of a resource or to manipulate it there 
has to be an URL that the consumer can use. &lt;br /&gt;On the server-side data is stored in the database and there is some sort of database representation. Whereas on the consumer/client-side data may be required in formats like JSON, XML, TXT, etc., which may be different from the way data is stored in the database. So, the idea here is that &lt;/span&gt;there must be specific guidelines for resource representation.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Also,
 there have to be some self-descriptive messages, known as metadata. This metadata helps both the producer and consumer to process the information in the request or response object. This metadata is transferred via HTTP headers. Like &lt;b&gt;&lt;i&gt;Content-Type &lt;/i&gt;&lt;/b&gt;which tells about the data format(JSON/XML,etc.),&amp;nbsp;&lt;b&gt;&lt;i&gt; HTTP status code &lt;/i&gt;&lt;/b&gt;which tells the status of the request like 200 for Success, 404 for Not Found, also&lt;b&gt;&lt;i&gt; Host &lt;/i&gt;&lt;/b&gt;which indicates the IP of the server.&lt;br /&gt;The last thing about this is the &lt;b&gt;Hypermedia&lt;/b&gt;,
 which states that the server not only sends response data but also sends the possible actions, which the client can take on the data, 
whenever required. This is also referred to as &lt;b&gt;HATEOAS &lt;/b&gt;(&lt;span class=&quot;ILfuVd&quot;&gt;&lt;span class=&quot;e24Kjd&quot;&gt;Hypermedia as the Engine of Application State&lt;/span&gt;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;/li&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;/span&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span id=&quot;client-server&quot; style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Client-Server&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx3o4hTXoj-5kGjscjPshAjB_YwBWcOGjlX0nDg0JiaUssCTGLmoyZqYEVrnikO_J5ZHcMOMHTTZFG4Bfnz0_5QEj1miHFT90g8YFM4KAosSONtJZ6qwwflIr9XqM4GoijWjrtA6knlzsL/s1600/cliebt-server.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;171&quot; data-original-width=&quot;531&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx3o4hTXoj-5kGjscjPshAjB_YwBWcOGjlX0nDg0JiaUssCTGLmoyZqYEVrnikO_J5ZHcMOMHTTZFG4Bfnz0_5QEj1miHFT90g8YFM4KAosSONtJZ6qwwflIr9XqM4GoijWjrtA6knlzsL/s400/cliebt-server.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;The
 Client-Server architecture states that we have a client and a server working independently. The client connects to the server via a uniform interface. The client and server must not reside in the same process. 
All communication between them must happen via RPC over HTTP. &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;This
 the architecture ensures that client application and the server must be 
able to evolve separately without any dependency on one another, as long
 as the uniform interface is not altered.&lt;/span&gt;&lt;/li&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;/span&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span id=&quot;stateless&quot; style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;b&gt;Statelessness&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Statelessness
 means that the server will not store any information regarding the latest request made by the client. There will be no sessions and no histories. Every client request will be treated as a new request.&lt;br /&gt;If the end-user wants a stateful application, then the client application needs to &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;manage
 the state of the application. Like, if the user wants an application 
where the user logs in and performs actions which are authorized to that user only, then &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;in
 each request made by the client should contain all the necessary 
the information which is needed by the server to process the request, like 
authentication tokens, authorization details, etc. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;/span&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span id=&quot;caching&quot; style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Caching&lt;/span&gt;&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYszGySVOVZ4kZrn4MF2Ldhr0SSY0_U_eY_1X53jlO30r7sq3LNYQ5Yx-LsJX094brsTDfDjvj0U_wed6jHcnXlpdXxmelpOf4PWxlCpcZz0L9BJRG96TWsTM7_uMESLUFUm-FumD_iF1G/s1600/cache.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;276&quot; data-original-width=&quot;731&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYszGySVOVZ4kZrn4MF2Ldhr0SSY0_U_eY_1X53jlO30r7sq3LNYQ5Yx-LsJX094brsTDfDjvj0U_wed6jHcnXlpdXxmelpOf4PWxlCpcZz0L9BJRG96TWsTM7_uMESLUFUm-FumD_iF1G/s400/cache.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Caching is the ability to store copies of frequently accessed data in several places along with the request-response path.&lt;br /&gt;In
 terms of REST APIs, caching is storing the response of APIs in an 
in-memory or distributed system, so that response can be fetched from 
the stored system within a short amount of time. Caching can improve 
performance and achieve higher scalability on the server-side.&lt;br /&gt;The architectural constraint for caching states that the server should mark the responses as cacheable or non-cacheable. It can be achieved by the server using HTTP headers.&lt;/span&gt;&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Cache-Control: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;With this header, the server defines the policy for the cache. Like who can cache the data, for how long data can be cached, etc.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Expires: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;This tells the client when the cached resource will get expired&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Last-Modified: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;With this header, the server tells the client when a resource in the cache was last modified&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;ETag:&lt;/b&gt; This is a unique identifier associated with a resource. It can be any unique id or name &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt; &lt;/span&gt;&lt;ul&gt;&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span id=&quot;layered&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Layered System&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggejOgE5ARCRHE7uboiloahcBPbnSvByaijowlvxd4cCr2gSYrXpnBFHl0C8JovfUeGo4-6AVytH1asNDziuRw6H-J7gpn0cbi9Pg-joB40wjsKKSQe0NPh3THpzbu7rPaLJzGaPRlT4zZ/s1600/layred.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;267&quot; data-original-width=&quot;721&quot; height=&quot;147&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggejOgE5ARCRHE7uboiloahcBPbnSvByaijowlvxd4cCr2gSYrXpnBFHl0C8JovfUeGo4-6AVytH1asNDziuRw6H-J7gpn0cbi9Pg-joB40wjsKKSQe0NPh3THpzbu7rPaLJzGaPRlT4zZ/s400/layred.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;This
 architectural constraint states that the client-server architecture should consist of multiple layers. No one layer should be able to see past its immediate next layer. One thing not allowed is that the client is directly connected to the app server. One thing that is required here is that the client must not connect directly to an App server because if this happens then the client has to carry out request/load distribution, which is not desirable. &lt;br /&gt;The benefits of layering are 
that it simplifies the architecture and hides the complexity of the 
various layers and also, the architecture can easily change as per needs
 by adding or removing any layer. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span id=&quot;ondemand&quot; style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Code on Demand (Optional)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;This
 is an optional constraint. This constraint states that the server can extend the client&#39;s functionality by sending executable code along with the data in response. Some examples of code on demand are Java Applets, 
JavaScript snippets, etc.&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;All the above constraints (except point 6) must be followed to build a truly RESTful API.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;These are the basic concepts that a developer should have knowledge of before indulging in advanced REST API development. Next up I will be sharing an article on hands-on development of a REST API and also deploying it to a cloud server.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;So do subscribe. Also, I’d like to grow my readership, If you enjoyed this blog post, share it with a friend! Stay safe and Happy Coding!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/5771201653467393345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/restful-api-architectural-constraints.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5771201653467393345'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5771201653467393345'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/restful-api-architectural-constraints.html' title='RESTful API - Architectural Constraints'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXHJpnJQtk22pqtICiSBbYOgA62xDhRADmSMUjxWV5njk7o0iyZCdzBYQwt1YOXmlrbQ1i4uy_oMgoj2wEqGD6RRNTJmjOiUHzdFlQuKcnwI4SM7rO0iGqTCfclT648NqqAXYTc8sNyCuV/s72-c/rest.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-5834561355481350575</id><published>2020-05-13T19:01:00.000+05:30</published><updated>2020-05-14T10:08:24.267+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tech"/><title type='text'>RESTful API Services - The Basics</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Most of you, especially those who have a keen interest in web development, have come across the term &lt;b&gt;&quot;REST API&quot;&lt;/b&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Overall it serves the purpose of fetching data from a source on the internet and we use that data in building our own applications. But there is certainly more to that.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;In this article, I will try to cover some of the basics of REST APIS, like what is a REST API and why it is called so, formats in which data transfer happens, and in the end, we will do an anatomy of a full REST API Request.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;So, let&#39;s get started&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;First and foremost,&lt;/span&gt; &lt;b&gt;&quot;What is an API?&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Well, to put it in simple terms an &lt;b&gt;API (Application Programming Interface)&lt;/b&gt; is like a user-interface to raw data and it is for the use of applications rather than for the use of humans. Also, there exists a well-defined agreement between the API producer and consumer, like in which format data will be exchanged between the parties, some authorization tokens/cookies in the request header, etc.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;Now &lt;b&gt;REST&lt;/b&gt; stands for &lt;b&gt;Representational State Transfer.&lt;/b&gt; To understand what do we mean by a representational state, let&#39;s touch upon the concepts of &lt;i&gt;entity&lt;/i&gt; and &lt;i&gt;attributes &lt;/i&gt;of DBMS. An&lt;i&gt; &lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;entity, &lt;/i&gt;as we know&lt;i&gt;,&lt;/i&gt; is a real-world object, and attributes are the properties that define the entity. Like a car is an entity having attributes like manufacturer, color, model no., etc as it&#39;s attributes. In other words this model no., manufacturer, color, etc. uniquely represents a car, so we say all these attributes together form the representational state of the car.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Have a look at this image below:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdlVVlxRXKL2icgP-2tycpZ_nNuA47ilS_JcH03pOCdDRm02M7wG5Am-dZ96jWwSyUNzwWzSppPXfr-oCVcmwzJlgiGpCiK0DZcEURQSFCG06CaUc_tNOcxRABtP_yBo14UYWC_Vv-B3Az/s1600/rest-arch.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;530&quot; data-original-width=&quot;768&quot; height=&quot;440&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdlVVlxRXKL2icgP-2tycpZ_nNuA47ilS_JcH03pOCdDRm02M7wG5Am-dZ96jWwSyUNzwWzSppPXfr-oCVcmwzJlgiGpCiK0DZcEURQSFCG06CaUc_tNOcxRABtP_yBo14UYWC_Vv-B3Az/s640/rest-arch.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Here, we have an entity Book. Its attributes are ISBN, title, edition, category, and author. So together these attributes form the representational state of each book. Now suppose we have an API in which we request with an ISBN and get back the details of the book, i.e. the current representational state of the book. What the API does here it takes the ISBN, queries the database with that ISBN and returns the representational state of the book that matches the ISBN. So, the API is a REST API as it transfers the representational state of the book from the database to the client.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Another aspect here is about the format of the data being transferred through a REST API. Well, REST API doesn&#39;t have any standard data format. A REST API is supposed to accept data in any format and send back the response in any format. Generally, a REST API has two parts to it, one it queries the database and gets the data row(s), and then there is a logical part that forms the response data in a specific format like JSON, XML or Text format.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvr2FbWTlhuDfdraoLY4KRyAHzhUiDsTNamM5UK1Qu3errNM0GPIem2eWCsWI2NAugWmiotHS6v5GYLxnBJEpTWIIXKUGUhU4pjTE6_C0jTCiqZLgB7bivt6-prEB8Y8TMt2WYKvotzRY_/s1600/data-arch.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;386&quot; data-original-width=&quot;744&quot; height=&quot;332&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvr2FbWTlhuDfdraoLY4KRyAHzhUiDsTNamM5UK1Qu3errNM0GPIem2eWCsWI2NAugWmiotHS6v5GYLxnBJEpTWIIXKUGUhU4pjTE6_C0jTCiqZLgB7bivt6-prEB8Y8TMt2WYKvotzRY_/s640/data-arch.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Now let&#39;s look at an actual REST API&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;GET https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants+in+Sydney&amp;amp;key=AB123z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;This is an API provided by Google Maps Platform. Here &#39;GET&#39; represents the HTTP Method. There are no. of HTTP Request&lt;b&gt; &lt;/b&gt;Methods to indicate the desired action. We can learn more about HTTP Request Methods &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods&quot;&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;The anatomy of the API is as follows: &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Root Endpoint:&lt;/span&gt; &lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Here&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;https://maps.googleapis.com/ &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;is the root endpoint. For a particular API provider, the root endpoint is the same.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Path: &lt;/b&gt;After the root endpoint, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;maps/api/place/textsearch/json &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;part is the API path. The path will be different for different APIs by a particular provider. One thing to note here is the &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;/json &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;is a path variable. In this API, this particular variable denotes the data format in which the response will be returned. We can put &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;/xml &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;here to get the response back in XML format.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Parameters&lt;/b&gt;: The part&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt; query=restaurants+in+Sydney&amp;amp;key=AB123z &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;are the query parameters.&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;These are&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt; in key-value pairs. Apart from query parameters, there can be body parameters that are sent in the request body.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;One thing to remember about REST API  is:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0px; background-color: white; display: inline !important; float: none; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;REST&lt;/b&gt; is not any standard or technology rather it is an architectural style for developing API  based on a standard set of principles. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;These things will help us to get a basic understanding of REST APIs. Although, there are many other things related to it, like architectural constraints, API security, and API Management. In the next article, I will be sharing REST API principles and architectural constraints, so do subscribe. Till then, Stay Safe and Happy Coding!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/5834561355481350575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/rest-api-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5834561355481350575'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/5834561355481350575'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/rest-api-basics.html' title='RESTful API Services - The Basics'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdlVVlxRXKL2icgP-2tycpZ_nNuA47ilS_JcH03pOCdDRm02M7wG5Am-dZ96jWwSyUNzwWzSppPXfr-oCVcmwzJlgiGpCiK0DZcEURQSFCG06CaUc_tNOcxRABtP_yBo14UYWC_Vv-B3Az/s72-c/rest-arch.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5795907029429874864.post-6340654364041052608</id><published>2020-05-02T00:31:00.000+05:30</published><updated>2020-05-09T23:59:11.407+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="books"/><title type='text'>3 books which can help you develop your personality during this lockdown period!</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt;Are you an avid reader?&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;If yes, then I am sure in this quarantine period you are making most of your book reading habit.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Well, I also have been reading lots of books recently. Mostly books on personality development and along with that biographies and autobiographies of some famous and successful people. &lt;br /&gt;Many people ask me why do I prefer reading mostly all these non-fiction books and not novels and fiction books. Well, to be honest, I also read novels too, but less. Reading any kind of book always adds values and is a good form of recreation too.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt; I prefer books related to personal development because it helps me grow. It creates a different mindset. Different books contain articles that will touch different areas of life and add values in that area. And reading biographies/autobiographies of successful people helps us to relate to situations in our life. We all have heard the saying &quot;Learn from your mistakes&quot;, but what I feel is we can learn from the mistakes many of these successful people did and how did they overcome it.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgObyHt2UdT3iFajxDqWIZ_X-oPliu_4s_6KD2LH8HWj5zxD1VpvUBB1BMv51Di_14iDAWTqd_II5u_A4Hu1bsLHG70McfiNbU0ScYgLq_gjGcEyCq9jCJcpw3UnrmzR7JS9x0vKB-s-SVB/s1600/Screenshot+2020-05-01+at+10.18.57+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;447&quot; data-original-width=&quot;598&quot; height=&quot;239&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgObyHt2UdT3iFajxDqWIZ_X-oPliu_4s_6KD2LH8HWj5zxD1VpvUBB1BMv51Di_14iDAWTqd_II5u_A4Hu1bsLHG70McfiNbU0ScYgLq_gjGcEyCq9jCJcpw3UnrmzR7JS9x0vKB-s-SVB/s320/Screenshot+2020-05-01+at+10.18.57+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;Recently I have completed the following three books. I found all these books of great value. I will briefly share details about each of them:&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;a href=&quot;https://www.amazon.in/Magic-thinking-Big-David-Schwartz/dp/1785040472&quot;&gt;THE MAGIC OF THINKING BIG&lt;/a&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh96NlrZTWJsvqR5ZXEr2cDIa4qJGqyOMUjdlD1HLIZAbfSZtXSN9SwvsnOlDpn_2XFbCcI2Z8hEhPpvVUfCz-qYc0dqZlCAzxbU24_KcMUYKp1dSCjVFOxfN2yFF95VLJzgakolylsqNPB/s1600/magic+of+thinking+big.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;499&quot; data-original-width=&quot;318&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh96NlrZTWJsvqR5ZXEr2cDIa4qJGqyOMUjdlD1HLIZAbfSZtXSN9SwvsnOlDpn_2XFbCcI2Z8hEhPpvVUfCz-qYc0dqZlCAzxbU24_KcMUYKp1dSCjVFOxfN2yFF95VLJzgakolylsqNPB/s320/magic+of+thinking+big.jpg&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: small;&quot;&gt;This
 book is written by David Schwartz is the best out there which helps us to understand our true potential. The author is a Ph.D. from Georgia State 
University and is a renowned life strategist. Once you have read the book you will be filled with positivity. There are many chapters in this book, each chapter touches upon a point where negativity can bring us down and how positive thinking can help us to come out of it. There are case studies and real-life examples by which the author helps us to defeat disbelief and the negative power it creates. It helps in effective decision making and will help build leadership qualities too.&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; One must give this book a read if he/she wants to capitalize on the power of positivity.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;&lt;b&gt; &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;

&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt; &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;a href=&quot;https://www.amazon.in/Think-Grow-Rich-Napoleon-Hill/dp/8192910911/ref=sr_1_1?crid=3FPFRMD1JTUNE&amp;amp;dchild=1&amp;amp;keywords=think+and+grow+rich+by+napoleon+hill+english&amp;amp;qid=1588349658&amp;amp;s=books&amp;amp;sprefix=THINK+AN%2Cstripbooks%2C296&amp;amp;sr=1-1&quot;&gt;&lt;b&gt;THINK AND GROW RICH&lt;/b&gt;&lt;/a&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxXDkqJm8p4XStP_QaNl-pqa3m5uqK0wdrMdoTXbsQpLTzvyhui2hGNhkqbMVOqkn1YmJxbSUok_aBhb_5vDmcuM2b6uMD0Ljd7f4pS_8UFFj77m7hE_svK6hY3NsDy5CE_RSGQXRAlNtb/s1600/think.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;499&quot; data-original-width=&quot;330&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxXDkqJm8p4XStP_QaNl-pqa3m5uqK0wdrMdoTXbsQpLTzvyhui2hGNhkqbMVOqkn1YmJxbSUok_aBhb_5vDmcuM2b6uMD0Ljd7f4pS_8UFFj77m7hE_svK6hY3NsDy5CE_RSGQXRAlNtb/s320/think.jpg&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;Think and Grow Rich&lt;/i&gt;, written by Napolean Hill &lt;/span&gt;is probably the most famous success book of all time. Napoleon Hill was an American self-help author who wrote about essentials to improve one&#39;s life. The inferred conclusion from the book is riches begin with a state of mind. If we want to get rich, we must first change our minds so that we become, as Napoleon Hill calls it, money-conscious. Quoting a line from the book &lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Success comes to those who become success conscious. Failure comes to 
those who indifferently allow themselves to become failure conscious.&lt;/blockquote&gt;
This line is self-explanatory and itself speaks so much. The book deals with various aspects like having a burning desire to achieve a goal, having faith in yourself, and how to achieve the goal by organized planning. Give it a read if you have a goal set and working to achieve it, this book can surely help.&lt;br /&gt;
&lt;br /&gt;

&lt;/li&gt;
&lt;li&gt;&lt;h3&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;a href=&quot;https://www.amazon.in/s?k=hit+refresh+by+satya+nadella&amp;amp;i=stripbooks&amp;amp;crid=2T1GT40FAZLWA&amp;amp;sprefix=hit+refre%2Cstripbooks%2C304&amp;amp;ref=nb_sb_ss_i_1_9&quot;&gt;HIT REFRESH&lt;/a&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7qnWT9lLns1lLhFIpTLq4h_jPczh4YDfVKn9WemgyIP2Ph6oyhPf29u2bgdsGcbYSQlk71FAlG7SWnzjv6N22ykxZCqrYw7tl6FhNXfZM9UEqT5sIxiSHUtM_FK_SRbHB7XK6Z9PC3sDq/s1600/hit-refresh.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;500&quot; data-original-width=&quot;330&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7qnWT9lLns1lLhFIpTLq4h_jPczh4YDfVKn9WemgyIP2Ph6oyhPf29u2bgdsGcbYSQlk71FAlG7SWnzjv6N22ykxZCqrYw7tl6FhNXfZM9UEqT5sIxiSHUtM_FK_SRbHB7XK6Z9PC3sDq/s320/hit-refresh.jpg&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Hit Refresh &lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;is an auto-biography by Microsoft&#39;s current CEO Satya Nadella. In this book, he shares his life&#39;s journey from Hyderabad to Redmond to join Microsoft and become its third CEO. This book is quite different from the previous two books. It states how Mr. Satya Nadella dealt with certain situations in his life while leading such a tech giant like Microsoft. Apart from these, the book throws light on how technologies like quantum computing, mixed reality, and artificial intelligence and shape our future. Also, in the book Mr. Nadella about trust values in the digital age like what norms and policies should be there regarding data security and privacy. If anyone wants a view on how technological impact will be in the near future along with that want to gain some leadership values then this book will be a good choice. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;times&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;If you have read any one of these books, do mention your thoughts and understandings in the comments, and also if you have any suggestions for some good read mention that as well. Stay safe and happy reading!&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://readsngeeks.blogspot.com/feeds/6340654364041052608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/3-books-for-personal-growth.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/6340654364041052608'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5795907029429874864/posts/default/6340654364041052608'/><link rel='alternate' type='text/html' href='https://readsngeeks.blogspot.com/2020/05/3-books-for-personal-growth.html' title='3 books which can help you develop your personality during this lockdown period!'/><author><name>Saptarshi</name><uri>http://www.blogger.com/profile/14307232844443900946</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdUHgrlpthVgy23dqzgvtpI1DYvXCbXfX2D_C_H49NCEHXiPiKVimDfEYPm7apcq6vYwCPnZoQgWbTlPMlFLrlk7-lnVqWkcB3rQYH_ZZsCH3c4gLuSCED2m7ui2Awdg/s220/pic.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgObyHt2UdT3iFajxDqWIZ_X-oPliu_4s_6KD2LH8HWj5zxD1VpvUBB1BMv51Di_14iDAWTqd_II5u_A4Hu1bsLHG70McfiNbU0ScYgLq_gjGcEyCq9jCJcpw3UnrmzR7JS9x0vKB-s-SVB/s72-c/Screenshot+2020-05-01+at+10.18.57+PM.png" height="72" width="72"/><thr:total>2</thr:total></entry></feed>