<?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 MrNikhillyadav on Medium]]></title>
        <description><![CDATA[Stories by MrNikhillyadav on Medium]]></description>
        <link>https://medium.com/@nikyadav20032003?source=rss-897784b4b176------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MiP4vTSKxS__zu0ezDz29Q.png</url>
            <title>Stories by MrNikhillyadav on Medium</title>
            <link>https://medium.com/@nikyadav20032003?source=rss-897784b4b176------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 16 May 2026 18:06:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikyadav20032003/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[Kubernetes Requests, limits and Horizontal pod autoscaling (HPA)]]></title>
            <link>https://medium.com/@nikyadav20032003/kubernetes-requests-limits-and-horizontal-pod-autoscaling-hpa-aa6cd0b9232a?source=rss-897784b4b176------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa6cd0b9232a</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[horizontal-pod-autoscaler]]></category>
            <category><![CDATA[scaling]]></category>
            <dc:creator><![CDATA[MrNikhillyadav]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 09:41:06 GMT</pubDate>
            <atom:updated>2025-06-19T09:41:06.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVZLj2t5XYejpfft3Ov4Xg.png" /><figcaption>horizontal pod autoscaling in kubernetes</figcaption></figure><h3>Kubernetes Resource Requests and Limits</h3><p><strong>Requests</strong> define the minimum resourczs (CPU/memory) guaranteed to a container. Kubernetes uses requests to:</p><ul><li>Schedule Pods on nodes with sufficient resources</li><li>Reserve resources for stable performance<br> <em>Example:</em> requests: {cpu: &quot;0.5&quot;, memory: &quot;256Mi&quot;} reserves half a CPU core and 256MB RAM.</li></ul><p><strong>Limits</strong> cap the maximum resources a container can use:</p><ul><li>Exceeding CPU limits causes throttling</li><li>Exceeding memory limits triggers OOM kills<br> <em>Example:</em> limits: {cpu: &quot;1&quot;, memory: &quot;512Mi&quot;} prevents the container from using &gt;1 CPU core or 512MB RAM.</li></ul><h3>Horizontal Pod Autoscaler (HPA) Scaling</h3><p>HPA automatically adjusts Pod replicas based on observed metrics, solving dynamic workload demands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*t6b3xLsJ-MqNUdzQ.png" /></figure><p><strong>How HPA Works</strong>:</p><ol><li><strong>Metric Collection</strong>: Every 15–30 seconds, HPA checks:</li></ol><ul><li>CPU/memory utilization</li><li>Custom metrics (e.g., HTTP requests per second)</li></ul><p><strong>2. Calculation</strong>: Compares current vs. target metrics:</p><p>desired_replicas = ceil[current_metric_value / target_metric_value]</p><p><strong>3. Scaling Decision</strong>:</p><ul><li>Scales up if utilization &gt; target</li><li>Scales down if utilization &lt; target</li></ul><p><strong>4. Action</strong>: Updates replica count in Deployment/StatefulSet</p><p><strong>Scaling Based on Resource Metrics</strong>:<br> HPA uses <strong>resource requests</strong> to calculate utilization percentages:</p><pre>CPU utilization % = (Actual CPU usage / CPU request) × 100</pre><p><em>Example:</em> If a Pod requests 0.5 CPU cores and uses 0.4 cores, utilization is 80%.</p><h3>Example: Node.js App with HPA</h3><pre># Deployment with resource requests<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nodejs-app<br>spec:<br>  replicas: 3<br>  template:<br>    spec:<br>      containers:<br>      - name: app<br>        image: node:18<br>        resources:<br>          requests:<br>            cpu: &quot;0.5&quot;<br>            memory: &quot;256Mi&quot;<br>          limits:<br>            cpu: &quot;1&quot;<br>            memory: &quot;512Mi&quot;<br><br># HPA Configuration<br><br>apiVersion: autoscaling/v2<br>kind: HorizontalPodAutoscaler<br>metadata:<br>  name: nodejs-hpa<br>spec:<br>  scaleTargetRef:<br>    apiVersion: apps/v1<br>    kind: Deployment<br>    name: nodejs-app<br>  minReplicas: 3<br>  maxReplicas: 10<br>  metrics:<br>  - type: Resource<br>    resource:<br>      name: cpu<br>      target:<br>        type: Utilization<br>        averageUtilization: 70</pre><p><strong>Behavior</strong>:</p><ul><li>If average CPU usage across Pods exceeds 70% of requested CPU (0.35 cores), HPA adds replicas</li><li>If usage drops below 70%, HPA removes replicas (minimum 3)</li><li>Pods never exceed 1 CPU core (limit)</li></ul><h3>Key Advantages of HPA</h3><ol><li><strong>Cost Efficiency</strong>: Scales down during low traffic</li><li><strong>Performance Stability</strong>: Maintains response times under load</li><li><strong>Automation</strong>: Eliminates manual scaling interventions</li><li><strong>Multi-Metric Support</strong>: Scales based on:</li></ol><ul><li>CPU/memory utilization</li><li>Custom app metrics (e.g., queue length)</li><li>External metrics (e.g., Cloud Pub/Sub backlog)</li></ul><p><strong>Limitations</strong></p><ul><li>Requires accurate resource requests for effective scaling</li><li>Scaling delay (typically 30–60 seconds)</li><li>Doesn’t adjust container-level resources (use VPA for vertical scaling)</li></ul><h3>First Principles Summary</h3><p><strong>Problem</strong>: Static resource allocation struggles with variable workloads, causing either:</p><ul><li>Over-provisioning (wasted resources)</li><li>Under-provisioning (poor performance)</li></ul><p><strong>Solution</strong>:</p><ul><li><strong>Requests/Limits</strong>: Isolate applications and prevent resource starvation</li><li><strong>HPA</strong>: Dynamically align resources with actual demand using metrics</li></ul><p>This combination enables efficient, self-healing infrastructure that responds to real-time workload changes while maintaining stability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa6cd0b9232a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Key Advantages of Kubernetes Over EC2 and ECS]]></title>
            <link>https://medium.com/@nikyadav20032003/key-advantages-of-kubernetes-over-ec2-and-ecs-110b08d27944?source=rss-897784b4b176------2</link>
            <guid isPermaLink="false">https://medium.com/p/110b08d27944</guid>
            <dc:creator><![CDATA[MrNikhillyadav]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 11:49:31 GMT</pubDate>
            <atom:updated>2025-04-19T11:49:31.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*jZfRpCAwvhfrWOc7.png" /></figure><p>Kubernetes simplifies application deployment by abstracting infrastructure management and automating container orchestration, unlike AWS EC2 or ECS, which require more manual intervention. Let’s break this down with a situational example:</p><h3>Situational Example: Deploying a Web Application</h3><h3>Scenario</h3><p>A team wants to deploy a containerized Node.js web app with Redis caching. Here’s how the process differs across platforms:</p><h3>1. AWS EC2 Approach</h3><p><strong>Steps Required</strong>:</p><ol><li><strong>Provision EC2 Instances</strong>: Manually launch and configure VMs (e.g., Ubuntu).</li><li><strong>SSH into VMs</strong>: Log into each instance to install Docker, clone the GitHub repo, and build the image:</li></ol><pre>git clone https://github.com/your/app.git<br>docker build -t my-app .<br>docker run -d -p 3000:3000 my-app</pre><ol><li><strong>Manual Scaling</strong>: Repeat steps for each new instance during traffic spikes.</li><li><strong>Load Balancing</strong>: Manually configure an Elastic Load Balancer (ELB).</li></ol><p><strong>Problems</strong>:</p><ul><li><strong>Time-Consuming</strong>: Repetitive setup for each VM.</li><li><strong>Error-Prone</strong>: Manual steps risk inconsistencies.</li><li><strong>No Self-Healing</strong>: If a VM crashes, the app stays down until manually restarted.</li></ul><h3>2. AWS ECS Approach</h3><p><strong>Steps Required</strong>:</p><ol><li><strong>Create a Task Definition</strong>: Define the Docker image, ports, and environment variables in JSON/YAML.</li><li><strong>Configure ECS Cluster</strong>: Use EC2 instances or Fargate (serverless) to host containers.</li><li><strong>Deploy Service</strong>: ECS pulls the image from Docker Hub and runs containers.</li></ol><p><strong>Improvements Over EC2</strong>:</p><ul><li><strong>Automated Container Orchestration</strong>: ECS manages container lifecycle.</li><li><strong>Integration with AWS Services</strong>: Auto-scaling and load balancing via Application Load Balancer (ALB).</li></ul><p><strong>Limitations</strong>:</p><ul><li><strong>AWS Lock-In</strong>: Tightly coupled with AWS APIs and tools.</li><li><strong>Limited Customization</strong>: Less control over infrastructure compared to Kubernetes.</li></ul><h3>3. Kubernetes Approach</h3><p><strong>Steps Required</strong>:</p><ol><li><strong>Define a Deployment</strong>: Declare the desired state in a YAML file:</li></ol><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: web-app<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: web<br>  template:<br>    metadata:<br>      labels:<br>        app: web<br>    spec:<br>      containers:<br>      - name: web<br>        image: your-dockerhub-username/web-app:latest<br>        ports:<br>        - containerPort: 3000</pre><p><strong>2. Apply the Configuration</strong>:</p><pre>kubectl apply -f deployment.yaml</pre><p><strong>3. Kubernetes Automates</strong>:</p><ul><li>Pulls the image from Docker Hub.</li><li>Schedules pods across nodes.</li><li>Monitors health and restarts failed containers.</li><li>Scales replicas up/down based on traffic.</li></ul><p><strong>Key Advantages</strong>:</p><ul><li><strong>No SSH or Manual Setup</strong>: Kubernetes manages nodes; you only define the desired state.</li><li><strong>Self-Healing</strong>: Restarts crashed containers automatically.</li><li><strong>Cloud-Agnostic</strong>: Same configuration works on AWS, GCP, or on-premises.</li><li><strong>Declarative Management</strong>: Focus on <em>what</em> to deploy, not <em>how</em>.</li></ul><h3>Why Kubernetes is Easier</h3><figure><img alt="ECS vs EC2 vs Kubernetes" src="https://cdn-images-1.medium.com/max/1024/1*zuzEzClOpfpKuNH7X9G_dA.png" /><figcaption>EC2 vs ECS vs Kubernetes</figcaption></figure><h3>Real-World Workflow Comparison</h3><p><strong>Task</strong>: Roll out a new version of the app.</p><p><strong>EC2/ECS</strong>:</p><ul><li>Update the Docker image tag in the task definition or rebuild on VMs.</li><li>Manually deploy or use ECS service updates.</li><li>Risk downtime during rollout.</li></ul><p><strong>Kubernetes</strong>:</p><ul><li>Update the image field in the deployment YAML.</li><li>Run kubectl apply.</li><li>Kubernetes performs a zero-downtime rolling update.</li></ul><h3>Why Avoid SSH?</h3><p>Kubernetes eliminates the need to SSH into nodes because:</p><ol><li><strong>Immutable Infrastructure</strong>: Nodes are treated as disposable; issues are resolved by replacing pods, not debugging VMs.</li><li><strong>Declarative API</strong>: All changes are made via kubectl or<strong> </strong>GitOps tools (e.g., Argo CD).</li><li><strong>Centralized Logs/Metrics</strong>: Use tools like Prometheus/Grafana instead of SSH-based debugging.</li></ol><h3>When to Use Which?</h3><ul><li><strong>EC2</strong>: Legacy apps not yet containerized.</li><li><strong>ECS</strong>: Simple AWS-centric apps with minimal customization needs.</li><li><strong>Kubernetes</strong>: Complex, cloud-agnostic microservices requiring granular control.</li></ul><p>By automating image management, scaling, and self-healing, Kubernetes reduces operational toil and lets developers focus on writing code rather than managing infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=110b08d27944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Controlled vs Uncontrolled components]]></title>
            <link>https://medium.com/@nikyadav20032003/controlled-vs-uncontrolled-components-516d500e5360?source=rss-897784b4b176------2</link>
            <guid isPermaLink="false">https://medium.com/p/516d500e5360</guid>
            <dc:creator><![CDATA[MrNikhillyadav]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 04:17:28 GMT</pubDate>
            <atom:updated>2025-03-25T04:17:28.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*WgWzo4EWwQ5WEEMfRNVdRw.png" /></figure><p>In React, controlled components manage their state using React’s state, while uncontrolled components manage their state internally within the DOM, accessed via refs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*qf76JMzpzESX0OOMdJZNTQ.png" /></figure><h3>Controlled component</h3><p>React’s state handles the form data, and the component updates the state when the input value changes. The input’s value is explicitly set through the value prop, ensuring React controls the input&#39;s value. An onChange event handler updates the state whenever the input value changes.</p><p>Controlled components offer predictability as the component manages the state of the form elements. We can perform real-time validation on the form data within the component&#39;s state</p><h3>Uncontrolled Component</h3><p>The input’s value is managed by the DOM itself, not by React state. You access the input’s value directly from the DOM, typically using a ref. We can perform validation on the input data only after the form is submitted , as the component doesn&#39;t have direct access to the form data in its state. uncontrolled components are not predictable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EiaoyMcwN-TTwBivTTm6qA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=516d500e5360" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s an Abstract class in typescript ?]]></title>
            <link>https://medium.com/@nikyadav20032003/whats-an-abstract-class-in-typescript-4148a3b461d5?source=rss-897784b4b176------2</link>
            <guid isPermaLink="false">https://medium.com/p/4148a3b461d5</guid>
            <category><![CDATA[typescript-tips]]></category>
            <category><![CDATA[abstract-class]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[classes-and-objects]]></category>
            <category><![CDATA[typeface]]></category>
            <dc:creator><![CDATA[MrNikhillyadav]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 03:57:11 GMT</pubDate>
            <atom:updated>2024-12-02T03:57:11.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="abstract class" src="https://cdn-images-1.medium.com/max/1024/1*GrMgJUeusSjF7fvR492PMQ.png" /></figure><h3>What’s an Abstract class in typescript ?</h3><p>An abstract class in TypeScript serves as a blueprint for other classes and cannot be instantiated directly. It is primarily used to define common behaviors and properties that can be shared among derived classes. Here’s a breakdown of the syntax and purpose of abstract classes:</p><h3>Syntax of Abstract Classes</h3><p>To declare an abstract class, you use the</p><pre>abstract</pre><p>keyword before the class definition. Inside an abstract class, you can define abstract methods, which do not have an implementation and must be implemented by any subclass that extends the abstract class.</p><h3>Example Syntax</h3><pre>typescriptabstract class Animal {<br>    *// Abstract method (no implementation)*<br>    abstract makeSound(): void;</pre><pre>    *// Concrete method (with implementation)*<br>    move(): void {<br>        console.log(&quot;Moving...&quot;);<br>    }<br>}</pre><h3>Key Points:</h3><ul><li>Abstract Class Declaration: Use the abstract keyword before the class keyword.</li><li>Abstract Methods: Methods declared with abstract do not have a body and must be implemented in derived classes.</li><li>Concrete Methods: You can also include regular methods with implementations that can be inherited by subclasses.</li><li>Cannot Instantiate: You cannot create an instance of an abstract class directly, which prevents its use without a concrete subclass.</li></ul><h3>Purpose of Abstract Classes</h3><ol><li>Common Interface: Abstract classes provide a common interface for all subclasses. This ensures that all derived classes implement certain methods, promoting consistency across related classes.</li><li>Code Reusability: They allow you to define shared behavior in one place (the abstract class), reducing code duplication in subclasses. For example, if multiple classes share common properties or methods, these can be defined once in the abstract class.</li><li>Polymorphism: Abstract classes enable polymorphism, allowing you to treat instances of derived classes as instances of the base abstract class. This is useful for designing systems where you want to handle different types of objects through a common interface.</li></ol><h3>Example of Usage</h3><pre>typescriptabstract class Shape {<br>    abstract calculateArea(): number;<br>}</pre><pre>class Rectangle extends Shape {<br>    constructor(private width: number, private height: number) {<br>        super();<br>    }</pre><pre>    calculateArea(): number {<br>        return this.width * this.height;<br>    }<br>}</pre><pre>class Circle extends Shape {<br>    constructor(private radius: number) {<br>        super();<br>    }</pre><pre>    calculateArea(): number {<br>        return Math.PI * this.radius * this.radius;<br>    }<br>}</pre><pre>const shapes: Shape[] = [new Rectangle(5, 10), new Circle(7)];<br>shapes.forEach(shape =&gt; {<br>    console.log(shape.calculateArea());<br>});</pre><h3>Conclusion</h3><p>Abstract classes are a powerful feature in TypeScript that help organize code through inheritance, enforce method implementation in subclasses, and promote code reuse. They are particularly useful in large applications where maintaining consistency across related classes is essential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4148a3b461d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Process of Accessing a Website]]></title>
            <link>https://medium.com/@nikyadav20032003/process-of-accessing-a-website-b672a55843a2?source=rss-897784b4b176------2</link>
            <guid isPermaLink="false">https://medium.com/p/b672a55843a2</guid>
            <category><![CDATA[ip-address]]></category>
            <category><![CDATA[http-server]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[MrNikhillyadav]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 07:17:40 GMT</pubDate>
            <atom:updated>2024-11-01T07:17:40.871Z</atom:updated>
            <content:encoded><![CDATA[<p>A web server is a crucial component of the internet infrastructure that facilitates the delivery of web content to users. It consists of both hardware and software that work together to process requests made by a client (typically a web browser) using the Hypertext Transfer Protocol (HTTP) or its secure variant, HTTPS.</p><h3>What is an HTTP Server?</h3><p>An <strong>HTTP server</strong> is a specific type of web server that understands and processes HTTP requests. When a user enters a URL in their browser, the browser sends an HTTP request to the server hosting the website. The server then retrieves the requested resource (such as an HTML page, image, or video) and sends it back to the browser, which displays it to the user.</p><h3>Functions of a Web Server</h3><ul><li><strong>Serving Static Content</strong>: Delivers files like HTML doc, images, and videos directly to users.</li><li><strong>Dynamic Content Generation</strong>: Processes requests that require real-time data retrieval from databases or application servers.</li><li><strong>Logging and Security</strong>: Records access logs for monitoring and security purposes, and can implement various security measures.</li></ul><h3>Why Do We Need Web Servers?</h3><p>Web servers are essential for several reasons:</p><ul><li><strong>Hosting Websites</strong>: They store and serve the files necessary for websites.</li><li><strong>Data Processing</strong>: They can execute server-side scripts to generate dynamic content.</li><li><strong>Resource Management</strong>: They handle multiple requests simultaneously, allowing many users to access content without significant delays.</li></ul><h3>Relationship Between HTTP Server, Domain Name, IP Address, and Port</h3><h3>Domain Name</h3><p>A <strong>domain name</strong> is a human-readable address (like <a href="http://www.example.com/">www.example.com</a>) that points to an IP address. It simplifies navigating the internet since users do not need to remember numerical IP addresses.</p><h3>IP Address</h3><p>An <strong>IP address</strong> is a unique numerical label assigned to each device connected to a network. When you enter a domain name in your browser, a Domain Name System (DNS) translates it into an IP address so your browser can locate the appropriate web server.</p><h3>Port</h3><p>A <strong>port</strong> is a communication endpoint on a server. By default, HTTP uses port 80 and HTTPS uses port 443. When your browser makes an HTTP request, it typically connects to these ports on the server specified by the IP address.</p><h3>The Process of Accessing a Website</h3><ol><li><strong>User Enters Domain Name</strong>: The user types a domain name into their web browser.</li><li><strong>DNS Lookup</strong>: The browser checks its cache for the corresponding IP address. If not found, it queries a DNS server to resolve the domain name into an IP address.</li><li><strong>Establishing Connection</strong>: The browser establishes a connection with the web server at the resolved IP address on the appropriate port (usually 80 for HTTP or 443 for HTTPS).</li><li><strong>Sending HTTP Request</strong>: The browser sends an HTTP request to the web server asking for specific resources (like an HTML page).</li><li><strong>Server Response</strong>:</li></ol><ul><li>The web server receives the request through its HTTP server component.</li><li>It processes the request, retrieves necessary files (static or dynamic), and sends them back as an HTTP response.</li></ul><p><strong>6. Displaying Content</strong>: The browser receives the response and renders the webpage for the user to view.</p><p>This entire process happens in seconds, enabling seamless browsing experiences across the internet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b672a55843a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>