<?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 Athira KK on Medium]]></title>
        <description><![CDATA[Stories by Athira KK on Medium]]></description>
        <link>https://medium.com/@iam-athirakk?source=rss-aa0a76b69130------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*i1eJioqNFVeuIgSwIihnXg@2x.jpeg</url>
            <title>Stories by Athira KK on Medium</title>
            <link>https://medium.com/@iam-athirakk?source=rss-aa0a76b69130------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:24:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iam-athirakk/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[Debugging CrashLoopBackOff: A Hands-On Lab Guide]]></title>
            <link>https://iam-athirakk.medium.com/debugging-crashloopbackoff-a-hands-on-lab-guide-a0a89d93924e?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0a89d93924e</guid>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Wed, 18 Mar 2026 12:57:43 GMT</pubDate>
            <atom:updated>2026-03-18T12:57:43.228Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Walk through four common failure scenarios — ConfigMap misconfiguration, missing files, failing probes, and resource pressure — and learn how to fix each one.</strong></p><p>Hey… 🫶 Welcome Back………………….🤞</p><p>What is CrashLoopBackOff?</p><p>CrashLoopBackOff is a Kubernetes pod state that means: the container started, crashed, Kubernetes tried to restart it, it crashed again — and this loop keeps repeating. Kubernetes applies an exponential backoff delay (10s → 20s → 40s → 80s → 5min max) before each retry, hence the name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJsksC0lndtWKw1XbXSGww.png" /></figure><p>When you see “Back-off restarting failed container”, it means the kubelet tried to restart a failed container, but the attempt was not successful. Instead of continuously restarting it immediately, Kubernetes introduces a delay before trying again.</p><p>So, what does “Back-off” mean here?</p><p>By default, Kubernetes automatically restarts containers when they crash. However, if the application keeps failing repeatedly, Kubernetes avoids rapid restart attempts. Instead, it waits for a short period before retrying.</p><p>This delay is intentional. It gives the application time in case the failure was due to a temporary issue. If the problem continues, Kubernetes gradually increases the waiting time between each restart attempt, up to a certain limit. This mechanism is known as the back-off strategy, and it helps prevent unnecessary resource consumption and continuous failure loops.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1HWRN7OQnz53jGydKMyBg.png" /></figure><p>The Kubernetes Troubleshooting Framework</p><p>Always follow this sequence. Do NOT skip steps — each command reveals something different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OOHnsFbGnxuLcwi8N6f6g.png" /></figure><blockquote>Create the Namespace</blockquote><p>Before deploying anything, create an isolated namespace so the lab does not interfere with anything else running on the cluster.</p><p><strong>Why:</strong> Namespaces give you a clean boundary. All resources created in this lab live here and can be torn down with a single kubectl delete namespace command when you are done.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: app-config<br>data:<br>  APP_MODE: &quot;production&quot;<br><br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: broken-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: broken-app<br>  template:<br>    metadata:<br>      labels:<br>        app: broken-app<br>    spec:<br>      containers:<br>      - name: app<br>        image: python:3.9<br>        command: [&quot;python&quot;]<br>        args: [&quot;app.py&quot;]   # ❌ missing file<br>        env:<br>        - name: DB_HOST<br>          value: mysql-service  <br>        - name: APP_MODE<br>          valueFrom:<br>            configMapKeyRef:<br>              name: app-config<br>              key: WRONG_KEY   # ❌ wrong key<br>        resources:<br>          requests:<br>            memory: &quot;2Gi&quot;   # ❌ too high → Pending<br>            cpu: &quot;2&quot;<br>        volumeMounts:<br>        - name: config<br>          mountPath: /config<br>        livenessProbe:<br>          httpGet:<br>            path: /health   # ❌ invalid endpoint<br>            port: 80<br>          initialDelaySeconds: 5<br>          periodSeconds: 5<br>      volumes:<br>      - name: config<br>        configMap:<br>          name: app-config</pre><pre>kubectl apply -f broken-app.yaml</pre><blockquote><strong>SCENARIO-1 Wrong ConfigMap key</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avz6wD5u2bVbU0LwOQphGg.png" /></figure><p>The deployment references WRONG_KEY in the ConfigMap, but the actual key is APP_MODE. Kubernetes will refuse to start the container since the referenced key doesn’t exist.</p><p>Fix: kubectl edit deployment broken-app</p><p>Change: key: APP_MODE</p><p>💡Always validate your ConfigMap keys with kubectl describe configmap before deploying. A typo here silently blocks container startup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfrgMMkhKAmZ1guGUKeybg.png" /></figure><blockquote><strong>SCENARIO-2 Application crash — missing file</strong></blockquote><p>The container tries to run python app.py, but app.py doesn’t exist in the image. Python exits immediately with a non-zero code, which triggers a restart loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPDccQE5kw4RjAbuoRSXdw.png" /></figure><p>Verify container config -</p><pre>kubectl describe pod broken-app-588b786995-nnfzk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgX7RFWqK6CGAfV8vc5VnA.png" /></figure><p><strong>Fix — replace the command with inline Python</strong></p><p><strong>- args: [“app.py”] # ❌ file doesn’t exist + args: + — “-c” + — “import time; print(‘App Running’); time.sleep(3600)”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7NGAIHNsKEp_NvYAWmoKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M8OxnlFnNMA9n_0NGWStqg.png" /></figure><p>💡Use kubectl logs — previous when the current container has already restarted — it shows logs from the crashed instance, not the new one.</p><blockquote><strong>SCENARIO-3 Liveness probe failure</strong></blockquote><p>The probe sends an HTTP GET to /health on port 80, but there is no web server in the container. Every probe fails, Kubernetes marks the container unhealthy, and restarts it — creating a loop even when the app technically ran fine.</p><p>⚠️If kubectl describe pod shows <strong>Exit Code: 0</strong> but the pod keeps restarting, the container is finishing too fast — not crashing. The liveness probe or resource pressure is the culprit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIINbY651Uxdldkh0rX-PA.png" /></figure><p>Fix — switch to an exec probe</p><p>Exit Code: 0 — Means, Your container finishes immediately, Kubernetes restarts it , Loop → CrashLoopBackOff</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhdr6uuDhyh1wLIVz-qMnA.png" /></figure><p>Edited to :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJADdG-1PJIveLMJvPGrPg.png" /></figure><p>💡Only use httpGet probes when your container actually serves HTTP. For batch jobs or Python scripts, an exec probe that runs a simple command is far more reliable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wazf-ek3GdV0ETeE5BbbwQ.png" /></figure><blockquote><strong>SCENARIO-4 Resource pressure → Pending pod</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ry3BGCzDfFU70F20XX2rZw.png" /></figure><p>This confirms:</p><ul><li>The <strong>application is running fine</strong></li><li>The reason for restarts is either:</li></ul><ol><li><strong>Container exits too fast</strong> → deployment expects long-running</li><li><strong>Node resource pressure</strong> → memory/CPU too high</li></ol><pre>Run kubectl get pods - status shows Pending(not Running or CrashLoopBackOff)<br>Run kubectl describe pod &lt;pod-name&gt; - look for Insufficient memoryor Insufficient cpuin Events<br>Check node capacity: kubectl describe nodes | grep -A5 &quot;Allocated&quot;</pre><p>Fix</p><p>💡A pod stuck in Pending means a scheduling problem, not an application problem. Always check describe pod events first — the scheduler leaves a clear message.</p><p>Edited and added</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ToJ8MLJA7H_mOoMgVOZzA.png" /></figure><p>Restart Count: 5</p><p>Fix: Sleep for a fixed time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Izpzr0FFV2zeoX4tkNNq0A.png" /></figure><p>Keeps container running → avoids CrashLoopBackOff , Good for testing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAOdRcUY_k6lhFylx5OVWw.png" /></figure><pre>Final corrected yaml file<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: app-config<br>data:<br>  APP_MODE: &quot;production&quot;   # ❌ wrong key example<br><br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: broken-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: broken-app<br>  template:<br>    metadata:<br>      labels:<br>        app: broken-app<br>    spec:<br>      containers:<br>      - name: app<br>        image: python:3.9<br>        command: [&quot;python&quot;]<br>        args: <br>        - &quot;-c&quot;<br>        - &quot;import time; print(&#39;App Running&#39;); time.sleep(3600)&quot;  # ✅ Keeps container running for liveness probe<br>        env:<br>        - name: DB_HOST<br>          value: mysql-service   <br>        - name: APP_MODE<br>          valueFrom:<br>            configMapKeyRef:<br>              name: app-config<br>              key: APP_MODE   # ✅ Fixed correct key<br>        resources:<br>          requests:<br>            memory: &quot;128Mi&quot;   # ✅ Fixed memory<br>            cpu: &quot;100m&quot;       # ✅ Reduced CPU<br>        volumeMounts:<br>        - name: config<br>          mountPath: /config<br>        livenessProbe:<br>          exec:          # ✅ Changed to exec probe since no web server<br>            command: [&quot;echo&quot;, &quot;ok&quot;]<br>          initialDelaySeconds: 5<br>          periodSeconds: 5<br>          timeoutSeconds: 1<br>          successThreshold: 1<br>          failureThreshold: 3<br>      volumes:<br>      - name: config<br>        configMap:<br>          name: app-config<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*eBnScfv0S9ypYyKFAulcsQ.jpeg" /></figure><p><strong>Other Real-World Causes of CrashLoopBackOff</strong></p><p>While the lab covered the most common scenarios, there are a few more causes you will encounter in real clusters that are equally important to understand.</p><p><strong>Permission Issue</strong></p><p>The container attempts to access a file, directory, or volume without the required permissions, causing the application to fail at startup or crash immediately. A common example is a mounted volume set to read-only while the app tries to write logs, or a non-root container attempting to access a restricted path like /var/log/app. This is easy to miss because the pod briefly enters a Running state before crashing — always check kubectl logs — previous when you see this pattern.</p><p><strong>Missing File in Volume</strong></p><p>The application expects a specific file inside a mounted ConfigMap, Secret, or persistent volume that simply isn’t there. Since the file is absent at startup, the app exits immediately and Kubernetes begins the restart loop. A typical case is the app looking for /config/settings.yaml while the key settings.yaml was never added to the ConfigMap. Running kubectl exec into the container and manually checking ls /config is the fastest way to catch this.</p><p><strong>Missing Dependency (Service Not Found)</strong></p><p>The application depends on an external service — a database, API, or message broker — that is either not deployed or unreachable at the time the container starts. Since the app cannot initialize a connection, it exits with a non-zero code and the loop begins. Setting DB_HOST=mysql-service while mysql-service has never been deployed to the namespace is one of the most common production mistakes. Use kubectl get svc and nslookup &lt;service-name&gt; from inside the container to verify reachability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Spw6ldm7w33Aiie4opjRWg.png" /></figure><p><strong>Thank you for exploring this with me! </strong>🫰🫰🫰</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0a89d93924e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taints and Tolerations in Kubernetes]]></title>
            <link>https://iam-athirakk.medium.com/taints-and-tolerations-in-kubernetes-4115f193c738?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/4115f193c738</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 05:31:51 GMT</pubDate>
            <atom:updated>2024-10-07T05:31:51.212Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey… 🫶 Welcome Back………………….🤞</p><p>Taints and tolerations are mechanisms used to prevent specific pods from being scheduled on certain nodes. They allow cluster administrators to manage the placement of pods more precisely.</p><p>📌<strong>Taints</strong>:</p><ul><li>A <strong>taint</strong> is applied to a node, telling Kubernetes that certain pods are not allowed to run on that node unless they tolerate the taint.</li></ul><p>A taint is a key-value pair with an effect. The three possible effects are:</p><ul><li><strong>NoSchedule</strong>: Pods that do not tolerate the taint will not be scheduled on this node.</li><li><strong>PreferNoSchedule</strong>: Kubernetes will try not to schedule pods that don’t tolerate the taint, but it may still place them on the node if no other options are available.</li><li><strong>NoExecute</strong>: Pods that don’t tolerate the taint will be evicted if they are already running on the node.</li></ul><p><strong>Example of a Taint:</strong></p><pre>kubectl taint nodes node1 key=value:NoSchedule</pre><ul><li>This would taint node1 with a key-value pair and prevent any pod that doesn&#39;t tolerate the taint from being scheduled.</li></ul><p>📌<strong>Tolerations</strong>:</p><ul><li>A <strong>toleration</strong> allows a pod to be scheduled on a node with a matching taint. Tolerations are applied at the pod level and “match” taints to allow a pod to run on a tainted node.</li><li>The toleration must specify the same key, value, and effect as the taint to allow scheduling.</li><li>Tolerations can also be configured with a <strong>time limit</strong> for how long a pod can tolerate the taint.</li></ul><p><strong>Example of a Toleration:</strong> In a pod specification, you can define a toleration like this:</p><pre>tolerations:<br>- key: &quot;key&quot;<br>  operator: &quot;Equal&quot;<br>  value: &quot;value&quot;<br>  effect: &quot;NoSchedule&quot;</pre><p><strong>Use Cases:</strong></p><p>◼️<strong>Dedicated Nodes for Critical Services:</strong></p><ul><li>Reserve specific nodes for critical services like databases (e.g., MySQL, PostgreSQL) or stateful applications that need dedicated resources.</li></ul><p>◼️<strong>Isolating Production and Non-Production Workloads:</strong></p><ul><li>Ensure production workloads are only scheduled on designated production nodes, keeping development and testing pods off those nodes.</li></ul><p>◼️<strong>Node Maintenance or Draining:</strong></p><ul><li>Temporarily prevent new workloads from being scheduled on nodes under maintenance while allowing essential monitoring/logging pods to remain.</li></ul><p>◼️<strong>Handling Specialized Hardware Nodes (e.g., GPU/SSD):</strong></p><ul><li>Ensure that only workloads requiring specialized hardware like GPUs or high-performance SSDs are scheduled on nodes equipped with such hardware.</li></ul><p>◼️<strong>Workload Isolation in Multi-Tenant Clusters:</strong></p><ul><li>Separate tenants in multi-tenant clusters by preventing workloads from different teams or departments from being scheduled on shared nodes.</li></ul><p>◼️<strong>Avoiding Overloaded or High-Latency Nodes:</strong></p><ul><li>Prevent critical, performance-sensitive applications from being scheduled on nodes with known high latency or heavy loads.</li></ul><p>◼️<strong>Faulty Node Management:</strong></p><ul><li>Evict non-critical workloads from nodes showing hardware failures or connectivity issues while allowing monitoring services to continue running.</li></ul><p>◼️<strong>Ensuring High Availability Across Zones:</strong></p><ul><li>Prevent critical workloads from being scheduled on unreliable zones, while allowing non-critical workloads to tolerate the taint and run in those zones.</li></ul><h4>Example of Taints and Tolerations in Kubernetes</h4><h4>Scenario:</h4><p>You have a Kubernetes cluster with multiple nodes, and one of the nodes (Node1) is undergoing maintenance. You want to ensure no general workloads (e.g., web or database pods) are scheduled on this node while it’s under maintenance. However, you still want to allow critical monitoring pods, such as Prometheus, to continue running to monitor the node’s state during maintenance.</p><h4>Objective:</h4><ul><li><strong>Taint Node1</strong> to prevent general pods from being scheduled on it.</li><li><strong>Add Toleration</strong> to allow only critical monitoring pods (like Prometheus) to tolerate the taint and run on Node1 during the maintenance period.</li></ul><p>◼️<strong>Steps:</strong></p><p><strong>1. Taint Node1 for Maintenance:</strong></p><p>Apply a taint to Node1 with the NoSchedule effect, meaning no new pods will be scheduled on this node unless they tolerate the taint.</p><pre>kubectl taint nodes Node1 maintenance=true:NoSchedule</pre><p>This command taints <strong>Node1</strong> with the key maintenance=true and the NoSchedule effect. As a result, Kubernetes prevents any pod that doesn’t tolerate this taint from being scheduled on the node.</p><h4>2. Toleration for Critical Monitoring Pods</h4><p>Now, you want critical monitoring pods (like <strong>Prometheus</strong>) to tolerate the taint and continue running on Node1. To achieve this, add a toleration to the pods’ specifications.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>name: prometheus-pod<br>spec:<br>containers:<br>- name: prometheus-container<br>image: prom/prometheus<br>tolerations:<br>- key: &quot;maintenance&quot;<br>operator: &quot;Equal&quot;<br>value: &quot;true&quot;<br>effect: &quot;NoSchedule&quot;</pre><p>This YAML defines a <strong>toleration</strong> for the <strong>Prometheus pod</strong>, which matches the maintenance=true taint on <strong>Node1</strong>. As a result, the <strong>Prometheus pod</strong> is allowed to tolerate the taint and continue running on the tainted node.</p><h4>3. No Toleration for Regular Pods</h4><p>Other general-purpose pods (e.g., <strong>Nginx web servers</strong>) that do not have the toleration for the maintenance=true taint will not be scheduled on Node1. These pods will either be scheduled on other available nodes or, if they were already running on Node1 before the taint was applied, they will be evicted.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>name: nginx-pod<br>spec:<br>containers:<br>- name: nginx-container<br>image: nginx</pre><p>Since the <strong>Nginx pod</strong> lacks the toleration for maintenance=true, Kubernetes will prevent it from being scheduled on <strong>Node1</strong>. Instead, it will run on another node in the cluster.</p><h4>◼️Result:</h4><ul><li><strong>Node1</strong> will not accept any new general-purpose workloads due to the taint.</li><li><strong>Critical monitoring pods</strong> (like Prometheus, which has the toleration) will continue running on <strong>Node1</strong>, ensuring observability during the maintenance window.</li><li>Once the maintenance is complete, you can remove the taint, and Node1 will start accepting regular pods again.</li></ul><h4>◼️Purpose of Taints and Tolerations:</h4><ol><li><strong>Resource Management:</strong> Prevent unnecessary workloads from running on a node under maintenance or in an unoptimized state.</li><li><strong>Selective Toleration:</strong> Ensure that only essential or critical pods (e.g., monitoring or logging tools) are allowed to run on a node with restricted capacity.</li><li><strong>Better Control:</strong> Give administrators more control over which workloads can run on specific nodes in the cluster based on operational priorities or hardware limitations.</li></ol><p>◼️<strong>Conclusion</strong>:</p><ul><li><strong>Taint:</strong> Node1 is marked as unavailable for general-purpose pods by applying a taint.</li><li><strong>Toleration:</strong> Only critical monitoring pods (e.g., Prometheus) are given tolerations so they can continue running on Node1, ensuring observability during maintenance.</li></ul><p><strong>Thank you for exploring this with me! </strong>🫰🫰🫰</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4115f193c738" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Architecture Overview]]></title>
            <link>https://iam-athirakk.medium.com/kubernetes-architecture-overview-0c77a57223c3?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c77a57223c3</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 03:02:01 GMT</pubDate>
            <atom:updated>2024-09-30T03:02:01.610Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey… 🫶 Welcome Back………………….🤞</p><h3>Kubernetes Architecture Overview</h3><p>Kubernetes is a powerful platform designed to manage containerized applications across a cluster of machines. It enables automated deployment, scaling, and management of application containers and ensures applications run as expected with minimal manual intervention. Kubernetes achieves this through a set of core components that work together to maintain the desired state of the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u0UqXijQqZV7keuU" /></figure><p><em>Image Source : Kubernetes official documentation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*McOPUFUSBuLfXTRj" /></figure><p><strong>Let’s take a real-time example to explain and better understand the concepts:</strong></p><p>Consider a company that manages several applications used by its customers. These applications need to be scalable, reliable, and easy to manage. To achieve this, the company decides to use Kubernetes, which automates the deployment, scaling, and management of containerized applications.</p><h3>Kubernetes Cluster Overview</h3><p>The Kubernetes cluster is like the central hub where all the company’s applications run. This cluster consists of <strong>worker nodes</strong> (which do the heavy lifting by running the applications) and a <strong>master node</strong> (which orchestrates and manages the entire system).</p><h3>📌Worker Nodes</h3><p>The worker nodes in Kubernetes are the machines, whether physical servers or virtual machines, that run the company’s applications inside <strong>pods</strong>. For instance, the company might run its web servers, databases, and background jobs across several worker nodes, ensuring that everything operates smoothly.</p><ul><li><strong>Kubelet</strong>: Each worker node has a kubelet, a small software agent responsible for making sure the applications (containers) run as instructed by the master node. Imagine that a new version of the company’s web server needs to be deployed. The kubelet on each worker node will ensure the web server’s container is updated and runs correctly.</li><li><strong>Container Runtime</strong>: Behind the scenes, the container runtime (like Docker or ContainerD) is what pulls the web server’s container image and runs it. If the company needs to scale up, new instances of the web server can quickly be started.</li><li><strong>Kube-proxy</strong>: Each node also has a kube-proxy, which manages the network rules to ensure that the different services in the company’s applications can talk to each other. For example, if the web server on one node needs to connect to a database on another node, kube-proxy ensures that the network traffic flows properly.</li></ul><h3>📌Master Node (Control Plane)</h3><p>The master node acts as the brain of the Kubernetes cluster. It manages everything, from scheduling applications to be run on worker nodes to ensuring that each part of the system operates as it should.</p><ul><li><strong>API Server</strong>: This is the main gateway for interacting with the Kubernetes cluster. Every time the company’s development team makes a change, like deploying a new service, they use a tool like kubectl, which talks to the API server. The API server validates requests, checks the current state of the system, and updates it based on new instructions.</li><li><strong>ETCD</strong>: ETCD is like the cluster’s memory. It stores every bit of information about the system, such as what applications are running, their configurations, and more. So, when the company’s development team deploys a new version of their application, this information is stored in ETCD, ensuring consistency and reliability across the system.</li><li><strong>Kube-Scheduler</strong>: This component is responsible for deciding where new applications (pods) should run. For example, if the company needs to launch a new instance of its web server, the kube-scheduler looks at all the available worker nodes and chooses the one with enough resources (CPU, memory) to handle the new workload. It also considers any policies like affinity rules that might dictate which node the web server should run on.</li><li><strong>Kube-Controller-Manager</strong>: The controller manager is responsible for ensuring that the system remains in the desired state. For instance, if a worker node crashes, the controller manager’s <strong>Node Controller</strong> will notice and shift the running applications to other nodes. If a specific service needs to maintain a certain number of running instances, the <strong>Replication Controller</strong> ensures that if one of the web servers crashes, a new one is automatically started.</li><li><strong>Cloud Controller Manager: </strong>For companies using cloud providers like AWS or Google Cloud, the Cloud Controller Manager handles cloud-specific tasks. For example, if a virtual machine (node) running on the cloud provider crashes, the cloud controller manager works with the provider’s API to check if the machine has been deleted or can be replaced. It also manages cloud load balancers to ensure external customers can always access the company’s services.</li></ul><p><strong>Let’s look into the architecture in detail to understand each component and its role within the system more thoroughly.</strong></p><h3>📌Worker Nodes</h3><ul><li><strong>Function</strong>: Worker nodes are the machines (physical or virtual) that actually run the containerized applications. Each worker node hosts one or more pods, which are the smallest deployable units in Kubernetes and encapsulate application containers. The worker nodes handle tasks like running, monitoring, and managing the pods.</li></ul><h4>Key Components on Worker Nodes:</h4><p>◼️K<strong>ubelet</strong>: The kubelet is an agent running on every worker node. Its primary responsibility is to ensure that containers are running in the pods as instructed by the control plane. The kubelet communicates with the API server to receive instructions about which pods to run. It monitors the health of the pods and reports their status back to the master node.</p><p>◼️<strong>Container Runtime</strong>: The container runtime is the software responsible for pulling container images and running containers. Popular container runtimes include Docker, ContainerD, and CRI-O. The kubelet uses the container runtime to manage the containers within the pods.</p><p>◼️<strong>Kube-proxy: </strong>The kube-proxy runs on each node and manages network rules, allowing communication between pods and services. It ensures that network traffic is directed appropriately to the backend pods based on the service definitions.</p><h3>📌Master Node (Control Plane)</h3><ul><li><strong>Function</strong>: The master node, also known as the control plane, manages the entire Kubernetes cluster. It is responsible for monitoring the state of worker nodes, scheduling applications (pods) onto worker nodes, and handling cluster-wide configurations. It oversees the overall orchestration of containers within the cluster.</li></ul><h4>Key Components of the Master Node:</h4><p>◼️<strong>Kube-apiserver:</strong></p><ul><li>The API server acts as the main interface for Kubernetes. It processes and validates all administrative requests (such as those made using kubectl or other tools) and coordinates with other components to maintain the cluster’s desired state.</li><li>The API server is responsible for exposing the Kubernetes API, which is used by other control plane components, external users, and automation systems to interact with the cluster. It also serves as the gateway for communication between internal components.</li></ul><p>◼️<strong>ETCD</strong>:</p><ul><li>ETCD is a distributed, reliable key-value store that holds the entire cluster’s state. This includes information about nodes, pods, configurations, secrets, accounts, roles, and more.</li><li>Every operation and state change in the cluster is recorded in ETCD. For example, when a new pod is deployed or when a node is added, the API server updates this information in the ETCD datastore. The system relies on ETCD to ensure that the desired state of the cluster is persisted and maintained over time.</li></ul><p>◼️K<strong>ube-scheduler:</strong></p><ul><li>The scheduler is responsible for assigning pods to nodes. When a new pod is created, the scheduler determines the best node for the pod to run on, based on various factors like available resources (CPU, memory), node capacity, and policies such as affinity/anti-affinity rules, taints, and tolerations.</li><li>The scheduler operates in two phases: filtering and scoring. In the filtering phase, it eliminates nodes that do not meet the pod’s requirements (e.g., insufficient resources). In the scoring phase, it ranks the remaining nodes to determine the best fit for the pod. The scheduler then informs the API server about the decision.</li></ul><p>◼️<strong>Kube-Controller-Manager</strong>:</p><ul><li>The Kube Controller Manager is responsible for running various controllers that ensure the desired state of the Kubernetes cluster. While each controller can run as an independent process, Kubernetes simplifies management by compiling them into a single binary and running them as a single process.</li><li>The controller manager continuously monitors the cluster’s state and responds to changes, ensuring that the cluster operates according to the desired configuration. It manages several controllers, each with its own responsibilities.</li></ul><p><strong>✔</strong> <strong><em>Types of Controllers:</em></strong></p><ol><li><strong>Node Controller</strong>: Detects when nodes go down or become unresponsive and responds to maintain cluster availability.</li><li><strong>Job Controller</strong>: Monitors Job objects and creates Pods to complete one-off tasks.</li><li><strong>EndpointSlice Controller</strong>: Manages EndpointSlice objects to link Services with their corresponding Pods.</li><li><strong>ServiceAccount Controller</strong>: Automatically creates default ServiceAccounts for new namespaces to handle access control.</li><li><strong>Replication Controller</strong>: Ensures the specified number of replicas for a Pod are running, creating new Pods if any fail.</li><li><strong>Deployment Controller</strong>: Manages the lifecycle of Deployments, ensuring application updates roll out smoothly across multiple Pods.</li></ol><p>◼️C<strong>loud-controller-manager:</strong></p><ul><li>The Cloud Controller Manager is responsible for integrating Kubernetes with cloud provider APIs. It manages cloud-specific control logic, allowing Kubernetes to interact with cloud-based resources like virtual machines and load balancers. Like the Kube Controller Manager, it combines multiple controllers into a single process to reduce complexity.</li><li>The cloud controller manager is optional for clusters that do not run in a cloud environment. It only manages controllers that are relevant to the cloud provider in use.</li></ul><p><strong>✔ <em>Types of Controllers with Cloud Dependencies:</em></strong></p><ol><li><strong>Node Controller</strong>: Works with the cloud provider to detect if a node has been deleted after it stops responding.</li><li><strong>Route Controller</strong>: Sets up network routes in the cloud infrastructure to ensure proper traffic flow.</li><li><strong>Service Controller</strong>: Manages cloud provider load balancers for Kubernetes Services, ensuring external traffic is routed correctly.</li></ol><p>When setting up a Kubernetes cluster, there are various approaches that can be taken, each with its own set of procedures and complexities.</p><p>One approach involves <strong>manually configuring</strong> the cluster from scratch. In this method, critical components such as the API server, ETCD, and controller manager must be installed on the master node by the user. This requires not only downloading and configuring the necessary binaries but also setting up ETCD as a service. Additionally, it is crucial to ensure that proper certificates are in place to facilitate secure communication among the different components of the cluster.</p><p>Alternatively, Kubernetes can be deployed using tools like <strong>kubeadm</strong>. This approach streamlines the installation process by automating the deployment of essential components. With kubeadm, the various components of the Kubernetes control plane are deployed as pods within the cluster, significantly simplifying the overall setup. This method also promotes adherence to best practices, ensuring that the cluster is configured in a way that enhances security and performance.</p><p><strong>Thank you for exploring this with me! </strong>🫰🫰🫰</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c77a57223c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Hands-On Guide to Key Features of Amazon EC2 (Elastic Compute Cloud)- A Complete Tutorial.]]></title>
            <link>https://iam-athirakk.medium.com/a-hands-on-guide-to-key-features-of-amazon-ec2-elastic-compute-cloud-f2ed4910a58e?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2ed4910a58e</guid>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Thu, 16 May 2024 04:58:44 GMT</pubDate>
            <atom:updated>2024-05-16T04:59:39.028Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hey Techies…👋</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Jjv6cJI6FdvAupapK0RqQ.png" /></figure><p>An EC2 instance, short for Elastic Compute Cloud instance, is a virtual server offered by Amazon Web Services (AWS) that provides resizable compute capacity in the cloud. Essentially, it allows users to rent virtual servers to run their applications or host their websites without the need to invest in physical hardware.</p><ul><li>EC2 instances offer a variety of configurations for CPU, memory, storage, and networking, catering to diverse workload requirements.</li><li>Users can select from optimized instance types, such as general-purpose, memory-intensive, or high-performance computing, to suit their specific needs.</li><li>Deployment and management are simplified through AWS Management Console, CLI, or SDKs, facilitating easy provisioning, monitoring, and scaling of instances.</li><li>EC2 serves a wide range of use cases, from basic web hosting to complex data analytics, meeting the computing requirements of businesses across industries and sizes.</li><li>EC2 follows a pay-as-you-go pricing model, ensuring cost-effectiveness by billing users based on instance type, usage duration, and other factors, thus accommodating varying business needs and budget constraints.</li></ul><p><strong>Purpose of having an EC2 Instance</strong></p><ul><li><strong>Flexibility</strong>: With a wide range of instance types and configurations, EC2 instances cater to diverse workload requirements, from basic web hosting to high-performance computing and data analytics.</li><li><strong>Scalability</strong>: EC2 instances offer scalable compute capacity, allowing businesses to easily adjust resources based on demand fluctuations. This scalability ensures efficient resource utilization and cost-effectiveness.</li><li><strong>Global Reach:</strong> With AWS’s global infrastructure, EC2 instances are available in multiple regions worldwide. This enables businesses to deploy applications closer to their target audience for improved performance and latency optimization.</li><li><strong>Security and Reliability: </strong>EC2 instances provide a secure and reliable environment for running applications, with features like built-in encryption, firewalls, and monitoring tools to safeguard data and ensure high availability.</li><li><strong>Ease of Management: </strong>EC2 instances can be quickly deployed and managed through AWS Management Console, CLI, or SDKs, streamlining the process of provisioning, monitoring, and scaling instances as needed.</li></ul><p>Amazon EC2 offers a variety of instance types tailored for diverse needs. These types feature different configurations of CPU, memory, storage, and networking capacity, providing flexibility in selecting resources for your applications. Additionally, each instance type includes multiple sizes, enabling easy scaling according to your workload’s demands.</p><p>EC2 Instance Types Overview:</p><p><strong>General Purpose:</strong></p><ul><li>These instances offer a balanced mix of compute, memory, and networking resources.</li><li>Ideal for applications like web servers and code repositories that require equal proportions of these resources.</li></ul><p><strong>Burstable Performance:</strong></p><ul><li>Also known as the T instance family, these instances provide baseline CPU performance with the ability to burst above it when needed.</li><li>Refer to the Amazon EC2 User Guide for Linux Instances for more details.</li></ul><p><strong>Compute Optimized:</strong></p><ul><li>Designed for compute-intensive applications requiring high-performance processors.</li><li>Suitable for tasks such as batch processing, media transcoding, and high-performance web servers.</li></ul><p><strong>Memory Optimized:</strong></p><ul><li>Tailored for workloads processing large datasets in memory.</li><li>Deliver fast performance for applications with substantial memory requirements.</li></ul><p><strong>Storage Optimized:</strong></p><ul><li>Intended for workloads demanding high, sequential read and write access to large data sets on local storage.</li><li>Optimized to provide high IOPS for applications requiring rapid random I/O operations.</li></ul><p><strong>Accelerated Computing:</strong></p><ul><li>Utilizes hardware accelerators or co-processors for efficient processing of functions like floating-point calculations and graphics processing.</li><li>Enhances performance compared to software-based processing on CPUs.</li></ul><p><strong>High-Performance Computing (HPC):</strong></p><ul><li>Purpose-built for running HPC workloads at scale on AWS, offering optimal price-performance.</li><li>Ideal for complex simulations and deep learning tasks requiring high-performance processors.</li></ul><p><strong>Previous Generation:</strong></p><ul><li>AWS continues to support previous generation instance types for users who have optimized their applications around them.</li><li>While current generation instance types offer better performance, previous generation types are still available for legacy applications.</li></ul><p>Understanding AWS Regions, Availability Zones, and Deployment Strategies</p><p><strong>Regions:</strong></p><ul><li>AWS divides its global infrastructure into geographical regions, such as North America, Europe, Asia Pacific, etc.</li><li>Each region is completely isolated from others and consists of multiple Availability Zones.</li><li>Users select a region when deploying resources like EC2 instances. The choice of region affects latency, compliance, and data residency.</li></ul><p><strong>Availability Zones (AZs):</strong></p><ul><li>Availability Zones are distinct data centers within a region, designed for fault tolerance and high availability.</li><li>They are physically separate from each other and are connected through high-speed, low-latency links.</li><li>Deploying resources across multiple AZs enhances fault tolerance. If one AZ experiences an issue, applications can continue running in others without interruption.</li></ul><p><strong>Deployment Strategy:</strong></p><ul><li>To ensure high availability and fault tolerance, it’s recommended to distribute resources (like EC2 instances) across multiple AZs within a region.</li><li>This strategy protects against failures or outages in a single AZ and ensures that applications remain accessible even if one AZ becomes unavailable.</li></ul><p><strong>Scalability and Performance:</strong></p><ul><li>Deploying resources across multiple AZs allows for better scalability and performance.</li><li>Load balancers can distribute incoming traffic evenly across multiple AZs, optimizing resource utilization and improving response times for users.</li></ul><p><strong>Data Residency and Compliance:</strong></p><ul><li>Different regions may have varying data residency regulations and compliance requirements.</li><li>Users need to select the appropriate region and AZs to ensure compliance with local regulations and keep data within designated geographic boundaries.</li></ul><p><strong>Cost Considerations:</strong></p><ul><li>Costs for AWS services may vary across regions, so users should consider pricing differences when selecting a region for deployment.</li><li>Additionally, data transfer costs may apply when transferring data between regions or AZs.</li></ul><p><strong>EC2 Major Purchasing options:</strong></p><p>1. 𝐎𝐧 𝐃𝐞𝐦𝐚𝐧𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Pay for the compute capacity per second , no up- front payment.We can decide when to launch,terminate,start.stop,or reboot.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔: short-term work-loads , irregular workloads that cannot be interrupted.</p><p>2. 𝐑𝐞𝐬𝐞𝐫𝐯𝐞𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — We can reserve instances in terms of 1year and 3year. Provide up to 70% discount compared to On-Demand. Payment method can be all upfront, partial upfront,no upfront. If you purchase Reserved Instances of a specific type in an availability zone and the same type is available in same zone then automatically charge at lower rate.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Long-term workloads , Applications with steady state or predictable usage.</p><p>3. 𝐒𝐩𝐨𝐭 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Most cost effective , We can request for unused instances up to 90% discount. But if someone is paying more than of yours, then instance will get loosed. So it is less reliable.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Image processing , non-critical applications.</p><p>4. 𝐃𝐞𝐝𝐢𝐜𝐚𝐭𝐞𝐝 𝐇𝐨𝐬𝐭𝐬– Physical server completely dedicated for your use. More expensive and can be purchase as on demand or reserved.Billing will be per-host.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Companies that have strong regulatory or compliance needs.</p><p>5.𝐃𝐞𝐝𝐢𝐜𝐚𝐭𝐞𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Instances running on hardware that’s dedicated to a single user. It can share hardware with other instances in same account. Billing will be per-instance.</p><p>6.𝐒𝐚𝐯𝐢𝐧𝐠𝐬 𝐏𝐥𝐚𝐧𝐬 — This will assist the user to lower the EC2 costs if they agree to keep it for a specific period — ideally, one or three years. The number of active instances are unrestricted.</p><p><strong>AMI (Amazon Machine Image):</strong></p><ul><li>An AMI is a template used to create virtual machines (instances) within the Amazon EC2 service.</li><li>It contains the operating system, application server, and applications necessary to launch an instance.</li><li>You can create custom AMIs or use pre-built AMIs provided by AWS and other users.</li></ul><p><strong>AMI Images:</strong></p><ul><li>AMI images are the actual files stored in Amazon S3 that represent the templates used to launch EC2 instances.</li><li>These images include the root volume snapshot and metadata required to launch an instance.</li><li>AMI images are versioned, allowing you to maintain multiple versions of an AMI and roll back to previous versions if needed.</li></ul><p><strong>Placement Groups</strong></p><ul><li>Placement groups are the way of logically grouping interdependent instances together in a selected region.</li><li>In other words, instances that are existing within a common availability zone can be grouped under placement group in order to suit workload requirements.</li><li>By using the placement group, we will increase the performance or improve the availability.</li></ul><p><strong>Types</strong></p><ul><li>Cluster placement group</li><li>Spread placement group</li><li>Partition placement group</li></ul><p>𝐁𝐞𝐧𝐞𝐟𝐢𝐭𝐬</p><ul><li>Can be able to launch multiple instances within the same AZ.</li><li>Low network latency.</li><li>High network throughput.</li></ul><p>𝐋𝐢𝐦𝐢𝐭𝐚𝐭𝐢𝐨𝐧𝐬</p><ul><li>Cannot merge placement groups.</li><li>Cannot launch dedicated hosts in placement groups.</li><li>Instances cannot span into multiple placement groups.</li></ul><p>𝐂𝐥𝐮𝐬𝐭𝐞𝐫 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>All the instances are placed in a same hardware rack inside an availability zone.</li><li>But if the rack fails, all instances fail at the same time.</li><li>This type of group will enable to achieve low latency network.</li><li>Good for High Performance applications.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞 — Application with low latency and high throughput.</li></ul><p>𝐒𝐩𝐫𝐞𝐚𝐝 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>All EC2 instances are placed in different hardware racks in a single availability zone.</li><li>A rack failure will not affect more than one instance.</li><li>We can create up to 7 EC2 instances per availability zone in spread placement group.</li><li>Good for high availability applications and not suitable for high performance applications.</li><li>It can span multiple availability zones in the same region.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞- Critical applications that needs to be isolated from failure from each other.</li></ul><p>𝐏𝐚𝐫𝐭𝐢𝐭𝐢𝐨𝐧 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>Group of instances spread across racks, and the instances in one partition do not share the underlying hardware with instances in different partition.</li><li>If a rack fails, it will affect on the instances within that particular partition only.</li><li>Partitions can be in different availability zones in the same region.</li><li>It strikes a balance between high performance and high availability.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞 — Big data applications like HDFS, HBase, Cassandra, Kafka.</li></ul><p>In AWS EC2, there are three main types of load balancers:</p><p><strong>Classic Load Balancer (CLB):</strong></p><ul><li>CLB is the original load balancer service provided by AWS.</li><li>It operates at both the application and transport layers (Layer 4 and Layer 7) of the OSI model.</li><li>CLB supports distributing incoming traffic across multiple EC2 instances in multiple Availability Zones.</li><li>It is suitable for applications that require simple load balancing without advanced features.</li></ul><p><strong>Application Load Balancer (ALB):</strong></p><ul><li>ALB operates at the application layer (Layer 7) of the OSI model.</li><li>It supports advanced routing features such as host-based routing, path-based routing, and routing based on HTTP headers.</li><li>ALB can handle HTTP and HTTPS traffic and provides support for WebSocket and HTTP/2 protocols.</li><li>It is ideal for modern web applications with multiple microservices or containers.</li></ul><p><strong>Network Load Balancer (NLB):</strong></p><ul><li>NLB operates at the transport layer (Layer 4) of the OSI model.</li><li>It provides ultra-low latency and high throughput, making it suitable for handling millions of requests per second.</li><li>NLB supports routing traffic to targets using IP addresses and TCP ports, making it ideal for TCP and UDP-based applications.</li><li>It is commonly used for applications that require high performance, scalability, and reliability, such as gaming, IoT, and real-time communication applications.</li></ul><p><strong>Target Groups</strong> are a fundamental component of Elastic Load Balancing (ELB) services in AWS, specifically associated with the Application Load Balancer (ALB) and Network Load Balancer (NLB).</p><p>Here’s a concise explanation:</p><p><strong>Routing</strong>:</p><ul><li>When configuring a load balancer (ALB or NLB), you specify one or more target groups to route traffic to.</li><li>Each target group defines the criteria for routing requests to its associated targets, such as based on a specific path, host, or HTTP header.</li></ul><p><strong>Health Checks:</strong></p><ul><li>Target Groups perform health checks on their registered targets to ensure they are capable of handling requests.</li><li>Unhealthy targets are automatically removed from the target group until they pass health checks again.</li></ul><p><strong>Load Balancing:</strong></p><ul><li>Target Groups distribute incoming traffic evenly across their registered targets according to the configured load balancing algorithm (e.g., round-robin or least outstanding requests).</li></ul><p><strong>Port Configuration:</strong></p><ul><li>Target Groups allow you to specify the port on which the targets receive traffic, allowing flexibility in routing requests to different ports on the same target.</li></ul><p><strong>Autoscaling:</strong></p><ul><li>Autoscaling is a feature provided by AWS that automatically adjusts the number of EC2 instances in a fleet based on user-defined policies.</li><li>It helps maintain the desired number of instances to handle varying levels of application traffic or workload demand.</li><li>Autoscaling can scale both up (adding more instances) and down (removing instances) dynamically, ensuring optimal resource utilization and cost efficiency.</li></ul><p><strong>Autoscaling Groups:</strong></p><ul><li>An Autoscaling Group (ASG) is a logical grouping of EC2 instances managed by the Auto Scaling service.</li><li>ASGs define the scaling policies, launch configurations, and other parameters that govern the behavior of the instances within the group.</li><li>ASGs automatically launch or terminate EC2 instances based on predefined scaling policies and health checks.</li><li>ASGs can be configured to distribute instances across multiple Availability Zones to improve fault tolerance and high availability.</li></ul><p><strong>Ways to connect to EC2 instances via the command line:</strong></p><ul><li>SSH connection</li><li>EC2 Instance Connect:</li><li>AWS CLI (Command Line Interface):</li><li>Third-Party Tools ( like PuTTY or MobaXterm)</li></ul><p>and more…..</p><p><strong>The launch of an ec2 instance:</strong></p><ul><li>Choose an AMI (Amazon Machine Image): This is a template for the virtual machine you want to create. It contains the operating system, software, configuration, and sometimes data.</li><li>Select an Instance Type: This determines the computational resources (CPU, RAM, storage, etc.) of your EC2 instance. There are various types optimized for different use cases.</li><li>Configure Instance Details: This includes settings like networking (VPC, subnet), IAM role, and user data (scripts or data to be run at instance launch).</li><li>Add Storage: Configure the amount and type of storage for your instance. This is typically done using Amazon EBS (Elastic Block Store), which provides block-level storage volumes.</li><li>Add Tags: Assign metadata to your instance in the form of key-value pairs. This helps with organization, management, and billing.</li><li>Configure Security Group: Define firewall rules for controlling inbound and outbound traffic to your instance. Security groups act as virtual firewalls.</li><li>Review and Launch: Review your instance configuration, make any necessary changes, select an existing key pair or create a new one for SSH access (for Linux instances), and then launch the instance.</li></ul><p>After launching the instance, you can access it using SSH (for Linux instances) or RDP (for Windows instances) using the key pair you selected or created. Remember to properly secure your instance and follow best practices for managing AWS resources.</p><p>Let’s walk through the process of launching an EC2 instance.</p><p>An EC2 instance essentially functions as a virtual machine.</p><p>Firstly, log in to your AWS console.</p><p>Next, choose your desired region. For instance, I’ll be selecting the North Virginia region. It’s advisable to select a region based on your current location, as some regions may incur higher costs compared to those in the US.</p><p>Each region is identified by a code, such as US East 1 for North Virginia.</p><p>To navigate to the EC2 service, click on “Services” and locate EC2 either by browsing through all services or by directly searching for EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jgcsk5kJXofr8ico" /></figure><p>Once in the EC2 dashboard, you’ll find an overview of your instances, volumes, and other relevant information. Keep in mind that the dashboard doesn’t auto-refresh, so be sure to manually refresh after making any changes.</p><p>Scrolling down, you’ll notice zones within the region, each identified by a code like 1A, 1B, etc. Typically, a region will have at least two zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*zqdbR0JlJTWwZejJ" /></figure><p>Click on “Instances” and then “Launch Instance” to initiate the instance creation process.</p><p>Before proceeding, it’s worth noting that the AWS console interface may evolve over time, but the core options and functionalities remain consistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LN6sn6fQ2GVHRtH1" /></figure><p>Now, let’s begin by assigning a name and optional tags to the instance. Tags can be useful for filtering and organization purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*WkAhGSqTJqd_B8zF" /></figure><p>Moving on to selecting the Amazon Machine Image (AMI), you’ll find a variety of options including quick start AMIs like Amazon Linux, Ubuntu, and Windows, as well as community AMIs and those from the AWS Marketplace. Carefully review the details and charges associated with each AMI.</p><p>For this example, let’s choose the Ubuntu AMI provided by Amazon Web Services, which is free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fTF-Uot0KJoPINox" /></figure><p>Ensure that the instance type selected aligns with your requirements. For free-tier usage, T2 micro instances are suitable for most learning purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tg4wgg4IoQtSTiZO" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*xFlJFi8S8XAQP91G" /></figure><p>Proceed to configure the network settings, including security groups. Security groups act as mandatory firewalls for EC2 instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*msbR018aCrjynY4x" /></figure><p>Customize the security group to allow necessary inbound and outbound traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jbdvbZ096kgPZTKN" /></figure><p>You can specify the storage size, typically defaulted to 10 GB, and further advanced details like user data, which allows for automated provisioning upon instance launch.</p><p>Finally, review your configuration and launch the instance.</p><p>Upon launching, the instance may take a few moments to become available. You can monitor its status in the EC2 dashboard.</p><p>Next, establish a connection to the instance; in this example, I’m using EC2 Instance Connect.</p><p>There are two methods to install Apache2:</p><ul><li>By incorporating commands in the user data section before initiating the instance launch, as demonstrated below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*CJbCoUtgINpnwyEa" /></figure><ul><li>Or, by executing the commands after connecting the ec2 instance via terminal.</li></ul><pre>sudo apt update<br>sudo apt install apache2 -y<br>sudo systemctl start apache2<br>sudo systemctl enable apache2<br>sudo systemctl status apache2</pre><p>Troubleshooting tip: If encountering connection issues, ensure the correct path to the SSH key or navigate to the directory containing the key before attempting to connect.</p><p>Once connected, you can verify the instance status, access web services like Apache, and configure firewall rules as needed to enable external access to your services.</p><p>Additionally, click on the Security Group, edit inbound rules, add the following rule, and save the rules. It’s important to note that allowing all IPs is solely for learning purposes and may vary depending on your project requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*mA0FyEqVbioOCSr0" /></figure><p>Go to the browser and copy the public IP followed by ‘:80’ to view the Apache page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*P7nkWKkHQtIstvkE" /></figure><p>***************************************************************************</p><p><strong>Elastic IP</strong></p><ul><li>Powering Off the EC2 Instance:</li><li>Take note of the current public and private IP addresses of the instance.</li><li>Stop the instance using the AWS Management Console.</li><li>Observing IP Address Changes:</li><li>After stopping the instance, observe that the public IP address is released while the private IP address remains unchanged.</li><li>Refresh the console to verify the changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ACdt4EypIFhfPBSx" /></figure><p><strong>Elastic IP Benefits:</strong></p><ul><li>Elastic IP addresses offer the advantage of maintaining a static public IP address even in scenarios where EC2 instances are restarted or recreated.</li><li>They provide a stable endpoint for applications or services that require a consistent public IP address.</li><li>With Elastic IP, there’s no need to update DNS records or reconfigure applications each time an instance is stopped or replaced.</li><li>It simplifies infrastructure management and enhances reliability by ensuring uninterrupted connectivity to resources hosted on EC2 instances.</li><li>Elastic IP addresses are particularly useful for scenarios requiring a fixed public IP address, such as hosting websites, APIs, or VPN gateways.</li><li>Allocating an Elastic IP:</li><li>Allocate an Elastic IP address from the AWS pool.</li><li>Associate the Elastic IP with the desired EC2 instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/0*98ziee2hmNeLii2_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wKHPw0XH0dubxOxV" /></figure><p>EC2 Instance Components:</p><ul><li>In addition to the EC2 instance itself, other components include the network interface and volumes (virtual hard disks).</li><li>The network interface manages connectivity and is associated with firewall rules, public IP addresses, and security groups.</li><li>Volumes represent the virtual hard disks attached to the instance, storing data and operating system files.</li><li>Understanding these components is essential for managing and configuring EC2 instances effectively.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3qbk9E8rlgaW1XEf" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Xs5WEf8kZIZOBuKF" /></figure><p>Navigating the EC2 Dashboard:</p><ul><li>Encourage exploration of the EC2 dashboard to view information about resources like key pairs, security groups, and volumes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gDnzlyZPMNp5RCQc" /></figure><p>Adjusting Instance Settings:</p><ul><li>Demonstrate how to change instance type and other settings like Elastic IP disassociation, network interface attachment/detachment, and security group changes.</li></ul><p>Reverting Instance Changes:</p><ul><li>Revert any instance changes made during the demonstration, such as changing the instance type, by powering on the instance and reverting the settings back to their original state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*zfPmkY2Z847ZhvxJ" /></figure><p><strong>Elastic Block Store (EBS)</strong></p><p>EBS serves as the virtual hard disk for EC2 instances, offering both EBS volumes and snapshots for data storage and backup.</p><p>EBS Volumes:</p><ul><li>EBS volumes, akin to physical hard disks, house the operating system data of EC2 instances and can store various types of data such as databases, web servers, and files.</li><li>During volume creation, users specify an availability zone, ensuring alignment with the instance’s location.</li><li>Data stored in EBS volumes is automatically replicated within the same availability zone, mitigating the risk of data loss due to local failures.</li></ul><p>Snapshots:</p><ul><li>Snapshots, used for backing up entire volumes, provide an additional layer of data protection.</li><li>These snapshots capture the state of the EBS volume at a specific point in time, facilitating data recovery and restoration.</li></ul><p>Types of EBS Volumes:</p><ul><li>EBS volumes come in various types catering to different workload requirements and performance needs.</li><li>General purpose volumes, SSD-based, are recommended for most workloads due to their balanced pricing and speed.</li><li>Provisioned IOPS volumes offer enhanced performance and are ideal for large databases requiring high input-output operations per second (IOPS).</li><li>Throughput optimized HDD volumes suit big data and data warehousing applications, while cold HDD volumes are cost-effective solutions for infrequently accessed data.</li><li>Magnetic volumes, the cheapest option, are suitable for backups and archives but offer lower performance.</li></ul><p>Choosing the Right Volume Type:</p><ul><li>The selection of an appropriate volume type depends on factors such as workload characteristics, performance requirements, and budget considerations.</li><li>AWS documentation provides detailed information and use cases for each volume type, aiding users in making informed decisions.</li></ul><p>After establishing a connection to the instance, execute the following commands. Please note that these commands can also be added to the instance creation process in the user data area:</p><pre>systemctl status apache2<br>cd /tmp<br>wget https://www.tooplate.com/zip-templates/2119_gymso_fitness.zip<br>unzip -o 2119_gymso_fitness.zip<br>cp -r 2119_gymso_fitness/* /var/www/html/<br>systemctl restart apache2</pre><p>These commands are designed to check the status of the Apache web server, navigate to the temporary directory, download a ZIP file containing website templates from a specified URL, unzip the downloaded file, copy the contents to the Apache document root directory, and finally restart the Apache service to apply the changes.</p><p>Here, we can observe the available volume types for creating an EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FRCzZ_8CPNlyognL" /></figure><p>Navigate to the Volumes section located on the left-hand side of the EC2 instances page and update the name of the volume associated with the instance mentioned earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*oaYzWbsHPuDzqdz-" /></figure><p>Adding extra storage to an EC2 instance, it’s crucial to consider the availability zone. Both the instance and the volume need to be in the same zone to ensure connectivity. When gathering requirements for additional storage, such as for web server images, it’s important to adhere to the free tier limit of 30 GB for EBS volumes. For instance, if there’s a need for five gigabytes of storage for web server images, it’s imperative to ensure that the total storage remains within the free tier limit.</p><p>Click on create volume:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ru7aEYSTEkbRNiRy" /></figure><p>Tags, you can give upon your wish, then click on Create Volume</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*M0bXD64bpGBX3tKC" /></figure><p>Choose the created volume, navigate to actions, and then opt for attaching the volume once it appears as available on the dashboard.</p><p>Select the instance , device name and click on attach volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EMi_GB2bQWyhWxn2" /></figure><p>(Please note I’ve selected /dev/xvdf in above screenshot as Device name).</p><p>If we run the “fdisk -l” command, we could see the new volume listed:</p><pre>fdisk -l</pre><p>List Disks: Start by running the command fdisk -l to list all disks. For instance, /dev/xvdf represents the root volume with a size of 8 GB, and it has a partition /dev/xvdaf1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*r4EcVRll60P6DIy2" /></figure><ul><li>Understand Partitions: Linux assigns partitioning numbers (e.g., xvda1) rather than names. Verify the root volume by checking its mount point using df -h. If /dev/xvda1 is mounted to the root directory, it contains the operating system data.</li><li>Create Partition: Identify the additional disk, such as /dev/xvdf, and use fdisk to create a partition. Choose the disk path (e.g., /dev/xvdf), follow the prompts to create a new partition, and write the changes using w.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/0*SvpmtSJBBRqWNnrx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7b8EKEvEEhIWcCWW" /></figure><pre>fdisk -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LoqI-OfM9wB8wnSK" /></figure><p>Format Partition: Use the appropriate formatting utility, such as mkfs.ext4, to format the partition. For example, run mkfs.ext4 /dev/xvdf1 to format the partition with ext4 format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*CZa3lyTphpReK7LX" /></figure><pre>mkfs.ext4 /dev/xvdf1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*TQpaHiEPQv5eYWtz" /></figure><p>Temporary Mount: Mount the partition temporarily using the mount command. For instance, mount /dev/xvdf1 /var/www/html/images. Verify the mount using df -h.</p><p>Create a directory: “ mkdir /tmp/image_backups”, and move all data from Images to newly created one</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*DK0cFoAisO4KoKPt" /></figure><p>Then mount the volume and verify as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ykXlD84Qhdj6bumt" /></figure><p>Permanent Mount: Edit the /etc/fstab file to configure permanent mounting. Add an entry with the partition path, mount point, format type, and other options. Save the file and test the configuration using mount -a.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Lbe4SMMpNUVQt_rG" /></figure><p>Save the file and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/0*Fy3E0nHBToc8gNwl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*gqxh8FFBO1H1w9Co" /></figure><p>Move Data: Move data from the backup directory to the mounted partition. For example, use mv command to move data from /tmp/img-backups to /var/www/html/images., and restart the apache2 service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xDC7r8D0qgpXWVfQ" /></figure><p>Verify: Check if the data is accessible through the browser. If not, consider disabling SELinux temporarily by modifying the /etc/selinux/config file and rebooting the system.</p><p>Take the public IP and paste in the browser: you could see the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Us-j9DH9S41eC429" /></figure><p><strong>EBS Snapshots</strong></p><p>Unmount the volume we created above as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*Of7IDYUCVSooCHvd" /></figure><p>Next, navigate to the AWS console, choose the volume that was created, and proceed to detach it by selecting the respective option.</p><p>Create a new volume same as shown above and attach it to the same ec2 instance.</p><p>Follow the same steps as mentioned above to create a new partition, format , and then create a directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/0*_UwAns028DlX7Yyb" /></figure><p>Add the new volume to the /etc/fstab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5zHg94hKxx4W9VuF" /></figure><p>Then mount it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*A8lycCUsvNVVqkl6" /></figure><p>Install mariadb-server package with the below steps:</p><pre>apt install mariadb-server<br>systemctl start mariadb<br>systemctl enable mariadb<br>systemctl status mariadb</pre><p>List the /var/lib/mysql contents:</p><pre>ls /var/lib/mysql/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fIzmOchz7UR2jrof" /></figure><p>Snapshot functionality primarily serves as a backup and restoration tool, crucial for mitigating data loss in the event of system failures. However, snapshots offer more than just backup capabilities.</p><p>In the event of data loss, the initial step involves unmounting the partition to prevent data overwriting. If the goal is to restore the existing partition, snapshots may not be applicable, as they provide a new volume containing the data. In such cases, unmounting the partition and employing recovery tools become essential.</p><p>When utilizing snapshots, unmounting the partition is the preliminary action, followed by detaching the corrupted volume. Subsequently, a new volume is created from the snapshot, retaining all data and partition configurations. Upon creation, the new volume is ready for attachment and mounting, effectively replacing the corrupted volume.</p><p>In essence, snapshots facilitate data restoration through volume replacement rather than repair, streamlining the recovery process and ensuring data integrity.</p><p>Take a Snapshot:</p><ul><li>Navigate to the Volume section in the AWS console.</li><li>Select the relevant volume, then click on “Actions” and choose “Create Snapshot.”</li><li>Provide a meaningful description and add tags for easy identification.</li><li>Click on “Create Snapshot” and wait for it to enter the completed state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*04eXOBH4Uxx9ii7K" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-phT7Yx6MAqvgKVy" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*RoEO-wE3zdtqhH36" /></figure><p>Delete Data:</p><ul><li>If you accidentally delete data or encounter corruption, proceed with data deletion.</li><li>Access the directory containing the data you wish to remove, e.g., /var/lib/mysql.</li><li>Use the command rm -rf * to remove all files and directories within the specified location.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*BiF2xj-x8L7LoqHA" /></figure><p>Unmount:</p><ul><li>Stop any relevant services to prevent further data overwrites.</li><li>Unmount the affected directory, e.g., /var/lib/mysql.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*74DO6g4PLl7KjA4D" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*1OUl0-zDASj2_eS-" /></figure><p>Detach Corrupted Volume:</p><ul><li>Navigate to the Volumes section and locate the corrupted volume.</li><li>Rename the volume for easy identification, e.g., “corrupted.”</li><li>Select “Actions” and choose “Detach Volume” to disconnect it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*V1kKJNvi6UyQLZNr" /></figure><p>Recover from Snapshot:</p><ul><li>Head to the Snapshots section and select the desired snapshot.</li><li>Click on “Actions” and choose “Create snapshots from volume”.</li><li>Customize volume settings such as type, size, and zone if needed.</li><li>Add appropriate tags for clarity</li><li>Click on “Create Volume” to finalize the recovery process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cNE1ztSLDfnEKPio" /></figure><p>In the Volumes console. goto Volumes and rename the new volume as “recovered”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Prf_PkpA8e5VZZih" /></figure><p>Goto actions and attach the volume</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*b8ZZoHmmSkw3UO_j" /></figure><p>Below, we examined the disks and found that they were not mounted. Consequently, we executed the mount -a command to rectify the issue. Upon verification, the disks were automatically mounted, allowing us to recover the deleted data by executing ls /var/lib/mysql/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*mKn7mHdtZUg358LC" /></figure><p>In the snapshot console, you’ll find various options beyond basic backup functionality. These include deleting snapshots, creating volumes from existing snapshots (which we’ve already covered), and managing fast snapshot restores for large volumes, albeit with additional charges.</p><p>Additionally, you can leverage snapshots to create images, known as Amazon Machine Images (AMIs). If the snapshot originates from a root volume, you can directly create an image from it.</p><p>Another useful feature is the ability to copy snapshots. By clicking the “copy” button, you can duplicate snapshots to different regions, which is particularly handy for multi-site setups. Moreover, during the copying process, you have the option to enable encryption for added security.</p><p>Furthermore, the snapshot interface offers a “modify permissions” button, allowing you to adjust access settings. This enables you to make snapshots public or share them with specific AWS accounts by providing their account IDs.</p><p>In summary, snapshots offer a simple yet powerful toolset with various benefits, making them an indispensable asset for managing AWS resources effectively.</p><p><strong>Elastic Load Balancer</strong></p><ul><li>Load balancing is a crucial aspect of managing clusters of servers efficiently. It involves distributing incoming network traffic across multiple servers to ensure optimal resource utilization, reliability, and scalability.</li><li>In AWS, Elastic Load Balancer (ELB) provides a scalable and reliable solution for load balancing, allowing users to distribute traffic across multiple targets seamlessly.</li></ul><p><strong>Key Components of ELB:</strong></p><p><strong>◼️</strong>Frontend Port and Backend Port:</p><ul><li>The frontend port is the port on which the load balancer listens for incoming traffic. For example, for HTTPS connections, the frontend port would typically be 443.</li><li>The backend port is the port on which the load balancer forwards traffic to the backend servers. It corresponds to the port where the application/service is running on the backend servers. For instance, if a Tomcat server is running on port 8080 on backend instances, the backend port would be set to 8080.</li></ul><p>◼️Types of ELB:</p><ul><li>Classic Load Balancer: Operates at the network layer (Layer 4) of the OSI model. It provides basic load balancing capabilities and distributes incoming traffic to backend instances based on configured rules.</li><li>Application Load Balancer (ALB): Operates at the application layer (Layer 7) of the OSI model. ALB supports advanced routing based on URL paths, hostnames, and other application-level attributes, making it ideal for HTTP and HTTPS traffic.</li><li>Network Load Balancer (NLB): Operates at the transport layer (Layer 4) of the OSI model. NLB is designed to handle extremely high volumes of traffic and offers ultra-low latency, making it suitable for TCP, UDP, and TLS traffic.</li></ul><p>◼️Load Balancer Targets:</p><ul><li>ELB distributes traffic to backend targets, which can include EC2 instances, containers, IP addresses, or Lambda functions.</li><li>Targets are distributed across multiple availability zones to improve fault tolerance and high availability.</li></ul><p><strong>Benefits of ELB:</strong></p><ul><li><strong><em>Scalability: </em></strong>ELB automatically scales in response to incoming traffic, ensuring that applications remain responsive even during traffic spikes.</li><li><strong><em>Fault Tolerance: </em></strong>By distributing traffic across multiple targets and availability zones, ELB enhances fault tolerance and resiliency.</li><li><strong><em>Simplified Management: </em></strong>ELB abstracts away the complexities of managing load balancers, allowing users to focus on building and scaling their applications.</li></ul><p>Let’s proceed with launching an instance and naming it as “web-health”.</p><p>You have the flexibility to choose between Amazon Linux, Ubuntu, or CentOS. The script provided in the resource section is compatible with both RPM-based and Debian-based operating systems. Since Amazon Linux is RPM-based, we’ll stick with it for this instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cwtJo07S0IAWs3dH" /></figure><p>Let’s opt for a t2.micro instance type and create a new key pair named “web-health-key” for secure access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Hv-_h-g4tmD2zR-Q" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*ZBIbX3YHKaTUzUKV" /></figure><p>Now, for the security group, let’s create a new one named “web-health-sg”, allowing inbound traffic on port 22 for SSH from your IP, and an additional rule for port 80, allowing traffic only from your IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SfyZBDvNnxjpRJ6z" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*KPkKOOU63tYody8l" /></figure><p>Moving forward, let’s proceed with the default storage settings and navigate to advanced details. Here, we’ll utilize the script in the “User data” section under “Advanced details”. Simply copy and paste it as instructed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*tSCMh9GvAWX0X1as.png" /></figure><p>Script:</p><pre>#!/bin/bash</pre><pre># Variable Declaration<br>#PACKAGE=&quot;httpd wget unzip&quot;<br>#SVC=&quot;httpd&quot;<br>URL=&#39;https://www.tooplate.com/zip-templates/2098_health.zip&#39;<br>ART_NAME=&#39;2098_health&#39;<br>TEMPDIR=&quot;/tmp/webfiles&quot;</pre><pre>yum --help &amp;&gt; /dev/null</pre><pre>if [ $? -eq 0 ]<br>then<br>   # Set Variables for CentOS<br>   PACKAGE=&quot;httpd wget unzip&quot;<br>   SVC=&quot;httpd&quot;</pre><pre>   echo &quot;Running Setup on CentOS&quot;<br>   # Installing Dependencies<br>   echo &quot;########################################&quot;<br>   echo &quot;Installing packages.&quot;<br>   echo &quot;########################################&quot;<br>   sudo yum install $PACKAGE -y &gt; /dev/null<br>   echo</pre><pre>   # Start &amp; Enable Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Start &amp; Enable HTTPD Service&quot;<br>   echo &quot;########################################&quot;<br>   sudo systemctl start $SVC<br>   sudo systemctl enable $SVC<br>   echo</pre><pre>   # Creating Temp Directory<br>   echo &quot;########################################&quot;<br>   echo &quot;Starting Artifact Deployment&quot;<br>   echo &quot;########################################&quot;<br>   mkdir -p $TEMPDIR<br>   cd $TEMPDIR<br>   echo</pre><pre>   wget $URL &gt; /dev/null<br>   unzip $ART_NAME.zip &gt; /dev/null<br>   sudo cp -r $ART_NAME/* /var/www/html/<br>   echo</pre><pre>   # Bounce Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Restarting HTTPD service&quot;<br>   echo &quot;########################################&quot;<br>   systemctl restart $SVC<br>   echo</pre><pre>   # Clean Up<br>   echo &quot;########################################&quot;<br>   echo &quot;Removing Temporary Files&quot;<br>   echo &quot;########################################&quot;<br>   rm -rf $TEMPDIR<br>   echo</pre><pre>   sudo systemctl status $SVC<br>   ls /var/www/html/</pre><pre>else<br>    # Set Variables for Ubuntu<br>   PACKAGE=&quot;apache2 wget unzip&quot;<br>   SVC=&quot;apache2&quot;</pre><pre>   echo &quot;Running Setup on CentOS&quot;<br>   # Installing Dependencies<br>   echo &quot;########################################&quot;<br>   echo &quot;Installing packages.&quot;<br>   echo &quot;########################################&quot;<br>   sudo apt update<br>   sudo apt install $PACKAGE -y &gt; /dev/null<br>   echo</pre><pre>   # Start &amp; Enable Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Start &amp; Enable HTTPD Service&quot;<br>   echo &quot;########################################&quot;<br>   sudo systemctl start $SVC<br>   sudo systemctl enable $SVC<br>   echo</pre><pre>   # Creating Temp Directory<br>   echo &quot;########################################&quot;<br>   echo &quot;Starting Artifact Deployment&quot;<br>   echo &quot;########################################&quot;<br>   mkdir -p $TEMPDIR<br>   cd $TEMPDIR<br>   echo</pre><pre>   wget $URL &gt; /dev/null<br>   unzip $ART_NAME.zip &gt; /dev/null<br>   sudo cp -r $ART_NAME/* /var/www/html/<br>   echo</pre><pre>   # Bounce Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Restarting HTTPD service&quot;<br>   echo &quot;########################################&quot;<br>   systemctl restart $SVC<br>   echo</pre><pre>   # Clean Up<br>   echo &quot;########################################&quot;<br>   echo &quot;Removing Temporary Files&quot;<br>   echo &quot;########################################&quot;<br>   rm -rf $TEMPDIR<br>   echo</pre><pre>   sudo systemctl status $SVC<br>   ls /var/www/html/<br>fi</pre><p>After launching the instance, it typically takes about 5 minutes to initialize. Once it’s up, we can check the public IP address and access the website via a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JFxv8zspIbjTAYZD" /></figure><p>In case you encounter any issues accessing the website, ensure that the security group allows traffic from your IP and that the HTTP service is running on the instance.</p><p>Following the successful setup of our website on the EC2 instance, we’ll proceed with creating an AMI and a launch template for future deployments.</p><p>Creating an AMI involves selecting the instance, navigating to Actions &gt; Image and templates &gt; Create image, and specifying a name for the AMI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*WtrzR-e7ngxM-gPR" /></figure><p>Provide a name for the AMI — Here I gave — “web-health-ami”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*chTJZFnTjc1zi0f0" /></figure><p>Once the AMI is created, we can leverage it to launch instances with identical configurations, ensuring consistency across our cluster.</p><p>Additionally, we can explore options like copying the AMI to other regions or sharing it with other AWS accounts for collaboration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ruu1fIFyOMOaUUV3" /></figure><p><em>Also, AWS offers a service known as EC2 Image Builder, allowing you to establish automated pipelines for image creation.</em></p><p><em>The image pipeline in Image Builder defines all aspects of the process to customize images. It consists of the image recipe, infrastructure configuration, distribution, and test settings.</em></p><p>With the AMI in place, we can streamline instance launches by creating a launch template. Given name as “web-health-template” and version as “V1”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uZVyN-13WlQQtSOf" /></figure><p>Then choose the “My AMIs” and select the AMI we created just before “web-health-ami”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Q_8q0ERcQqPOuscd" /></figure><p>Select the instance type as t2.micro</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sfbA9I8fyneTZx3A" /></figure><p>Select our key pair we created for the instance “web-health”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kkwLt6CZK7Z9BOg4" /></figure><p>Select the security group as “web-health-sg” we created for our instance “web-health”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_FNqxEmaWpZn0SnM" /></figure><p>Just give as below: When launching an instance from this template, I’ll modify the name to follow a format such as 2,3,4 etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qA5zgRH9nWL0gxDG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7iMMwfBadh9AuaX-" /></figure><p>With the AMI in place, we can streamline instance launches by creating a launch template. This template encapsulates all the configuration details, allowing for quick and consistent instance deployments.</p><p>By utilizing launch templates, we can expedite the process of launching instances and maintain standardized configurations across our infrastructure.</p><p>After configuring our instances, AMI, and launch template, we’ll proceed to set up a load balancer to distribute traffic efficiently across our web servers.</p><p>Simply navigate to the template section, locate your desired template, and select it. Then, choose the action “launch instance from template.” During the launch process, you’ll have the opportunity to make adjustments as needed. For example, you can modify the tag to “web-health01 to web-health02 two” before proceeding to launch the instance. That’s all there is to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Jr5QZeX3lIJQvmWT" /></figure><p>Now we have 2 instances which we created from templates and we can create ’n’ number of instances upon our business needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*oXnmadCLhUIgjHUX" /></figure><p>We have successfully created an AMI and established a launch template utilizing this custom AMI.</p><p>Presently, we have two web servers operating here. These servers are not individually accessible by users. Instead, users must access them through a unified endpoint, which directs requests to either of these instances. This single endpoint is facilitated by a load balancer.</p><p>In the Load Balancer section, we will first navigate to target groups. Target groups function as collections of instances, each subject to health checks. Essentially, they are groups comprising instances. Let’s proceed to create a target group.</p><p>Starting with creating a target group, we’ll define health checks and specify the instances to include.</p><p>Choose target type as “Instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uT_gLwFz5aXx5ruQ" /></figure><p>Provide a name as below and Port number 80, protocol HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GDc1NHuoAU_ffAb8" /></figure><p>In our setup, we’ve implemented health checks within the target group. These health checks allow the target group to assess the status of each instance. If an instance is deemed unhealthy during these checks, the target group will refrain from routing requests to that specific instance.</p><p>Now, you might wonder, how does the target group determine if an instance is healthy or not? It’s a similar process to how we, as humans, assess the health of a website. We simply open the website in a browser and check if it’s functioning properly. If everything looks good, we consider the website to be healthy.</p><p>Similarly, the target group conducts health checks by sending HTTP requests to the instances. When configuring these health checks, we specify the protocol (HTTP) and the health check path (/).</p><p>Let’s break down what the health check path (/) signifies. Imagine your website’s URL is<a href="http://ip/"> http://IP:80</a>. The slash at the end of this URL represents the root directory of the website. It’s where the homepage resides.</p><p>Now, if your website has subfolders, such as “videos” or “images,” the health check path would be adjusted accordingly (e.g., /videos or /images).</p><p>In essence, by specifying the health check path as “/”, we’re instructing the target group to check the root directory of our website. When the target group receives a successful response (HTTP 200 OK) from this path, it considers the instance to be healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0pAPOhkR-mSdF0Y1" /></figure><p>In our setup, traffic is expected to flow through the default port, which is port 80. However, if your website operates on a different port, you would need to specify it here.</p><p>To do so, you would select the “override” option and provide the appropriate port number, such as 8090. However, since we know that our website operates on port 80, we will leave it as is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*90Li2Kn07eWiSGXg" /></figure><p>The “Healthy threshold” parameter determines the number of consecutive successful health checks required before declaring the instance as healthy. By default, it is set to five, but you can adjust it to two or ten as per your preference. With a threshold of five, the system checks the instance’s health five times, and if all checks pass successfully, the instance is marked as healthy.</p><p>In our case, I will reduce it to two. This means that the instance will be considered healthy if it passes two consecutive health checks. Similarly, the “Unhealthy threshold” specifies the number of consecutive failed health checks required to declare the instance as unhealthy. If an instance returns an unhealthy status twice in a row, it will be marked as unhealthy.</p><p>The “Timeout” parameter determines how long the system waits for a response from the website during each health check. If the website does not respond within the specified timeout period (default is 5 seconds), the system moves on to the next check.</p><p>Health checks, whether for determining the instance’s health or unhealthiness, occur at regular intervals, typically every 30 seconds. This interval can be adjusted within a range of 5 to 300 seconds.</p><p>When performing health checks, the system looks for a success exit code, typically HTTP 200, indicating that the website is functioning properly. While we can visually confirm this by checking the website in a browser, the target group relies on these exit codes to determine the instance’s health status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*QG7zGh16AiRP6Nvy" /></figure><p>So the below are the instances running and click on the “Include as pending below option”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tUL5Wmtp0iBLxpmU" /></figure><p>And the targets are in running state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wtrH-nbsIixWY0Cu" /></figure><p>Once the target group is set up, we’ll proceed to create an application load balancer (ALB), specifying its name, internet-facing nature, and availability zones.</p><p>We will go with application load balancer for http, https traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/0*uL6j2W41inpo2UxW" /></figure><p>Give a load balancer name “web-health-elb” and We want it to be available on the Internet, so we’ll keep it Internet facing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ChxOUX0fOInmUIOU" /></figure><p>When setting up the load balancer, it’s necessary to specify the availability zones where the load balancer will operate. The system requires a minimum of two zones to ensure redundancy and high availability.</p><p>For our configuration, I will choose to select all available zones. This ensures that the load balancer operates across multiple zones, maximizing its availability and fault tolerance. This approach provides a high level of availability at the load balancer level, which is crucial for maintaining continuous service availability.</p><p>By selecting all zones, we distribute the load balancing functionality across multiple data centers or regions, reducing the risk of downtime due to failures in any single zone. This enhances the resilience and reliability of our application infrastructure, allowing it to withstand potential disruptions in individual zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kOcKmkU5BYHYHqmN" /></figure><p>Click on the “Create a new security group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kHNrDJCItiaIHzlw" /></figure><p>For the security configuration of our load balancer, we’ll create a new security group to define its access permissions. It’s important to name this security group appropriately for easy identification and management.</p><p>We’ll name it “web-health-elb-sg” to indicate that it’s the security group for our health project’s load balancer. Using descriptive names helps maintain clarity and organization within our AWS environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tz8BLEfS7iFM5cKr" /></figure><p>As for the inbound rule, we want to allow access on port 80 from anywhere, making the load balancer accessible to the public. We’ll specify the protocol as IPv6 to accommodate modern internet standards, especially considering the increasing adoption of IPv6 by internet service providers, including mobile networks.</p><p><em>Ensuring broad accessibility while maintaining security is crucial for our load balancer’s functionality and usability. Making these considerations and adopting best practices, such as proper naming conventions and access control, contributes to the overall robustness of our infrastructure.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5fNU4o2IWEZa2xPH" /></figure><p>Now select the security group we created just now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0Tv_Sl1yF4Tm1Ano" /></figure><p>Ensuring that the ALB’s security group allows inbound traffic on port 80 from any source, we’ll configure listeners to route traffic to the target group on port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Kbi4c19il_v9r-53" /></figure><p>Now let’s create a load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ld0lrWaxfqLFKux1" /></figure><p>Upon viewing the load balancer, you’ll notice that it initially enters the provisioning state, transitioning to the active state once fully provisioned. However, despite reaching the active state, attempting to access the website directly from the load balancer may not yield the expected results.</p><p>When encountering this issue, accessing the website via the load balancer’s DNS name might result in a 504 Gateway Timeout error, indicating a failure to establish a connection between the load balancer and the instances. Despite verifying that the instances are healthy, the presence of this error suggests a potential obstacle preventing traffic from passing between the load balancer and the instances.</p><p>To address this challenge, we need to identify and resolve the underlying cause obstructing traffic flow between the load balancer and the instances. This discrepancy could be attributed to misconfigured security groups, routing issues, or other network-related factors.</p><p>By diagnosing and rectifying this barrier, we can ensure seamless connectivity between the load balancer and the instances, thereby resolving the 504 Gateway Timeout error and enabling users to access the website reliably through the load balancer.</p><p>Each instance is shielded by a security group, a vital layer of defense governing inbound and outbound traffic. Upon inspection, we observed that both instances share the same security group. However, upon reviewing its inbound rules, we discovered that port 80 was only permitted from our IP address, rather than from the load balancer.</p><p>To rectify this, we need to adjust the security group settings to allow traffic from the load balancer. But before proceeding, it’s prudent to verify the status of the target group. The target group conducts health checks to determine an instance’s well-being. If an instance is deemed unhealthy, the target group will cease routing traffic to it. In this scenario, instances were marked as unhealthy due to the inability to access port 80.</p><p>Returning to the security group settings, we locate the security group associated with the instances and modify its inbound rules. Specifically, we add a new rule permitting port 80 access from the security group of the load balancer. By specifying the source as the load balancer’s security group, we ensure that any member of the load balancer’s group can communicate with the instances over port 80.</p><p>Additionally, it’s beneficial to include a descriptive label for this rule, such as “allow port 80 from ELB,” to enhance clarity and documentation. Descriptive labels streamline management and aid in understanding the purpose of each rule, promoting efficient administration and troubleshooting.</p><p>Make the security groups inbound rules as below of “web-health”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FdDTIa-esDp3nkih" /></figure><p>Save the rule.</p><p>Make sure that the targets are healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FsyUFt_huCL-iPC2" /></figure><p>Now check it on the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pwzq7StlEIsoltjV" /></figure><p>Managing instances within target groups is a critical aspect of optimizing the performance and availability of applications deployed on AWS. Target groups serve as collections of instances that are subject to health checks, ensuring that traffic is routed only to healthy instances.</p><p>Here are some key points to consider when managing instances within target groups:</p><ol><li><strong>Health Monitoring: </strong>Target groups continuously monitor the health of instances by conducting health checks based on configured parameters. These health checks assess the instance’s ability to respond to requests and determine its overall health status.</li><li><strong>Registration and Deregistration:</strong> Instances can be registered or deregistered from target groups dynamically based on operational requirements. This flexibility allows for seamless scaling and maintenance operations without disrupting application availability.</li><li><strong>Maintenance and Scaling: </strong>Registering or deregistering instances from target groups is a common practice during maintenance activities or when scaling the application. By removing unhealthy or underperforming instances from the target group, traffic can be effectively redirected to healthy instances, ensuring consistent application performance.</li><li><strong>Load Balancing: </strong>Target groups play a crucial role in load balancing by distributing incoming traffic across multiple instances based on predefined rules and health check results. This ensures optimal resource utilization and enhances application reliability and scalability.</li><li><strong>Automation: </strong>Managing instances within target groups can be automated using AWS services such as Auto Scaling, which automatically adjusts the number of instances in response to changing demand. This automation helps optimize resource usage and ensures that the application can handle fluctuations in traffic effectively.</li></ol><p>Finally, we’ll familiarize ourselves with managing instances within the target group, including registering and deregistering instances as needed for maintenance or scaling purposes.</p><p><strong>Introduction to CloudWatch:</strong></p><ul><li>AWS CloudWatch is a comprehensive monitoring service offered by Amazon Web Services.</li><li>Originally focused on monitoring, CloudWatch has expanded its capabilities to include logging, events, and more.</li><li>It serves as a central hub for monitoring the performance and health of AWS environments.</li></ul><p><strong>Key Features of CloudWatch:</strong></p><p><strong>◼️</strong>Monitoring Service:</p><ul><li>CloudWatch serves as a monitoring solution for AWS resources, tracking performance metrics such as CPU utilization, disk I/O, and network traffic.</li><li>It automatically generates standard metrics for various AWS services used in a region.</li></ul><p><strong>◼️</strong>Logging Solution:</p><ul><li>In addition to monitoring, CloudWatch functions as a logging solution, allowing users to collect, store, and analyze log data generated by AWS resources and applications.</li><li>Logs from services like EC2 instances can be streamed to CloudWatch for centralized log management.</li></ul><p><strong>◼️</strong>Event Monitoring:</p><ul><li>CloudWatch captures real-time events within the AWS environment, such as instance launches, terminations, or volume creations.</li><li>Users can set triggers and notifications based on these events, often integrated with AWS Lambda functions.</li></ul><p><strong>◼️</strong>Standard and Custom Metrics:</p><ul><li>CloudWatch provides both standard and custom metrics for monitoring AWS resources.</li><li>Standard metrics cover common performance indicators like CPU utilization, network traffic, and disk operations.</li><li>Users can define custom metrics tailored to their specific monitoring needs.</li></ul><p><strong>◼️</strong>Alarms and Notifications:</p><ul><li>Users can set alarms on CloudWatch metrics to trigger notifications when predefined thresholds are breached.</li><li>Notifications can be sent via email or integrated with Amazon SNS for broader alerting capabilities.</li></ul><p><strong>◼️</strong>Integration with AWS Services:</p><ul><li>CloudWatch seamlessly integrates with various AWS services, including EC2 instances and EBS volumes.</li><li>Metrics and logs from these services are collected and monitored by CloudWatch, providing insights into resource performance.</li></ul><p><strong>Practical Use Cases:</strong></p><ul><li>CloudWatch simplifies monitoring by automatically collecting metrics for AWS resources.</li><li>Users can customize monitoring settings and set up alarms to receive timely notifications of any performance anomalies.</li><li>Practical examples include setting alarms for CPU utilization exceeding a certain threshold, which triggers email notifications via SNS.</li></ul><p>If you’ve already reviewed the previous blog post, we’ve provided a template for launching EC2 instances. Kindly review it, or proceed to create an EC2 instance.</p><p>Select the EC2 instance and click on monitoring:</p><p>Before proceeding further, take note of the various metric names available, such as CPU utilization, which indicates the percentage of CPU being used over time. Additionally, observe other metrics like status checks, network in and out (in bytes), network packets in and out (count), and disk read operations.</p><p>These metrics are automatically generated by CloudWatch when you launch an EC2 instance.</p><p>If you require additional metrics, such as RAM or disk utilization, you’ll need to create custom metrics.However, for the purpose of this session, we’ll focus solely on CPU utilization, as it’s one of the most critical metrics to monitor.</p><p>By default, CloudWatch checks and updates these metrics every 5 minutes, populating the corresponding graphs.If you prefer more frequent updates, you can enable detailed monitoring, though it’s important to note that this option isn’t free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xQetzN3d7R3Vqlcd" /></figure><p>For this hands-on, enabling detailed monitoring is optional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*03wtLgr2MNncGY5V" /></figure><ol><li>Select the option to “Enable” detailed monitoring, indicating that CloudWatch should monitor metrics every minute.</li><li>Keep in mind that detailed monitoring incurs additional charges compared to the default 5-minute monitoring interval.</li><li>Despite the additional cost, enabling detailed monitoring offers more granular insights into your AWS environment’s performance.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*2oVD3YqosxEkZVmB" /></figure><p>Log in to the terminal of the EC2 instance and switch as root user.</p><p>Then install the stress tool along with its dependencies on your instance.</p><p>Stress is a versatile tool designed to test the limits of your Linux operating system, particularly focusing on CPU performance and other system metrics. Simply running the stress command allows you to stress the CPU. You can specify parameters such as the number of CPUs to stress and even utilize functions like the square root function. Additionally, stress can be used to stress other components like IO and RAM, but for our purpose, we’re concentrating on CPU stress testing.</p><pre>yum install stress -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*BLJJTvB-Nlxc9asx" /></figure><pre>nohup stress -c 3 -t 100 &amp;</pre><p>This command executes the stress utility in the background using the nohup command, which allows the process to continue running even after the terminal session is terminated. Let’s break down the command:</p><ul><li>nohup: Prevents the following command from being terminated when the terminal session ends.</li><li>stress: The stress testing utility.</li><li>-c 3: Specifies that 3 worker threads will be used to stress the CPU cores.</li><li>-t 100: Specifies that the stress test will run for 100 seconds.</li><li>&amp;: Runs the command in the background.</li></ul><p>So, this command will run the stress test with 3 worker threads for 100 seconds, and the process will continue running even if the terminal session is closed.</p><p>Execute the top command.</p><pre>top</pre><p>You’ll notice four stress processes running, indicating the CPU utilization at 100 or close to it, reflected by the load average increment.</p><p>Continuously stressing the instance like this will be monitored by CloudWatch, updating the graph every minute.</p><p>Repeat this process a few times, running for intervals like 100 seconds and 200 seconds. After a few minutes, you’ll observe a pattern forming on the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*w61kDGIdwikuuS3z" /></figure><p>Let’s create a script for this process.</p><pre>vim stress.sh<br>sleep 60 &amp;&amp; stress -c 4 -t 60 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 60 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 30 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 100 &amp;&amp; sleep 30 &amp;&amp; stress -c 4 -t 200<br>:wq!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OUGYBPZ55_ffBDQ8" /></figure><p>This sequence of commands progressively varies the duration of the stress tests, interspersed with periods of rest. It’s a way to simulate different levels of CPU load on the system over time. designed to stress test the system’s CPU using the stress utility. Let’s break down each part:</p><p><strong>◼️</strong>sleep 60: This command pauses execution for 60 seconds before proceeding to the next command. It introduces a delay in the sequence.</p><p><strong>◼️</strong>stress -c 4 -t 60: This command runs the stress utility with the following options:</p><p><strong>◼️</strong>-c 4: Specifies that 4 worker threads will be used to stress the CPU cores.</p><p><strong>◼️</strong>-t 60: Specifies that the stress test will run for 60 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 60: Similar to the second command, this runs a stress test for another 60 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 30: This command runs a shorter stress test for 30 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 100: This command runs a longer stress test for 100 seconds.</p><p><strong>◼️</strong>sleep 30: A shorter pause of 30 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 200: This command runs an even longer stress test for 200 seconds.</p><p>Execute this script</p><pre>./stress.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3PlZ0YDmj-4PlskV" /></figure><p>We generate a graph by running the command. I simply executed it using nohup stress.sh &amp;.</p><p>Ensure your script is executable.</p><pre>chmod +x stress.sh</pre><p>Now, when observing the top output, you may intermittently notice the stress command based on the ongoing operations within your script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EYaGL-rcSTXteDJQ" /></figure><p>Now, let’s navigate to the CloudWatch service to configure an alarm for CPU utilization on this instance.</p><p>First, head over to the “All alarms” section.</p><p>Next, click on the “Create Alarm” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PKx3ZIfPVcqWQw-E" /></figure><p>To select the CPU utilization metric, start by navigating to the EC2 service.</p><p>Then, locate the “Per-instance metrics” section and find your instance. If you don’t immediately see your instance, wait for a few moments for the information to load.</p><p>Once you’ve found your instance, look for the CPU utilization metric.</p><p>Select the CPU utilization metric by clicking on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*58DIHz8N2ZIhAvd1" /></figure><p>In this step, we can choose the period for which the alarm will be evaluated.</p><p>For this demonstration, I’ll keep the period set to 5 minutes.</p><p>Next, we specify the condition for triggering the alarm based on CPU utilization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qn-ZzeMyewpoViYh" /></figure><p>For example, we can set the condition to trigger the alarm if the CPU utilization is greater than or equal to 60 for a period of 5 minutes.</p><p>Once we’ve defined the condition, we proceed to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gdmiLJBeKi3LVtG6" /></figure><p>If you don’t find your desired topic listed, you can click on “Create Topic.” Provide a name for the topic, enter your email address, and click on “Create Topic.”</p><p>However, since we already created a topic for billing alarms earlier, I’ll select the same topic, which contains my email address.</p><p>This topic is designated for notifications. So, when the alarm state is triggered, it will send a notification to this topic, ultimately resulting in an email notification being sent to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/0*Dbad7-423ib8E1XA" /></figure><p>There are several other actions you can take, such as EC2 actions. For instance, you might want to stop, terminate, or reboot the instance if it triggers an alarm.</p><p>In some cases, a high CPU utilization might prevent you from logging into the instance via SSH. Rebooting the instance could be a temporary solution to address this issue.</p><p>However, for the purpose of this demonstration, we will skip these additional actions. We will stick to email notifications only and proceed to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eDWFYQ0Cv-wggu0i" /></figure><p>Let’s give the alarm a descriptive name.</p><p>The naming convention will be: “warning-web-health-alarm-notification-cpu” for the specific instance.</p><p>In our organization, a warning is triggered when the utilization exceeds 60%. We could set up additional alarms for critical situations, such as when it surpasses 80%. However, for now, we’ll proceed with just one alarm.</p><p>Now, let’s move on to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vEaUX1XwvD_1S0dz" /></figure><p>After a while, CloudWatch will collect the data and display whether the instance is in an alarm state or if it’s okay.</p><p>Now, this process aligns with the basic principles of any monitoring tool. You have metrics or checks, alarms triggered by those metrics or checks, and actions associated with those alarms, such as sending email notifications.</p><p>Whether it’s Prometheus, Nagios, Icinga, Zenos, or others, the concept remains similar. However, with CloudWatch, monitoring is already configured, and you only need to set up alarms. In contrast, with other tools, such as those you set up yourself, the entire monitoring system needs configuration, typically by the monitoring or administration team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*f6z17CSSPliKXDQq" /></figure><p>Currently, the graph fluctuates because I’ve executed the stress command multiple times. Remember, you need to run the stress command for at least 5 minutes or longer for it to exceed the threshold and trigger the email notification.</p><p>After running the command for 5 minutes, wait for the notification to arrive in your inbox.</p><p>Moreover, you can create a reverse alarm to monitor the instance’s OK state. For instance, if the CPU utilization is below 40, it’s considered OK. You can set up alarms for different thresholds and states, and you have the flexibility to create up to ten alarms under the free tier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lFuWP_7zw0wWikM9" /></figure><p>Email notification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dtwZ7cGYur2Jw9kz" /></figure><p>I encourage you to experiment with these alarms to familiarize yourself with their functionalities. Set alarms for various data points, both in alarm and OK states, using different conditions like greater than or less than. Once you’re comfortable, remember to terminate the instance and delete the alarms before moving on to the next section, particularly the auto-scaling group section.</p><p><strong>Auto Scaling Groups (ASG)</strong></p><p>Auto Scaling Groups (ASG) seamlessly integrates with CloudWatch to monitor specific metrics, such as CPU utilization. If a metric, like CPU utilization, exceeds a predefined threshold, ASG adjusts capacity by either adding or removing instances in the group. This adjustment is based on CloudWatch alarms, which trigger actions to maintain performance or control costs.</p><p>When creating an auto scaling group, you’ll configure launch configurations or launch templates, similar to those used in EC2 instances for ELB exercises. These configurations provide the necessary information for launching instances within the ASG.</p><p>To dynamically adjust capacity based on metrics, ASG employs scaling policies. You can define these policies, such as step scaling, to add or remove instances based on workload fluctuations. For instance, you could specify that if CPU usage exceeds 60%, launch two additional instances, or if it exceeds 80%, launch four instances.</p><p>When setting up an auto scaling group, you specify parameters like minimum, desired, and maximum capacity. The minimum size ensures a baseline level of instances that cannot be terminated, while desired capacity represents the typical number of running instances. The maximum size limits the total number of instances the group can scale up to, helping to control costs.</p><p>In practice, ASG operates by creating a group powered by launch configurations. When a metric breach triggers a CloudWatch alarm, scaling policies kick in to launch or terminate instances accordingly, ensuring optimal performance and resource utilization.</p><p>Now, let’s dive into the practical implementation of these concepts.</p><p>Before diving into the auto scaling group setup, let’s ensure we have all the necessary components in place.</p><p>Firstly, we’ll need the launch template, which should already be created as per the instructions provided in the load balancer section. If the launch template has been removed or needs to be recreated, refer back to the load balancer section for detailed steps on how to create it.</p><p>Now, let’s proceed to the Target Group setup.</p><p>◼️Navigate to the Target Group section.</p><p>◼️Click on the “Create target group” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MhSZ6AzSGrpVEKXx.png" /></figure><p>◼️Configure the target group settings, such as name. For example, let’s name it “web-health-tg”.</p><p>◼️Keep the other configurations as default and proceed by clicking “Next”.</p><p>◼️Since we don’t have any instances yet, select the option to create an empty target group.</p><p>◼️Complete the target group creation process by following the prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sgdWaNIlRi629TCq.png" /></figure><p>Indeed, the Auto Scaling group will automatically add instances to this target group as needed based on your scaling policies and the metrics you’ve configured, ensuring seamless scalability and efficient resource management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*obwDZrpMX5shTsW5.png" /></figure><p>We’ll proceed by creating a load balancer for this target group. Let’s select “Create load balancer” and opt for the application load balancer, maintaining consistency with our previous setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lcVyqN1Zi5AJb40P.png" /></figure><p>We’ll name it “health-elb” and choose the same availability zones and security groups used previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*b1tAvQHRTN4LlRa4.png" /></figure><p>Remember to remove the Default Security Group. Next, we’ll configure it to forward traffic to the target group we just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lxI1KSezk-SuWYD_.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JLsMVooi5mP8No_1.png" /></figure><p>If you already have these resources set up, you can reuse them; otherwise, go ahead and create them now. Here’s our load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EtXaVoBUxTPV6Ih8.png" /></figure><p>Let’s revisit the launch template. This template is essential as it defines the configuration for the instances that will be launched by the auto scaling group.</p><p>Since we’ve previously created the launch template, we can review its settings to ensure everything is configured correctly.</p><p><a href="https://iam-athirakk.medium.com/maximizing-efficiency-and-reliability-with-elastic-load-balancer-1aae54b5788b">https://iam-athirakk.medium.com/maximizing-efficiency-and-reliability-with-elastic-load-balancer-1aae54b5788b</a></p><p>It’s important to verify that the required AMI is available and accessible. If you’ve already prepared the AMI, it should be readily available for selection within the launch template settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*stfL5N-Mjoq6BJMN.png" /></figure><p>The launch template specifies details such as the Amazon Machine Image (AMI) to be used for the instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JjvmuDwNRMRc2GUy.png" /></figure><p>Now, let’s navigate to the auto scaling groups section.</p><p>Let’s initiate the creation process by assigning a name to our auto scaling group. For simplicity, let’s name it “web-health-asg”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*TTBs5ASnjughMwAg.png" /></figure><p>Next, we’ll select our launch template for the auto scaling group.</p><p>You might also notice the option to use a launch configuration, which serves a similar purpose to a launch template. However, AWS now recommends using launch templates due to their added flexibility.</p><p>One notable advantage of launch templates is their editability. Unlike launch configurations, which cannot be modified once created, launch templates allow for easy edits and the creation of multiple versions. This versatility enables you to tailor your configurations to different environments or instance types seamlessly.</p><p>As we proceed, we’ll opt for the launch template, leveraging its benefits for our auto scaling group. You’ll notice the option to select different versions of the launch template, providing flexibility in configuration management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*I5o1rE8t_-IfIgGn.png" /></figure><p><strong>Choose instance launch options</strong></p><p>In this step, we need to specify the availability zones where we want our instances to be launched.</p><p>You have the option to select specific zones or allow AWS to choose based on availability. It’s generally recommended to choose at least two zones for redundancy and fault tolerance.</p><p>Let’s proceed by selecting all zones and moving to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*UYoRON_Tsw_wuc6M.png" /></figure><p><strong>Configure advanced options</strong></p><p>In this step, we have the option to attach our auto scaling group to an existing load balancer.</p><p>Since our website will benefit from a load balancer, especially with multiple instances, we’ll choose to attach it to an existing load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fr0qFP9vsgy2Yso7.png" /></figure><p>We’ll then select the target group that we previously created. This ensures that the instances launched by our auto scaling group are registered with the specified target group, allowing the load balancer to distribute traffic effectively across these instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*a8go8xVN4gIhKNp_.png" /></figure><p>In this step, we configure the health check settings for our instances within the auto scaling group.</p><p>The primary responsibility of the auto scaling group is to maintain the desired number of healthy instances, ensuring optimal performance and reliability.</p><p>By default, the auto scaling group performs basic EC2 health checks, which include hardware and virtual machine checks. However, these checks only verify the instance’s basic functionality and do not guarantee the health of your application or website.</p><p>To enable more comprehensive health checks, we opt for ELB (Elastic Load Balancer) health checks. This leverages the target group health check functionality discussed in the load balancer section.</p><p>The target group conducts health checks every 300 seconds, verifying the health of instances based on specified criteria such as port availability and process responsiveness. If an instance fails this health check, indicating a potential issue with the hosted application or service, the target group declares it as unhealthy.</p><p>Upon detecting an unhealthy instance, the auto scaling group takes corrective action by terminating the problematic instance and launching a replacement. This ensures that the overall system remains resilient and capable of handling fluctuations in workload and application health effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gsGNOeKmF4hFlKHY.png" /></figure><p><strong>Configure group size and scaling</strong></p><p>Now, let’s proceed to the next step.</p><p>Here, we specify the capacity settings for our auto scaling group. We define the desired, minimum, and maximum number of instances that the group should maintain.</p><ul><li>Desired capacity: This indicates the number of instances we want to have in our auto scaling group. For example, setting it to 2 means we aim to have two instances running at all times.</li><li>Minimum capacity: This represents the minimum number of instances that must be running in the auto scaling group, regardless of the workload or scaling policies. In our case, we set it to 1 to ensure there is always at least one instance available.</li><li>Maximum capacity: This defines the upper limit on the number of instances that can be launched by the auto scaling group. Even if the workload demands more instances, the group will not exceed this limit. Here, we set it to 8 to cap the maximum number of instances at eight.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LNfWET-DYydQr05v.png" /></figure><p>Understanding the distinction between desired, minimum, and maximum capacities is crucial. While desired capacity determines the ideal number of instances, minimum capacity ensures a baseline level of availability, and maximum capacity prevents excessive scaling beyond a predetermined threshold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JIKuQbE_OvHU06ev.png" /></figure><p>Next, we delve into scaling policies, which dictate how the auto scaling group responds to changes in workload or system metrics.</p><ul><li>Scaling policies: These policies govern when and how the auto scaling group should scale out (add instances) or scale in (remove instances) based on predefined conditions. We can choose from various scaling policy types, such as target tracking scaling policies or simple scaling policies.</li></ul><p>For instance, we opt for a target tracking scaling policy based on CPU utilization. If the combined CPU utilization across instances exceeds 50%, the auto scaling group will add instances to handle the increased workload. Conversely, if CPU utilization drops below 50%, instances may be removed to optimize resource usage.</p><p>Additionally, we have the option to enable scaling protection, which safeguards newly launched instances from immediate termination. This feature can be beneficial in scenarios where instances require time to initialize or synchronize data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cjEttlphikkBo9SC.png" /></figure><p>By configuring these capacity and scaling policy settings, we ensure that our auto scaling group operates efficiently, maintaining optimal performance while dynamically adjusting to changing demand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*E0Mn3_wAK2-pxXak.png" /></figure><p><strong>Add notifications</strong></p><p>Now, let’s proceed to the next step.</p><p>Here, we have the option to configure event notifications for various actions performed by the auto scaling group.</p><ul><li>Notification settings: We can specify a notification topic to receive notifications for specific events related to the auto scaling group’s lifecycle. These events include instance launches, terminations, failures to launch, and failures to terminate.</li></ul><p>By defining a notification topic, we ensure that relevant stakeholders or automated systems are promptly informed of any changes or issues affecting the auto scaling group’s operation. This facilitates proactive monitoring and troubleshooting, allowing us to maintain the reliability and availability of our infrastructure.</p><p>After configuring the notification settings as needed, we can proceed to the next stage of the auto scaling group setup process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eZeLAyj6dv0YUnjC.png" /></figure><p><strong>Add tags</strong></p><p>Let’s add tags for identification purposes.</p><ul><li>Tag Name: “web-health”</li></ul><p>We’ll keep the naming simple and generic since the number of instances can vary dynamically based on scaling policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*n0IMCGGhmKGmhEJv.png" /></figure><p>Now, let’s proceed by clicking on “Next” and review all the provided information before finalizing the creation of the auto scaling group. Once verified, we can proceed with the creation process.</p><p>Currently, we don’t have any instances running. As per our configuration, the desired capacity is set to two instances. So, the auto scaling group will start creating instances to meet this desired capacity.</p><p>You can observe that two instances are being created to fulfill the desired capacity. Additionally, there’s a scaling policy in place. If the CPU utilization drops below 50%, it will terminate instances accordingly. However, it will always maintain a minimum of one instance.</p><p>In the instance management section, you’ll find all the instances within the auto scaling group. This section is particularly useful for troubleshooting purposes. Here, you can perform various actions such as detaching an instance from the auto scaling group, setting it to standby mode, or bringing it back into service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*v6H0gHP0m82hMiKC.png" /></figure><p>You have the option to set scale-in protection for instances. This means that these instances won’t be terminated by the auto-scaling process. This feature is particularly useful during troubleshooting or maintenance activities when you don’t want instances to be terminated unexpectedly.</p><p>We’ll wait for a few minutes to ensure that all instances are in a healthy state. Once they are marked as healthy, we’ll explore some additional options. Currently, both instances are running and healthy. You should also see them updated in the target group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fAPPJjzg5UgJLcgt.png" /></figure><p>When managing instances within an auto-scaling group, it’s crucial to remember that these instances are dynamic. They are automatically created and deleted by the auto-scaling group based on the defined policies and metrics. Therefore, manual changes to instances should be avoided to prevent unexpected behavior.</p><p>Any changes to instances should be made through the launch template. This includes changes such as instance type, security group, application upgrades, or software installations. If you need to make changes, create a new launch template or a new version of the existing launch template with the desired configurations.</p><p>To apply changes to instances, you can edit the auto-scaling group and select the new launch template. Once the changes are saved, you must initiate an instance refresh to apply the changes to existing instances. During instance refresh, instances are terminated and recreated based on the updated launch template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jIVJBR53XxJbzRh9.png" /></figure><p>When initiating an instance refresh, ensure that you specify a minimum healthy percentage. This ensures that a certain percentage of instances remain healthy during the refresh process, preventing disruptions to your application. It’s recommended to set a higher healthy percentage to maintain application stability.</p><p>Once changes are applied and instance refresh is initiated, monitor the auto-scaling group activity to ensure that new instances are launched successfully and the application remains available. Avoid manual termination of instances unless necessary for troubleshooting or maintenance purposes.</p><p><em>Please note — instance: i-02e53d55300f6659a I stopped purposefully.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*YHNgZz__efyAsJFt.png" /></figure><p>We can see 2 instances are running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fvig0k9Cr2jX4NUt.png" /></figure><p>By following these best practices, you can effectively manage instances within your auto-scaling group while ensuring the reliability and scalability of your application.</p><p>In conclusion, auto-scaling groups in AWS offer a powerful solution for managing the scalability and availability of your application infrastructure. By dynamically adjusting the number of EC2 instances based on predefined policies and metrics, auto-scaling groups enable you to efficiently handle fluctuating traffic loads while maintaining optimal performance and cost-effectiveness.</p><p>Key points to remember include:</p><ol><li>Dynamic Nature: Auto-scaling groups automatically create and terminate EC2 instances based on configured scaling policies, ensuring that your application can handle varying levels of demand without manual intervention.</li><li>Launch Templates: Changes to instance configurations should be made through launch templates, allowing for easy management of instance settings such as instance type, security groups, and software configurations.</li><li>Instance Refresh: When updating configurations, initiate an instance refresh to apply changes to existing instances. Specify a minimum healthy percentage to ensure application stability during the refresh process.</li><li>Avoid Manual Changes: Manual changes to instances within auto-scaling groups should be avoided to prevent conflicts with scaling policies and unexpected behavior. Instead, utilize launch templates for any necessary updates.</li><li>Monitoring and Maintenance: Regularly monitor the auto-scaling group activity to ensure that instances are being created and terminated as expected. Conduct troubleshooting and maintenance activities carefully to avoid disruptions to your application.</li></ol><p>Refer this link to get hands-on experience in Auto Scaling — <a href="https://medium.com/@iam-athirakk/aws-auto-scaling-d67063e1abf8">https://medium.com/@iam-athirakk/aws-auto-scaling-d67063e1abf8</a></p><p>Refer this link to get hands-on experience in Application Load Balancer — <a href="https://medium.com/@iam-athirakk/application-load-balancer-463da91c8960">https://medium.com/@iam-athirakk/application-load-balancer-463da91c8960</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2ed4910a58e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Auto Scaling Groups in AWS]]></title>
            <link>https://iam-athirakk.medium.com/managing-auto-scaling-groups-in-aws-7d543c93012e?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d543c93012e</guid>
            <category><![CDATA[services]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Tue, 07 May 2024 07:48:06 GMT</pubDate>
            <atom:updated>2024-05-07T07:55:11.672Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hey Techies…👋</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*ffNEUMeRI3tOJ-tohXShLQ.png" /></figure><p>Auto Scaling Groups (ASG) seamlessly integrates with CloudWatch to monitor specific metrics, such as CPU utilization. If a metric, like CPU utilization, exceeds a predefined threshold, ASG adjusts capacity by either adding or removing instances in the group. This adjustment is based on CloudWatch alarms, which trigger actions to maintain performance or control costs.</p><p>When creating an auto scaling group, you’ll configure launch configurations or launch templates, similar to those used in EC2 instances for ELB exercises. These configurations provide the necessary information for launching instances within the ASG.</p><p>To dynamically adjust capacity based on metrics, ASG employs scaling policies. You can define these policies, such as step scaling, to add or remove instances based on workload fluctuations. For instance, you could specify that if CPU usage exceeds 60%, launch two additional instances, or if it exceeds 80%, launch four instances.</p><p>When setting up an auto scaling group, you specify parameters like minimum, desired, and maximum capacity. The minimum size ensures a baseline level of instances that cannot be terminated, while desired capacity represents the typical number of running instances. The maximum size limits the total number of instances the group can scale up to, helping to control costs.</p><p>In practice, ASG operates by creating a group powered by launch configurations. When a metric breach triggers a CloudWatch alarm, scaling policies kick in to launch or terminate instances accordingly, ensuring optimal performance and resource utilization.</p><p>Now, let’s dive into the practical implementation of these concepts.</p><p>Before diving into the auto scaling group setup, let’s ensure we have all the necessary components in place.</p><p>Firstly, we’ll need the launch template, which should already be created as per the instructions provided in the load balancer section. If the launch template has been removed or needs to be recreated, refer back to the load balancer section for detailed steps on how to create it.</p><p>Now, let’s proceed to the Target Group setup.</p><p>◼️Navigate to the Target Group section.</p><p>◼️Click on the “Create target group” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*OiABVKRXauZNTr8_Y8YJCg.png" /></figure><p>◼️Configure the target group settings, such as name. For example, let’s name it “web-health-tg”.</p><p>◼️Keep the other configurations as default and proceed by clicking “Next”.</p><p>◼️Since we don’t have any instances yet, select the option to create an empty target group.</p><p>◼️Complete the target group creation process by following the prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*ZQaACyI8Z5EIoGdyzcAl3A.png" /></figure><p>Indeed, the Auto Scaling group will automatically add instances to this target group as needed based on your scaling policies and the metrics you’ve configured, ensuring seamless scalability and efficient resource management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OgF2rtQSBYPmn8WYyw8x-A.png" /></figure><p>We’ll proceed by creating a load balancer for this target group. Let’s select “Create load balancer” and opt for the application load balancer, maintaining consistency with our previous setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYT9ZQA8zjMTaW3h9LYM0Q.png" /></figure><p>We’ll name it “health-elb” and choose the same availability zones and security groups used previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUkn_Ka5bAG4BYk7FPNlGA.png" /></figure><p>Remember to remove the Default Security Group. Next, we’ll configure it to forward traffic to the target group we just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQkcavFcmXwXDJRiv5kyhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHaZ5nx5dOEYnL4KXGJV1Q.png" /></figure><p>If you already have these resources set up, you can reuse them; otherwise, go ahead and create them now. Here’s our load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mbUHa8ezQHkX7CpCMVbag.png" /></figure><p>Let’s revisit the launch template. This template is essential as it defines the configuration for the instances that will be launched by the auto scaling group.</p><p>Since we’ve previously created the launch template, we can review its settings to ensure everything is configured correctly.</p><p><a href="https://iam-athirakk.medium.com/maximizing-efficiency-and-reliability-with-elastic-load-balancer-1aae54b5788b">https://iam-athirakk.medium.com/maximizing-efficiency-and-reliability-with-elastic-load-balancer-1aae54b5788b</a></p><p>It’s important to verify that the required AMI is available and accessible. If you’ve already prepared the AMI, it should be readily available for selection within the launch template settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-t1aIC4v0DT1Hje0wzLCmg.png" /></figure><p>The launch template specifies details such as the Amazon Machine Image (AMI) to be used for the instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJtzr8u-8By56D3cT064fg.png" /></figure><p>Now, let’s navigate to the auto scaling groups section.</p><p>Let’s initiate the creation process by assigning a name to our auto scaling group. For simplicity, let’s name it “web-health-asg”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*posCZovUd0to66MzKK-brw.png" /></figure><p>Next, we’ll select our launch template for the auto scaling group.</p><p>You might also notice the option to use a launch configuration, which serves a similar purpose to a launch template. However, AWS now recommends using launch templates due to their added flexibility.</p><p>One notable advantage of launch templates is their editability. Unlike launch configurations, which cannot be modified once created, launch templates allow for easy edits and the creation of multiple versions. This versatility enables you to tailor your configurations to different environments or instance types seamlessly.</p><p>As we proceed, we’ll opt for the launch template, leveraging its benefits for our auto scaling group. You’ll notice the option to select different versions of the launch template, providing flexibility in configuration management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*m2_wnbZpEnMIC8DHTTei_g.png" /></figure><p><strong>Choose instance launch options</strong></p><p>In this step, we need to specify the availability zones where we want our instances to be launched.</p><p>You have the option to select specific zones or allow AWS to choose based on availability. It’s generally recommended to choose at least two zones for redundancy and fault tolerance.</p><p>Let’s proceed by selecting all zones and moving to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*w2XAwb4CIO-kuBVxiBS8Wg.png" /></figure><p><strong>Configure advanced options</strong></p><p>In this step, we have the option to attach our auto scaling group to an existing load balancer.</p><p>Since our website will benefit from a load balancer, especially with multiple instances, we’ll choose to attach it to an existing load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*Ye2fMpOJKhD7Y0KTrNQo5A.png" /></figure><p>We’ll then select the target group that we previously created. This ensures that the instances launched by our auto scaling group are registered with the specified target group, allowing the load balancer to distribute traffic effectively across these instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*9H5Q04xoTQUsnZ03RsQinA.png" /></figure><p>In this step, we configure the health check settings for our instances within the auto scaling group.</p><p>The primary responsibility of the auto scaling group is to maintain the desired number of healthy instances, ensuring optimal performance and reliability.</p><p>By default, the auto scaling group performs basic EC2 health checks, which include hardware and virtual machine checks. However, these checks only verify the instance’s basic functionality and do not guarantee the health of your application or website.</p><p>To enable more comprehensive health checks, we opt for ELB (Elastic Load Balancer) health checks. This leverages the target group health check functionality discussed in the load balancer section.</p><p>The target group conducts health checks every 300 seconds, verifying the health of instances based on specified criteria such as port availability and process responsiveness. If an instance fails this health check, indicating a potential issue with the hosted application or service, the target group declares it as unhealthy.</p><p>Upon detecting an unhealthy instance, the auto scaling group takes corrective action by terminating the problematic instance and launching a replacement. This ensures that the overall system remains resilient and capable of handling fluctuations in workload and application health effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*g2BmfIJVp1JeVulO8n3CXQ.png" /></figure><p><strong>Configure group size and scaling</strong></p><p>Now, let’s proceed to the next step.</p><p>Here, we specify the capacity settings for our auto scaling group. We define the desired, minimum, and maximum number of instances that the group should maintain.</p><ul><li>Desired capacity: This indicates the number of instances we want to have in our auto scaling group. For example, setting it to 2 means we aim to have two instances running at all times.</li><li>Minimum capacity: This represents the minimum number of instances that must be running in the auto scaling group, regardless of the workload or scaling policies. In our case, we set it to 1 to ensure there is always at least one instance available.</li><li>Maximum capacity: This defines the upper limit on the number of instances that can be launched by the auto scaling group. Even if the workload demands more instances, the group will not exceed this limit. Here, we set it to 8 to cap the maximum number of instances at eight.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*BMRmbE3Nqqa4lYtSYNLdvA.png" /></figure><p>Understanding the distinction between desired, minimum, and maximum capacities is crucial. While desired capacity determines the ideal number of instances, minimum capacity ensures a baseline level of availability, and maximum capacity prevents excessive scaling beyond a predetermined threshold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*Ytb_HTKsbvRhNavm8fPJPw.png" /></figure><p>Next, we delve into scaling policies, which dictate how the auto scaling group responds to changes in workload or system metrics.</p><ul><li>Scaling policies: These policies govern when and how the auto scaling group should scale out (add instances) or scale in (remove instances) based on predefined conditions. We can choose from various scaling policy types, such as target tracking scaling policies or simple scaling policies.</li></ul><p>For instance, we opt for a target tracking scaling policy based on CPU utilization. If the combined CPU utilization across instances exceeds 50%, the auto scaling group will add instances to handle the increased workload. Conversely, if CPU utilization drops below 50%, instances may be removed to optimize resource usage.</p><p>Additionally, we have the option to enable scaling protection, which safeguards newly launched instances from immediate termination. This feature can be beneficial in scenarios where instances require time to initialize or synchronize data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*haGbP5YW0_rx0NheBv3PpQ.png" /></figure><p>By configuring these capacity and scaling policy settings, we ensure that our auto scaling group operates efficiently, maintaining optimal performance while dynamically adjusting to changing demand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*po32ZfwIWBYq29lP0WoYxg.png" /></figure><p><strong>Add notifications</strong></p><p>Now, let’s proceed to the next step.</p><p>Here, we have the option to configure event notifications for various actions performed by the auto scaling group.</p><ul><li>Notification settings: We can specify a notification topic to receive notifications for specific events related to the auto scaling group’s lifecycle. These events include instance launches, terminations, failures to launch, and failures to terminate.</li></ul><p>By defining a notification topic, we ensure that relevant stakeholders or automated systems are promptly informed of any changes or issues affecting the auto scaling group’s operation. This facilitates proactive monitoring and troubleshooting, allowing us to maintain the reliability and availability of our infrastructure.</p><p>After configuring the notification settings as needed, we can proceed to the next stage of the auto scaling group setup process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*4ae2S15SohwccvLTPRuhFw.png" /></figure><p><strong>Add tags</strong></p><p>Let’s add tags for identification purposes.</p><ul><li>Tag Name: “web-health”</li></ul><p>We’ll keep the naming simple and generic since the number of instances can vary dynamically based on scaling policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*U23FhHqs5bVpOIZqTmcBDw.png" /></figure><p>Now, let’s proceed by clicking on “Next” and review all the provided information before finalizing the creation of the auto scaling group. Once verified, we can proceed with the creation process.</p><p>Currently, we don’t have any instances running. As per our configuration, the desired capacity is set to two instances. So, the auto scaling group will start creating instances to meet this desired capacity.</p><p>You can observe that two instances are being created to fulfill the desired capacity. Additionally, there’s a scaling policy in place. If the CPU utilization drops below 50%, it will terminate instances accordingly. However, it will always maintain a minimum of one instance.</p><p>In the instance management section, you’ll find all the instances within the auto scaling group. This section is particularly useful for troubleshooting purposes. Here, you can perform various actions such as detaching an instance from the auto scaling group, setting it to standby mode, or bringing it back into service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xg91381fJH3-_9KqXcw6dw.png" /></figure><p>You have the option to set scale-in protection for instances. This means that these instances won’t be terminated by the auto-scaling process. This feature is particularly useful during troubleshooting or maintenance activities when you don’t want instances to be terminated unexpectedly.</p><p>We’ll wait for a few minutes to ensure that all instances are in a healthy state. Once they are marked as healthy, we’ll explore some additional options. Currently, both instances are running and healthy. You should also see them updated in the target group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HkP9KcAQFe_UW-E1eTL-RA.png" /></figure><p>When managing instances within an auto-scaling group, it’s crucial to remember that these instances are dynamic. They are automatically created and deleted by the auto-scaling group based on the defined policies and metrics. Therefore, manual changes to instances should be avoided to prevent unexpected behavior.</p><p>Any changes to instances should be made through the launch template. This includes changes such as instance type, security group, application upgrades, or software installations. If you need to make changes, create a new launch template or a new version of the existing launch template with the desired configurations.</p><p>To apply changes to instances, you can edit the auto-scaling group and select the new launch template. Once the changes are saved, you must initiate an instance refresh to apply the changes to existing instances. During instance refresh, instances are terminated and recreated based on the updated launch template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*NRPXLEgOb1i0uZslBI_w4Q.png" /></figure><p>When initiating an instance refresh, ensure that you specify a minimum healthy percentage. This ensures that a certain percentage of instances remain healthy during the refresh process, preventing disruptions to your application. It’s recommended to set a higher healthy percentage to maintain application stability.</p><p>Once changes are applied and instance refresh is initiated, monitor the auto-scaling group activity to ensure that new instances are launched successfully and the application remains available. Avoid manual termination of instances unless necessary for troubleshooting or maintenance purposes.</p><p><em>Please note — instance: i-02e53d55300f6659a I stopped purposefully.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNhEEqxDz_xnO1bNVrjD3A.png" /></figure><p>We can see 2 instances are running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2fUTaClMzrtnzLKYkbQnw.png" /></figure><p>By following these best practices, you can effectively manage instances within your auto-scaling group while ensuring the reliability and scalability of your application.</p><p>In conclusion, auto-scaling groups in AWS offer a powerful solution for managing the scalability and availability of your application infrastructure. By dynamically adjusting the number of EC2 instances based on predefined policies and metrics, auto-scaling groups enable you to efficiently handle fluctuating traffic loads while maintaining optimal performance and cost-effectiveness.</p><p>Key points to remember include:</p><ol><li>Dynamic Nature: Auto-scaling groups automatically create and terminate EC2 instances based on configured scaling policies, ensuring that your application can handle varying levels of demand without manual intervention.</li><li>Launch Templates: Changes to instance configurations should be made through launch templates, allowing for easy management of instance settings such as instance type, security groups, and software configurations.</li><li>Instance Refresh: When updating configurations, initiate an instance refresh to apply changes to existing instances. Specify a minimum healthy percentage to ensure application stability during the refresh process.</li><li>Avoid Manual Changes: Manual changes to instances within auto-scaling groups should be avoided to prevent conflicts with scaling policies and unexpected behavior. Instead, utilize launch templates for any necessary updates.</li><li>Monitoring and Maintenance: Regularly monitor the auto-scaling group activity to ensure that instances are being created and terminated as expected. Conduct troubleshooting and maintenance activities carefully to avoid disruptions to your application.</li></ol><p>We’re concluding our discussion on EC2 concepts for now, but stay tuned for real-world scenarios in upcoming sessions.</p><p>Stay tuned for practical applications and hands-on examples.</p><p>Thank you 😊🫰🫶</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d543c93012e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CloudWatch: Enhancing Monitoring and Notification]]></title>
            <link>https://iam-athirakk.medium.com/aws-cloudwatch-enhancing-monitoring-and-notification-580295bfb52c?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/580295bfb52c</guid>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Wed, 01 May 2024 01:16:54 GMT</pubDate>
            <atom:updated>2024-05-01T01:16:54.543Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hey Techies…👋</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*GyDKM4ZehVM-ezTsfujPYg.png" /></figure><p><strong>Introduction to CloudWatch:</strong></p><ul><li>AWS CloudWatch is a comprehensive monitoring service offered by Amazon Web Services.</li><li>Originally focused on monitoring, CloudWatch has expanded its capabilities to include logging, events, and more.</li><li>It serves as a central hub for monitoring the performance and health of AWS environments.</li></ul><p><strong>Key Features of CloudWatch:</strong></p><p><strong>◼️</strong>Monitoring Service:</p><ul><li>CloudWatch serves as a monitoring solution for AWS resources, tracking performance metrics such as CPU utilization, disk I/O, and network traffic.</li><li>It automatically generates standard metrics for various AWS services used in a region.</li></ul><p><strong>◼️</strong>Logging Solution:</p><ul><li>In addition to monitoring, CloudWatch functions as a logging solution, allowing users to collect, store, and analyze log data generated by AWS resources and applications.</li><li>Logs from services like EC2 instances can be streamed to CloudWatch for centralized log management.</li></ul><p><strong>◼️</strong>Event Monitoring:</p><ul><li>CloudWatch captures real-time events within the AWS environment, such as instance launches, terminations, or volume creations.</li><li>Users can set triggers and notifications based on these events, often integrated with AWS Lambda functions.</li></ul><p><strong>◼️</strong>Standard and Custom Metrics:</p><ul><li>CloudWatch provides both standard and custom metrics for monitoring AWS resources.</li><li>Standard metrics cover common performance indicators like CPU utilization, network traffic, and disk operations.</li><li>Users can define custom metrics tailored to their specific monitoring needs.</li></ul><p><strong>◼️</strong>Alarms and Notifications:</p><ul><li>Users can set alarms on CloudWatch metrics to trigger notifications when predefined thresholds are breached.</li><li>Notifications can be sent via email or integrated with Amazon SNS for broader alerting capabilities.</li></ul><p><strong>◼️</strong>Integration with AWS Services:</p><ul><li>CloudWatch seamlessly integrates with various AWS services, including EC2 instances and EBS volumes.</li><li>Metrics and logs from these services are collected and monitored by CloudWatch, providing insights into resource performance.</li></ul><p><strong>Practical Use Cases:</strong></p><ul><li>CloudWatch simplifies monitoring by automatically collecting metrics for AWS resources.</li><li>Users can customize monitoring settings and set up alarms to receive timely notifications of any performance anomalies.</li><li>Practical examples include setting alarms for CPU utilization exceeding a certain threshold, which triggers email notifications via SNS.</li></ul><p>If you’ve already reviewed the previous blog post, we’ve provided a template for launching EC2 instances. Kindly review it, or proceed to create an EC2 instance.</p><p>Select the EC2 instance and click on monitoring:</p><p>Before proceeding further, take note of the various metric names available, such as CPU utilization, which indicates the percentage of CPU being used over time. Additionally, observe other metrics like status checks, network in and out (in bytes), network packets in and out (count), and disk read operations.</p><p>These metrics are automatically generated by CloudWatch when you launch an EC2 instance.</p><p>If you require additional metrics, such as RAM or disk utilization, you’ll need to create custom metrics.However, for the purpose of this session, we’ll focus solely on CPU utilization, as it’s one of the most critical metrics to monitor.</p><p>By default, CloudWatch checks and updates these metrics every 5 minutes, populating the corresponding graphs.If you prefer more frequent updates, you can enable detailed monitoring, though it’s important to note that this option isn’t free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YRWInOWe1Lp0BZbi" /></figure><p>For this hands-on, enabling detailed monitoring is optional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b6W2f7R4Vx-B7t22" /></figure><ol><li>Select the option to “Enable” detailed monitoring, indicating that CloudWatch should monitor metrics every minute.</li><li>Keep in mind that detailed monitoring incurs additional charges compared to the default 5-minute monitoring interval.</li><li>Despite the additional cost, enabling detailed monitoring offers more granular insights into your AWS environment’s performance.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*eP2OyFqb6Q1S33Dw" /></figure><p>Log in to the terminal of the EC2 instance and switch as root user.</p><p>Then install the stress tool along with its dependencies on your instance.</p><p>Stress is a versatile tool designed to test the limits of your Linux operating system, particularly focusing on CPU performance and other system metrics. Simply running the stress command allows you to stress the CPU. You can specify parameters such as the number of CPUs to stress and even utilize functions like the square root function. Additionally, stress can be used to stress other components like IO and RAM, but for our purpose, we’re concentrating on CPU stress testing.</p><pre>yum install stress -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*AQ25ToLkDOz26PXX" /></figure><pre>nohup stress -c 3 -t 100 &amp;</pre><p>This command executes the stress utility in the background using the nohup command, which allows the process to continue running even after the terminal session is terminated. Let’s break down the command:</p><ul><li>nohup: Prevents the following command from being terminated when the terminal session ends.</li><li>stress: The stress testing utility.</li><li>-c 3: Specifies that 3 worker threads will be used to stress the CPU cores.</li><li>-t 100: Specifies that the stress test will run for 100 seconds.</li><li>&amp;: Runs the command in the background.</li></ul><p>So, this command will run the stress test with 3 worker threads for 100 seconds, and the process will continue running even if the terminal session is closed.</p><p>Execute the top command.</p><pre>top</pre><p>You’ll notice four stress processes running, indicating the CPU utilization at 100 or close to it, reflected by the load average increment.</p><p>Continuously stressing the instance like this will be monitored by CloudWatch, updating the graph every minute.</p><p>Repeat this process a few times, running for intervals like 100 seconds and 200 seconds. After a few minutes, you’ll observe a pattern forming on the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/0*MvFU1IRVPFC-PcxA" /></figure><p>Let’s create a script for this process.</p><pre>vim stress.sh<br>sleep 60 &amp;&amp; stress -c 4 -t 60 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 60 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 30 &amp;&amp; sleep 60 &amp;&amp; stress -c 4 -t 100 &amp;&amp; sleep 30 &amp;&amp; stress -c 4 -t 200<br>:wq!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mz-qDtJ02WY4jPTj" /></figure><p>This sequence of commands progressively varies the duration of the stress tests, interspersed with periods of rest. It’s a way to simulate different levels of CPU load on the system over time. designed to stress test the system’s CPU using the stress utility. Let’s break down each part:</p><p><strong>◼️</strong>sleep 60: This command pauses execution for 60 seconds before proceeding to the next command. It introduces a delay in the sequence.</p><p><strong>◼️</strong>stress -c 4 -t 60: This command runs the stress utility with the following options:</p><p><strong>◼️</strong>-c 4: Specifies that 4 worker threads will be used to stress the CPU cores.</p><p><strong>◼️</strong>-t 60: Specifies that the stress test will run for 60 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 60: Similar to the second command, this runs a stress test for another 60 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 30: This command runs a shorter stress test for 30 seconds.</p><p><strong>◼️</strong>sleep 60: Another pause of 60 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 100: This command runs a longer stress test for 100 seconds.</p><p><strong>◼️</strong>sleep 30: A shorter pause of 30 seconds.</p><p><strong>◼️</strong>stress -c 4 -t 200: This command runs an even longer stress test for 200 seconds.</p><p>Execute this script</p><pre>./stress.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*2jrsAn51_8-e0QOO" /></figure><p>We generate a graph by running the command. I simply executed it using nohup stress.sh &amp;.</p><p>Ensure your script is executable.</p><pre>chmod +x stress.sh</pre><p>Now, when observing the top output, you may intermittently notice the stress command based on the ongoing operations within your script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GJ35OBVyv-0_qfZ_" /></figure><p>Now, let’s navigate to the CloudWatch service to configure an alarm for CPU utilization on this instance.</p><p>First, head over to the “All alarms” section.</p><p>Next, click on the “Create Alarm” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vOWSl8UVRjizh1BR" /></figure><p>To select the CPU utilization metric, start by navigating to the EC2 service.</p><p>Then, locate the “Per-instance metrics” section and find your instance. If you don’t immediately see your instance, wait for a few moments for the information to load.</p><p>Once you’ve found your instance, look for the CPU utilization metric.</p><p>Select the CPU utilization metric by clicking on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xi2ICN6zIPNRL7BT" /></figure><p>In this step, we can choose the period for which the alarm will be evaluated.</p><p>For this demonstration, I’ll keep the period set to 5 minutes.</p><p>Next, we specify the condition for triggering the alarm based on CPU utilization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/0*YWmzO5eYzFUiRJf5" /></figure><p>For example, we can set the condition to trigger the alarm if the CPU utilization is greater than or equal to 60 for a period of 5 minutes.</p><p>Once we’ve defined the condition, we proceed to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*umRCDK4JetWbbI6j" /></figure><p>If you don’t find your desired topic listed, you can click on “Create Topic.” Provide a name for the topic, enter your email address, and click on “Create Topic.”</p><p>However, since we already created a topic for billing alarms earlier, I’ll select the same topic, which contains my email address.</p><p>This topic is designated for notifications. So, when the alarm state is triggered, it will send a notification to this topic, ultimately resulting in an email notification being sent to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/0*odhcd54iGixsn3zC" /></figure><p>There are several other actions you can take, such as EC2 actions. For instance, you might want to stop, terminate, or reboot the instance if it triggers an alarm.</p><p>In some cases, a high CPU utilization might prevent you from logging into the instance via SSH. Rebooting the instance could be a temporary solution to address this issue.</p><p>However, for the purpose of this demonstration, we will skip these additional actions. We will stick to email notifications only and proceed to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*jEFx1wz3I_TR99CO" /></figure><p>Let’s give the alarm a descriptive name.</p><p>The naming convention will be: “warning-web-health-alarm-notification-cpu” for the specific instance.</p><p>In our organization, a warning is triggered when the utilization exceeds 60%. We could set up additional alarms for critical situations, such as when it surpasses 80%. However, for now, we’ll proceed with just one alarm.</p><p>Now, let’s move on to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/0*KInljQe4Dge3IdD0" /></figure><p>After a while, CloudWatch will collect the data and display whether the instance is in an alarm state or if it’s okay.</p><p>Now, this process aligns with the basic principles of any monitoring tool. You have metrics or checks, alarms triggered by those metrics or checks, and actions associated with those alarms, such as sending email notifications.</p><p>Whether it’s Prometheus, Nagios, Icinga, Zenos, or others, the concept remains similar. However, with CloudWatch, monitoring is already configured, and you only need to set up alarms. In contrast, with other tools, such as those you set up yourself, the entire monitoring system needs configuration, typically by the monitoring or administration team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jcf16YYAmCcInvEx" /></figure><p>Currently, the graph fluctuates because I’ve executed the stress command multiple times. Remember, you need to run the stress command for at least 5 minutes or longer for it to exceed the threshold and trigger the email notification.</p><p>After running the command for 5 minutes, wait for the notification to arrive in your inbox.</p><p>Moreover, you can create a reverse alarm to monitor the instance’s OK state. For instance, if the CPU utilization is below 40, it’s considered OK. You can set up alarms for different thresholds and states, and you have the flexibility to create up to ten alarms under the free tier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TggJuX75XyZ_8irn" /></figure><p>Email notification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tzIzF2yiQVfHbT0K" /></figure><p>I encourage you to experiment with these alarms to familiarize yourself with their functionalities. Set alarms for various data points, both in alarm and OK states, using different conditions like greater than or less than. Once you’re comfortable, remember to terminate the instance and delete the alarms before moving on to the next section, particularly the auto-scaling group section. Reference on few concepts: Imran Teli — Udemy.</p><p>Stay tuned for practical applications and hands-on examples.</p><p>Thank you 😊🫰🫶</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=580295bfb52c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing Efficiency and Reliability with Elastic Load Balancer]]></title>
            <link>https://iam-athirakk.medium.com/maximizing-efficiency-and-reliability-with-elastic-load-balancer-1aae54b5788b?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/1aae54b5788b</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 03:02:04 GMT</pubDate>
            <atom:updated>2024-04-19T03:02:04.301Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hey Techies…👋</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*12YVxdNbaLv_ShW9fn4nng.png" /></figure><p><strong>Elastic Load Balancer</strong></p><ul><li>Load balancing is a crucial aspect of managing clusters of servers efficiently. It involves distributing incoming network traffic across multiple servers to ensure optimal resource utilization, reliability, and scalability.</li><li>In AWS, Elastic Load Balancer (ELB) provides a scalable and reliable solution for load balancing, allowing users to distribute traffic across multiple targets seamlessly.</li></ul><p><strong>Key Components of ELB:</strong></p><p><strong>◼️</strong>Frontend Port and Backend Port:</p><ul><li>The frontend port is the port on which the load balancer listens for incoming traffic. For example, for HTTPS connections, the frontend port would typically be 443.</li><li>The backend port is the port on which the load balancer forwards traffic to the backend servers. It corresponds to the port where the application/service is running on the backend servers. For instance, if a Tomcat server is running on port 8080 on backend instances, the backend port would be set to 8080.</li></ul><p>◼️Types of ELB:</p><ul><li>Classic Load Balancer: Operates at the network layer (Layer 4) of the OSI model. It provides basic load balancing capabilities and distributes incoming traffic to backend instances based on configured rules.</li><li>Application Load Balancer (ALB): Operates at the application layer (Layer 7) of the OSI model. ALB supports advanced routing based on URL paths, hostnames, and other application-level attributes, making it ideal for HTTP and HTTPS traffic.</li><li>Network Load Balancer (NLB): Operates at the transport layer (Layer 4) of the OSI model. NLB is designed to handle extremely high volumes of traffic and offers ultra-low latency, making it suitable for TCP, UDP, and TLS traffic.</li></ul><p>◼️Load Balancer Targets:</p><ul><li>ELB distributes traffic to backend targets, which can include EC2 instances, containers, IP addresses, or Lambda functions.</li><li>Targets are distributed across multiple availability zones to improve fault tolerance and high availability.</li></ul><p><strong>Benefits of ELB:</strong></p><ul><li><strong><em>Scalability: </em></strong>ELB automatically scales in response to incoming traffic, ensuring that applications remain responsive even during traffic spikes.</li><li><strong><em>Fault Tolerance: </em></strong>By distributing traffic across multiple targets and availability zones, ELB enhances fault tolerance and resiliency.</li><li><strong><em>Simplified Management: </em></strong>ELB abstracts away the complexities of managing load balancers, allowing users to focus on building and scaling their applications.</li></ul><p>Let’s proceed with launching an instance and naming it as “web-health”.</p><p>You have the flexibility to choose between Amazon Linux, Ubuntu, or CentOS. The script provided in the resource section is compatible with both RPM-based and Debian-based operating systems. Since Amazon Linux is RPM-based, we’ll stick with it for this instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*katIG9cVfcFJNOmS" /></figure><p>Let’s opt for a t2.micro instance type and create a new key pair named “web-health-key” for secure access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*X1Ryy686ZCpC_ds_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*TcWblRhQhMJDMZGB" /></figure><p>Now, for the security group, let’s create a new one named “web-health-sg”, allowing inbound traffic on port 22 for SSH from your IP, and an additional rule for port 80, allowing traffic only from your IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*r8CnyfGjxjAPnL0e" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0uTJXNaWE56WFxBV" /></figure><p>Moving forward, let’s proceed with the default storage settings and navigate to advanced details. Here, we’ll utilize the script in the “User data” section under “Advanced details”. Simply copy and paste it as instructed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*rRI8_kFbFN6egR9TFr6m_A.png" /></figure><p>Script:</p><pre>#!/bin/bash<br><br># Variable Declaration<br>#PACKAGE=&quot;httpd wget unzip&quot;<br>#SVC=&quot;httpd&quot;<br>URL=&#39;https://www.tooplate.com/zip-templates/2098_health.zip&#39;<br>ART_NAME=&#39;2098_health&#39;<br>TEMPDIR=&quot;/tmp/webfiles&quot;<br><br>yum --help &amp;&gt; /dev/null<br><br>if [ $? -eq 0 ]<br>then<br>   # Set Variables for CentOS<br>   PACKAGE=&quot;httpd wget unzip&quot;<br>   SVC=&quot;httpd&quot;<br><br>   echo &quot;Running Setup on CentOS&quot;<br>   # Installing Dependencies<br>   echo &quot;########################################&quot;<br>   echo &quot;Installing packages.&quot;<br>   echo &quot;########################################&quot;<br>   sudo yum install $PACKAGE -y &gt; /dev/null<br>   echo<br><br>   # Start &amp; Enable Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Start &amp; Enable HTTPD Service&quot;<br>   echo &quot;########################################&quot;<br>   sudo systemctl start $SVC<br>   sudo systemctl enable $SVC<br>   echo<br><br>   # Creating Temp Directory<br>   echo &quot;########################################&quot;<br>   echo &quot;Starting Artifact Deployment&quot;<br>   echo &quot;########################################&quot;<br>   mkdir -p $TEMPDIR<br>   cd $TEMPDIR<br>   echo<br><br>   wget $URL &gt; /dev/null<br>   unzip $ART_NAME.zip &gt; /dev/null<br>   sudo cp -r $ART_NAME/* /var/www/html/<br>   echo<br><br>   # Bounce Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Restarting HTTPD service&quot;<br>   echo &quot;########################################&quot;<br>   systemctl restart $SVC<br>   echo<br><br>   # Clean Up<br>   echo &quot;########################################&quot;<br>   echo &quot;Removing Temporary Files&quot;<br>   echo &quot;########################################&quot;<br>   rm -rf $TEMPDIR<br>   echo<br><br>   sudo systemctl status $SVC<br>   ls /var/www/html/<br><br>else<br>    # Set Variables for Ubuntu<br>   PACKAGE=&quot;apache2 wget unzip&quot;<br>   SVC=&quot;apache2&quot;<br><br>   echo &quot;Running Setup on CentOS&quot;<br>   # Installing Dependencies<br>   echo &quot;########################################&quot;<br>   echo &quot;Installing packages.&quot;<br>   echo &quot;########################################&quot;<br>   sudo apt update<br>   sudo apt install $PACKAGE -y &gt; /dev/null<br>   echo<br><br>   # Start &amp; Enable Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Start &amp; Enable HTTPD Service&quot;<br>   echo &quot;########################################&quot;<br>   sudo systemctl start $SVC<br>   sudo systemctl enable $SVC<br>   echo<br><br>   # Creating Temp Directory<br>   echo &quot;########################################&quot;<br>   echo &quot;Starting Artifact Deployment&quot;<br>   echo &quot;########################################&quot;<br>   mkdir -p $TEMPDIR<br>   cd $TEMPDIR<br>   echo<br><br>   wget $URL &gt; /dev/null<br>   unzip $ART_NAME.zip &gt; /dev/null<br>   sudo cp -r $ART_NAME/* /var/www/html/<br>   echo<br><br>   # Bounce Service<br>   echo &quot;########################################&quot;<br>   echo &quot;Restarting HTTPD service&quot;<br>   echo &quot;########################################&quot;<br>   systemctl restart $SVC<br>   echo<br><br>   # Clean Up<br>   echo &quot;########################################&quot;<br>   echo &quot;Removing Temporary Files&quot;<br>   echo &quot;########################################&quot;<br>   rm -rf $TEMPDIR<br>   echo<br><br>   sudo systemctl status $SVC<br>   ls /var/www/html/<br>fi</pre><p>After launching the instance, it typically takes about 5 minutes to initialize. Once it’s up, we can check the public IP address and access the website via a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hhz-cbW60p2lyXOb" /></figure><p>In case you encounter any issues accessing the website, ensure that the security group allows traffic from your IP and that the HTTP service is running on the instance.</p><p>Following the successful setup of our website on the EC2 instance, we’ll proceed with creating an AMI and a launch template for future deployments.</p><p>Creating an AMI involves selecting the instance, navigating to Actions &gt; Image and templates &gt; Create image, and specifying a name for the AMI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*04GorrWigaQn3alI" /></figure><p>Provide a name for the AMI — Here I gave — “web-health-ami”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pIdiGIDN1cNX8jmN" /></figure><p>Once the AMI is created, we can leverage it to launch instances with identical configurations, ensuring consistency across our cluster.</p><p>Additionally, we can explore options like copying the AMI to other regions or sharing it with other AWS accounts for collaboration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vN2c_nJQRI9rOlIX" /></figure><p><em>Also, AWS offers a service known as EC2 Image Builder, allowing you to establish automated pipelines for image creation.</em></p><p><em>The image pipeline in Image Builder defines all aspects of the process to customize images. It consists of the image recipe, infrastructure configuration, distribution, and test settings.</em></p><p>With the AMI in place, we can streamline instance launches by creating a launch template. Given name as “web-health-template” and version as “V1”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*ba1LKb3O8zyGQj4R" /></figure><p>Then choose the “My AMIs” and select the AMI we created just before “web-health-ami”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/0*OUULWMq68KuLZzBY" /></figure><p>Select the instance type as t2.micro</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/0*SAgO96VWBWoKP36v" /></figure><p>Select our key pair we created for the instance “web-health”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*JpJp610LOWlGJNPp" /></figure><p>Select the security group as “web-health-sg” we created for our instance “web-health”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/0*243k98reNcDBmNJg" /></figure><p>Just give as below: When launching an instance from this template, I’ll modify the name to follow a format such as 2,3,4 etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/0*gF2sdgDvGN7SQg7y" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YG2H6zr744i4F2RE" /></figure><p>With the AMI in place, we can streamline instance launches by creating a launch template. This template encapsulates all the configuration details, allowing for quick and consistent instance deployments.</p><p>By utilizing launch templates, we can expedite the process of launching instances and maintain standardized configurations across our infrastructure.</p><p>After configuring our instances, AMI, and launch template, we’ll proceed to set up a load balancer to distribute traffic efficiently across our web servers.</p><p>Simply navigate to the template section, locate your desired template, and select it. Then, choose the action “launch instance from template.” During the launch process, you’ll have the opportunity to make adjustments as needed. For example, you can modify the tag to “web-health01 to web-health02 two” before proceeding to launch the instance. That’s all there is to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*wRmmLT4Kp02U9p7N" /></figure><p>Now we have 2 instances which we created from templates and we can create ’n’ number of instances upon our business needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eKN3ZQqlatwo_WuA" /></figure><p>We have successfully created an AMI and established a launch template utilizing this custom AMI.</p><p>Presently, we have two web servers operating here. These servers are not individually accessible by users. Instead, users must access them through a unified endpoint, which directs requests to either of these instances. This single endpoint is facilitated by a load balancer.</p><p>In the Load Balancer section, we will first navigate to target groups. Target groups function as collections of instances, each subject to health checks. Essentially, they are groups comprising instances. Let’s proceed to create a target group.</p><p>Starting with creating a target group, we’ll define health checks and specify the instances to include.</p><p>Choose target type as “Instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*jBA6zjJ8mAbj-vOI" /></figure><p>Provide a name as below and Port number 80, protocol HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/0*sDuWORBCGA07U24o" /></figure><p>In our setup, we’ve implemented health checks within the target group. These health checks allow the target group to assess the status of each instance. If an instance is deemed unhealthy during these checks, the target group will refrain from routing requests to that specific instance.</p><p>Now, you might wonder, how does the target group determine if an instance is healthy or not? It’s a similar process to how we, as humans, assess the health of a website. We simply open the website in a browser and check if it’s functioning properly. If everything looks good, we consider the website to be healthy.</p><p>Similarly, the target group conducts health checks by sending HTTP requests to the instances. When configuring these health checks, we specify the protocol (HTTP) and the health check path (/).</p><p>Let’s break down what the health check path (/) signifies. Imagine your website’s URL is<a href="http://ip/"> http://IP:80</a>. The slash at the end of this URL represents the root directory of the website. It’s where the homepage resides.</p><p>Now, if your website has subfolders, such as “videos” or “images,” the health check path would be adjusted accordingly (e.g., /videos or /images).</p><p>In essence, by specifying the health check path as “/”, we’re instructing the target group to check the root directory of our website. When the target group receives a successful response (HTTP 200 OK) from this path, it considers the instance to be healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*JOYOA8SiKT_k1NZg" /></figure><p>In our setup, traffic is expected to flow through the default port, which is port 80. However, if your website operates on a different port, you would need to specify it here.</p><p>To do so, you would select the “override” option and provide the appropriate port number, such as 8090. However, since we know that our website operates on port 80, we will leave it as is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*vojpiKu0c86W51ow" /></figure><p>The “Healthy threshold” parameter determines the number of consecutive successful health checks required before declaring the instance as healthy. By default, it is set to five, but you can adjust it to two or ten as per your preference. With a threshold of five, the system checks the instance’s health five times, and if all checks pass successfully, the instance is marked as healthy.</p><p>In our case, I will reduce it to two. This means that the instance will be considered healthy if it passes two consecutive health checks. Similarly, the “Unhealthy threshold” specifies the number of consecutive failed health checks required to declare the instance as unhealthy. If an instance returns an unhealthy status twice in a row, it will be marked as unhealthy.</p><p>The “Timeout” parameter determines how long the system waits for a response from the website during each health check. If the website does not respond within the specified timeout period (default is 5 seconds), the system moves on to the next check.</p><p>Health checks, whether for determining the instance’s health or unhealthiness, occur at regular intervals, typically every 30 seconds. This interval can be adjusted within a range of 5 to 300 seconds.</p><p>When performing health checks, the system looks for a success exit code, typically HTTP 200, indicating that the website is functioning properly. While we can visually confirm this by checking the website in a browser, the target group relies on these exit codes to determine the instance’s health status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*hOejtKvf3Tfs23gL" /></figure><p>So the below are the instances running and click on the “Include as pending below option”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C_8n6Mwigu2O3Mft" /></figure><p>And the targets are in running state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jXOAaxJcIuKXa3Eo" /></figure><p>Once the target group is set up, we’ll proceed to create an application load balancer (ALB), specifying its name, internet-facing nature, and availability zones.</p><p>We will go with application load balancer for http, https traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/0*N-0hAJsl6k9DBbh2" /></figure><p>Give a load balancer name “web-health-elb” and We want it to be available on the Internet, so we’ll keep it Internet facing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nOHZc3Uzn7SKLijA" /></figure><p>When setting up the load balancer, it’s necessary to specify the availability zones where the load balancer will operate. The system requires a minimum of two zones to ensure redundancy and high availability.</p><p>For our configuration, I will choose to select all available zones. This ensures that the load balancer operates across multiple zones, maximizing its availability and fault tolerance. This approach provides a high level of availability at the load balancer level, which is crucial for maintaining continuous service availability.</p><p>By selecting all zones, we distribute the load balancing functionality across multiple data centers or regions, reducing the risk of downtime due to failures in any single zone. This enhances the resilience and reliability of our application infrastructure, allowing it to withstand potential disruptions in individual zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hwUdhV2FkADviSpM" /></figure><p>Click on the “Create a new security group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DaHmDzWoeHehVVYy" /></figure><p>For the security configuration of our load balancer, we’ll create a new security group to define its access permissions. It’s important to name this security group appropriately for easy identification and management.</p><p>We’ll name it “web-health-elb-sg” to indicate that it’s the security group for our health project’s load balancer. Using descriptive names helps maintain clarity and organization within our AWS environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*05fulPp_AWkD2j2Z" /></figure><p>As for the inbound rule, we want to allow access on port 80 from anywhere, making the load balancer accessible to the public. We’ll specify the protocol as IPv6 to accommodate modern internet standards, especially considering the increasing adoption of IPv6 by internet service providers, including mobile networks.</p><p><em>Ensuring broad accessibility while maintaining security is crucial for our load balancer’s functionality and usability. Making these considerations and adopting best practices, such as proper naming conventions and access control, contributes to the overall robustness of our infrastructure.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jv5A6w2P40siO1l1" /></figure><p>Now select the security group we created just now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qj2eYlCmLQHcuDkQ" /></figure><p>Ensuring that the ALB’s security group allows inbound traffic on port 80 from any source, we’ll configure listeners to route traffic to the target group on port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VAbCNp37pJiIXIbO" /></figure><p>Now let’s create a load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vf5Mt8VTOWVkdY3x" /></figure><p>Upon viewing the load balancer, you’ll notice that it initially enters the provisioning state, transitioning to the active state once fully provisioned. However, despite reaching the active state, attempting to access the website directly from the load balancer may not yield the expected results.</p><p>When encountering this issue, accessing the website via the load balancer’s DNS name might result in a 504 Gateway Timeout error, indicating a failure to establish a connection between the load balancer and the instances. Despite verifying that the instances are healthy, the presence of this error suggests a potential obstacle preventing traffic from passing between the load balancer and the instances.</p><p>To address this challenge, we need to identify and resolve the underlying cause obstructing traffic flow between the load balancer and the instances. This discrepancy could be attributed to misconfigured security groups, routing issues, or other network-related factors.</p><p>By diagnosing and rectifying this barrier, we can ensure seamless connectivity between the load balancer and the instances, thereby resolving the 504 Gateway Timeout error and enabling users to access the website reliably through the load balancer.</p><p>Each instance is shielded by a security group, a vital layer of defense governing inbound and outbound traffic. Upon inspection, we observed that both instances share the same security group. However, upon reviewing its inbound rules, we discovered that port 80 was only permitted from our IP address, rather than from the load balancer.</p><p>To rectify this, we need to adjust the security group settings to allow traffic from the load balancer. But before proceeding, it’s prudent to verify the status of the target group. The target group conducts health checks to determine an instance’s well-being. If an instance is deemed unhealthy, the target group will cease routing traffic to it. In this scenario, instances were marked as unhealthy due to the inability to access port 80.</p><p>Returning to the security group settings, we locate the security group associated with the instances and modify its inbound rules. Specifically, we add a new rule permitting port 80 access from the security group of the load balancer. By specifying the source as the load balancer’s security group, we ensure that any member of the load balancer’s group can communicate with the instances over port 80.</p><p>Additionally, it’s beneficial to include a descriptive label for this rule, such as “allow port 80 from ELB,” to enhance clarity and documentation. Descriptive labels streamline management and aid in understanding the purpose of each rule, promoting efficient administration and troubleshooting.</p><p>Make the security groups inbound rules as below of “web-health”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O8MnRaEm8FaaxUqT" /></figure><p>Save the rule.</p><p>Make sure that the targets are healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-9p-4DWxqVPZIAjx" /></figure><p>Now check it on the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oHl_4MX78R9rWNy4" /></figure><p>Managing instances within target groups is a critical aspect of optimizing the performance and availability of applications deployed on AWS. Target groups serve as collections of instances that are subject to health checks, ensuring that traffic is routed only to healthy instances.</p><p>Here are some key points to consider when managing instances within target groups:</p><ol><li><strong>Health Monitoring: </strong>Target groups continuously monitor the health of instances by conducting health checks based on configured parameters. These health checks assess the instance’s ability to respond to requests and determine its overall health status.</li><li><strong>Registration and Deregistration:</strong> Instances can be registered or deregistered from target groups dynamically based on operational requirements. This flexibility allows for seamless scaling and maintenance operations without disrupting application availability.</li><li><strong>Maintenance and Scaling: </strong>Registering or deregistering instances from target groups is a common practice during maintenance activities or when scaling the application. By removing unhealthy or underperforming instances from the target group, traffic can be effectively redirected to healthy instances, ensuring consistent application performance.</li><li><strong>Load Balancing: </strong>Target groups play a crucial role in load balancing by distributing incoming traffic across multiple instances based on predefined rules and health check results. This ensures optimal resource utilization and enhances application reliability and scalability.</li><li><strong>Automation: </strong>Managing instances within target groups can be automated using AWS services such as Auto Scaling, which automatically adjusts the number of instances in response to changing demand. This automation helps optimize resource usage and ensures that the application can handle fluctuations in traffic effectively.</li></ol><p>Finally, we’ll familiarize ourselves with managing instances within the target group, including registering and deregistering instances as needed for maintenance or scaling purposes. Reference: Imran Teli — Udemy.</p><p>By grasping these concepts and experimenting with the setup, we can gain a comprehensive understanding of deploying and managing web applications on AWS.</p><p>Stay tuned for practical applications and hands-on examples.</p><p>Thank you 😊🫰🫶</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1aae54b5788b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EC2 Instance Launch Process and EBS Snapshot Management]]></title>
            <link>https://iam-athirakk.medium.com/ec2-instance-launch-process-and-ebs-snapshot-management-9063b47958a3?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/9063b47958a3</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 02:43:54 GMT</pubDate>
            <atom:updated>2024-04-15T02:43:54.260Z</atom:updated>
            <content:encoded><![CDATA[<p>EC2 Instance Launch Process and EBS Snapshot Management</p><p><strong>Hey Techies…👋</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*jOwGsNN1VTOG179CCHL9Mg.png" /></figure><p><strong>The launch of an ec2 instance:</strong></p><ul><li>Choose an AMI (Amazon Machine Image): This is a template for the virtual machine you want to create. It contains the operating system, software, configuration, and sometimes data.</li><li>Select an Instance Type: This determines the computational resources (CPU, RAM, storage, etc.) of your EC2 instance. There are various types optimized for different use cases.</li><li>Configure Instance Details: This includes settings like networking (VPC, subnet), IAM role, and user data (scripts or data to be run at instance launch).</li><li>Add Storage: Configure the amount and type of storage for your instance. This is typically done using Amazon EBS (Elastic Block Store), which provides block-level storage volumes.</li><li>Add Tags: Assign metadata to your instance in the form of key-value pairs. This helps with organization, management, and billing.</li><li>Configure Security Group: Define firewall rules for controlling inbound and outbound traffic to your instance. Security groups act as virtual firewalls.</li><li>Review and Launch: Review your instance configuration, make any necessary changes, select an existing key pair or create a new one for SSH access (for Linux instances), and then launch the instance.</li></ul><p>After launching the instance, you can access it using SSH (for Linux instances) or RDP (for Windows instances) using the key pair you selected or created. Remember to properly secure your instance and follow best practices for managing AWS resources.</p><p>Let’s walk through the process of launching an EC2 instance.</p><p>An EC2 instance essentially functions as a virtual machine.</p><p>Firstly, log in to your AWS console.</p><p>Next, choose your desired region. For instance, I’ll be selecting the North Virginia region. It’s advisable to select a region based on your current location, as some regions may incur higher costs compared to those in the US.</p><p>Each region is identified by a code, such as US East 1 for North Virginia.</p><p>To navigate to the EC2 service, click on “Services” and locate EC2 either by browsing through all services or by directly searching for EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UA8Cl3vLyq1VaxJH" /></figure><p>Once in the EC2 dashboard, you’ll find an overview of your instances, volumes, and other relevant information. Keep in mind that the dashboard doesn’t auto-refresh, so be sure to manually refresh after making any changes.</p><p>Scrolling down, you’ll notice zones within the region, each identified by a code like 1A, 1B, etc. Typically, a region will have at least two zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*CNbtjmVPXwUoYajm" /></figure><p>Click on “Instances” and then “Launch Instance” to initiate the instance creation process.</p><p>Before proceeding, it’s worth noting that the AWS console interface may evolve over time, but the core options and functionalities remain consistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*NhdWp0O4GnFYhkoZ" /></figure><p>Now, let’s begin by assigning a name and optional tags to the instance. Tags can be useful for filtering and organization purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*TtbDzokUw233PpXb" /></figure><p>Moving on to selecting the Amazon Machine Image (AMI), you’ll find a variety of options including quick start AMIs like Amazon Linux, Ubuntu, and Windows, as well as community AMIs and those from the AWS Marketplace. Carefully review the details and charges associated with each AMI.</p><p>For this example, let’s choose the Ubuntu AMI provided by Amazon Web Services, which is free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*BFeMVsUPut--UCgY" /></figure><p>Ensure that the instance type selected aligns with your requirements. For free-tier usage, T2 micro instances are suitable for most learning purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*4u-rTVqLL0Ez2iQ3" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*C_YgfTOcsLKhSRBq" /></figure><p>Proceed to configure the network settings, including security groups. Security groups act as mandatory firewalls for EC2 instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*VrXLpnnwhTUi1APF" /></figure><p>Customize the security group to allow necessary inbound and outbound traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*BYLAOVILSlokc_i4" /></figure><p>You can specify the storage size, typically defaulted to 10 GB, and further advanced details like user data, which allows for automated provisioning upon instance launch.</p><p>Finally, review your configuration and launch the instance.</p><p>Upon launching, the instance may take a few moments to become available. You can monitor its status in the EC2 dashboard.</p><p>Next, establish a connection to the instance; in this example, I’m using EC2 Instance Connect.</p><p>There are two methods to install Apache2:</p><ul><li>By incorporating commands in the user data section before initiating the instance launch, as demonstrated below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/0*Whcrcmh6nS3uC20Y" /></figure><ul><li>Or, by executing the commands after connecting the ec2 instance via terminal.</li></ul><pre>sudo apt update<br>sudo apt install apache2 -y<br>sudo systemctl start apache2<br>sudo systemctl enable apache2<br>sudo systemctl status apache2</pre><p>Troubleshooting tip: If encountering connection issues, ensure the correct path to the SSH key or navigate to the directory containing the key before attempting to connect.</p><p>Once connected, you can verify the instance status, access web services like Apache, and configure firewall rules as needed to enable external access to your services.</p><p>Additionally, click on the Security Group, edit inbound rules, add the following rule, and save the rules. It’s important to note that allowing all IPs is solely for learning purposes and may vary depending on your project requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wI2cRMdYe2T7QLU6" /></figure><p>Go to the browser and copy the public IP followed by ‘:80’ to view the Apache page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rJqJlrPspMKjJw87" /></figure><p>***************************************************************************</p><p><strong>Elastic IP</strong></p><ul><li>Powering Off the EC2 Instance:</li><li>Take note of the current public and private IP addresses of the instance.</li><li>Stop the instance using the AWS Management Console.</li><li>Observing IP Address Changes:</li><li>After stopping the instance, observe that the public IP address is released while the private IP address remains unchanged.</li><li>Refresh the console to verify the changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0h8qCiSN3E1Ynia5" /></figure><p><strong>Elastic IP Benefits:</strong></p><ul><li>Elastic IP addresses offer the advantage of maintaining a static public IP address even in scenarios where EC2 instances are restarted or recreated.</li><li>They provide a stable endpoint for applications or services that require a consistent public IP address.</li><li>With Elastic IP, there’s no need to update DNS records or reconfigure applications each time an instance is stopped or replaced.</li><li>It simplifies infrastructure management and enhances reliability by ensuring uninterrupted connectivity to resources hosted on EC2 instances.</li><li>Elastic IP addresses are particularly useful for scenarios requiring a fixed public IP address, such as hosting websites, APIs, or VPN gateways.</li><li>Allocating an Elastic IP:</li><li>Allocate an Elastic IP address from the AWS pool.</li><li>Associate the Elastic IP with the desired EC2 instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/0*0Y7CSwUBzmsNwvt-" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*8a-480zWzWsJ0A7F" /></figure><p>EC2 Instance Components:</p><ul><li>In addition to the EC2 instance itself, other components include the network interface and volumes (virtual hard disks).</li><li>The network interface manages connectivity and is associated with firewall rules, public IP addresses, and security groups.</li><li>Volumes represent the virtual hard disks attached to the instance, storing data and operating system files.</li><li>Understanding these components is essential for managing and configuring EC2 instances effectively.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-sE0hD2YW7nSo9rh" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PfX44f5FeOdwSmAj" /></figure><p>Navigating the EC2 Dashboard:</p><ul><li>Encourage exploration of the EC2 dashboard to view information about resources like key pairs, security groups, and volumes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SGIMPmXX-AmMaJMb" /></figure><p>Adjusting Instance Settings:</p><ul><li>Demonstrate how to change instance type and other settings like Elastic IP disassociation, network interface attachment/detachment, and security group changes.</li></ul><p>Reverting Instance Changes:</p><ul><li>Revert any instance changes made during the demonstration, such as changing the instance type, by powering on the instance and reverting the settings back to their original state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fc3JrKA0o0oq9268" /></figure><p><strong>Elastic Block Store (EBS)</strong></p><p>EBS serves as the virtual hard disk for EC2 instances, offering both EBS volumes and snapshots for data storage and backup.</p><p>EBS Volumes:</p><ul><li>EBS volumes, akin to physical hard disks, house the operating system data of EC2 instances and can store various types of data such as databases, web servers, and files.</li><li>During volume creation, users specify an availability zone, ensuring alignment with the instance’s location.</li><li>Data stored in EBS volumes is automatically replicated within the same availability zone, mitigating the risk of data loss due to local failures.</li></ul><p>Snapshots:</p><ul><li>Snapshots, used for backing up entire volumes, provide an additional layer of data protection.</li><li>These snapshots capture the state of the EBS volume at a specific point in time, facilitating data recovery and restoration.</li></ul><p>Types of EBS Volumes:</p><ul><li>EBS volumes come in various types catering to different workload requirements and performance needs.</li><li>General purpose volumes, SSD-based, are recommended for most workloads due to their balanced pricing and speed.</li><li>Provisioned IOPS volumes offer enhanced performance and are ideal for large databases requiring high input-output operations per second (IOPS).</li><li>Throughput optimized HDD volumes suit big data and data warehousing applications, while cold HDD volumes are cost-effective solutions for infrequently accessed data.</li><li>Magnetic volumes, the cheapest option, are suitable for backups and archives but offer lower performance.</li></ul><p>Choosing the Right Volume Type:</p><ul><li>The selection of an appropriate volume type depends on factors such as workload characteristics, performance requirements, and budget considerations.</li><li>AWS documentation provides detailed information and use cases for each volume type, aiding users in making informed decisions.</li></ul><p>After establishing a connection to the instance, execute the following commands. Please note that these commands can also be added to the instance creation process in the user data area:</p><pre>systemctl status apache2<br>cd /tmp<br>wget https://www.tooplate.com/zip-templates/2119_gymso_fitness.zip<br>unzip -o 2119_gymso_fitness.zip<br>cp -r 2119_gymso_fitness/* /var/www/html/<br>systemctl restart apache2</pre><p>These commands are designed to check the status of the Apache web server, navigate to the temporary directory, download a ZIP file containing website templates from a specified URL, unzip the downloaded file, copy the contents to the Apache document root directory, and finally restart the Apache service to apply the changes.</p><p>Here, we can observe the available volume types for creating an EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*35BoY3CeV48T1bYv" /></figure><p>Navigate to the Volumes section located on the left-hand side of the EC2 instances page and update the name of the volume associated with the instance mentioned earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dUG4wTpQFe-m8iNj" /></figure><p>Adding extra storage to an EC2 instance, it’s crucial to consider the availability zone. Both the instance and the volume need to be in the same zone to ensure connectivity. When gathering requirements for additional storage, such as for web server images, it’s important to adhere to the free tier limit of 30 GB for EBS volumes. For instance, if there’s a need for five gigabytes of storage for web server images, it’s imperative to ensure that the total storage remains within the free tier limit.</p><p>Click on create volume:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*F4m1QmeS4ZvXioXY" /></figure><p>Tags, you can give upon your wish, then click on Create Volume</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/0*l13kgM5mErjcGmuN" /></figure><p>Choose the created volume, navigate to actions, and then opt for attaching the volume once it appears as available on the dashboard.</p><p>Select the instance , device name and click on attach volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/0*0fFdNm4MMyRzR5HH" /></figure><p>(Please note I’ve selected /dev/xvdf in above screenshot as Device name).</p><p>If we run the “fdisk -l” command, we could see the new volume listed:</p><pre>fdisk -l</pre><p>List Disks: Start by running the command fdisk -l to list all disks. For instance, /dev/xvdf represents the root volume with a size of 8 GB, and it has a partition /dev/xvdaf1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*HFwyV1QbGTshCApd" /></figure><ul><li>Understand Partitions: Linux assigns partitioning numbers (e.g., xvda1) rather than names. Verify the root volume by checking its mount point using df -h. If /dev/xvda1 is mounted to the root directory, it contains the operating system data.</li><li>Create Partition: Identify the additional disk, such as /dev/xvdf, and use fdisk to create a partition. Choose the disk path (e.g., /dev/xvdf), follow the prompts to create a new partition, and write the changes using w.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/0*OFsBu2W3AvVmKDjF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*tmBO-3egwIW2mURx" /></figure><pre>fdisk -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/0*T03bCqRJ_Ci0Hjr-" /></figure><p>Format Partition: Use the appropriate formatting utility, such as mkfs.ext4, to format the partition. For example, run mkfs.ext4 /dev/xvdf1 to format the partition with ext4 format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HdvmQKasE7BSLm09" /></figure><pre>mkfs.ext4 /dev/xvdf1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*vdrFT6BpCDOGw8fL" /></figure><p>Temporary Mount: Mount the partition temporarily using the mount command. For instance, mount /dev/xvdf1 /var/www/html/images. Verify the mount using df -h.</p><p>Create a directory: “ mkdir /tmp/image_backups”, and move all data from Images to newly created one</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*p_s_qw0GtUKKSGRc" /></figure><p>Then mount the volume and verify as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/0*uNzHFAoP3Fx156LW" /></figure><p>Permanent Mount: Edit the /etc/fstab file to configure permanent mounting. Add an entry with the partition path, mount point, format type, and other options. Save the file and test the configuration using mount -a.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/0*kUYRlaO_lOO592D3" /></figure><p>Save the file and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/0*Qj6dlX6V-nlarKGt" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*negt8QHT1RvGgkc2" /></figure><p>Move Data: Move data from the backup directory to the mounted partition. For example, use mv command to move data from /tmp/img-backups to /var/www/html/images., and restart the apache2 service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*8ftCPRehE8Cxl6pV" /></figure><p>Verify: Check if the data is accessible through the browser. If not, consider disabling SELinux temporarily by modifying the /etc/selinux/config file and rebooting the system.</p><p>Take the public IP and paste in the browser: you could see the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2nBHj00ouKHEN4OM" /></figure><p><strong>EBS Snapshots</strong></p><p>Unmount the volume we created above as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*ILWNHpsfCgeCsRkl" /></figure><p>Next, navigate to the AWS console, choose the volume that was created, and proceed to detach it by selecting the respective option.</p><p>Create a new volume same as shown above and attach it to the same ec2 instance.</p><p>Follow the same steps as mentioned above to create a new partition, format , and then create a directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/0*n8ePCGT7yQ2aqAxQ" /></figure><p>Add the new volume to the /etc/fstab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*ZQtfnzVwQ15XIYLL" /></figure><p>Then mount it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*Ik5qFufAsw4Hpaox" /></figure><p>Install mariadb-server package with the below steps:</p><pre>apt install mariadb-server<br>systemctl start mariadb<br>systemctl enable mariadb<br>systemctl status mariadb</pre><p>List the /var/lib/mysql contents:</p><pre>ls /var/lib/mysql/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HpDlnPa__pv9qCEs" /></figure><p>Snapshot functionality primarily serves as a backup and restoration tool, crucial for mitigating data loss in the event of system failures. However, snapshots offer more than just backup capabilities.</p><p>In the event of data loss, the initial step involves unmounting the partition to prevent data overwriting. If the goal is to restore the existing partition, snapshots may not be applicable, as they provide a new volume containing the data. In such cases, unmounting the partition and employing recovery tools become essential.</p><p>When utilizing snapshots, unmounting the partition is the preliminary action, followed by detaching the corrupted volume. Subsequently, a new volume is created from the snapshot, retaining all data and partition configurations. Upon creation, the new volume is ready for attachment and mounting, effectively replacing the corrupted volume.</p><p>In essence, snapshots facilitate data restoration through volume replacement rather than repair, streamlining the recovery process and ensuring data integrity.</p><p>Take a Snapshot:</p><ul><li>Navigate to the Volume section in the AWS console.</li><li>Select the relevant volume, then click on “Actions” and choose “Create Snapshot.”</li><li>Provide a meaningful description and add tags for easy identification.</li><li>Click on “Create Snapshot” and wait for it to enter the completed state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Oj56LIOUr9v8KqCI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*hROQ79pFcv7QzW_0" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4KOW1JL1_Vq6DHcz" /></figure><p>Delete Data:</p><ul><li>If you accidentally delete data or encounter corruption, proceed with data deletion.</li><li>Access the directory containing the data you wish to remove, e.g., /var/lib/mysql.</li><li>Use the command rm -rf * to remove all files and directories within the specified location.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*im9iwZJpiIqT0rDX" /></figure><p>Unmount:</p><ul><li>Stop any relevant services to prevent further data overwrites.</li><li>Unmount the affected directory, e.g., /var/lib/mysql.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mqOtZE5_lFDD5Ysg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*zrwIn-3Gxxpcf28t" /></figure><p>Detach Corrupted Volume:</p><ul><li>Navigate to the Volumes section and locate the corrupted volume.</li><li>Rename the volume for easy identification, e.g., “corrupted.”</li><li>Select “Actions” and choose “Detach Volume” to disconnect it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JAdoVaBxSi8kllw6" /></figure><p>Recover from Snapshot:</p><ul><li>Head to the Snapshots section and select the desired snapshot.</li><li>Click on “Actions” and choose “Create snapshots from volume”.</li><li>Customize volume settings such as type, size, and zone if needed.</li><li>Add appropriate tags for clarity</li><li>Click on “Create Volume” to finalize the recovery process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*cIts-0Stl6x3L2vK" /></figure><p>In the Volumes console. goto Volumes and rename the new volume as “recovered”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e7LSFJ8I4RCjZZ0h" /></figure><p>Goto actions and attach the volume</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*AyPNe0W5-mp1KVxe" /></figure><p>Below, we examined the disks and found that they were not mounted. Consequently, we executed the mount -a command to rectify the issue. Upon verification, the disks were automatically mounted, allowing us to recover the deleted data by executing ls /var/lib/mysql/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xj7LSV7nEbIZ7f1D" /></figure><p>In the snapshot console, you’ll find various options beyond basic backup functionality. These include deleting snapshots, creating volumes from existing snapshots (which we’ve already covered), and managing fast snapshot restores for large volumes, albeit with additional charges.</p><p>Additionally, you can leverage snapshots to create images, known as Amazon Machine Images (AMIs). If the snapshot originates from a root volume, you can directly create an image from it.</p><p>Another useful feature is the ability to copy snapshots. By clicking the “copy” button, you can duplicate snapshots to different regions, which is particularly handy for multi-site setups. Moreover, during the copying process, you have the option to enable encryption for added security.</p><p>Furthermore, the snapshot interface offers a “modify permissions” button, allowing you to adjust access settings. This enables you to make snapshots public or share them with specific AWS accounts by providing their account IDs.</p><p>In summary, snapshots offer a simple yet powerful toolset with various benefits, making them an indispensable asset for managing AWS resources effectively.</p><p>Stay tuned for practical applications and hands-on examples.</p><p>Thank you 😊🫰🫶</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9063b47958a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief Introduction to EC2 Instance:]]></title>
            <link>https://iam-athirakk.medium.com/a-brief-introduction-to-ec2-instance-2d12e7221d00?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d12e7221d00</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 05:04:08 GMT</pubDate>
            <atom:updated>2024-04-08T05:04:34.101Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A Brief Introduction to EC2 Instance:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*q3MRvQpJO9LzsrlW8nXchQ.png" /></figure><p>An EC2 instance, short for Elastic Compute Cloud instance, is a virtual server offered by Amazon Web Services (AWS) that provides resizable compute capacity in the cloud. Essentially, it allows users to rent virtual servers to run their applications or host their websites without the need to invest in physical hardware.</p><ul><li>EC2 instances offer a variety of configurations for CPU, memory, storage, and networking, catering to diverse workload requirements.</li><li>Users can select from optimized instance types, such as general-purpose, memory-intensive, or high-performance computing, to suit their specific needs.</li><li>Deployment and management are simplified through AWS Management Console, CLI, or SDKs, facilitating easy provisioning, monitoring, and scaling of instances.</li><li>EC2 serves a wide range of use cases, from basic web hosting to complex data analytics, meeting the computing requirements of businesses across industries and sizes.</li><li>EC2 follows a pay-as-you-go pricing model, ensuring cost-effectiveness by billing users based on instance type, usage duration, and other factors, thus accommodating varying business needs and budget constraints.</li></ul><p><strong>Purpose of having an EC2 Instance</strong></p><ul><li><strong>Flexibility</strong>: With a wide range of instance types and configurations, EC2 instances cater to diverse workload requirements, from basic web hosting to high-performance computing and data analytics.</li><li><strong>Scalability</strong>: EC2 instances offer scalable compute capacity, allowing businesses to easily adjust resources based on demand fluctuations. This scalability ensures efficient resource utilization and cost-effectiveness.</li><li><strong>Global Reach:</strong> With AWS’s global infrastructure, EC2 instances are available in multiple regions worldwide. This enables businesses to deploy applications closer to their target audience for improved performance and latency optimization.</li><li><strong>Security and Reliability: </strong>EC2 instances provide a secure and reliable environment for running applications, with features like built-in encryption, firewalls, and monitoring tools to safeguard data and ensure high availability.</li><li><strong>Ease of Management: </strong>EC2 instances can be quickly deployed and managed through AWS Management Console, CLI, or SDKs, streamlining the process of provisioning, monitoring, and scaling instances as needed.</li></ul><p>Amazon EC2 offers a variety of instance types tailored for diverse needs. These types feature different configurations of CPU, memory, storage, and networking capacity, providing flexibility in selecting resources for your applications. Additionally, each instance type includes multiple sizes, enabling easy scaling according to your workload’s demands.</p><p>EC2 Instance Types Overview:</p><p><strong>General Purpose:</strong></p><ul><li>These instances offer a balanced mix of compute, memory, and networking resources.</li><li>Ideal for applications like web servers and code repositories that require equal proportions of these resources.</li></ul><p><strong>Burstable Performance:</strong></p><ul><li>Also known as the T instance family, these instances provide baseline CPU performance with the ability to burst above it when needed.</li><li>Refer to the Amazon EC2 User Guide for Linux Instances for more details.</li></ul><p><strong>Compute Optimized:</strong></p><ul><li>Designed for compute-intensive applications requiring high-performance processors.</li><li>Suitable for tasks such as batch processing, media transcoding, and high-performance web servers.</li></ul><p><strong>Memory Optimized:</strong></p><ul><li>Tailored for workloads processing large datasets in memory.</li><li>Deliver fast performance for applications with substantial memory requirements.</li></ul><p><strong>Storage Optimized:</strong></p><ul><li>Intended for workloads demanding high, sequential read and write access to large data sets on local storage.</li><li>Optimized to provide high IOPS for applications requiring rapid random I/O operations.</li></ul><p><strong>Accelerated Computing:</strong></p><ul><li>Utilizes hardware accelerators or co-processors for efficient processing of functions like floating-point calculations and graphics processing.</li><li>Enhances performance compared to software-based processing on CPUs.</li></ul><p><strong>High-Performance Computing (HPC):</strong></p><ul><li>Purpose-built for running HPC workloads at scale on AWS, offering optimal price-performance.</li><li>Ideal for complex simulations and deep learning tasks requiring high-performance processors.</li></ul><p><strong>Previous Generation:</strong></p><ul><li>AWS continues to support previous generation instance types for users who have optimized their applications around them.</li><li>While current generation instance types offer better performance, previous generation types are still available for legacy applications.</li></ul><p>Understanding AWS Regions, Availability Zones, and Deployment Strategies</p><p><strong>Regions:</strong></p><ul><li>AWS divides its global infrastructure into geographical regions, such as North America, Europe, Asia Pacific, etc.</li><li>Each region is completely isolated from others and consists of multiple Availability Zones.</li><li>Users select a region when deploying resources like EC2 instances. The choice of region affects latency, compliance, and data residency.</li></ul><p><strong>Availability Zones (AZs):</strong></p><ul><li>Availability Zones are distinct data centers within a region, designed for fault tolerance and high availability.</li><li>They are physically separate from each other and are connected through high-speed, low-latency links.</li><li>Deploying resources across multiple AZs enhances fault tolerance. If one AZ experiences an issue, applications can continue running in others without interruption.</li></ul><p><strong>Deployment Strategy:</strong></p><ul><li>To ensure high availability and fault tolerance, it’s recommended to distribute resources (like EC2 instances) across multiple AZs within a region.</li><li>This strategy protects against failures or outages in a single AZ and ensures that applications remain accessible even if one AZ becomes unavailable.</li></ul><p><strong>Scalability and Performance:</strong></p><ul><li>Deploying resources across multiple AZs allows for better scalability and performance.</li><li>Load balancers can distribute incoming traffic evenly across multiple AZs, optimizing resource utilization and improving response times for users.</li></ul><p><strong>Data Residency and Compliance:</strong></p><ul><li>Different regions may have varying data residency regulations and compliance requirements.</li><li>Users need to select the appropriate region and AZs to ensure compliance with local regulations and keep data within designated geographic boundaries.</li></ul><p><strong>Cost Considerations:</strong></p><ul><li>Costs for AWS services may vary across regions, so users should consider pricing differences when selecting a region for deployment.</li><li>Additionally, data transfer costs may apply when transferring data between regions or AZs.</li></ul><p><strong>EC2 Major Purchasing options:</strong></p><p>1. 𝐎𝐧 𝐃𝐞𝐦𝐚𝐧𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Pay for the compute capacity per second , no up- front payment.We can decide when to launch,terminate,start.stop,or reboot.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔: short-term work-loads , irregular workloads that cannot be interrupted.</p><p>2. 𝐑𝐞𝐬𝐞𝐫𝐯𝐞𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — We can reserve instances in terms of 1year and 3year. Provide up to 70% discount compared to On-Demand. Payment method can be all upfront, partial upfront,no upfront. If you purchase Reserved Instances of a specific type in an availability zone and the same type is available in same zone then automatically charge at lower rate.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Long-term workloads , Applications with steady state or predictable usage.</p><p>3. 𝐒𝐩𝐨𝐭 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Most cost effective , We can request for unused instances up to 90% discount. But if someone is paying more than of yours, then instance will get loosed. So it is less reliable.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Image processing , non-critical applications.</p><p>4. 𝐃𝐞𝐝𝐢𝐜𝐚𝐭𝐞𝐝 𝐇𝐨𝐬𝐭𝐬– Physical server completely dedicated for your use. More expensive and can be purchase as on demand or reserved.Billing will be per-host.</p><p>𝑼𝒔𝒆 𝒄𝒂𝒔𝒆𝒔 — Companies that have strong regulatory or compliance needs.</p><p>5.𝐃𝐞𝐝𝐢𝐜𝐚𝐭𝐞𝐝 𝐈𝐧𝐬𝐭𝐚𝐧𝐜𝐞𝐬 — Instances running on hardware that’s dedicated to a single user. It can share hardware with other instances in same account. Billing will be per-instance.</p><p>6.𝐒𝐚𝐯𝐢𝐧𝐠𝐬 𝐏𝐥𝐚𝐧𝐬 — This will assist the user to lower the EC2 costs if they agree to keep it for a specific period — ideally, one or three years. The number of active instances are unrestricted.</p><p><strong>AMI (Amazon Machine Image):</strong></p><ul><li>An AMI is a template used to create virtual machines (instances) within the Amazon EC2 service.</li><li>It contains the operating system, application server, and applications necessary to launch an instance.</li><li>You can create custom AMIs or use pre-built AMIs provided by AWS and other users.</li></ul><p><strong>AMI Images:</strong></p><ul><li>AMI images are the actual files stored in Amazon S3 that represent the templates used to launch EC2 instances.</li><li>These images include the root volume snapshot and metadata required to launch an instance.</li><li>AMI images are versioned, allowing you to maintain multiple versions of an AMI and roll back to previous versions if needed.</li></ul><p><strong>Placement Groups</strong></p><ul><li>Placement groups are the way of logically grouping interdependent instances together in a selected region.</li><li>In other words, instances that are existing within a common availability zone can be grouped under placement group in order to suit workload requirements.</li><li>By using the placement group, we will increase the performance or improve the availability.</li></ul><p><strong>Types</strong></p><ul><li>Cluster placement group</li><li>Spread placement group</li><li>Partition placement group</li></ul><p>𝐁𝐞𝐧𝐞𝐟𝐢𝐭𝐬</p><ul><li>Can be able to launch multiple instances within the same AZ.</li><li>Low network latency.</li><li>High network throughput.</li></ul><p>𝐋𝐢𝐦𝐢𝐭𝐚𝐭𝐢𝐨𝐧𝐬</p><ul><li>Cannot merge placement groups.</li><li>Cannot launch dedicated hosts in placement groups.</li><li>Instances cannot span into multiple placement groups.</li></ul><p>𝐂𝐥𝐮𝐬𝐭𝐞𝐫 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>All the instances are placed in a same hardware rack inside an availability zone.</li><li>But if the rack fails, all instances fail at the same time.</li><li>This type of group will enable to achieve low latency network.</li><li>Good for High Performance applications.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞 — Application with low latency and high throughput.</li></ul><p>𝐒𝐩𝐫𝐞𝐚𝐝 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>All EC2 instances are placed in different hardware racks in a single availability zone.</li><li>A rack failure will not affect more than one instance.</li><li>We can create up to 7 EC2 instances per availability zone in spread placement group.</li><li>Good for high availability applications and not suitable for high performance applications.</li><li>It can span multiple availability zones in the same region.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞- Critical applications that needs to be isolated from failure from each other.</li></ul><p>𝐏𝐚𝐫𝐭𝐢𝐭𝐢𝐨𝐧 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 𝐆𝐫𝐨𝐮𝐩</p><ul><li>Group of instances spread across racks, and the instances in one partition do not share the underlying hardware with instances in different partition.</li><li>If a rack fails, it will affect on the instances within that particular partition only.</li><li>Partitions can be in different availability zones in the same region.</li><li>It strikes a balance between high performance and high availability.</li><li>𝐔𝐬𝐞 𝐂𝐚𝐬𝐞 — Big data applications like HDFS, HBase, Cassandra, Kafka.</li></ul><p>In AWS EC2, there are three main types of load balancers:</p><p><strong>Classic Load Balancer (CLB):</strong></p><ul><li>CLB is the original load balancer service provided by AWS.</li><li>It operates at both the application and transport layers (Layer 4 and Layer 7) of the OSI model.</li><li>CLB supports distributing incoming traffic across multiple EC2 instances in multiple Availability Zones.</li><li>It is suitable for applications that require simple load balancing without advanced features.</li></ul><p><strong>Application Load Balancer (ALB):</strong></p><ul><li>ALB operates at the application layer (Layer 7) of the OSI model.</li><li>It supports advanced routing features such as host-based routing, path-based routing, and routing based on HTTP headers.</li><li>ALB can handle HTTP and HTTPS traffic and provides support for WebSocket and HTTP/2 protocols.</li><li>It is ideal for modern web applications with multiple microservices or containers.</li></ul><p><strong>Network Load Balancer (NLB):</strong></p><ul><li>NLB operates at the transport layer (Layer 4) of the OSI model.</li><li>It provides ultra-low latency and high throughput, making it suitable for handling millions of requests per second.</li><li>NLB supports routing traffic to targets using IP addresses and TCP ports, making it ideal for TCP and UDP-based applications.</li><li>It is commonly used for applications that require high performance, scalability, and reliability, such as gaming, IoT, and real-time communication applications.</li></ul><p><strong>Target Groups</strong> are a fundamental component of Elastic Load Balancing (ELB) services in AWS, specifically associated with the Application Load Balancer (ALB) and Network Load Balancer (NLB).</p><p>Here’s a concise explanation:</p><p><strong>Routing</strong>:</p><ul><li>When configuring a load balancer (ALB or NLB), you specify one or more target groups to route traffic to.</li><li>Each target group defines the criteria for routing requests to its associated targets, such as based on a specific path, host, or HTTP header.</li></ul><p><strong>Health Checks:</strong></p><ul><li>Target Groups perform health checks on their registered targets to ensure they are capable of handling requests.</li><li>Unhealthy targets are automatically removed from the target group until they pass health checks again.</li></ul><p><strong>Load Balancing:</strong></p><ul><li>Target Groups distribute incoming traffic evenly across their registered targets according to the configured load balancing algorithm (e.g., round-robin or least outstanding requests).</li></ul><p><strong>Port Configuration:</strong></p><ul><li>Target Groups allow you to specify the port on which the targets receive traffic, allowing flexibility in routing requests to different ports on the same target.</li></ul><p><strong>Autoscaling:</strong></p><ul><li>Autoscaling is a feature provided by AWS that automatically adjusts the number of EC2 instances in a fleet based on user-defined policies.</li><li>It helps maintain the desired number of instances to handle varying levels of application traffic or workload demand.</li><li>Autoscaling can scale both up (adding more instances) and down (removing instances) dynamically, ensuring optimal resource utilization and cost efficiency.</li></ul><p><strong>Autoscaling Groups:</strong></p><ul><li>An Autoscaling Group (ASG) is a logical grouping of EC2 instances managed by the Auto Scaling service.</li><li>ASGs define the scaling policies, launch configurations, and other parameters that govern the behavior of the instances within the group.</li><li>ASGs automatically launch or terminate EC2 instances based on predefined scaling policies and health checks.</li><li>ASGs can be configured to distribute instances across multiple Availability Zones to improve fault tolerance and high availability.</li></ul><p><strong>Ways to connect to EC2 instances via the command line:</strong></p><ul><li>SSH connection</li><li>EC2 Instance Connect:</li><li>AWS CLI (Command Line Interface):</li><li>Third-Party Tools ( like PuTTY or MobaXterm)</li></ul><p>and more…..</p><p>Refer this link to get hands-on experience in Auto Scaling — <a href="https://medium.com/@iam-athirakk/aws-auto-scaling-d67063e1abf8">https://medium.com/@iam-athirakk/aws-auto-scaling-d67063e1abf8</a></p><p>Refer this link to get hands-on experience in Application Load Balancer — <a href="https://medium.com/@iam-athirakk/application-load-balancer-463da91c8960">https://medium.com/@iam-athirakk/application-load-balancer-463da91c8960</a></p><p>In the next blog , we will see the labs on various aspects of ec2 instances, real-time problems and their solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d12e7221d00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing a new blog series:  :  …]]></title>
            <link>https://iam-athirakk.medium.com/introducing-a-new-blog-series-f286bf8b8583?source=rss-aa0a76b69130------2</link>
            <guid isPermaLink="false">https://medium.com/p/f286bf8b8583</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Athira KK]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 11:57:48 GMT</pubDate>
            <atom:updated>2024-04-01T11:57:48.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀Introducing a new blog series: 𝐃𝐞𝐯𝐎𝐩𝐬 𝐃𝐲𝐧𝐚𝐦𝐢𝐜𝐬: 𝐀𝐖𝐒 𝐒𝐞𝐫𝐯𝐢𝐜𝐞𝐬 𝐒𝐞𝐫𝐢𝐞𝐬! 🚀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*2GzHFb5f3q4tavalNpb64Q.png" /></figure><p>In this series, we’ll explore the core AWS services that helps a DevOps engineer in their labs. We will begin by going over each service’s basics , offering clear explanations and useful examples to understand their core functionalities. We will explore Amazon SNS and few more services as part of this series.</p><p>Yet, that’s not all! Once the basics are completed, we’ll take things to the next level with advanced-level insights and best practices.</p><p>Stay tuned for the first blog, where we’ll explore into the basics of AWS EC2 and how it powers modern cloud computing infrastructures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f286bf8b8583" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>