<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajat Kumar Nayak</title>
    <description>The latest articles on DEV Community by Rajat Kumar Nayak (@rajat-nayak).</description>
    <link>https://dev.to/rajat-nayak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F944446%2Fce527948-e066-464a-8a0b-7af04d7332b5.jpg</url>
      <title>DEV Community: Rajat Kumar Nayak</title>
      <link>https://dev.to/rajat-nayak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajat-nayak"/>
    <language>en</language>
    <item>
      <title>From Code to Impact</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Wed, 04 Dec 2024 15:43:14 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/from-code-to-impact-4abn</link>
      <guid>https://dev.to/rajat-nayak/from-code-to-impact-4abn</guid>
      <description>&lt;p&gt;This is not the typical technology blog I used to publish.&lt;/p&gt;

&lt;p&gt;Before getting into the main topic of discussion I thought let’s have a background.&lt;/p&gt;

&lt;p&gt;I have an approach and everyone suggested also that I learn better by building projects and implementing the concepts. From college seniors to tech influencers emphasized the fact that you must implement whatever you are learning in projects. Well they are correct and everyone should learn software development by building projects, in short must implement the concepts.&lt;/p&gt;

&lt;p&gt;But I came to realize whenever we are building any project we should solve a problem statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I am saying this?&lt;/strong&gt;&lt;br&gt;
On 30th November 2024, I came across a folder on my phone which has basically all the applications that I built during my college days to understand the concepts of Android development.&lt;/p&gt;

&lt;p&gt;I assumed that none of the applications would be working. Again why I thought that.&lt;/p&gt;

&lt;p&gt;It is because I used to integrate Firebase as a backend for all my applications during my initial days of Android development. Now we all know that if we don’t do any transaction in the storage or any of the services of the Firebase for a prolonged period, firebase will automatically stop the service after giving proper email notifications and all.&lt;/p&gt;

&lt;p&gt;But a strange thing happened.&lt;br&gt;
I clicked my blood donation app, tried to register as a new user and guess what it worked. The user got successfully registered and it was after 2 years. and when I entered the home screen I could see around 100s of users having their details submitted as the donor.&lt;/p&gt;

&lt;p&gt;Seeing over 100 registered donors filled me with pride and reminded me of the potential of even small, college-level projects to contribute meaningfully to society.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What exactly I am trying to say?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s not always a fancy tech stack that will help to build a great project. P.S. I am not saying my project is great. (Ha ha..)But what I’m trying to say is that if we think about the final outcome that our product will deliver, that will bring about change and impact in society.&lt;/p&gt;

&lt;p&gt;So, the next time you start a project, think beyond the code. Think about the problem you’re solving and the impact you can create. Who knows? Years from now, your work might still be helping someone.&lt;/p&gt;

&lt;p&gt;You can find that project here. &lt;a href="https://github.com/rajat-gith/BloodDonationApp" rel="noopener noreferrer"&gt;https://github.com/rajat-gith/BloodDonationApp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>community</category>
    </item>
    <item>
      <title>Unleashing Real-Time Data: Setting Up Kafka on EC2 and Connecting from Your Local Machine</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Tue, 25 Jun 2024 13:46:36 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/unleashing-real-time-data-setting-up-kafka-on-ec2-and-connecting-from-your-local-machine-4mca</link>
      <guid>https://dev.to/rajat-nayak/unleashing-real-time-data-setting-up-kafka-on-ec2-and-connecting-from-your-local-machine-4mca</guid>
      <description>&lt;p&gt;This blog post will show you how to install Apache Kafka on an Amazon EC2 instance and connect to it locally to take use of the potential of real-time data. We will guide you through every step of the process, including setting up Kafka on the cloud and managing data streams using a producer and consumer. By the end, you will be able to use a specialized GitHub repository to conduct an analysis of the stock market. For those who want to learn more about real-time analytics and data streaming, this extensive guide is ideal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So let's begin&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Setup Kafka
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Create an EC2 Instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/UyBETtpkxlA" rel="noopener noreferrer"&gt;Create EC2 Instance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit Security Group&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/6q5kVaH-tvU" rel="noopener noreferrer"&gt; Edit Security Group &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect to EC2 Instance&lt;/strong&gt;&lt;br&gt;
1.Go to the Downloads folder where the key is located&lt;br&gt;
2.Fetch the SSH Connect Command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign in to the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Navigate to the EC2 service.&lt;/li&gt;
&lt;li&gt;In the EC2 Dashboard, click on "Instances" in the left sidebar.&lt;/li&gt;
&lt;li&gt;Select the instance you want to connect to by clicking on its checkbox.&lt;/li&gt;
&lt;li&gt;Click the "Connect" button at the top of the page.&lt;/li&gt;
&lt;li&gt;In the "Connect to instance" page that opens, select the "SSH client" tab.&lt;/li&gt;
&lt;li&gt;Scroll down to the section titled "Example". Here, you'll see the exact SSH command to use for connecting to your instance.&lt;/li&gt;
&lt;li&gt;You can copy this command directly from the dashboard. It will look something like this:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "your-key-name.pem" ec2-user@ec2-12-34-56-78.compute-1.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now you are connected to remote EC2 Instance&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run this command to Download Kafka&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://downloads.apache.org/kafka/3.7.0/kafka_2.13-3.7.0.tgz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install Amazon Corretto (OpenJDK):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install -y java-1.8.0-amazon-corretto-devel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Navigate to the kafka folder&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; cd kafka_2.13-3.7.0/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now Similarly open two terminal connecting to the EC2 Instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6g7mp5taphsgpzg93fz5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6g7mp5taphsgpzg93fz5.png" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the first terminal run the following command to start zookeeper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/zookeeper-server-start.sh config/zookeeper.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the second terminal run the following command to start server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd kafka_2.13-3.7.0/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/kafka-server-start.sh config/server.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hurray you can see your server starting !!&lt;/p&gt;

&lt;p&gt;Now stop both the services and now focus on an important step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There is an important step here:&lt;/strong&gt;&lt;br&gt;
To make our local system connect to the Kafka that is on the remote EC2 instance we need to make a little bit of configurational changes.&lt;/p&gt;

&lt;p&gt;Run the following command in your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano config/server.properties

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fah5onkvl5hjhvno1gv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fah5onkvl5hjhvno1gv.png" alt="Image description" width="800" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Find this line:&lt;br&gt;
&lt;strong&gt;ADVERTISED_LISTENERS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In your case, it will be localhost.&lt;/li&gt;
&lt;li&gt;Change it to the public IPV4 of your instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbebvd9tovkk20buylzt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbebvd9tovkk20buylzt.png" alt="Image description" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Press CTRL+X and SHIFT+Y and then Enter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And we are done !!&lt;/p&gt;

&lt;p&gt;We can check the running of kafka&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd kafka_2.13-3.7.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/kafka-topics.sh --create --topic sample_topic --bootstrap-server {Public IP of your EC2 Instance:9092} --replication-factor 1 --partitions 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start Producer:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/kafka-console-producer.sh --topic sample_topic --bootstrap-server {Public IP of your EC2 Instance:9092} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Start Consumer:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Duplicate the session &amp;amp; enter in a new console --&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd kafka_2.13-3.7.0/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/kafka-console-consumer.sh --topic sample_topic --bootstrap-server {Public IP of your EC2 Instance:9092}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write some messages in producer side and you can receive the same in consumer side.&lt;/p&gt;

&lt;p&gt;Now we can build our project locally and by properly mentioning the details we can connect to the Kakfa.&lt;/p&gt;

&lt;p&gt;I have worked on a project that leads to stock market analysis and plots the graph in real time. You can find the code below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rajat-gith/stock-market-analysis.git" rel="noopener noreferrer"&gt;https://github.com/rajat-gith/stock-market-analysis.git&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Effortless Node.js Deployment on Amazon EC2 with tmux: A Step-by-Step Guide</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Sun, 04 Feb 2024 13:37:54 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/effortless-nodejs-deployment-on-amazon-ec2-with-tmux-a-step-by-step-guide-13m5</link>
      <guid>https://dev.to/rajat-nayak/effortless-nodejs-deployment-on-amazon-ec2-with-tmux-a-step-by-step-guide-13m5</guid>
      <description>&lt;p&gt;In this blog, we will have a clear and step-by-step understanding of how to host our node application on an Amazon EC2 instance and how to keep the application running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
Imagine you're a chef in a busy kitchen, about to serve a delicious dish. But just as you're ready, someone unplugs the oven!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
That's what it's like hosting an application on EC2. When you close the terminal, your app goes offline, leaving users in the lurch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
Enter tmux, your kitchen assistant! It keeps your app running in the background, like a backup generator for your oven. With tmux, your app stays online, serving users seamlessly.&lt;/p&gt;

&lt;p&gt;So, when hosting on EC2, don't forget tmux. It's the secret ingredient for uninterrupted service!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now Let's look at the steps to implement it..&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The entire steps will be broadly classified into 3 main categories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-1 Develop a Node JS Application.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initiate a Node Application&lt;br&gt;
&lt;code&gt;npm init -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install express dotenv, express npm package.&lt;br&gt;
&lt;code&gt;npm install express dotenv&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a .env file.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtbfmzyh91c4l5t53fq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtbfmzyh91c4l5t53fq3.png" alt="Image description" width="259" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a sample node application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("dotenv").config();
const express = require("express");
const app = express();
const PORT = process.env.PORT || 3001;

app.get("/", (req, res) =&amp;gt; {
  res.send("Welcome to AWS World");
});


app.listen(PORT, () =&amp;gt; {
  console.log(`Server running on ${PORT}`);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your node application is ready to push into the remote repository.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialize a git repo using:&lt;br&gt;
&lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure to add .gitignore file and add node_modules folder inside .gitignore.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fud0wyvyjsu6uzk0jxzmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fud0wyvyjsu6uzk0jxzmd.png" alt="Image description" width="500" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create the main branch&lt;br&gt;
&lt;code&gt;git checkout -b main&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the remote origin:&lt;br&gt;
&lt;code&gt;git remote add origin &amp;lt;repo-link&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then Commit the changes with the following commands:&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git commit -m &amp;lt;commit message&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push the commit into the remote repo using:&lt;br&gt;
&lt;code&gt;git push origin &amp;lt;branch-name&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we pushed the code successfully into the remote repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-2 It's time to start with the AWS EC2 hoisting part.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have attached a video below which describes how to create an EC2 instance.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vBd9sintVAA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;After you have the instance now it time to setup the ports to open for our application to display.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Head over to the security groups option in the instance dashboard.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg2nna06rk9i274pv4l3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg2nna06rk9i274pv4l3.png" alt="Image description" width="800" height="271"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;strong&gt;Edit Inbound Rules&lt;/strong&gt; Option.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fwqc3gqqlbwp0hzuj9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fwqc3gqqlbwp0hzuj9p.png" alt="Image description" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a new rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw0ch8tkky0hyyuw5w7x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw0ch8tkky0hyyuw5w7x.png" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we are ready with setting up the EC2 instance now let's move to connecting our instance and hoisting the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up SSH and Hoisting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set up SSH in your local system. &lt;/p&gt;

&lt;p&gt;You can check whether SSH is present in your system by running &lt;code&gt;ssh&lt;/code&gt; in your command prompt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xmc0yozewbc6jw94vts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xmc0yozewbc6jw94vts.png" alt="Image description" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the output is not the same as above then you can setup SSH by following the steps mentioned in the provided blog link.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://interworks.com/blog/2021/09/08/how-to-enable-ssh-commands-in-windows/" rel="noopener noreferrer"&gt;Setup SSH&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you are done with SSH follow the below-mentioned steps.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the bellow command to connect to the instance.
&lt;code&gt;ssh -i &amp;lt;key-path&amp;gt; ubuntu@&amp;lt;public-ip&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijhvpg4ulj0jkeisecs9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijhvpg4ulj0jkeisecs9.png" alt="Image description" width="800" height="649"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make a directory of your choice name.&lt;br&gt;
&lt;code&gt;mkdir node-app&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move inside the director.&lt;br&gt;
&lt;code&gt;cd node-app&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check for git using the &lt;code&gt;git --version&lt;/code&gt; command.&lt;br&gt;
If not found you can install using &lt;code&gt;sudo apt install git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlx8bcu56szxx4oga5ia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlx8bcu56szxx4oga5ia.png" alt="Image description" width="784" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;clone the remote app that we created previously.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9y7hm6kednw17obwy9e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9y7hm6kednw17obwy9e.png" alt="Image description" width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Move inside the cloned folder using &lt;code&gt;cd node-app&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjl0drk7s4av8a52u5vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjl0drk7s4av8a52u5vg.png" alt="Image description" width="788" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Then you can install packages using &lt;br&gt;
&lt;code&gt;npm install&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It will install all necessary packages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install tmux using&lt;br&gt;
&lt;code&gt;sudo apt install tmux&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhyf90sm8rkzaoma7m2xz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhyf90sm8rkzaoma7m2xz.png" alt="Image description" width="800" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start a new tmux session:
&lt;code&gt;tmux new-session -s session_name&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukkkrxl6tjvzvm6r6mv0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukkkrxl6tjvzvm6r6mv0.png" alt="Image description" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run the node application in the tmux session using &lt;br&gt;
&lt;code&gt;node index.js&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To detach from the tmux session without stopping the Node.js app, press Ctrl+b then d.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hurray you have hoisted the application with continuous running.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F685e9wo76z55j9xb4pob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F685e9wo76z55j9xb4pob.png" alt="Image description" width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can again attach to a pre-existing session using the following command.
&lt;code&gt;tmux attach -t session_name&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we have pretty much covered how to host a node application in an EC2 instance and run it continuously with Node JS. If you have any doubt I will be more than happy to help. You can mail your queries to '&lt;a href="mailto:rajatnayak1582002@gmail.com"&gt;rajatnayak1582002@gmail.com&lt;/a&gt;'.&lt;/p&gt;

</description>
      <category>node</category>
      <category>aws</category>
      <category>devops</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Caching in NodeJS with Redis</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Fri, 26 Jan 2024 17:47:38 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/caching-in-nodejs-with-redis-3o48</link>
      <guid>https://dev.to/rajat-nayak/caching-in-nodejs-with-redis-3o48</guid>
      <description>&lt;p&gt;This blog post will provide a brief explanation on how to use Redis caching to improve server response time, boost performance, and reduce fetch times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; To run Redis Stack on Windows we need to install Docker.&lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;Download Docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; After installing Docker open the terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4a383ir4a8oath9h526.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4a383ir4a8oath9h526.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The command pulls the redis-stack image from the docker hub and runs it.&lt;/p&gt;

&lt;p&gt;You can open the Docker Desktop and see the status of the image running.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxa6qil2jraqw5kc264a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxa6qil2jraqw5kc264a.png" alt="Image description" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, we can visit &lt;code&gt;http://localhost:8001/&lt;/code&gt; and access the redis stack dashboard:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zo9gs0slvke0g1p6t6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zo9gs0slvke0g1p6t6w.png" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the Redis setup is complete, let's move on to the Node.js portion.&lt;/p&gt;

&lt;p&gt;We will first look without Redis, then with Redis, to see the difference.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Initiate a node package with the following command:&lt;br&gt;
&lt;code&gt;npm init&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install express and axios package:&lt;br&gt;
&lt;code&gt;npm install express axios&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find the code below for index.js:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Import the necessary modules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");
const axios = require("axios");
const app = express();
const port = 3000;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get("/todos", async (req, res) =&amp;gt; {
  try {
    // Record the start time
    const startTime = Date.now();

    // Make a GET request to the typicode todos endpoint
    const response = await axios.get(
      "https://jsonplaceholder.typicode.com/todos"
    );

    // Record the end time
    const endTime = Date.now();

    // Calculate the total time taken
    const totalTime = endTime - startTime;

    // Extract todos from the response
    const todos = response.data;

    // Send the todos along with the total time as a JSON response
    res.json({ todos: todos, totaltime: totalTime });
  } catch (error) {
    console.error("Error fetching todos:", error.message);
    res.status(500).json({ error: "Internal Server Error" });
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the api in Postman you can see the response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbdwvlj10xznotv5xkf9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbdwvlj10xznotv5xkf9.png" alt="Image description" width="702" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Redis&lt;/strong&gt;&lt;br&gt;
Add the following Lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Redis = require('ioredis');
const redisClient = new Redis();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially no data in Redis:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9ssmr9cd5rv26goy4dz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9ssmr9cd5rv26goy4dz.png" alt="Image description" width="800" height="704"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The complete index.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");
const axios = require("axios");
const Redis = require("ioredis");

const app = express();
const port = 3000;

// Create a Redis client
const redisClient = new Redis();

app.get("/todos", async (req, res) =&amp;gt; {
  try {
    // Record the start time
    const startTime = Date.now();

    // Check if the response is cached in Redis
    const cachedTodos = await redisClient.get("todos");

    // Record the end time
    const endTime = Date.now();

    if (cachedTodos) {
      // If cached data is found, send it directly
      const parsedTodos = JSON.parse(cachedTodos);

      // Calculate the total time taken for fetching from Redis
      const totalTime = endTime - startTime;

      res.json({ todos: parsedTodos, totalTime, source: "Redis Cache" });
    } else {
      // Make a GET request to the typicode todos endpoint
      const apiStartTime = Date.now();
      const response = await axios.get(
        "https://jsonplaceholder.typicode.com/todos"
      );
      const apiEndTime = Date.now();

      // Calculate the total time taken for fetching from the API
      const apiTotalTime = apiEndTime - apiStartTime;

      // Extract todos from the response
      const todos = response.data;

      // Save the todos to Redis for future use with a TTL of 60 seconds (adjust as needed)
      await redisClient.set("todos", JSON.stringify(todos), "EX", 60);

      // Calculate the total time taken for the entire operation
      const totalTime = apiEndTime - startTime;

      // Send the todos along with the total time as a JSON response
      res.json({ todos, totalTime, apiTotalTime, source: "API" });
    }
  } catch (error) {
    console.error("Error fetching todos:", error.message);
    res.status(500).json({ error: "Internal Server Error" });
  }
});

app.listen(port, () =&amp;gt; {
  console.log(`Server is running on http://localhost:${port}`);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the API in postman:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6tkndnb3twth4ty31bz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6tkndnb3twth4ty31bz.png" alt="Image description" width="358" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find that a string in the redis stack browser window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuw4oz9rmjhrpybaoic98.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuw4oz9rmjhrpybaoic98.png" alt="Image description" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And wohoo!! After using Redis:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxx02kmghbrw845d7o9l6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxx02kmghbrw845d7o9l6.png" alt="Image description" width="592" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The response time has reduced significantly.&lt;/p&gt;

&lt;p&gt;So we have pretty much covered how to use Redis as a cache to improve perfomance and efficiency. If you have any doubt I will be more than happy to help. You can mail your queries to '&lt;a href="mailto:rajatnayak1582002@gmail.com"&gt;rajatnayak1582002@gmail.com&lt;/a&gt;'.&lt;/p&gt;

</description>
      <category>node</category>
      <category>redis</category>
      <category>development</category>
      <category>cache</category>
    </item>
    <item>
      <title>Linux Permissions</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Sun, 21 Jan 2024 12:46:28 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/linux-permissions-1p8h</link>
      <guid>https://dev.to/rajat-nayak/linux-permissions-1p8h</guid>
      <description>&lt;h2&gt;
  
  
  What are Linux Permissions?
&lt;/h2&gt;

&lt;p&gt;Linux permissions, as the name implies, are a technique of granting different permissions to a person or group of users.&lt;/p&gt;

&lt;p&gt;We'll go over how permissions are defined, how people are assigned permissions, and how they're used.&lt;/p&gt;

&lt;p&gt;How to check permissions?&lt;/p&gt;

&lt;p&gt;Run Command: &lt;br&gt;
&lt;code&gt;ls -a -l&lt;/code&gt;&lt;br&gt;
The output of the command will be &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3xiwye6v4aopywzm20h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3xiwye6v4aopywzm20h.png" alt="Image description" width="749" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see we have a directory and a file.&lt;br&gt;
we will now focus on the first column which has complete information on the permissions.&lt;/p&gt;

&lt;p&gt;The permission column has values of each ten characters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3ahvf8cxncwxnqhcujb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3ahvf8cxncwxnqhcujb.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first place can be either a 'd' or an empty value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;'d'&lt;/strong&gt; represents that it is a directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Different types of users:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User&lt;/strong&gt;: We can say that 'User' refers to the owner of the file or directory who has created the file or directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Groups&lt;/strong&gt;: It refers to a group of users who are assigned permissions to execute.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In production circumstances, groups are primarily employed. When building a project, several groups are formed based on the use case.&lt;/p&gt;

&lt;p&gt;For a better understanding let us consider working on a project on management systems. Then we categorize users based on their role and assign permissions.&lt;/p&gt;

&lt;p&gt;Some groups such as developers have the privilege of editing the source code and making appropriate changes.&lt;/p&gt;

&lt;p&gt;Some users entitled as contributors can have limited access to some of the directories which are made public by the owner for review and corresponding changes.&lt;/p&gt;

&lt;p&gt;In such scenarios, the owner adds users to groups, and permissions are assigned to the groups so that all the users entitled to the group have the privilege of exercising based on the permission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Others&lt;/strong&gt;: This category consists of all other users available and it has maximum possible risk and the directories and files are vulnerable to security threats and attacks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Permissions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Read&lt;/strong&gt;: As its name suggests it allows the user or group to read the content of the directory or file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Write&lt;/strong&gt;: This permission allows the users to change the contents of the file and make changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Execute&lt;/strong&gt;: This permission allows the users or group to execute the contents of the file. Generally bash scripts that are designed to solve specific purpose are executed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By default, the owner of the file has read and write permissions enabled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why the owner doesn't have the execute permission by default?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we have a closer look at the 1st set of permissions then we can notice that the owner lacks the execute permission.&lt;/p&gt;

&lt;p&gt;This is because not every file is meant for execution at first. So to prevent any accidental execution that can lead to unwanted circumstances the file doesn't have execute permission.&lt;/p&gt;

&lt;p&gt;Based on our use case we can give execute permission to the user using the command &lt;code&gt;chmod&lt;/code&gt;. We will look into detail how we can assign permissions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ways to represent permissions&lt;/strong&gt;&lt;br&gt;
There are two ways to represent permissions. The first one is to represent with acronyms.&lt;br&gt;
r -&amp;gt; read&lt;br&gt;
w -&amp;gt; write&lt;br&gt;
x -&amp;gt; execute&lt;/p&gt;

&lt;p&gt;The other way to represent permission is with octal number. Each permission has a numeric value assigned to it:&lt;/p&gt;

&lt;p&gt;r (read): 4&lt;br&gt;
w (write): 2&lt;br&gt;
x (execute): 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Denoting a permission&lt;/strong&gt;&lt;br&gt;
Some examples of permissions sets:&lt;/p&gt;

&lt;p&gt;Suppose we want to give read and write and permission:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Either we can use 'r', 'w', 'x' : &lt;code&gt;rw&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;read -&amp;gt; 4
write -&amp;gt; 2
That eventually leads to 6&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use Case 1:&lt;/p&gt;

&lt;p&gt;For example, a file might have read, write, and execute permissions for its owner, and only read permission for all other users. That looks like this:&lt;/p&gt;

&lt;p&gt;Owner: rwx = 4+2+1 = 7&lt;br&gt;
Group: r-- = 4+0+0 = 4&lt;br&gt;
Others: r-- = 4+0+0 = 4&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The chmod Command&lt;/strong&gt;&lt;br&gt;
The chmod command can be used to either assign permission or remove permission from the user or the group.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;+&lt;/strong&gt; in the command denotes that the mentioned permission is granted to the group or user.&lt;br&gt;
&lt;strong&gt;-&lt;/strong&gt; represents that the mentioned permission being removed from the user or group.&lt;/p&gt;

&lt;p&gt;Some examples of using chmod command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Assign read and write permissions to the owner:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;chmod u+rw filename&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Assign execute permissions to the group:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;chmod g+x filename&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Assign read,write,execute to owner and read,write permission to group.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Way 1:&lt;br&gt;
&lt;code&gt;chmod u=rwx,g=rw filename&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Way 2:&lt;br&gt;
read -&amp;gt; 4&lt;br&gt;
write -&amp;gt; 2&lt;br&gt;
execute -&amp;gt; 1&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod 760 filename&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So we have pretty much covered the topic of permissions in Linux. If you have any doubt I will be more than happy to help. You can mail your queries to '&lt;a href="mailto:rajatnayak1582002@gmail.com"&gt;rajatnayak1582002@gmail.com&lt;/a&gt;'.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>permission</category>
      <category>tutorial</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>WebRTC Explained: Behind the Scenes of Seamless Video Calls</title>
      <dc:creator>Rajat Kumar Nayak</dc:creator>
      <pubDate>Fri, 06 Oct 2023 15:18:17 +0000</pubDate>
      <link>https://dev.to/rajat-nayak/webrtc-explained-behind-the-scenes-of-seamless-video-calls-1ke7</link>
      <guid>https://dev.to/rajat-nayak/webrtc-explained-behind-the-scenes-of-seamless-video-calls-1ke7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hello Everyone!! 👋👋 We all must have come across video calling applications like Google Meet, Zoom, or Microsoft Teams app, and the list goes on. Whether you are a student or a working professional we all must have used this application for educational purposes and to conduct official meetings or get connected with distant family members. &lt;/p&gt;

&lt;p&gt;In order to implement a video conferencing platform we need to understand the implementation of WebRTC. So let us have a deep understanding of how WebRTC works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is WebRTC?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;WebRTC stands for &lt;strong&gt;Web Real-Time Communication&lt;/strong&gt;, and it allows for &lt;strong&gt;instant&lt;/strong&gt;, &lt;strong&gt;low-latency communication over the internet&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One most fascinating features of WebRTC is that gets easily integrated into web browsers such as Chrome, Firefox, and Safari. making it readily accessible without the need for additional plugins or installations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;Let's first understand the fundamental terms we will be using in the next steps before diving into the technical details.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NAT (Network Address Translation): The fundamental use case of NAT is to map a private IP address used in a local network into a public IP address.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might be thinking why we are considering this?&lt;/p&gt;

&lt;p&gt;When two hosts attempt to connect to each other, NAT devices such as routers and firewalls either block or interfere with the connection. To avoid this issue, WebRTC implementation frequently uses different strategies. In the meanwhile, we shall investigate those strategies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what the heck is NAT Traversal?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NAT traversal is the process of finding a way for two computers or devices to connect with each other while being separated by various NAT (Network Address Translation) routers.&lt;/p&gt;

&lt;p&gt;So in order to facilitate NAT Traversal we make use of STUN and TURN Servers and exchange of ICE Candidates.&lt;/p&gt;

&lt;p&gt;Okay, there's too much jargon in this line 😮‍💨😮‍💨. Let's break it down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are ICE Candidates?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WebRTC generates ICE candidates, which are IP addresses and port combinations that could be used to make connections. These possibilities come from a variety of sources, including local network interfaces and STUN servers. These candidates assist peers in negotiating the optimum approach to establish a connection while taking NAT setups into account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STUN:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is a protocol that allows a device to discover its public IP address and port when it is behind a NAT device. STUN servers are typically located on the public internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;TURN:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If STUN is unable to make a direct connection, usually due to severe NAT configurations or firewall constraints, ICE can use a TURN server. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The TURN server serves as a relay, accepting data from one device and relaying it to another. When direct peer-to-peer connections are not possible, this relayed communication ensures that data can flow between the devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is an important concept we need to know to have a clear understanding of how things work and that is &lt;strong&gt;Signaling&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Signaling is responsible for coordinating communication across WebRTC peers. It entails exchanging session control messages such as SDP (Session Description Protocol) offers, responses, and ICE candidates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Signaling can be accomplished through the use of numerous protocols, such as WebSocket, HTTP, or bespoke protocols. The application developer selects the signaling protocol and server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When a WebRTC peer sends an ICE candidate that includes STUN-derived information to the remote peer through signaling, it helps the remote peer understand how to reach it through NAT devices.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So until now, we have a brief understanding with the help of ICE Candidates two peers will be able to connect with each other.&lt;/p&gt;

&lt;p&gt;Now taking into consideration video-calling applications we need to transmit applications from one peer to another peer.&lt;/p&gt;

&lt;p&gt;So how this is possible? 🤔🤔&lt;/p&gt;

&lt;p&gt;The answer is it is possible SDP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now what is SDP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SDP (Session Description Protocol) is a protocol that is used to describe the media capabilities and preferences of a device. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;After getting access to the device's camera and microphone, the information is transferred to the other peer through SDP and is referred to as an SDP Offer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The SDP offer provides information about its media capabilities, network settings, and audio and video preferences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The receiving peer responds with an SDP response, indicating its own media capabilities, preferences, and any necessary alterations to match the offer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The SDP offer/answer exchange ensures that the media settings, codecs, and other parameters for the call are agreed upon by both peers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It supports dynamic configuration and modifications during the call if necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So upon successful SDP exchange and the peer connection is established, the browsers start streaming audio and video directly to each other. This data is encrypted using Secure Real-time Transport Protocol (SRTP) to ensure privacy and security.&lt;/p&gt;

&lt;p&gt;Now in all these steps, you have noticed the major steps. So let us summarize the above contents into a brief.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The peers that need to get connected first undergo NAT Traversal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is implemented with the help of ICE Candidates and STUN/TURN Servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After ICE Candidates, the peers get connected and now the turn comes to exchange media information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebRTC asks for permission for media such as audio and video and an SDP offer is created which is then sent to the remote peer and in response it receives the SDP answer from the remote peer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The media is transmitted in an encrypted format in order to prevent malicious activities.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this way after an exchange of media information, the browsers start streaming audio and video directly to each other. &lt;/p&gt;

&lt;p&gt;So I hope you enjoyed reading the article and that I was able to help you understand what goes on behind the scenes of WebRTC to some extent.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>webrtc</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
