<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bhupendra on Medium]]></title>
        <description><![CDATA[Stories by Bhupendra on Medium]]></description>
        <link>https://medium.com/@bhupendra_Maurya?source=rss-b51508f4afc0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8k6lKZyBLqMkQkXh</url>
            <title>Stories by Bhupendra on Medium</title>
            <link>https://medium.com/@bhupendra_Maurya?source=rss-b51508f4afc0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:51:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhupendra_Maurya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[State Management in react using Recoil-An Overview]]></title>
            <link>https://medium.com/@bhupendra_Maurya/state-management-in-react-using-recoil-an-overview-61f3988c65cc?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/61f3988c65cc</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[recoil]]></category>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 10:47:38 GMT</pubDate>
            <atom:updated>2025-03-10T10:47:38.238Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1. RecoilRoot</strong></p><ul><li>The top-level component that enables Recoil state management in a React application.</li><li>It must wrap the entire component tree where Recoil is used.</li><li>Example:</li></ul><pre>import { RecoilRoot } from &#39;recoil&#39;;<br><br>function App() {<br>  return (<br>    &lt;RecoilRoot&gt;<br>      &lt;MyComponent /&gt;<br>    &lt;/RecoilRoot&gt;<br>  );<br>}</pre><p><strong>2. atom</strong></p><ul><li>Represents a piece of state that can be read and written by any component.</li><li>Atoms are independent, meaning they don’t rely on other atoms or selectors.</li><li>Example:</li></ul><pre>import { atom } from &#39;recoil&#39;;<br><br>const counterState = atom({<br>  key: &#39;counterState&#39;, // Unique ID<br>  default: 0,          // Default value<br>});</pre><p><strong>3. useRecoilState(atomOrSelector)</strong></p><ul><li>A React hook that works like useState but for Recoil atoms or selectors.</li><li>It returns [state, setState], allowing both reading and updating of the atom/selector.</li><li>Example:</li></ul><pre>import { useRecoilState } from &#39;recoil&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useRecoilState(counterState);<br>  return &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Count: {count}&lt;/button&gt;;<br>}</pre><p><strong>4. useRecoilValue(atomOrSelector)</strong></p><ul><li>A hook used when you only need to <strong>read</strong> an atom or selector but don’t need to update it.</li><li>Prevents unnecessary re-renders caused by passing the setter function.</li><li>Example:</li></ul><pre>import { useRecoilValue } from &#39;recoil&#39;;<br><br>function DisplayCount() {<br>  const count = useRecoilValue(counterState);<br>  return &lt;p&gt;Count: {count}&lt;/p&gt;;<br>}</pre><p><strong>5. useSetRecoilState(atomOrSelector)</strong></p><ul><li>A hook that only provides a setter function to update the atom or selector without re-rendering on value read.</li><li>Useful in event handlers or effects where you don’t need to read the current state.</li><li>Example:</li></ul><pre>import { useSetRecoilState } from &#39;recoil&#39;;<br><br>function IncrementButton() {<br>  const setCount = useSetRecoilState(counterState);<br>  return &lt;button onClick={() =&gt; setCount((prev) =&gt; prev + 1)}&gt;Increment&lt;/button&gt;;<br>}</pre><p><strong>6. selectors</strong></p><ul><li>Functions that derive state based on atoms and other selectors.</li><li>They can be <strong>pure functions</strong> (computed values) or <strong>asynchronous selectors</strong> (fetching data).</li><li>Example of a computed selector:</li></ul><pre>import { selector } from &#39;recoil&#39;;<br><br>const doubleCountState = selector({<br>  key: &#39;doubleCountState&#39;,<br>  get: ({ get }) =&gt; get(counterState) * 2,<br>});</pre><ul><li>Example of an async selector fetching data:</li></ul><pre>const fetchUserData = selector({<br>  key: &#39;fetchUserData&#39;,<br>  get: async () =&gt; {<br>    const response = await fetch(&#39;https://api.example.com/user&#39;);<br>    return response.json();<br>  },<br>});</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61f3988c65cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding useEffect Dependency Array and Cleanup Function in React]]></title>
            <link>https://medium.com/@bhupendra_Maurya/understanding-useeffect-dependency-array-in-react-41c8c7f2c7c4?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c8c7f2c7c4</guid>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[useeffect-hook]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 09:27:10 GMT</pubDate>
            <atom:updated>2025-02-28T10:04:55.882Z</atom:updated>
            <content:encoded><![CDATA[<p>The dependency array in useEffect determines <strong>when</strong> the effect runs. Let&#39;s break it down into three cases:</p><h3>1️⃣ No Dependency Array Passed (useEffect(() =&gt; {...}))</h3><pre>useEffect(() =&gt; {<br>  console.log(&quot;Effect running...&quot;);<br>});</pre><h3>🔥 Behavior:</h3><ul><li>Runs <strong>on every render and re-render</strong> of the component.</li><li>If the component updates (e.g., state changes), useEffect runs <strong>again</strong>.</li><li>This can lead to <strong>performance issues</strong> if the effect involves expensive operations (e.g., API calls).</li></ul><h3>📌 Example:</h3><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>const NoDependency = () =&gt; {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    console.log(&quot;Effect ran!&quot;);<br>  });<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Count: {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>export default NoDependency;</pre><p><strong>📝 What happens?</strong></p><ul><li>The effect runs <strong>on mount</strong> and <strong>every time </strong><strong>count updates</strong>.</li><li>Clicking the button updates count, causing <strong>re-renders</strong>, and the effect runs <strong>again</strong>.</li></ul><h3>2️⃣ Empty Dependency Array (useEffect(() =&gt; {...}, []))</h3><pre>useEffect(() =&gt; {<br>  console.log(&quot;Effect ran once!&quot;);<br>}, []);</pre><h3>🔥 Behavior:</h3><ul><li>Runs <strong>only once</strong>, when the component <strong>mounts</strong>.</li><li>Does <strong>not</strong> run again on re-renders or state updates.</li><li>Useful for <strong>initial setup</strong> (e.g., fetching data when the component loads).</li></ul><h3>📌 Example:</h3><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>const EmptyDependency = () =&gt; {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    console.log(&quot;Component mounted!&quot;);<br>  }, []);<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Count: {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>export default EmptyDependency;</pre><p><strong>📝 What happens?</strong></p><ul><li>The effect <strong>runs only once</strong> when the component first loads.</li><li>Clicking the button updates count, but the effect <strong>does not</strong> run again.</li></ul><h3>3️⃣ Value Passed Inside Dependency Array (useEffect(() =&gt; {...}, [value]))</h3><pre>useEffect(() =&gt; {<br>  console.log(&quot;Effect ran because `count` changed!&quot;);<br>}, [count]);</pre><h3>🔥 Behavior:</h3><ul><li>Runs <strong>once</strong> on mount.</li><li>Runs <strong>again whenever the specified value changes</strong>.</li><li>Useful when the effect <strong>depends on state or props</strong>.</li></ul><h3>📌 Example:</h3><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>const WithDependency = () =&gt; {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    console.log(`Effect ran because count changed to ${count}`);<br>  }, [count]);<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Count: {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>export default WithDependency;</pre><p><strong>📝 What happens?</strong></p><ul><li>The effect runs <strong>once</strong> when the component mounts.</li><li>Clicking the button updates count, triggering <strong>the effect to run again</strong>.</li><li>If count <strong>does not change</strong>, the effect <strong>won’t run</strong>.</li></ul><h3>🚀 Summary Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Y4ETx59ErEBQv-8Suab-hQ.png" /></figure><h3>Understanding the Cleanup Function in useEffect</h3><p>The <strong>optional function</strong> inside useEffect is called a <strong>cleanup function</strong>. It runs <strong>when the component unmounts</strong> or <strong>before the effect runs again</strong> if dependencies change.</p><h3>📌 Why Do We Need Cleanup in useEffect?</h3><p>✅ <strong>Avoid memory leaks</strong> (especially for timers, API calls, event listeners).<br> ✅ <strong>Clean up previous side effects</strong> before applying a new one.<br> ✅ <strong>Improve performance</strong> by preventing unnecessary operations.</p><h3>🛠 Example 1: Cleaning Up a Timer</h3><p>Let’s say we create a <strong>timer</strong> inside useEffect, but we forget to clear it. This can cause unexpected behavior.</p><h3>❌ Bad Example (No Cleanup)</h3><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>const Timer = () =&gt; {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    setInterval(() =&gt; {<br>      console.log(&quot;Updating count:&quot;, count);<br>      setCount((prev) =&gt; prev + 1);<br>    }, 1000);<br>  }, []); // Runs only once<br>  return &lt;h1&gt;Count: {count}&lt;/h1&gt;;<br>};<br>export default Timer;</pre><p><strong>🚨 Problem:</strong></p><ul><li>Every time the component re-renders, a <strong>new timer is created</strong> without removing the old one.</li><li>This leads to <strong>multiple intervals running at the same time</strong>, which can cause <strong>unexpected results</strong>.</li></ul><h3>✅ Fixed Example (Using Cleanup)</h3><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>const Timer = () =&gt; {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    const interval = setInterval(() =&gt; {<br>      console.log(&quot;Updating count:&quot;, count);<br>      setCount((prev) =&gt; prev + 1);<br>    }, 1000);<br>    return () =&gt; {<br>      console.log(&quot;Clearing interval...&quot;);<br>      clearInterval(interval); // Cleanup: stops the previous interval<br>    };<br>  }, [count]); // Runs when count updates<br>  return &lt;h1&gt;Count: {count}&lt;/h1&gt;;<br>};<br>export default Timer;</pre><h3>🔥 What Happens Here?</h3><ul><li>The setInterval runs every <strong>1 second</strong>.</li><li><strong>Before creating a new interval</strong>, React <strong>clears the previous one</strong>.</li><li>This prevents <strong>multiple intervals</strong> from running at the same time.</li></ul><h3>🛠 Example 2: Cleaning Up Event Listeners</h3><p>When adding <strong>event listeners</strong> inside useEffect, we must remove them when the component unmounts.</p><h3>❌ Bad Example (No Cleanup)</h3><pre>import React, { useEffect } from &quot;react&quot;;<br>const MouseTracker = () =&gt; {<br>  useEffect(() =&gt; {<br>    window.addEventListener(&quot;mousemove&quot;, () =&gt; {<br>      console.log(&quot;Mouse moved!&quot;);<br>    });<br>  }, []); // Runs only once<br>  return &lt;h1&gt;Move your mouse&lt;/h1&gt;;<br>};<br>export default MouseTracker;</pre><p><strong>🚨 Problem:</strong></p><ul><li>The event listener <strong>stays active</strong> even after the component is removed.</li><li>This can <strong>slow down</strong> the app or cause <strong>unexpected behavior</strong>.</li></ul><h3>✅ Fixed Example (Using Cleanup)</h3><pre>import React, { useEffect } from &quot;react&quot;;<br>const MouseTracker = () =&gt; {<br>  useEffect(() =&gt; {<br>    const handleMouseMove = () =&gt; {<br>      console.log(&quot;Mouse moved!&quot;);<br>    };<br>    window.addEventListener(&quot;mousemove&quot;, handleMouseMove);<br>    return () =&gt; {<br>      console.log(&quot;Removing event listener...&quot;);<br>      window.removeEventListener(&quot;mousemove&quot;, handleMouseMove);<br>    };<br>  }, []);<br>  return &lt;h1&gt;Move your mouse&lt;/h1&gt;;<br>};<br>export default MouseTracker;</pre><h3>🔥 What Happens Here?</h3><ul><li>The event listener is added <strong>when the component mounts</strong>.</li><li><strong>When the component unmounts</strong>, the <strong>cleanup function removes the event listener</strong>.</li></ul><h3>📌 When Does the Cleanup Function Run?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*Atj5DAlet3-dN8g97TOKDQ.png" /></figure><h3>🚀 Summary</h3><p>✅ <strong>Use cleanup for timers, event listeners, and subscriptions</strong>.<br> ✅ <strong>Runs before the effect runs again</strong> (if dependencies change).<br> ✅ <strong>Prevents memory leaks and improves performance</strong>.</p><h3>🚀 Best Practices for useEffect</h3><p>✅ <strong>Use empty </strong><strong>[] for one-time setup</strong> (e.g., fetching initial data).<br> ✅ <strong>Use </strong><strong>[value] if the effect should run only when </strong><strong>value changes</strong>.<br> ✅ <strong>Avoid missing dependencies</strong> (React will warn if you forget them).<br> ✅ <strong>Don’t mutate state inside </strong><strong>useEffect unless necessary</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c8c7f2c7c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Reconciliation & Diffing Algorithm in React]]></title>
            <link>https://medium.com/@bhupendra_Maurya/reconciliation-diffing-algorithm-in-react-4d341d6057a9?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d341d6057a9</guid>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Sun, 02 Feb 2025 07:27:40 GMT</pubDate>
            <atom:updated>2025-02-02T07:27:40.289Z</atom:updated>
            <content:encoded><![CDATA[<p>React is fast because it efficiently updates the UI <strong>without re-rendering the entire DOM</strong>. This is achieved using:</p><p>1️⃣ <strong>Reconciliation</strong> — The process of updating the UI efficiently.<br>2️⃣ <strong>Diffing Algorithm</strong> — The algorithm React uses to compare the old and new UI.</p><h3>🟢 1. What is Reconciliation?</h3><p>Reconciliation is the <strong>process of updating the DOM</strong> in React when <strong>state or props change</strong>.</p><h3>🔹 Steps in Reconciliation:</h3><ol><li><strong>React creates a Virtual DOM</strong> — A lightweight copy of the actual DOM.</li><li><strong>It compares the new Virtual DOM with the previous Virtual DOM</strong> (using the diffing algorithm).</li><li><strong>It calculates the minimum changes</strong> required.</li><li><strong>It updates only the necessary parts of the Real DOM</strong> — making it super efficient!</li></ol><p>🚀 <strong>React avoids direct DOM manipulation</strong> because:<br> ✔ The real DOM is slow to update.<br> ✔ Reconciliation makes UI updates efficient.</p><h3>🟢 2. Diffing Algorithm (How React Compares Changes)</h3><p>React’s <strong>Diffing Algorithm</strong> helps determine <strong>what changed in the Virtual DOM</strong> and updates the UI <strong>efficiently</strong>.</p><h3>🔥 How the Diffing Algorithm Works</h3><h3>🔹 Step 1: Comparing Elements (&lt;h1&gt; vs &lt;p&gt;)</h3><p>If two elements have <strong>different types</strong>, React <strong>destroys</strong> the old element and creates a new one.</p><h4>Example:</h4><pre>function App() {<br>  return &lt;h1&gt;Hello, World!&lt;/h1&gt;;<br>}</pre><p>⬇ <strong>Changes to:</strong></p><pre>function App() {<br>  return &lt;p&gt;Hello, World!&lt;/p&gt;;<br>}</pre><p>🔴 React <strong>removes </strong><strong>&lt;h1&gt;</strong> and creates a new &lt;p&gt; instead of modifying it.</p><h3>🔹 Step 2: Comparing Attributes (className, id, style)</h3><p>If the element <strong>type remains the same</strong>, React compares its <strong>attributes</strong> and updates only the changed ones.</p><h4>Example:</h4><pre>&lt;div className=&quot;old-class&quot;&gt;&lt;/div&gt;</pre><p>⬇ Changes to:</p><pre>&lt;div className=&quot;new-class&quot;&gt;&lt;/div&gt;</pre><p>✅ React <strong>updates only </strong><strong>className</strong> without recreating the entire &lt;div&gt;.</p><h3>🔹 Step 3: Comparing Children (Lists &amp; Keys Matter!)</h3><p>When dealing with <strong>lists or child elements</strong>, React <strong>compares</strong> their positions and <strong>uses keys</strong> to optimize updates.</p><h4>🔴 Bad Example (Without key)</h4><pre>const items = [&quot;Apple&quot;, &quot;Banana&quot;, &quot;Cherry&quot;];<br>return (<br>  &lt;ul&gt;<br>    {items.map((item) =&gt; (<br>      &lt;li&gt;{item}&lt;/li&gt; // No key (React finds it harder to track changes)<br>    ))}<br>  &lt;/ul&gt;<br>);</pre><p>If “Apple” is removed, React <strong>shifts all items</strong>, causing unnecessary re-renders.</p><h4>✅ Good Example (With key)</h4><pre>const items = [&quot;Apple&quot;, &quot;Banana&quot;, &quot;Cherry&quot;];<br>return (<br>  &lt;ul&gt;<br>    {items.map((item, index) =&gt; (<br>      &lt;li key={index}&gt;{item}&lt;/li&gt; // Using a unique key<br>    ))}<br>  &lt;/ul&gt;<br>);</pre><p>🔹 Now React <strong>tracks items correctly</strong> and only updates changed items.</p><h3>🚀 Key Optimizations in React’s Diffing Algorithm</h3><p>✔ <strong>Component Type Matters</strong> — If the type is different, React destroys &amp; recreates it.<br> ✔ <strong>Attribute Changes Are Tracked</strong> — Only changed attributes are updated.<br> ✔ <strong>Keys in Lists Help Performance</strong> — Keys let React efficiently reorder elements.<br> ✔ <strong>Minimal DOM Updates</strong> — React only updates the <strong>necessary parts</strong>.</p><p><em>Let’s go step by step with a </em><strong><em>practical example</em></strong><em> to see how reconciliation and the diffing algorithm work in React.</em></p><h3>🟢 Step 1: Initial Render (Virtual DOM Created)</h3><p>Imagine we have a simple component that displays a heading.</p><pre>import React, { useState } from &quot;react&quot;;<br><br>function App() {<br>  const [title, setTitle] = useState(&quot;Hello, World!&quot;);<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{title}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; setTitle(&quot;Hello, React!&quot;)}&gt;Change Title&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default App;</pre><h3>🛠 What Happens Internally?</h3><p>1️⃣ React <strong>creates a Virtual DOM</strong> with:</p><pre>&lt;div&gt;<br>  &lt;h1&gt;Hello, World!&lt;/h1&gt;<br>  &lt;button&gt;Change Title&lt;/button&gt;<br>&lt;/div&gt;</pre><p>2️⃣ React <strong>renders</strong> this Virtual DOM to the actual DOM.</p><h3>🔵 Step 2: Updating the State (Triggers Reconciliation)</h3><p>When you click the <strong>Change Title</strong> button, React updates the state:</p><pre>setTitle(&quot;Hello, React!&quot;);</pre><h3>🛠 What Happens Now?</h3><p>1️⃣ React <strong>creates a new Virtual DOM</strong>:</p><pre>&lt;div&gt;<br>  &lt;h1&gt;Hello, React!&lt;/h1&gt;<br>  &lt;button&gt;Change Title&lt;/button&gt;<br>&lt;/div&gt;</pre><p>2️⃣ <strong>Diffing Algorithm Compares:</strong></p><ul><li>✅ &lt;div&gt; stays the same.</li><li>✅ &lt;button&gt; stays the same.</li><li>🔄 &lt;h1&gt; content changes! React updates only <strong>inner text</strong>, not the whole element.</li></ul><p>3️⃣ <strong>React updates only the changed part in the Real DOM</strong>:</p><pre>- &lt;h1&gt;Hello, World!&lt;/h1&gt;<br>+ &lt;h1&gt;Hello, React!&lt;/h1&gt;</pre><p>✅ <strong>Efficient update! No unnecessary re-rendering.</strong></p><h3>🔴 Step 3: What If We Change the Element Type?</h3><p>Let’s change &lt;h1&gt; to &lt;p&gt; dynamically:</p><pre>function App() {<br>  const [isHeading, setIsHeading] = useState(true);<br>return (<br>    &lt;div&gt;<br>      {isHeading ? &lt;h1&gt;Hello, World!&lt;/h1&gt; : &lt;p&gt;Hello, World!&lt;/p&gt;}<br>      &lt;button onClick={() =&gt; setIsHeading(!isHeading)}&gt;Toggle&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Now, if you click the button:</p><pre>- &lt;h1&gt;Hello, World!&lt;/h1&gt;<br>+ &lt;p&gt;Hello, World!&lt;/p&gt;</pre><p>❌ <strong>React destroys the </strong><strong>&lt;h1&gt; and creates a new </strong><strong>&lt;p&gt; instead of modifying the text!</strong><br> 💡 This is because <strong>different element types trigger a full re-render.</strong></p><h3>🔵 Step 4: Updating a List (Why Keys Matter)</h3><p>Let’s add a list of items dynamically:</p><pre>function App() {<br>  const [items, setItems] = useState([&quot;Apple&quot;, &quot;Banana&quot;, &quot;Cherry&quot;]);<br>return (<br>    &lt;div&gt;<br>      &lt;ul&gt;<br>        {items.map((item) =&gt; (<br>          &lt;li&gt;{item}&lt;/li&gt; // No key used<br>        ))}<br>      &lt;/ul&gt;<br>      &lt;button onClick={() =&gt; setItems([&quot;Banana&quot;, &quot;Cherry&quot;])}&gt;Remove Apple&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>🛠 What Happens?</h3><p>1️⃣ React creates a Virtual DOM:</p><pre>&lt;ul&gt;<br>  &lt;li&gt;Apple&lt;/li&gt;<br>  &lt;li&gt;Banana&lt;/li&gt;<br>  &lt;li&gt;Cherry&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>2️⃣ When “Apple” is removed, React <strong>shifts all elements</strong>, causing unnecessary re-renders.</p><p>❌ <strong>Inefficient update!</strong></p><p>✅ <strong>Fix: Add Keys!</strong></p><pre>&lt;ul&gt;<br>  {items.map((item) =&gt; (<br>    &lt;li key={item}&gt;{item}&lt;/li&gt; // Unique key helps React track items<br>  ))}<br>&lt;/ul&gt;</pre><p>Now React only removes &quot;Apple&quot; instead of shifting elements, making the update <strong>super fast!</strong></p><h3>🎯 Conclusion</h3><ul><li><strong>React updates only changed elements (Text change ✅, Element change ❌).</strong></li><li><strong>Keys in lists prevent unnecessary re-renders.</strong></li><li><strong>React’s Diffing Algorithm makes updates super fast.</strong></li></ul><h3>🎯 Summary</h3><ul><li><strong>Reconciliation</strong>: The process React uses to update the UI efficiently.</li><li><strong>Diffing Algorithm</strong>: A method to compare old and new Virtual DOMs.</li><li><strong>Keys in Lists</strong>: Help React identify and update elements properly.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d341d6057a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Password Hashing using bcrypt]]></title>
            <link>https://medium.com/@bhupendra_Maurya/password-hashing-using-bcrypt-e36f5c655e09?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e36f5c655e09</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[bcrypt]]></category>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 18:53:35 GMT</pubDate>
            <atom:updated>2024-09-23T18:53:35.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q_yaBfvPnxcNEqjw.png" /></figure><h3>What is bcrypt?</h3><p>bcrypt is a popular and widely used cryptographic hashing function for securely storing passwords. It is designed to be slow and resistant to brute-force attacks, making it a reliable choice for password hashing. Unlike simple hashing algorithms like MD5 or SHA-256, bcrypt includes a &quot;salt&quot; and iterative processing, providing enhanced security.</p><h3>How bcrypt Works</h3><p>bcrypt works by performing the following steps:</p><ol><li><strong>Salting</strong>: It generates a random string of characters (salt) and combines it with the password before hashing. This ensures that even if two users have the same password, their hashed values will be different.</li><li><strong>Hashing</strong>: After salting the password, bcrypt performs multiple rounds of hashing. The number of hashing rounds is customizable (e.g., 10, 12, etc.), and higher rounds mean more security but take longer to compute.</li><li><strong>Hash Verification</strong>: When a user logs in, bcrypt re-hashes the provided password with the original salt and compares it with the stored hash to verify if the passwords match.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*NZBu-vO1eRvIBeLG.png" /></figure><h3>How to Use bcrypt in Node.js</h3><p>Here’s how to implement bcrypt in a Node.js/Express application:</p><h4>Installation</h4><pre>npm install bcrypt</pre><h4>Basic Usage</h4><ol><li><strong>Hashing a Password</strong></li></ol><pre>const bcrypt = require(&#39;bcrypt&#39;);<br>const saltRounds = 10;  // Number of hashing rounds (can increase for more security)<br><br>const password = &#39;mySecretPassword&#39;;<br><br>// Hash the password<br>bcrypt.hash(password, saltRounds, (err, hash) =&gt; {<br>  if (err) throw err;<br>  console.log(&#39;Hashed Password:&#39;, hash);<br>});</pre><p><strong>2. Comparing Passwords</strong></p><p>To verify if the entered password matches the stored hashed password, use bcrypt.compare():</p><pre>const bcrypt = require(&#39;bcrypt&#39;);<br><br>const storedHash = &#39;hashedPasswordFromDB&#39;;<br><br>const enteredPassword = &#39;mySecretPassword&#39;;<br><br>// Compare password with the hash stored in the database<br>bcrypt.compare(enteredPassword, storedHash, (err, result) =&gt; {<br>  if (err) throw err;<br>  if (result) {<br>    console.log(&#39;Password is correct!&#39;);<br>  } else {<br>    console.log(&#39;Password is incorrect.&#39;);<br>  }<br>});</pre><h4>Synchronous Usage</h4><p>bcrypt also provides synchronous versions of these methods</p><pre>const hash = bcrypt.hashSync(password, saltRounds);<br>const isMatch = bcrypt.compareSync(enteredPassword, storedHash);</pre><h3>When to Use bcrypt</h3><p>You should use bcrypt when handling sensitive data like passwords, especially in:</p><ol><li><strong>User Authentication</strong>: Hashing and storing user passwords to prevent storing plain text passwords.</li><li><strong>Data Protection</strong>: Any system where user security or sensitive data is crucial.</li><li><strong>API Authentication</strong>: Securing passwords in applications, including APIs, to protect users’ credentials.</li></ol><p><strong>Best practices</strong> recommend never storing user passwords in plaintext in your database, and bcrypt provides a secure way to hash and store them safely.</p><h3>Why bcrypt is Secure</h3><ul><li><strong>Salting</strong>: Random salt prevents attackers from precomputing hashes using methods like rainbow tables, making it difficult to reverse-engineer the original password.</li><li><strong>Slow Processing</strong>: The iterative nature of bcrypt is intentional. While it takes longer to generate and verify hashes, this also makes brute-force attacks much harder since each guess takes time.</li><li><strong>Adaptive Hashing</strong>: bcrypt allows you to increase the number of hashing rounds over time as hardware becomes more powerful. This ensures your hashing algorithm stays effective even as attackers’ resources improve.</li></ul><h3>Security Considerations</h3><ul><li><strong>Salt Rounds</strong>: Using too few salt rounds makes bcrypt less secure, but too many rounds can slow down the application. A typical number of salt rounds is between 10-12.</li><li><strong>Avoid Hardcoding Salt</strong>: Always let bcrypt generate the salt automatically; don&#39;t hardcode salts in your code.</li></ul><h3>Common Use Cases</h3><ul><li><strong>Authentication in Web Applications</strong>: Store hashed passwords in databases, ensuring even if your database is compromised, attackers can’t easily retrieve user passwords.</li><li><strong>API Access</strong>: Protect API keys or sensitive tokens by hashing them before storage.</li></ul><h3>Additional Features of bcrypt</h3><ul><li><strong>Cross-platform Compatibility</strong>: bcrypt can be used across different platforms and languages (Node.js, Python, PHP, etc.), which makes it versatile for a variety of applications.</li><li><strong>Automatic Salting</strong>: bcrypt automatically generates a unique salt for each password, ensuring no two passwords will have the same hash, even if they&#39;re the same string.</li></ul><h3>Example: Password Handling in Express</h3><p>Below is a complete example of how bcrypt can be integrated into a basic Express.js authentication flow:</p><pre>const express = require(&#39;express&#39;);<br>const bcrypt = require(&#39;bcrypt&#39;);<br>const app = express();<br>app.use(express.json());<br><br>let users = []; // This is just an in-memory store, typically this would be a database<br><br>// Register Route<br>app.post(&#39;/register&#39;, async (req, res) =&gt; {<br>  try {<br>    const saltRounds = 10;<br>    const hashedPassword = await bcrypt.hash(req.body.password, saltRounds);<br>    users.push({ username: req.body.username, password: hashedPassword });<br>    res.status(201).send(&#39;User registered successfully&#39;);<br>  } catch {<br>    res.status(500).send(&#39;Error registering user&#39;);<br>  }<br>});<br><br>// Login Route<br>app.post(&#39;/login&#39;, async (req, res) =&gt; {<br>  const user = users.find(u =&gt; u.username === req.body.username);<br>  if (!user) return res.status(400).send(&#39;User not found&#39;);<br><br>  try {<br>    if (await bcrypt.compare(req.body.password, user.password)) {<br>      res.send(&#39;Login successful&#39;);<br>    } else {<br>      res.send(&#39;Incorrect password&#39;);<br>    }<br>  } catch {<br>    res.status(500).send(&#39;Error logging in&#39;);<br>  }<br>});<br><br>app.listen(3000, () =&gt; console.log(&#39;Server running on port 3000&#39;));</pre><p>In this example:</p><ul><li><strong>Registration</strong>: User passwords are hashed before being stored.</li><li><strong>Login</strong>: Hashed passwords are compared during login to authenticate the user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuTygvC-N11coeY3zHvHQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uYkYQcBdQpkPyLTi-am0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sACqe44ZaU_QW4j5-lXVIw.png" /></figure><h3>Conclusion</h3><p>bcrypt is a highly secure and industry-standard tool for handling password hashing. Its features, such as automatic salting, iterative hashing, and resistance to brute-force attacks, make it an excellent choice for protecting sensitive user data in any application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e36f5c655e09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Binding in Angular]]></title>
            <link>https://medium.com/@bhupendra_Maurya/data-binding-in-angular-1ba242bef57f?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ba242bef57f</guid>
            <category><![CDATA[property-binding]]></category>
            <category><![CDATA[angular-data-binding]]></category>
            <category><![CDATA[two-way-binding]]></category>
            <category><![CDATA[string-interpolation]]></category>
            <category><![CDATA[one-way-binding]]></category>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 10:29:59 GMT</pubDate>
            <atom:updated>2024-09-16T10:35:08.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M0UhDhQ-21achCiF.png" /></figure><h3>Table of contents</h3><ul><li>1. Interpolation (One-Way Data Binding)</li><li>2. Property Binding (One-Way Binding)</li><li>3. Attribute Binding</li><li>4. Style Binding</li><li>5. Class Binding</li><li>6. Event Binding</li><li>7. Two-Way Data Binding</li><li>8. Comparison of Bindings</li><li>9. Choosing the Right Binding</li><li>10. Example</li></ul><p>In Angular, bindings are a way to communicate between the component’s data and the view (HTML template). There are several types of bindings in Angular, each suited to different scenarios. Let’s dive into the various types of data binding mechanisms with examples, and when to use each type:</p><h3>1. Interpolation (One-Way Data Binding)</h3><p>Description: Interpolation binds data from the component class to the view. It is a one-way data flow where the data flows from the component to the template.</p><p><strong>Syntax: </strong>{{ expression }}</p><p><strong>Example:</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;h1&gt;{{ title }}&lt;/h1&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  title = &#39;Hello, Angular!&#39;;<br>}</pre><p><strong>Explanation:</strong> The value of the title property in the component is displayed inside the h1 tag in the template.</p><p><strong>When to use: </strong>Use interpolation when you want to display a value from the component class inside the HTML. This is suitable for dynamically showing text or values, such as user input or fetched data, that don’t require any interaction back to the component.</p><h3>2. Property Binding (One-Way Binding)</h3><p>Description: Property binding is used to bind values to DOM properties (not HTML attributes) in the view. This also has a one-way flow from the component class to the DOM.</p><p><strong>Syntax:</strong> [property]=&quot;expression&quot;</p><p><strong>Example:</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;img [src]=&quot;imageUrl&quot; alt=&quot;Angular Logo&quot; /&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  imageUrl = &#39;https://angular.io/assets/images/logos/angular/angular.svg&#39;;<br>}</pre><p><strong>Explanation:</strong> The [src] binds the imageUrl property from the component to the src attribute of the img tag.</p><p><strong>When to use: </strong>Use property binding when you want to dynamically set DOM properties such as src, disabled, or value. It’s useful when you want the UI to reflect changes made in the component data.</p><h3>3. Attribute Binding</h3><p>Description: Attribute binding sets the value of an HTML attribute, not a DOM property. Unlike property binding, it is useful when working with custom attributes or specific HTML attributes like aria, role, colspan, etc.</p><p><strong>Syntax:</strong> [attr.attributeName]=&quot;expression&quot;</p><p><strong>Example:</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;button [attr.aria-label]=&quot;buttonLabel&quot;&gt;Click Me&lt;/button</pre><pre>// app.component.ts<br>export class AppComponent {<br>  buttonLabel = &#39;Submit Button&#39;;<br>}</pre><p><strong>Explanation:</strong> The value of the buttonLabel property is dynamically assigned to the aria-label attribute of the button.</p><p><strong>When to use:</strong> Use attribute binding when you need to work with attributes that are not directly supported by property binding, such as aria attributes for accessibility.</p><h3>4. Style Binding</h3><p>Description: Style binding is used to set inline styles for a DOM element. You can bind individual CSS properties or apply multiple styles.</p><p><strong>Syntax:</strong></p><ul><li><strong>Single style:</strong> [<a href="http://style.property/">style.property</a>]=&quot;expression&quot;</li><li><strong>Multiple styles:</strong> [ngStyle]=&quot;stylesObject&quot;</li></ul><p><strong>Example (Single style):</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;p [style.color]=&quot;isRed ? &#39;red&#39; : &#39;blue&#39;&quot;&gt;This text changes color&lt;/p&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  isRed = true;<br>}</pre><p><strong>Example (Multiple styles):</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;p [ngStyle]=&quot;{&#39;font-size&#39;: fontSize, &#39;font-weight&#39;: fontWeight}&quot;&gt;Styled Text&lt;/p&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  fontSize = &#39;20px&#39;;<br>  fontWeight = &#39;bold&#39;;<br>}</pre><p><strong>Explanation:</strong></p><ul><li>The first example dynamically sets the color of the text based on a boolean property isRed.</li><li>The second example dynamically applies multiple styles using the ngStyle directive.</li></ul><p>When to use: Use style binding when you need to apply dynamic inline styles to elements based on component properties or conditions.</p><h3>5. Class Binding</h3><p>Description: Class binding is used to add or remove classes on DOM elements conditionally. Like style binding, it can bind a single class or multiple classes.</p><p><strong>Syntax:</strong></p><ul><li><strong>Single class:</strong> [class.className]=&quot;expression&quot;</li><li><strong>Multiple classes: </strong>[ngClass]=&quot;classesObject&quot;</li></ul><p><strong>Example (Single class):</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;p [class.active]=&quot;isActive&quot;&gt;This text can be active&lt;/p&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  isActive = true;<br>}</pre><p><strong>Example (Multiple classes):</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;p [ngClass]=&quot;{&#39;active&#39;: isActive, &#39;disabled&#39;: isDisabled}&quot;&gt;This text has dynamic classes&lt;/p&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  isActive = true;<br>  isDisabled = false;<br>}</pre><p><strong>Explanation:</strong></p><ul><li>The first example adds or removes the active class based on the value of the isActive property.</li><li>The second example conditionally applies multiple classes using ngClass.</li></ul><p><strong>When to use:</strong> Use class binding when you want to conditionally apply or remove classes based on component data.</p><h3>6. Event Binding</h3><p>Description: Event binding is used to handle DOM events, like click, keyup, change, etc. This is a one-way binding from the template to the component.</p><p><strong>Syntax:</strong> (eventName)=&quot;expression&quot;</p><p><strong>Example:</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;button (click)=&quot;onClick()&quot;&gt;Click Me&lt;/button&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  onClick() {<br>    alert(&#39;Button clicked!&#39;);<br>  }<br>}</pre><p><strong>Explanation:</strong> When the button is clicked, the onClick() method is invoked, and the alert is shown.</p><p><strong>When to use:</strong> Use event binding when you want to capture user actions or DOM events and execute logic in your component, like form submissions, button clicks, or keyboard events.</p><h3>7. Two-Way Data Binding</h3><p>Description: Two-way data binding allows the component to bind data to the view and the view to update the component, creating a synchronized data flow. This is achieved using the [(ngModel)] directive (requires FormsModule).</p><p><strong>Syntax:</strong> [(ngModel)]=&quot;property&quot;</p><p><strong>Example:</strong></p><pre>&lt;!-- app.component.html --&gt;<br>&lt;input type=&quot;text&quot; [(ngModel)]=&quot;name&quot; /&gt;<br>&lt;p&gt;Your name is: {{ name }}&lt;/p&gt;</pre><pre>// app.component.ts<br>export class AppComponent {<br>  name = &#39;&#39;;<br>}</pre><p><strong>Explanation:</strong> The input field is bound to the name property. Any changes made in the input field automatically update name, and any changes in name reflect in the input field.</p><p><strong>When to use:</strong> Use two-way data binding when you need bidirectional communication between the component and the view, such as in forms where user inputs need to be synced with component data.</p><h3>Comparison of Bindings</h3><ul><li><strong>One-way Data Binding:</strong> Component → View (e.g., Interpolation, Property Binding). Use when you only need to display data.</li><li><strong>Event Binding:</strong> View → Component (e.g., (click) event). Use when you need to capture and respond to user actions.</li><li><strong>Two-way Data Binding:</strong> Component ↔ View (e.g., [(ngModel)]). Use in forms or inputs where data flows both ways.</li><li><strong>Style and Class Binding:</strong> Component → View. Use to apply dynamic styles or classes based on component logic.</li></ul><h3>Choosing the Right Binding</h3><ul><li><strong>Display data: </strong>Use interpolation or property binding.</li><li><strong>Update data in response to user input:</strong> Use event binding or two-way data binding.</li><li><strong>Style dynamically: </strong>Use style or class binding.</li><li><strong>Handling DOM events:</strong> Use event binding.</li></ul><h3>Example</h3><p>To create an input field in Angular and display its value in an h1 tag using one-way data binding, you can use interpolation for displaying the value and bind the input element to a component property using [(ngModel)].</p><h3>Steps:</h3><ol><li>Install FormsModule: You need to import FormsModule to use [(ngModel)] for two-way data binding.</li><li>Component Class: Define the inputValue property in the component class.</li></ol><p>In your app.component.ts file:</p><pre>import { Component } from &#39;@angular/core&#39;;<br>import { FormsModule } from &#39;@angular/forms&#39;;<br>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  imports: [ FormsModule],<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent {<br>  inputValue: string = &#39;&#39;;  // This will hold the input value<br>}</pre><p>3. Component Template: Use [(ngModel)] for one-way data binding from the input field to the component.</p><p>In your app.component.html file:</p><pre>&lt;input type=&quot;text&quot; [(ngModel)]=&quot;inputValue&quot; placeholder=&quot;Type something&quot; /&gt;<br>&lt;h1&gt;{{ inputValue }}&lt;/h1&gt;</pre><h3>Explanation:</h3><ul><li>The [(ngModel)]=&quot;inputValue&quot; binds the value from the input field to the inputValue variable in the component.</li><li>The {{ inputValue }} inside the h1 tag displays the value of inputValue.</li></ul><p>Now, when the user types into the input field, the value will be reflected in the h1 tag.</p><p>To achieve the same functionality without using ngModel from FormsModule, we can rely on event binding for one-way data flow. In this case, you would capture the input event from the text field and manually update the component property, which will be reflected in the h1 tag.</p><p>Here’s how to do it using property binding and event binding:</p><h3>Steps:</h3><ol><li>Component Template: Use the input event to bind to a function that updates the component property.</li></ol><p>In your app.component.html file:</p><pre>&lt;input type=&quot;text&quot; (input)=&quot;onInputChange($event)&quot; placeholder=&quot;Type something&quot; /&gt;<br>&lt;h1&gt;{{ inputValue }}&lt;/h1&gt;</pre><p>2. Component Class: In the class, create a method that captures the input event and updates the inputValue.</p><p>In your app.component.ts file:</p><pre>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent {<br>  inputValue: string = &#39;&#39;;  // Holds the input value<br><br>  // Updates the inputValue when user types<br>  onInputChange(event: Event): void {<br>    const target = event.target as HTMLInputElement;<br>    this.inputValue = target.value;<br>  }<br>}</pre><h3>Explanation:</h3><h3>Explanation:</h3><ul><li>The (input) event is bound to the onInputChange() method, which gets triggered every time the user types in the input field.</li><li>The method updates the inputValue property with the new value from the input field.</li><li>The {{ inputValue }} interpolation then reflects this value in the h1 tag.</li></ul><p>This method avoids using ngModel and still achieves the same result with manual event handling.</p><h3>Written by</h3><p><a href="https://medium.com/@bhupendra_Maurya">Bhupendra</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ba242bef57f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Storage Services]]></title>
            <link>https://medium.com/@bhupendra_Maurya/aws-storage-services-029bda8b5861?source=rss-b51508f4afc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/029bda8b5861</guid>
            <category><![CDATA[aws-block-storage]]></category>
            <category><![CDATA[aws-efs]]></category>
            <category><![CDATA[aws-storage]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-glacier]]></category>
            <dc:creator><![CDATA[Bhupendra]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 09:27:57 GMT</pubDate>
            <atom:updated>2024-04-22T09:27:57.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*6uJFkH7AVt7d6NLfmC64nw.png" /></figure><p><strong>Scenario</strong> : Gia have a business on premises and now she want to move her businesss to AWS she need some storage solutions .</p><p><strong>Scene:</strong> Gia, a business owner, is on a call with John, an AWS specialist. Gia is looking to migrate her on-premises business to AWS and needs storage solutions.</p><p><strong>Gia:</strong> Hi John, thanks for taking my call. I’m Gia, and I’m looking to move my business to the cloud using AWS. I currently have everything stored on-premises, but I’m hoping to find a more scalable and cost-effective solution.</p><p><strong>John:</strong> Hi Gia, happy to help! AWS offers a variety of storage services to fit different needs. Can you tell me a bit more about what kind of data you’ll be storing and how you’ll be accessing it?</p><p><strong>Gia:</strong> Sure. I mostly have <strong>unstructured</strong> <strong>data</strong> like <strong>documents</strong>, <strong>images</strong>, and <strong>backups</strong>. My applications need to access some of this data frequently, while other data can be archived for long-term storage.</p><p><strong>John:</strong> Understood. Based on what you’ve described, there are three main categories of AWS storage services to consider: <strong>block storage, file storage, </strong>and<strong> object storage.</strong></p><p><strong>Block Storage:</strong></p><ul><li>This is best suited for storing data that needs to be accessed by individual block units, like hard drives.</li><li>It offers high performance and is ideal for running operating systems, databases, and applications that require low latency access.</li><li>The primary service in this category is:</li><li><strong>Amazon Elastic Block Store (EBS):</strong> EBS provides persistent block storage volumes for EC2 instances. You can attach EBS volumes to your instances and use them like traditional hard drives.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*AdrE5EZo7WZR0YXzI-aKpQ.png" /></figure><p><strong>File Storage:</strong></p><ul><li>This is designed for storing and managing file systems that can be accessed by multiple applications or users simultaneously.</li><li>It provides a familiar file system structure, similar to what you might have on-premises.</li><li>Here are the main services to consider:</li><li><strong>Amazon Elastic File System (EFS):</strong> EFS offers a simple, scalable file system for use with EC2 instances. It’s ideal for sharing data between applications within a single Availability Zone.</li><li><strong>Amazon FSx:</strong> This service provides a wider range of file system options, including popular choices like FSx for Windows File Server, FSx for NetApp ONTAP, and FSx for OpenZFS. These offer compatibility with specific file system protocols and features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNyQwzvqhIDPEYoNl0Vu9g.png" /></figure><p><strong>Object Storage:</strong></p><ul><li>This is a highly scalable and cost-effective solution for storing large amounts of unstructured data.</li><li>Objects are individually addressed and retrieved, making it ideal for backups, archives, and storing large datasets like media files.</li><li>The primary service in this category is:</li><li><strong>Amazon Simple Storage Service (S3):</strong> S3 is an incredibly versatile storage solution with various storage classes to optimize cost based on access frequency. It’s great for storing any type of object and offers features like data lakes, disaster recovery, and static website hosting.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*TAAwBVEdMNWLPVgkJLaL6w.png" /></figure><p><strong>Gia:</strong> This is all very helpful, John. So, if I have frequently accessed application data, would EBS or EFS be a better choice?</p><p><strong>John:</strong> That depends on your specific needs. EBS offers higher performance and is ideal for mission-critical applications requiring low latency. EFS is a good choice for sharing data between applications within an Availability Zone and is generally more cost-effective.</p><p><strong>Gia:</strong> Perfect. And for my backups and archives, it sounds like S3 would be the way to go?</p><p><strong>John:</strong> Absolutely! S3 offers different storage classes with varying retrieval times and costs. You can choose the class that best suits your access needs for backups and archives.</p><p><strong>Gia:</strong> This clarifies a lot, John. I feel much more confident about choosing the right storage solutions for my business on AWS.</p><p><strong>John:</strong> I’m glad I could help, Gia! There are additional factors to consider when choosing storage, like security and replication. Let me know if you have any further questions about those or anything else related to your AWS migration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=029bda8b5861" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>