<?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 SandaniMuthukumarana on Medium]]></title>
        <description><![CDATA[Stories by SandaniMuthukumarana on Medium]]></description>
        <link>https://medium.com/@sandanimuthukumarana?source=rss-5fac584e7d31------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JJza_4O_KXeM5tNr9HjhXg.png</url>
            <title>Stories by SandaniMuthukumarana on Medium</title>
            <link>https://medium.com/@sandanimuthukumarana?source=rss-5fac584e7d31------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:04:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sandanimuthukumarana/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[Bulkhead Pattern in Microservices]]></title>
            <link>https://medium.com/@sandanimuthukumarana/bulkhead-pattern-in-microservices-5407f9cc426c?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/5407f9cc426c</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 07:01:29 GMT</pubDate>
            <atom:updated>2026-01-13T08:03:55.230Z</atom:updated>
            <content:encoded><![CDATA[<h3>Preventing One Slow Service from Breaking Everything</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uprjjz1dWfKlixbePsZi5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*of_OQP6SEwNahWgE4LNXzQ.png" /></figure><h4>Introduction</h4><p>In a microservices system, a single service often depends on many other services.<br> For example assume there are 3 services. So <strong>Order Service</strong> may call a <strong>Payment Service</strong> and a <strong>Shipping Service</strong> to complete an order.</p><p>When everything works well, this is not a problem.<br> But what happens when <strong>one dependent service becomes slow or unresponsive</strong>?</p><p>This is where the <strong>Bulkhead Pattern</strong> becomes important.</p><h4>The Problem: Shared Resources Cause System Failure</h4><p>Imagine an <strong>Order Service</strong> that depends on two services</p><ul><li>Payment Service</li><li>Shipping Service</li></ul><p>Without using the Bulkhead pattern, the Order Service uses <strong>one shared thread pool</strong> for all outgoing calls.</p><p>Then,</p><ul><li>Payment Service becomes slow or unresponsive</li><li>All threads in the shared pool get blocked waiting for payment responses</li><li>No threads are left to call the Shipping Service</li><li>Even though Shipping Service is healthy, it cannot be accessed</li><li>As a result, <strong>the entire Order Service becomes unresponsive</strong></li></ul><p>This means <strong>one slow dependency can block all other functionalities</strong>.</p><p>Then,<br>Healthy services become unavailable</p><ul><li>Users experience failures even when parts of the system are working</li><li>A single problem spreads across the system</li><li>Overall reliability of the system is reduced</li></ul><p>So this is serious issue.!!!</p><p>This called <strong>failure propagation</strong>, and it is exactly what the Bulkhead pattern prevents.</p><h4>How Bulkhead pattern solve this?</h4><p>The <strong>Bulkhead Pattern</strong> solves this problem by <strong>isolating resources</strong>.</p><p>The name comes from ship design.<br> Ships use bulkheads to divide compartments so that if one section floods, the entire ship does not sink.</p><p>In microservices, we apply the same idea to <strong>threads, connections, or memory</strong>.</p><h4>How Bulkhead Pattern Works?</h4><p>Instead of using one shared resource pool, we <strong>divide resources into separate compartments</strong>.</p><p>Each dependency gets its <strong>own limited resource pool</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIRpc5j6BZtyrznJY5zZsg.png" /></figure><h4>Example Resource Partitioning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*RWvdlhx-k8DyPDb255Ln7A.png" /></figure><p>So what happens during failure?<br>Payment Service becomes slow</p><ul><li>All <strong>20 payment threads</strong> get consumed</li><li>Payment-related functionality is affected</li><li>Shipping Service still has <strong>its own 20 threads</strong></li><li>Shipping calls continue to work normally</li><li>Order Service remains <strong>partially functional instead of fully down</strong></li></ul><p>Now, the failure is <strong>contained</strong>, not spread.</p><h4>Benefits of Using Bulkhead Pattern</h4><ul><li>Prevents one service from blocking others</li><li>Improves system stability</li><li>Limits the impact of failures</li><li>Keeps healthy parts of the system running</li><li>Improves user experience</li></ul><h4>When Should You Use Bulkhead Pattern?</h4><p>Bulkhead pattern is useful when</p><ul><li>A service depends on multiple external services</li><li>Different dependencies have different reliability</li><li>High availability is important</li><li>You want to prevent cascading failures</li></ul><p>In a microservices system, failures can happen at any time. The real problem is when one slow service affects the whole system. The Bulkhead pattern helps avoid this by separating resources for each dependency. When one service becomes slow, only its related functionality is affected, while other healthy services continue to work. This makes the system more stable and reliable. In real applications, this pattern is usually implemented using resilience libraries like Resilience4j, which will be explained in future articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5407f9cc426c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Docker-What Happens Inside the Kernel When You Run docker run]]></title>
            <link>https://medium.com/@sandanimuthukumarana/the-secret-life-of-docker-what-happens-inside-the-kernel-when-you-run-docker-run-1c6fd6d95888?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c6fd6d95888</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 09:05:12 GMT</pubDate>
            <atom:updated>2025-11-17T09:05:12.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SK8nSGrCV1OWkVik" /></figure><p>When u want to run docker image and u want to create the container u type,<br>docker run -it ubuntu bash<br>after this u might think docker instantly creates a whole new machine. But realty is not that..</p><p>The truth is docker doesnt create new machine. it takes the process (the bash command ) and wraps it in three layers of linux kernal magic.</p><ul><li><strong>Namespaces</strong> → Create the illusion that the process has its own isolated world</li><li><strong>cgroups</strong> → Control how much of the shared hardware that process can use</li><li><strong>OverlayFS → </strong>Give the process its own filesystem without copying everything</li></ul><p>what is the result?<br>A container that looks and feels like its own machine, but is actually just a regular process with special restrictions.</p><p>so lets explore this journey step by step.</p><h3>What happen inside the kernel when docker run executes?</h3><p>U type <br>docker run -it ubuntu bash</p><p>after that</p><h4>The Docker Client Contacts the Docker Daemon</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*ph6H7dMuv-Wwb2DU0cH4AQ.png" /><figcaption>what happen inside</figcaption></figure><p>When u type docker run u actually talking to a program running in the background called docker daemon.<br>Docker Daemon is a background program that actually creates and manages containers.</p><p>ur docker command is like just message. it says “Please create a container using Ubuntu image and run bash inside it.”</p><p>Docker daemon,<br>runs as root on ur system. This is why Docker containers can do privileged things. The daemon has the power to</p><ul><li>Create namespaces (kernel feature, requires root)</li><li>Create cgroups (kernel feature, requires root)</li><li>Mount filesystems (kernel feature, requires root)</li></ul><p>ok then,</p><h4>The Daemon Prepares the Filesystem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*RW6cOX-0GE-Z4l_bCcsZpA.png" /></figure><p>The daemon first prepares a filesystem for your container using OverlayFS.</p><p>so before discussing what happen in here i will explain about this docker filesystem.</p><blockquote>In Docker, everything inside a container from system libraries to your application files lives in a <strong>layered filesystem</strong>. Each Docker image is built from multiple <strong>layers</strong>, where every layer represents a set of filesystem changes, such as adding or modifying files. These layers are stacked on top of each other to form the complete image.<br>It has four layers-<br>1. <strong>Lower layer (read-only)<br></strong>2. <strong>diff/ layer (writable)<br></strong>3. <strong>merged/ layer (what you see inside the container)</strong></blockquote><ul><li><strong>Lower layer</strong> → Read-only Ubuntu image (shared by all containers)</li><li><strong>diff/ layer</strong> → Empty writable directory (unique to this container)</li><li><strong>merged/ layer</strong> → What the container sees (magic combination of both)</li></ul><p>so this directory structured create in</p><p><strong>/var/lib/docker/overlay2/CONTAINER_ID/</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*RPFe1oEeEgbeqb2AQ_8i-Q.png" /></figure><p>At this point nothing actually running yet.. We have just prepared the filesystem. But notice <strong>we haven’t copy the image</strong>. We <strong>just pointing</strong> to it.</p><p>imagine without the OverlayFS:</p><ul><li>Each container would be a full copy of Ubuntu (500 MB — 1 GB)</li><li>100 containers = 50–100 GB on disk</li><li>Startup would be slow (copying takes time)</li></ul><p>But u dont hv this issue now..</p><ul><li>All containers share the same Ubuntu image</li><li>100 containers = shared image + small diffs = ~1.5 GB</li><li>Startup is instant (no copying needed)</li></ul><p>next,</p><h4>The Daemon Creates a cgroup for Resource Limiting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*ykVaa-buErGlKpdvQP0Jxg.png" /></figure><p>Before we even start the process, we set up resource boundaries. We’re telling the kernel: This container can use UP TO 1 CPU core, UP TO 512 MB memory, etc.</p><p><strong>How cgroup works?<br></strong>cgroups = Control groups. They’re files in the /sys/fs/cgroup/ directory that the kernel reads to enforce limits.</p><p>/sys/fs/cgroup/cpu.max ← CPU limit<br>/sys/fs/cgroup/memory.max ← Memory limit<br>/sys/fs/cgroup/io.max ← I/O limit<br>/sys/fs/cgroup/pids.max ← Process count limit</p><p>The Kernel Watches These-</p><p>The Linux kernel constantly monitors these files. When a process in the container tries to use more resources than allowed, the kernel…,</p><ul><li><strong>For CPU:</strong> Throttles the process (slows it down)</li><li><strong>For memory:</strong> Kills the process (OOM — Out of Memory)</li><li><strong>For I/O:</strong> Limits throughput</li><li><strong>For PIDs:</strong> Prevents creating new processes</li></ul><p>You set <em>-memory=512m</em> when running the container.</p><p>Docker creates: /sys/fs/cgroup/.../memory.max = 536870912(512 MB in bytes)<br>Your container app tries to use 600 MB of memory.<br>Kernel sees: memory usage (600 MB) &gt; memory limit (512 MB)<br>Kernel does: <strong>OOM Kill - </strong>kills the process<br>The app inside the container crashes, and you see: <strong>killed</strong></p><p>so then.,</p><h4>The Daemon Creates Namespaces</h4><p>what happens</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*eyTrfWrpLGzCVrfY-Ymmew.png" /></figure><p>Now we create namespaces. Think of a namespace as a “virtual world” for a specific resource.</p><p>When you’re inside a namespace, you only see things in YOUR namespace. You don’t see other processes on the host system. You don’t see other network interfaces. It’s like each container lives in its own private world.</p><p>Let me explain each namespace and how they contribute to the container illusion…</p><h4>Namespace 1 : PID Namespace (Process ID Isolation)</h4><p>Normally on a Linux system, you can see all processes:</p><p><strong>What It Does?</strong></p><blockquote># On your host machine:<br>ps aux</blockquote><blockquote># You see:<br>root 1 systemd<br>root 45 dockerd<br>root 5678 sshd<br>user 5679 bash</blockquote><p><strong>The Illusion Inside the Container?</strong></p><p>Inside a PID namespace, the container only sees:</p><blockquote># Host view (reality):<br>root 5001 bash (inside container)<br>root 5002 curl (inside container)<br>root 5003 nginx (inside container)</blockquote><p><strong>So What Actually Happened?</strong></p><p>The host system is running these processes with PIDs 5001, 5002, 5003.<br>But inside the container’s PID namespace, they appear as PIDs 1, 10, 20.The kernel maintains a translation table:</p><blockquote>Container PID 1 ←→ Host PID 5001 (bash)<br>Container PID 10 ←→ Host PID 5002 (curl)<br>Container PID 20 ←→ Host PID 5003 (nginx)</blockquote><p>The container thinks it’s the only thing running. It has no idea about the host’s systemd (PID 1), the host’s sshd, or any other containers. The container truly believes it’s running on its own machine with its own PID 1.</p><p><strong>Example</strong></p><blockquote># Inside container:<br>$ ps aux<br>UID PID PPID COMMAND<br>root 1 0 bash</blockquote><blockquote># This bash process is PID 1 in the container!<br># But on the host, it’s actually PID 5001.</blockquote><p>Why is PID 1 special? Because PID 1 is the “init” process. In a real machine, PID 1 is systemd and it’s the parent of all other processes. In a container, your bash becomes PID 1, making the container feel like its own machine.</p><h4>Namespace 2: Network Namespace (Network Interface Isolation)</h4><p><strong>What It Does?</strong></p><p>Normally, all processes share the same network interfaces.</p><blockquote># On your host machine:<br>ifconfig</blockquote><blockquote># You see:<br>eth0: 192.168.1.100<br>lo: 127.0.0.1<br>docker0: 172.17.0.1</blockquote><p><strong>The Illusion Inside the Container</strong></p><p>Inside a network namespace, the container only sees its own network interface</p><blockquote># Inside container:<br>ifconfig</blockquote><blockquote># It sees:<br>eth0: 172.17.0.2<br>lo: 127.0.0.1</blockquote><p>the docker network is difference but local is same..</p><p><strong>Actually what happen in there?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*mKLYOHGsNRu0FobZN-cMMw.png" /></figure><p>When the container sends a packet through eth0, it actually goes to veth12345678 on the host, which forwards it to the docker bridge, which forwards it to the real network interface.</p><p>as a example think about ..</p><p>Inside the container..<br>$ curl <a href="http://example.com/">http://example.com</a></p><p>Lets look what actually happen in here,</p><ol><li>Container creates packet</li><li>Container thinks it’s sending on eth0</li><li>Kernel sees it’s eth0 inside network namespace</li><li>Kernel forwards to veth12345678 on host</li><li>veth12345678 forwards to docker0 bridge</li><li>docker0 bridge forwards to host eth0</li><li>Packet reaches example.com</li><li>Response comes back</li><li>Reverse path brings response to container</li><li>Container sees response on eth0</li></ol><p>The container sees its own network configuration. It can’t see (and can’t interfere with) the host’s network or other containers’ networks. This give perfect isolation..</p><h4>Namespace 3: Mount Namespace (Filesystem Isolation)</h4><p>Normally, all processes see the same mounted filesystems..</p><blockquote># On your host machine:<br>mount | head -20</blockquote><blockquote># You see:<br>/dev/sda1 on / (root filesystem)<br>/dev/sda2 on /home<br>/dev/sda3 on /var<br>tmpfs on /dev/shm<br>/mnt/usb on /mnt/usb<br>… and 20+ more</blockquote><p>Inside a mount namespace, the container only sees specific mounts..</p><blockquote># Inside container:<br>mount | head</blockquote><blockquote># It sees:<br>/dev/overlay on / (the merged/ OverlayFS mount!)<br>tmpfs on /dev<br>tmpfs on /sys<br>tmpfs on /proc<br>tmpfs on /run</blockquote><p>in here we cant see /home,/var,/mnt/usb, no host filesystem..</p><p>so in here docker used the mount namespace to</p><ul><li>Hide the host’s filesystem</li><li>Mount the container’s OverlayFS as root /</li><li>Mount virtual filesystems for /dev, /sys, /proc</li></ul><h4><strong>Namespace 4: The Hostname</strong></h4><p>Normally, when we check on a host, all processes see the same hostname:</p><blockquote># On your host machine:<br>hostname</blockquote><blockquote># Output:<br>production-server</blockquote><p>Inside a UTS namespace, the container sees its own hostname:</p><blockquote># Inside container:<br>hostname</blockquote><blockquote># Output:<br>d74e3c45a6b2 (random container ID or custom hostname you set)</blockquote><p>in here The container can have its own hostname without affecting the host or other containers. This is useful for application configuration that relies on hostname.</p><h4>Namespace 5: IPC Namespace (Inter-Process Communication Isolation)</h4><p>IPC (Inter-Process Communication) includes shared memory, message queues, and semaphores. A container’s IPC namespace keeps it from interfering with or being interfered by the host’s IPC mechanisms.</p><p>so..</p><p>This prevents containers from interfering with each other’s inter-process communication. Security and isolation.</p><h4>Namespace 6: User Namespace (User ID Isolation)</h4><p>By default, the root user inside a container is the host’s root. With user namespaces enabled, you can map the container’s root to an unprivileged user on the host:</p><blockquote>Container sees: uid=0 (root)<br>Host sees: uid=1000 (dockremap user)</blockquote><p>Even if someone breaks out of the container, they’re just an unprivileged user on the host.</p><h4>Namespace 7: Cgroup Namespace (Resource Visibility Isolation)</h4><p>The container sees its cgroups as if they’re the root of the system, unable to see other containers’ resource limits or the overall system structure.</p><p>now..</p><h3>Starts the Process</h3><p>Now all the preparations are done. Docker has created the filesystem layers, set up the cgroups for resource limiting, and created all the namespaces for isolation. Everything is ready. The daemon now calls a special Linux system call named clone. This is similar to the fork system call, but it’s more powerful. It creates a new process and assigns it to all the namespaces that were just created.</p><p>usually this new process is bash shell, inside those isolated environments. From inside the container, this bash process feels like it is running on its own machine. It thinks it is <strong>PID 1</strong>, which is normally the first and most important process in an operating system. It has its own network, its own filesystem, and its own hostname. It does not know anything about resource limits or namespaces the kernel handles those things silently. So, the container comes to life and starts running as if it is a small independent system. But from the host machine’s point of view, it is simply another regular process, just with some isolation and restrictions applied.</p><h3>How Namespaces and cgroups Work Together</h3><h4>Why You Need Both</h4><p>Namespaces and cgroups must work together for containers to function properly.</p><p>Think of a container running a very heavy process that needs a lot of CPU power. If the system only used namespaces, the container would feel like it has its own world. It would not see other processes or other systems, which is great for isolation. But there would be no control on how much CPU it uses. The container could take all the CPU power and slow down every other container or even the host machine. So namespaces alone are not enough they only give the illusion of separation but do not stop a container from using too many resources.</p><p>Now imagine the opposite case: if the system only used cgroups, then resource limits like CPU and memory would be controlled, but the container would still see everything on the machine all processes, all networks, and all system resources. There would be no privacy or isolation. This is why both are needed. Namespaces make the container feel like a completely separate system, and cgroups make sure it can only use a fair amount of resources.</p><p>Together, they create the containers isolated and controlled environments that work side by side on the same machine.</p><p><strong>Example-</strong></p><p>Imagine you have a server with <strong>4 CPU cores</strong> and <strong>16GB of RAM</strong>. You want to run three applications: a web server (nginx), a database (PostgreSQL), and a cache (Redis). You run each application inside its own Docker container and set different resource limits for each one</p><ul><li><strong>nginx</strong> → allowed <strong>2 CPU cores</strong> and <strong>1GB RAM</strong></li><li><strong>PostgreSQL</strong> → allowed <strong>1.5 CPU cores</strong> and <strong>2GB RAM</strong></li><li><strong>Redis</strong> → allowed <strong>0.5 CPU cores</strong> and <strong>512MB RAM</strong></li></ul><p>Inside each container, namespaces make the application feel like it has its own private computer. nginx believes it has 2 CPUs and 1GB memory all to itself. PostgreSQL and Redis think the same way, each with their own numbers. Each of them thinks they are <strong>PID 1</strong>, the first and main process on the system. They don’t know about the host machine or the other containers.</p><p>But the host sees reality. It sees three processes running at the same time, each using some share of CPU and RAM. For example:</p><ul><li>nginx might actually use 1.5 CPU cores and 800MB</li><li>PostgreSQL might use 1 CPU core and 1.5GB</li><li>Redis might use 0.1 CPU core and 300MB</li></ul><p>Together, they are only using 2.6 CPU cores and 2.6GB RAM, so the system still has plenty of resources free.</p><p>During all this, the kernel is the referee. It watches every process and enforces the resource limits set by cgroups. If nginx tries to use more than 2 cores, the kernel stops it. If PostgreSQL tries to use too much memory, the kernel blocks extra allocation and if needed, will even kill the process to protect the system.</p><p>Because of namespaces and cgroups working together, one container cannot hurt the others. Even if nginx suddenly becomes crazy and tries to use 100% of the CPU, the kernel will restrict it to only 2 cores. PostgreSQL and Redis continue running smoothly without slowdown.</p><p>Containers live together, but each in their own safe world.</p><h3>Container Lifecycle -Why <em>Stop</em> and <em>Delete</em> Are Not the Same</h3><p>A container has a life cycle <br> <strong>start → run → stop → restart or delete</strong>.<br> Many people think stopping and deleting are similar since both end the container. But they behave <strong>very differently</strong> specially for your data.</p><h4><strong>Stopping a Container</strong></h4><p>It like a clicking pause button..<br>When you stop a container, Docker sends a signal to the main process inside</p><p><strong>SIGTERM</strong> → A polite request</p><ul><li>“Please shut down safely”</li><li>Allows the app to save files, close databases, write logs</li></ul><p>If the app doesn’t stop within ~10 seconds:<br> <strong>SIGKILL</strong> → Force stop</p><ul><li>No saving</li><li>Immediate shutdown</li></ul><p>But the key point is..</p><p><strong>Stopping does NOT delete the container’s filesystem or data.</strong></p><p>Everything remains:</p><ul><li>The <strong>diff</strong> layer (all changes made inside the container)</li><li>Container configuration</li><li>Stored files, logs, databases all safe and preserved</li></ul><p>Stopping is like pausing a video..Progress saved ,You can play it again later</p><p>You can <strong>restart</strong> the container and everything appears exactly as befor because Docker re-mounts the same filesystem layers again.</p><h4>Deleting a Container</h4><p>Deleting a container first stops it.<br>Then Docker removes everything that belongs to that container:</p><ul><li>Deletes the diff directory (all created files are gone)</li><li>Removes metadata and container ID from Docker</li><li>Cleans up cgroups &amp; namespaces</li><li>Removes the container’s reference to the image layers</li></ul><p>After deletion<br>Docker forgets that the container ever existed.</p><p>No recovery option. No recycle bin.<br> Unless you created backups, the data is <strong>permanently gone</strong>.</p><p>Deleting is like removing a video file…<br>You cannot continue later ,the stored progress and content are wiped out</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c6fd6d95888" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment Patterns in Microservices- Part 2]]></title>
            <link>https://medium.com/@sandanimuthukumarana/deployment-patterns-in-microservices-part-2-666fac685dc4?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/666fac685dc4</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Sun, 05 Oct 2025 11:55:02 GMT</pubDate>
            <atom:updated>2025-10-07T14:08:38.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*2QOngvZKR52IyEvP.jpg" /></figure><p>Releasing new version of software has always been risky. then as software engineers how we deliver changers to the users safely? In this point deployment rollout strategies come..</p><p>From this article lets discuss about Microservice deployment patterns like Blue Green, Canary, and Dark Launch allow teams to test, release, and validate new versions with minimal risk..</p><h3>Blue Green deployment pattern</h3><p>This is strategy for releasing software updates with zero downtime and minimal risk. There are two identical production environment, a blue environment and green.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*qDa-b8S7UBbwZ7oeIoX4kA.png" /><figcaption>blue green production environment</figcaption></figure><p>Blue environment → This is the current live version of ur application.<br>Green environment → This is the new version, that u preparing to release.</p><p>lets take example.,</p><p>There is a server on there,</p><p>total num of incoming request per minute → 18000<br>to get TPS (Transaction per second) → 18000/60 = 300 TPS <br>each instance safely handle 10 TPS <br>num of instance→ 300/10=30</p><p>so u need 30 instances to serve the traffic at peak load.</p><p>so when blue green setup u need 30 instance for blue and 30 instance for green..</p><p><strong>01.Initial state</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*lhRGDpz3vtPDxvYo5T5bjw.png" /></figure><p>Here we setup two identical environment duplication and traffic routing. here blue is live and green is idel.<br>All user traffic is direct to the blue environment, its running the current version of ur application. <br>users never connect directly to the blue or green environmrnt. Thye go throught a load balancer or reverse proxy. The LB has list of active services.(in this initial state currently it only have blue servers)<br>Green is deployed and running. But ths Load Balancer does not route the traffic to it. Internally developers can still access green (through a special URL or staging route)</p><p>Here the load balancer maintain the routing table like this<br> <em>Active Environment: BLUE<br>Blue Pool: 100% traffic<br>Green Pool: 0% traffic</em></p><p>database handling- both environments usually share the same database. But only blue is actively making writes/read from real users. Green may connect to the DB for testing, but typically with fake or shadow traffic.</p><p><strong>02.Test green</strong><br>At this stage..,<br>Blue is still active (all user traffic flows to it)<br>Green is deployed with the new version but hidden from real users.</p><p>So..<br>here new app version is deployed to the Green servers/containers. And this can be do via CI/CD tools.(Jenkins,Github)<br>now..<br>green is running but not receive real requests.<br>then..<br>Health check start!!Load balancer or orchestrator (like Kubernetes, AWS ALB, NGINX) sends health check pings to Green. ex- checks CPU and memory, Ensure DB connection works..If Green responds correctly, it’s marked healthy. If not, deployment fails early.<br>Then..<br>we do automated test on green.<br>in here CI/CD pipeline usually run, Unit test → for code level verification.<br>Integration tests → DB, APIs, external services connectivity.<br>Smoke tests → Basic “does it work?” tests.</p><p>Then we do QA manually..<br>in there, Developers/testers may have a temporary URL for Green.QA team tests UI/UX, performance, edge cases.</p><p>Only if these all test are passed, we move into 3rd stage..</p><p><strong>03.Flip</strong><br>In here we update the load balancer so traffic moves from blue to green.<br>In here load balancer pool update..,</p><p><em>Blue target group weight = 100% → 0%<br>Green target group weight = 0% → 100%</em></p><p>And Kubernetes service selector change from,<br>version: Blue → version: green<br> All new request now goes to green pods.</p><p>when u flip Green become live version and blue become standby.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*AG4imHrGFKuVv3C9nOLYcQ.png" /><figcaption>Flip</figcaption></figure><p>DNS record updated to green’s IP. Not truly instant (cached record may take time).</p><p>special!!!<br>here this haven&#39;t downtime bcz it immediately switching to other one.<br>The load balancer never goes offline → it simply changes routing rules. Users don’t notice anything because there’s always one healthy environment (Blue or Green) behind it.</p><p><strong>04.Monitor</strong></p><p>Once the flip happens (traffic is routed Blue → Green),now the new environment is live and serving real users. But the process doesnt stop there.the real challenge begins ensuring Green is actually stable. here we watch green once health after the switch.</p><p>so..<br>Right after the flip, monitoring systems start collecting live metrics from multiple layers.</p><p>System-level metrics → tools like Prometheus Node Exporter, Datadog Agent, or AWS CloudWatch collect CPU usage, memory, network latency, and disk I/O.<br>Application-level metrics → internal metrics exposed via endpoints (e.g., request rate, error count, response time).<br>Database and Queue metrics → exporters gather. Database query latency, Connection pool usage ,Message queue lag (Kafka topic offsets, RabbitMQ consumer lag)<br> These metrics reveal if the new version is efficiently handling backend load.</p><p>then..,</p><p>All services in Green continuously emit structured logs and tracing data. Logs are centralized via tools like ELK Stack (Elasticsearch, Logstash, Kibana), Splunk, or Grafana Loki.<br>Distributed tracing tools such as Jaeger, Zipkin, or AWS X-Ray track the full journey of a request across microservices.<br>and..,<br>This helps detect exactly where a failure occurs — whether it’s due to a database timeout, a cache issue, or an external API failure.</p><p>To ensure real users are not affected, we use..</p><p>Synthetic monitoring tools (like Pingdom, New Relic Synthetics, or Selenium tests) run predefined user journeys (login → browse → checkout) from various global regions to test real endpoints.<br>also..,<br>Real User Monitoring (RUM) tools embedded in browsers (e.g., Google Analytics, Datadog RUM) capture client-side errors, page load times, and performance metrics in real time.<br>so..<br>This layer helps verify that the Green environment performs smoothly for actual users, not just backend systems.</p><p>and here..Preconfigured alerts continuously evaluate system health:</p><p>Example thresholds: “Alert if error rate &gt; 1% for 5 minutes.” ,“Alert if P95 latency &gt; 500ms.”</p><p>Tools like PagerDuty, Opsgenie, or Slack Integrations notify on call engineers instantly if any issue arises.</p><p>After.,</p><p>All collected metrics, traces, and logs are <strong>visualized in dashboards</strong> (Grafana, Kibana, CloudWatch). Engineers watch trends closely specially..Error rates, Response latency, Resource utilization</p><p>If everything remains stable after a set observation window (often 30–60 minutes), the deployment is declared successful.<br> If anomalies appear, the system triggers an automated or manual rollback to the Blue environment.</p><p><strong>05.Rollback</strong><br>If monitoring shows issues (errors spike, latency climbs, features break), rollback is triggered. point traffic back to blue instantly.</p><p>in here..,</p><p>Immediately redirect traffic back to Blue.<br>Users go back to the stable version.<br>Engineers investigate Green offline.</p><p>First..,<br>LB deregisters Green instances and re-registers Blue instances. Since Blue was left untouched, it can instantly serve traffic again. This change is atomic→ no downtime for users..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*i5LoRKF-iaXnlyqTZT1npQ.png" /><figcaption>rollback</figcaption></figure><p>How session and state management happen?<br>If sessions are stateless (JWTs, Redis store) → rollback is seamless. If sessions were tied to Green memory → users may be logged out after rollback. (This is why externalized sessions are a best practice.)</p><p>and how database rollback management happen?<br>If Green introduced DB schema changes, rollback is tricky..,<br>If schema migration was backward compatible → Blue continues to work.<br>If schema migration was destructive (dropping columns, incompatible writes) → rollback may fail, requiring DB restore.</p><p>That’s why DB migrations are usually done in <strong>expand → contract pattern</strong>.</p><p>How automation rollback?<br>Modern CI/CD pipelines support automated rollback triggers.<br><em>ex-<br>if error_rate &gt; 2% for 10m:<br> rollback()</em></p><p><strong>06.Cleanup</strong><br>Once the Green environment has been monitored for a while and proven to be fully stable in production, it’s time to clean up and prepare for the next deployment cycle.</p><p>After stability is confirmed:</p><p>The Green environment officially becomes the new live production system.<br>The Blue environment (the old version) now serves no active traffic. At this point, teams have two options →</p><p>Retire Blue: shut it down completely to reduce infrastructure and cloud costs.<br>Keep Blue as a rollback option: keep it running or in a suspended state (for quick re-activation if hidden issues appear in Green later).</p><p>Once it’s decided that the Blue environment is no longer needed, engineers can safely decommission it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*q4hchepBsZLJVIEkE4aUwg.png" /></figure><p>In here..</p><p>Tools like Terraform, Ansible, Helm, or CloudFormation automatically destroy the old Blue servers, containers, load balancers, and database replicas if they’re no longer required.<br>In cloud setups, this means deleting compute instances (EC2, VM, or Kubernetes pods), freeing up load-balancer target groups, and detaching old storage volumes.</p><p>and..,<br>Old Docker images or deployment packages related to Blue are either archived or deleted from registries (e.g., AWS ECR, Docker Hub) to keep environments clean and prevent confusion.</p><p>special!!!<br>The CI/CD pipeline re labels the environments marking Green as the new “Blue.”<br> For the next release cycle, a new Green environment will be provisioned again beside it.<br> This means every cycle alternates roles the newly deployed environment is always “Green,” and the current stable one is “Blue.”</p><p>after..,<br>Old environment credentials, API tokens, or secrets are revoked.<br>Network routes and DNS records that pointed to Blue are removed to prevent accidental traffic leaks or stale routing.<br>Old log streams, alert rules, and dashboards tied to Blue are archived or updated to point at the new environment, ensuring monitoring remains clean and relevant.</p><p>final outcomes are..<br>Only the healthy, optimized Green environment remains live.<br>The system is stable, cost-efficient, and ready for the next version rollout.<br>The deployment cycle resets Green becomes the new Blue, and the process repeats seamlessly for future updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*o75DKecr69upYzp4liWGCw.png" /><figcaption>final outcome</figcaption></figure><p>Why we use this?<br>We use this to mitigate risk and ensure high availability when releasing new software. The core problem solves are</p><ol><li>zero downtime → users don’t see errors while u upgrade.</li><li>Fast rollback → if the new version is bad u can instantly send traffic back to old version.</li><li>Safe testing → u can verify the new build in a production-like environment before exposing it to everyone.</li></ol><h3>Canary deployment Pattern</h3><p>A canary deployment is a release strategy where you roll out a new version of an application to a small subset of users first, then gradually increase the percentage of traffic if everything looks good.</p><p><strong>01. Prepare environments</strong></p><p>In this stage we have both versions side by side.,<br>Baseline version (v1) → The current stable version serving users.<br>Canary version (v2) → The new version you want to roll out gradually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*3qMswHceCaxb1a7OpbkC0A.png" /></figure><p><strong>in here..,</strong></p><p>Your CI/CD pipeline deploys v2 to production infrastructure but limits user access initially.</p><p>This could mean:<br>A new pod deployment in Kubernetes with updated labels. A new EC2 instance group or container service task. Both versions are connected to the same database, but sometimes v2 uses read only operations first to ensure compatibility.</p><p>The goal here is..,<br>both old and new systems are <strong>ready and running</strong>, but only v1 is getting full traffic initially.</p><p><strong>02. Route a tiny % of traffic</strong></p><p>Now, you “release” the canary..<br>it meaning,<br>only a small percentage of production users (say, 1–5%) are routed to the new version (v2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*ElA2FVpjYDGz2BiUMEr9qg.png" /></figure><p>This traffic control is done through:<br>Load balancer rules<br>API gateway routing <br>Service mesh traffic splitting</p><p>Example<br>95% of requests → v1 <br>5% of requests → v2</p><p>The routing happens using weighted algorithms, meaning each incoming request is probabilistically directed to the appropriate version.</p><p>So this allows..<br>the new version to be tested under real user load not just test traffic.</p><p><strong>03. Monitor metrics</strong></p><p>Once the canary is exposed to real traffic, observability systems come into play.<br> The engineering team watches how the canary behaves in production conditions.</p><p>some metrics monitors are..</p><p>Error rate (HTTP 5xx, failed requests)<br>Latency (response time)<br>Resource usage (CPU, memory)<br>Database query times<br>Business KPIs (conversion rate, checkout success, API revenue)</p><p>If the canary behaves normally, the system automatically flags it as <em>healthy</em>.</p><p>This is the trust but verify phase<br>you’re testing the new version with <strong>real traffic </strong>in a controlled, safe way</p><p><strong>04. Increase gradually</strong></p><p>If everything looks good after the initial monitoring window, traffic to v2 is increased step by step.</p><p>Deployment controllers automatically adjust traffic weights:</p><p>Step 1: 5% → 10%<br>Step 2: 10% → 25%<br>Step 3: 25% → 50%<br>Step 4: 50% → 100%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*voB8fVQK_Qs1u9GGA8GhUA.png" /></figure><p>Each increase is followed by a pause window (e.g., 15 minutes to 1 hour), during which metrics are evaluated again.<br>Traffic weight changes are handled by service mesh controllers (e.g., Istio Virtual Service) without restarting pods or causing downtime.</p><p>special!!!<br>The gradual rollout ensures that even if a bug exists, its effect is limited to a small user group before full exposure.</p><p><strong>05. Roll back fast if needed</strong></p><p>If any anomaly is detected for example, error rate spikes, latency increases, or business KPI drops traffic is instantly reverted back to the stable version.</p><p>The deployment controller automatically sets the traffic weight for v2 back to 0%.</p><p>then..,<br>All requests now flow only to v1 again.<br>The canary pods/instances remain running for debugging..logs and traces are analyzed.<br>Alerts are sent to the team (via PagerDuty, Slack, or Opsgenie).</p><p>special!!!<br>Since rollback only changes routing rules (not infrastructure), it happens in seconds, ensuring almost zero impact to users.</p><p><strong>06. Clean up</strong></p><p>Once v2 proves stable at 100% traffic and enough time passes without issues, it officially becomes the new baseline version.</p><p>Old version (v1) is retired:<br>Containers, pods, or instances are destroyed via CI/CD cleanup scripts.<br>Monitoring rules and dashboards are updated to reference v2.<br>Version labels are updated v2 now becomes the “stable” baseline for the next release cycle.</p><p>Optionally,<br> v1 can be kept idle for a short period as a backup, especially in high risk systems.</p><h4>Comparison to blue-green vs CANARY</h4><p>blue-green is an all-or-nothing flip. It’s fast and simple. but doesn’t allow for gradual testing with real user traffic.</p><p>Canary is a gradual controlled rollout. it more complex to manage but provide more control and is ideal for discovering issues that only appear with real user behavior.</p><h3>Dark launch / shadow traffic</h3><p>This provide solution for →<br>testing new feature or code in a live production environment without affecting end-users in there.</p><ul><li>code live in production.</li><li>Only small, controlled group (like internal staff, beta users, or specific request segments) can access it.</li><li>for the majority of people the code is invisible (dark)</li></ul><p>the benefit are<br>01. Real world testing → u test in production with real traffic <br>02. Zero user impact → users don’t see errors if new feature fail <br>03. Performance validation → u see how the new code scale under actual load.</p><p>Challenging are,<br>complexity<br>double cost<br>data consistency <br>monitoring overhead</p><p>How it works:</p><ol><li>Deploy new feature code alongside the current system into production ex: new recommendation algorithm in a shopping app.</li><li>Feature toggle / flagging system is used to control access.. by default new feature is off for all users % u selectively turn it on for test groups.</li><li>Shadow traffic (optional): <br>u can duplicate a percentage of live user requests and send them to the new feature / service but. discard is response. this way the new system is tested under real load but users only see the old response.</li><li>Monitor metrics.<br>compare performance, correctness, latency, and error rates of new vs old features.</li><li>Gradual exposure<br>slowly enable the feature for larger groups of real users.</li><li>Full release.<br>once validated u flip the feature toggle so its available for everyone.</li></ol><p>there are some ways to implement this pattern..,</p><p>Isolated idempotent: Ensures that each operation can be safely retried without causing unintended side effects, allowing reliable testing in isolation.</p><p>Dry run mode: Executes the new feature code without making actual changes, providing a safe environment to validate behavior.</p><p>Golden replay: Replays historical data through the new system to compare its output against a known baseline, ensuring consistency.</p><p>Sandbox: Creates a controlled, isolated environment where the new feature can be tested with real-like data without impacting the live system.</p><h4>Blue green Vs Canary Vs Dark launch</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*7ksOPN8iS_zBygLKhaX8UQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=666fac685dc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment Patterns in Microservices- Part 1]]></title>
            <link>https://medium.com/@sandanimuthukumarana/deployment-patterns-in-microservices-part-1-7d71d2f2bf29?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d71d2f2bf29</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Tue, 30 Sep 2025 11:00:29 GMT</pubDate>
            <atom:updated>2025-09-30T16:29:38.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*4DFUxLF-IjZMFo0w" /></figure><p>The biggest challenge in microservices is not only building them but also deploying and maintaining them. To handle these challenges, it is important to understand deployment patterns and how they can be applied to microservices.</p><p>There are two categories,</p><ul><li><strong>Container level deployment techniques</strong> (sidecar, adapter, ambassador).</li><li><strong>Service rollout strategies</strong> (blue-green, canary, dark launch).</li></ul><p>In this article , I will explain the Container level deployment techniques and take a closer look at how they work.</p><h4>Side car Pattern</h4><p>side car pattern is one of the main technique in microservices Deployment pattern..</p><p><strong>What is side car?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*Zrc1nByx90qvfUEC.png" /><figcaption>side car</figcaption></figure><p>A sidecar is an additional container that runs in the same pod as the main application service. It provides supporting functionalities such as logging, monitoring, configuration management, networking, or service discovery</p><p><strong>side car pattern structure</strong></p><p>In Kubernetes, a pod can host multiple containers. With the sidecar pattern, the pod contains both the main service container and the sidecar container. The sidecar runs independently but is tightly coupled with the main container, allowing it to enhance or extend the functionality of the service without modifying the application itself.</p><p>remember..!<br>side car is not deserve for business logic. It handle cross-cutting concerns.<br>ex-Logging, metrics collection , security, casing or proxy</p><p>Types of side car implementation<br>01.Ambassador pattern<br>02.Adapter pattern</p><h4><strong>Ambassador pattern</strong></h4><p>Ambassador pattern is microservice deployment pattern,in here there are intermediate component call ambassador</p><p>Ambassador act as proxy between main application server and remote servers.</p><p>Ambassador there are two deployment services..<br>01.Inside ambassador<br>02.Outside ambassador</p><p><strong>Inside Ambassador</strong></p><p>runs next to your app (sidecar style). Thats why this call inside ambassador .This handle outbound network traffic from the main app.<br>This deploy in the same pod/VM.</p><p>lets clarify these more using real world example..</p><p>imagine in your pod u have employee service. This employee service made with outdated old technology. And there are another new technological ERP system. Then employee service want to access that ERP system. But it cant because it need modern libraries. But employee service didn&#39;t have that and also updating a employee service is not easy..</p><p>So solution is..,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*NMGZURUnNaF9husnV7gBwg.png" /><figcaption>Inside ambassador</figcaption></figure><p>We can deploy employee service and ambassador container together in one pod. It calling local endpoint.(ex:http://localhost:9000) Then the ambassador process take that call and then.,<br>Converts the request into the format the ERP expects.<br>Sends the request to the remote ERP system.<br>Receives the response.<br>Translates it back and returns it to the Employee Service.</p><p><strong>Common Scenarios →</strong></p><p>01.Legacy service integration<strong><br></strong>Old app can’t talk to modern systems (needs modern libraries).<br>Example: Old Employee Service talks to new ERP through ambassador.</p><p>02.Protocol translation<br>Your service speaks HTTP, but the target system only accepts gRPC, SOAP, or some custom protocol. The ambassador does the conversion.</p><p>03.Retries &amp; failover<br>Your service calls an external API that may fail.<br>Ambassador adds retry, timeout, circuit breaker logic → your service stays simple.</p><p>04.Connection pooling<strong><br></strong>Ambassador manages DB or cache connections for efficiency.</p><p>05.Security outbound<br>Your service doesn’t know how to attach OAuth/JWT tokens, but ambassador automatically attaches them.</p><p>there are Advantages and Disadvantages..</p><p><strong>Advantages →</strong><br>Simplifies app code. App only talk to the localhost.<br>Easier upgrades by changing the ambassador configuration<br>Great for legacy application that don&#39;t support.</p><p><strong>Disadvantages →</strong><br>as every instance it has its own ambassador.it can cuz to that overhead..</p><p><strong>Outside Ambassador</strong></p><p>runs Infront of the application services. like gateway or proxy.This runs as its own service, not the same pod. It lives in a difference pod. So this call as Outside ambassador. This handle inbound traffic to the main application.</p><p>let me explain these using an example..<br>imagine u have, Employee service, customer service Both services need to interact with external gateway. Now this payment gateway required authentication tokens, retries on failures, logging and specific API format.<br>so if each service implement the logic on itself it hard to maintain, can duplicate..</p><p>the solution is outside ambassador</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNGvTqy5bRRzctc2x4IOYA.png" /><figcaption>outside ambassador</figcaption></figure><p>Deploy a single ambassador container as a separate service (can be in its own pod).<br>here ambassador handle..</p><ul><li>Authentication tokens</li><li>Retries on failure</li><li>Logging and monitoring</li><li>Converting service requests to match the Payment Gateway API</li></ul><p><strong>Advantages</strong></p><p>As centralized communication it easy to maintain.<br>Service stay simple and independent.<br>Can scale if need</p><p><strong>Disadvantages</strong></p><p>Single point of failure if not scaled.</p><p><strong>Common scenarios →</strong></p><p>API gateway/ Security layer- protects ur service from the internet. Adds authentication, rate limiting, request validation.</p><p>Monitoring and Logging — Outside ambassador logs all traffic before it reaches your service.<br>Useful for audits and debugging.</p><p>Traffic shaping / throttle — Ambassador slows down or limits requests to prevent overloading the service</p><p><strong>Adapter pattern</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2AumTv9VKb1hPQXCG7h4g.png" /><figcaption>adapter pattern</figcaption></figure><p>The Adapter Pattern allows two components with incompatible interfaces to work together by putting a translator (adapter) in between.</p><p>let me explain…<br>u have written code. It expect data in JSON. An old library only returns Linstead of writing everything, u write an adapter that receives XML , convert it to JSON. gives it back to ur code..</p><p>Microservices are often heterogeneous, they build in difference languages, by using difference protocols.(eg:REST, gRPC, SOAP, Kafka)</p><p>Adapter pattern in microservice mean, deploying an adapter container that sides between two services with incompatible communication. It translate one protocol /format into another.</p><p>example..,</p><h4>Example in Kubernetes</h4><p>Imagine:</p><ul><li>You have a Java App that exports monitoring data in JMX format.</li><li>Your monitoring tool (Prometheus) only understands Prometheus metrics format.</li></ul><p>Solution:</p><ul><li>Run your Java App container in a Pod.</li><li>Add an Adapter Container (JMX-to-Prometheus exporter).</li><li>Prometheus scrapes the adapter, not the Java app.</li></ul><p>So the Adapter Container acts as the bridge between app-specific data and the monitoring system’s expectations..</p><p><strong>Inside Adapter</strong></p><p>The adapter lives inside the microservice boundary (in the same pod/container group).It is tightly coupled to one service → acts like a translator that only this service uses. Commonly seen as a sidecar container.</p><p>example..</p><p>there are Billing service and also there Lagacy ERP system. Billling service only knows Rest/JSON, but legacy ERP requires SOAP/XML..<br>Inside adapter container translate REST → SOAP for outbound calls.</p><p><strong>Outside Adapter</strong></p><p>The adapter lives outside the microservice boundary (separate service or gateway).It can serve multiple services as a shared translator/proxy. Exposed as an external entry point.</p><p>example..</p><p>There are Legacy payroll Service it expose SOAP/XML. And there are new HR service it expect REST/JSON. Outside Adapter exposes REST endpoints → converts to SOAP for Payroll.</p><p><strong>Why Adapter pattern?</strong><br>It reduce existing code/system without rewriting. <br>To decouple systems for external dependencies.<br>To standardize communication in distributed environment.</p><p>Sidecar, Adapter, and Ambassador patterns focus on how containers collaborate inside a pod to handle complexity. But what happens when we want to release a <em>new version</em> of a service in production without causing downtime or user disruption? That’s where deployment rollout strategies like <strong>Blue-Green, Canary, and Dark Launch</strong> comes..</p><p>Lets discuss them from next article…!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d71d2f2bf29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Routing Patterns and Resilience Patterns in Microservices]]></title>
            <link>https://medium.com/@sandanimuthukumarana/routing-patterns-and-resilience-patterns-in-microservices-cd43bde3b117?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd43bde3b117</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 04:24:09 GMT</pubDate>
            <atom:updated>2025-09-22T04:24:09.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXt58IB3JElBk2pYCTJHLw.png" /></figure><p>Today from this article., lets discuss about some design patterns in microservices….from very simple to high level.</p><p>Before talking about pattern it’s essential to understand the two main types of <br>traffic that flow through a microservices architecture. Look at following diagram..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KM2A2nCVbrDWZ3NyNBIxYQ.png" /><figcaption>how north south and east west traffic works</figcaption></figure><ul><li><strong>North-South Traffic:</strong> This is the external traffic that flows <strong>into and out of</strong> our microservices cluster. It represents the communication between a client and our backend services.</li><li><strong>East-West Traffic:</strong> This is the internal traffic that flows <strong>inside</strong> the cluster, representing the communication between different microservices themselves.</li></ul><p>Given these definitions, the first patterns we should discuss are the ones that manage these two types of traffic.</p><p>For North South Traffic, the most fundamental pattern is the API Gateway. It serves as the single point of entry that handles all incoming external traffic and routes it to the correct backend service. Once a request has been routed by the gateway and is inside the cluster, the next challenge is for that service to communicate with other services. This is where patterns for East West Traffic comes, such as Service Discovery and Client-Side Resilience (like Circuit Breakers and Timeouts), which are crucial for managing the internal communication between microservices.</p><p>First talk about..</p><h3><strong>API gateway..</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WwgH5x6uXAn7DScyODcxg.png" /><figcaption>API gateway in microservice</figcaption></figure><p>API gateway is centralized entry point for manage client request, and routing them for appropriate backend services.</p><p>The <strong>API Gateway</strong> is the central and most important pattern for managing traffic in a microservices architecture. It is the single tool you use for your entire API management.</p><p>The reason it’s so powerful is that it includes many capabilities to do its job. One of its main and most fundamental capabilities is acting as a <strong>reverse proxy</strong>.</p><p>so..<br>what is …</p><h3><strong>Proxy</strong></h3><p>A proxy is a server or software that act as intermediary between client and server..</p><p><strong>01.Forward proxy</strong></p><p>Placed Infront of client. Hide the client identity from the server. Server doesn&#39;t know the client. Client aware they are using proxy.<br>ex- Company network proxy that filter the employee internal traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*digAYRErAKi26-95rNojMA.png" /><figcaption>Forward proxy</figcaption></figure><p><strong>02.Reverse proxy</strong></p><p>Placed the Infront of services. hide the servers from client<br>ex- NGINX <br>Here client don&#39;t know about the proxy..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jgug6-nJY35DiAMGwF2ZWQ.png" /><figcaption>reverse proxy</figcaption></figure><p>By using API gateway and proxy we can talk to each other services ..But each server scale further. Each server have multiple instances. They running at the same time. To call them we use different technique.<br>We call it as….</p><h3>Discovery pattern</h3><p>The core component of this pattern is the <strong>Service Registry. <br></strong>When a service starts, it <strong>registers</strong> itself with the Service Registry, providing its location and health status. When a service needs to communicate with another, it <strong>looks up</strong> the location of that service in the registry</p><p>There are two main ways can lookup happen..</p><p><strong>01.Client-side Discovery</strong><br>Client responsible for discovering service instance.</p><p>process →<br>when a client wants call a service, it first contact service registry.<br>ex- order service →registers 10.0.0.5: 8080</p><p>The service registry give back list of available instances. Then the client pick one instance to call. It can use load balancing strategy.</p><p>After choosing, the client makes the network call directly to that instance.</p><p>Look at following example..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KE4EiDYAOgaZSjDVoCpkw.jpeg" /><figcaption>E Commerce application</figcaption></figure><p>API gateway &amp; get the request. And it looks at the path of request it check routing table and request go to order service.</p><p>And then API gateway asking from service registry about available instance at order service. And it gives available Instances and next API gateway choose one of them using load balancing technique</p><p>then the API gateway internaly forward a request to the chosen order service instance.</p><p>order service instance got the request. then process it.</p><p>Sent back response to the API Gateway.</p><p><strong>02. Server-side Discovery</strong></p><p>In server-side discovery, the client doesn’t need to find service instances by itself.<br>The client just sends a request to a load balancer (or API Gateway).</p><p>Process →</p><p>When the client wants to call a service, it sends the request to a load balancer / gateway instead of directly contacting the service registry.</p><p>The load balancer is the one that talks to the service registry and gets the list of available service instances.</p><p>It then chooses one instance (using round-robin, random, etc.) and forwards the request to that service instance.</p><p>The service instance processes the request and sends the response back → through the load balancer → to the client.</p><p>Example →</p><p>A client wants to call the Order Service.</p><p>It sends the request to the API Gateway.</p><p>The gateway checks the service registry for available instances of the Order Service.</p><p>The gateway uses a load balancing strategy to pick one.</p><p>It forwards the request internally to that Order Service instance.</p><p>The instance processes the request and sends the response back to the gateway, which then returns it to the client.</p><h3>BFF -Backend for frontend Pattern</h3><p>this is architectural pattern, where separate backend service is build for each specific front end client.</p><p>In normal way,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPVT1MVssNnUHI1XReHBpw.png" /></figure><p>→this can be disconnect between backend and frontend team.</p><p>→ Sharing one backend means every change must be coordinated with other frontend teams, which shows things down</p><p>As solution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_a6K0IuDIDrSnqw5BvtoA.png" /></figure><p>→ introduced new layer between frontend and the backend. this call backend for frontend CBFF)</p><p>→ each type of frontend get it own BFF</p><p>this BFF ,</p><p>→ handle only what FE need.</p><p>→Makes app faster and easier</p><p>How this work?<br>→ Web client sends request like Get / Web/profile to the API gateway.</p><p>→ API gateway read… /web/ part. so then this direct to web BFF.then it use service registry to find running instances.</p><p>→ Web BFF receive the request for / profile. then it know what are the details to use. it send requests to particular microservices</p><p>In microservices</p><p>the common error is cascading Failure to avoid that. We can use some routing patterns</p><h3>Circuit breaker pattern</h3><p>this act like electrical circuit breaker. It monitors calls to a service and it detects a certain numbers of failures or timeouts</p><p>Client → Order Service → Payment Service.</p><p>if payment service have performance issue. it doesn’t crash, but become extremely slow</p><p>now a request come to order service to process a new request .the order service send request to payment service . there is no circuit breaker.</p><p>so the order service has no choice. it has to be wait for payment service to respond. As it waits, it holds on to a valuable resource a thread</p><p>As more and more request come in , same thing happen each new request to the order service.</p><p>it use one thread from its pool to handle it.Soon there all threads left. So order service can’t start new work because all its threads are sitting idle waiting for slow responses.</p><p>Solution →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBpQAKm5DSUkjadBUf6j4Q.png" /></figure><p>the circuit breaker watches calls from order service → payment service. it quickly detects that the calls are failing</p><p>When it detects &amp; enough failures, it stops sending new calls to the slow service. this call Trip.</p><p>Fail Fast — instead of waiting 30 s, the order service immediately gets quick error. (payment unavailable )</p><p>preserve resources :-because of error is fast, thread don&#39;t stay blocked, they go back to the pool.</p><p>Contain failure = Order service can still answer other requests. (Check order history )and doesn&#39;t drag the gateway down.</p><p>Recovery: After some time ,the breaker can “half — open” to test if payment service has recovered.</p><h3>Timeout</h3><p>in microservice architecture services depends on each other. if one service (service A) call another service (Service B) and service B is slow or unresponsive, service A will sit and wait.</p><p>While A is waiting ,<br>- it keeps one of its worker threads busy<br>- more Calls come in, → more threads get stuck<br>- it runs out of threads → it can’t handle any request at all<br>- other services (or the API gateway) that depends on<br>A also get stuck.</p><p>timeouts stop this from happening⁠</p><p>this tell your service, if u doesn’t hear back x milestone, Stop waiting.</p><p>How this works →<br>• Configuration.<br>You decide how long to wait (eg: 5000 ms = s o).<br>You set this in code or configuration file for each network Call</p><p>• Service A — → service B<br>Same moment timer start counting</p><p>• If B responds before the timer ends →it success <br>If timer expire first → timeout</p><p>• When timeout happens the caller is cancelled..A timeout exception is thrown. the waiting thread freed.</p><p>error handing →</p><p>After catching exception A can choose:<br>retry (for different instance)<br>Fall back (return cached.)<br>return a error to its caller.</p><p><strong>Circuit breakers Vs Timeout.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9w75Tpu4FBzEbI_DOBQ2w.png" /></figure><p>The slow service scenario <br>Client → order service → payment service</p><p>payment service become slow.<br>without timeout :- order service waits the full 10s for every call ,holding threads. Circuit breaker never see failure. because technically the call succeed after 10s.<br>order service run out of threads → cascading failures.</p><p>Timeout fix this — After 2s, the call is aborted with timeout exception.</p><p>order Service release the threads an can serve other request.</p><p>but if u only use timeout, the caller will keep trying every request and aborting after 2 s. that still loads the payment service and wastes resources.</p><p>After adding circuit breaker ,it count timeout (failures)</p><p>After the threshold (eg: 5 Failures )it opens the Circuit and order service stops calling payment for cool down period.</p><h3>Exponential Backoff</h3><p>In distributed systems, failures are normal.<br>When a client request fails, it may retry immediately.<br>But if thousands of clients retry at the same time, a <strong>thundering herd</strong> problem happens.</p><h4>Solution</h4><p><strong>1. Initial request fails</strong></p><ul><li>Order Service → calls → Payment Service to charge a customer.</li><li>But the Payment Service is overloaded and responds with 503-Service unavailable error.</li></ul><p><strong>2. Native retry (no backoff)</strong></p><ul><li>The Order Service immediately retries.</li><li>Thousands of other clients get the same error and retry at the same time.</li><li>The Payment Service gets hit with a big spike of traffic.</li></ul><p><strong>3. Retry with Exponential Backoff</strong></p><ul><li>Instead, the Order Service waits before retrying.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QCxovCmNcLT_YBy7ikXDyQ.png" /></figure><ul><li>The wait time increases after each failure.</li></ul><p>Now imagine if all the clients or services use the exact same backoff schedule-they can still hit the system at the same time (the <strong>thundering herd</strong> problem).<br> So we add a <strong>jitter</strong> value.</p><h3>Jitter</h3><p>Jitter is a small random variation added to the wait time in an exponential backoff algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AVpn_ZKXHvb8vuBderXTg.png" /></figure><p>How to add Jitter →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7x2-vzgFTOFYBUyk552WYw.png" /></figure><h3>Hedging</h3><p>Hedging is a <strong>client-side latency reduction strategy</strong>.</p><p><strong>Example →</strong><br> The Order Service needs to make a call to the Payment Service to authorize a new order.</p><p>Order Service — — call — → Payment Service</p><p>The Payment Service has several running instances, but a few of them might currently run slowly due to high load or temporary issues.</p><p>We want to ensure our Order Service does not get stuck with a slow service instance.</p><p>A typical healthy service may take ~40 ms to respond, so we configure the <strong>hedging timeout</strong> to 50 ms.</p><h4>How it happens</h4><p><strong>Time = 0 ms:</strong><br>Order Service sends request1 to Payment Service <strong>instance A</strong>.</p><p>Order Service — request1 → Payment Service (instance A)</p><p><strong>Time = 50 ms:</strong><br> If there’s still no reply from instance A, the Order Service decides to hedge.</p><p><strong>Time = 50 ms:</strong><br> It sends request2 to Payment Service <strong>instance B</strong>.</p><p>Order Service — request2 → Payment Service (instance B)</p><p>The first successful response (from A or B) is taken, and the other is ignored.<br> This reduces latency if one instance is slow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ON7xN3w-4ZZG2Ihz11Uk4A.png" /></figure><p><strong>Time = 90 ms:<br></strong>B replies (40 ms take to process)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SOlyHB9tpQgQ-4sdl5FoMg.png" /></figure><p><strong>Time = 150 ms:</strong></p><p>A → reply <br>but respond discard</p><h3>Bulkhead Pattern</h3><p>provide isolated resources to each dependencies</p><p>in a microservices system a single service often depends on multiple other systems/services.</p><p>imagine..<br>Order service call payment service<br>Order service call shipping service</p><p>without bulkhead,</p><p>Order service uses a single, shared pool of resources for all its outgoing network calls.</p><p>If payment service becomes slow or unresponsive All the threads in the pool get stuck waiting for payment response. <br>Now there are no threads left to call Shipping Service (which is healthy), <br>the entire order service becomes unresponsive.</p><p>Solution</p><p>Bulkhead pattern prevents this by partitioning resources. <br>So each dependency gets its own compartment.</p><p>→ Create separate, dedicated, limited pool of threads for each dependency.<br>→ If one pool fills up, only the related functionality is affected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60mztqSO9RQfXvKFcxVVVQ.png" /></figure><p>→ If payment service misbehaves and consumes all 20 threads, that does not affect the shipping service.<br>→ Now the problem is solved.</p><h4>Client side vs Server side patterns.</h4><p><strong>Client side</strong><br>A design pattern implemented in the service making the request to another service. <br>Protects the service sending request from failures or slowness.</p><p><strong>Server side</strong><br>A design pattern implemented in the service receiving requests from other services. <br>Protects the service receiving requests from too many or bad requests.(Rate limiting, load shedding)</p><h3>Rate limiting</h3><p>A way to control how many requests a service will accept in a given time period.<br>Why:<br> To protect the service from being overloaded by too many calls at once.</p><p>Example:</p><p>An API only allows 100 requests per second from a client.If the client sends more, extra requests are blocked or delayed (often returning a 429 too many request error).</p><p>Helps keep the system stable and fair for all users.</p><h3>Load Shedding</h3><p>What it is:<br> When a service is already at its maximum capacity, it <strong>rejects new requests</strong> instead of trying to handle them all.</p><p>Why:<br> So the service can keep working well for current requests, rather than slowing down or crashing.</p><p>Example:</p><p>A payment service can only handle 500 calls at a time.</p><p>If 600 calls come in, it immediately rejects 100 (maybe with a 503 service unavailable error).</p><p>Like a restaurant saying “we’re full” instead of letting too many people in and ruining everyone’s meal.</p><h3>Back Pressure</h3><p>A signal from the service to tell clients or upstream systems to slow down sending data when it’s overwhelmed.</p><p>This happen because..<br>Prevents queues from growing too big and keeps memory/CPU under control.</p><p>Example:</p><p>A streaming service can process 1,000 messages per second.</p><p>If it starts lagging, it asks the sender to reduce speed or pauses message delivery until it catches up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd43bde3b117" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Java’s ClassLoader Delegation Model]]></title>
            <link>https://medium.com/@sandanimuthukumarana/understanding-javas-classloader-delegation-model-6e8d50ad5105?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e8d50ad5105</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 00:15:41 GMT</pubDate>
            <atom:updated>2025-09-10T04:53:38.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*IaPvIL3_uP3pv-Es.jpg" /></figure><p>Have You ever wondered how actually loads your Java classes at runtime?From this article, I discuss how the JVM uses ClassLoaders to bring .class files into memory, the different types of ClassLoaders involved, and how the delegation model controls the loading process. I’ll also explain it with my assignment example so you can clearly see what happens behind the scenes when a Java program runs.</p><p>Every Java program starts its life as a simple text file(.java file) In there we write our classes and methods. But the computer doesn’t understand this plain Java code directly. So the first step is compilation.</p><p>When we compile the file, the Java compiler translates our human readable code into bytecode, It is stored inside a .class file.<br>Then we come the interesting part.. when we run the program using the java command, the Java Virtual Machine (JVM) takes over. But the JVM doesn’t gobble up the entire bytecode at once. Instead, it loads classes only when they are needed. And this is where the ClassLoader system comes into the stage..</p><p><strong>what are the class loaders?</strong></p><p>In simple terms, a ClassLoader is a part of the JVM loading area. It loading .class files into memory. When the program needs them they are ready to be used.</p><p><strong>What are the types of class loaders?</strong></p><p>Java uses different ClassLoaders to organize and manage how classes are loaded into memory. Each ClassLoader has a specific role, depending on the type of class it loads. The main types are,</p><p><strong>Bootstrap ClassLoader</strong></p><p>The highest level loader in Java. This responsible for loading core Java classes, such as java.lang.String and java.util.List.</p><p>Written in native code, so it’s part of the JVM itself.</p><p><strong>Extension (or Platform) ClassLoader</strong></p><p>Loads classes that extend the functionality of the core Java platform. Typically loads classes from the jre/lib/ext folder or other extension directories.</p><p><strong>Application (or System) ClassLoader</strong></p><p>The loader that handles your own project classes.It Loads classes from the classpath…for example, the folder where your compiled .class files are located</p><p>Each of these ClassLoaders has a clearly defined responsibility, making it easier for the JVM to organize and manage all the classes your program might use.</p><p><strong>What is the Delegation model?</strong></p><p>Now u know each one has its own responsibility, but how do they work together when a class needs to be loaded?</p><p>This is where the <strong>Delegation Model</strong> comes. Instead of each loader acting alone, Java uses a parent first approach. Whenever a ClassLoader is asked to load a class, it first delegates the request to its parent. Only if the parent cannot find the class does the loader attempt to load it itself.</p><p>It mean,</p><ul><li>The Application ClassLoader asks the Extension ClassLoader first.</li><li>The Extension ClassLoader asks the Bootstrap ClassLoader first.</li><li>The Bootstrap loader is the last resort.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g0Ds5Wk0A0svpMOpHIQU5g.png" /></figure><p>Look at following diagram,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KgCOtJI1nWhIazW1HLMJA.png" /></figure><ul><li>The request first reaches the Application Class Loader. Instead of immediately attempting to load the class, it delegates the request to its parent, the Extension Class Loader, without checking its own capability.</li><li>The Extension Class Loader then delegates the request further to its parent, the Bootstrap Class Loader, without attempting to load the class itself.</li><li>The Bootstrap Class Loader, responsible for loading core Java classes (e.g., java.lang.* from rt.jar), evaluates the request. If it cannot handle the class, it passes the responsibility back to the Extension Class Loader.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTrs_a2ZDFQc3m-GJNwy0g.png" /></figure><p>The Extension Class Loader then checks if it can handle the class. If it can, it loads the class at this level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8oN_TWmTbDsfxyhWVZup6Q.png" /></figure><p>If the Extension Class Loader cannot handle it, it delegates back to the Application Class Loader. The Application Class Loader then assesses and loads the class if it is within its classpath.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkO6Z5YOIrcdL4mdw-RiWg.png" /></figure><p>If all three loaders Bootstrap, Extension, and Application fail to handle the request, a Class Not Found Exception is thrown.</p><p>Lets Discuss how ClassLoaders work using Hands-On Example..</p><p>To see them in action, I played a little game with my Employee.class..I kept moving it into different shelves and watched who came to pick it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwgDtBnjjTp8TpSRXWgkUQ.png" /><figcaption>Main.java class</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*PY8SHvUvGMOtWHfzPcKllA.png" /><figcaption>Employee.java class</figcaption></figure><p><strong>Case 1 → Employee in the Project Folder</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayN5vZPkj4D4c14BHm4cXg.png" /></figure><p>I compile this java files and created class files.And run the Main. This is the output i got from this case.It says class loading in Application class loader.(Appclass loader)<br>This happen because when the JVM starts, it first asks the Bootstrap and Extension loaders if they can find the class. If they cannot, the request is passed down to the Application loader. Since Employee was in the project folder, the AppClassLoader successfully loaded it.</p><p>All normal user-defined classes are loaded this way by default.</p><p><strong>Case 2 → Employee in </strong><strong>jre/lib/ext</strong></p><p>In this case i want to store my Employee class file in jre/lib/ext directory. So firstly i convert this .class file to .jar file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*op-5s7yEg5BJ2xbglZEY4w.png" /></figure><p>After created .jar file your files look like above. Then Moved the JAR file into the Java Extension folder, Now we have .class file in our normal class path and .jar file in our ext folder. Both have resources. Lets look which class loader loaded the Employee class object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1enlmdpkSAd49A2p9-eDUw.png" /></figure><p>It say ext class loader..That mean extention class loader. The JVM no longer lets the Application ClassLoader load it. Instead, it delegates up the chain, and the Extension ClassLoader<strong> </strong>takes over.</p><p><strong>Case 3 → Employee in </strong><strong>jre/lib</strong></p><p>I moved the JAR into the jre/lib folder. It is where rt.jar lives..this is where the JVM’s core classes like String and Object are stored. Then i run the Main. Now, the output showed something different</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*jpfJv_3E1dtnP0SDyUDdFw.png" /></figure><p>The class was still loaded by the Extension ClassLoader, not the Bootstrap loader as I expected.</p><p>Why?</p><ul><li>The Bootstrap loader is not dynamic.</li><li>It only loads the core platform classes that are packaged inside the JDK itself (like java.lang.* , java.util.* , etc.).</li><li>Even though I placed Employee.jar inside the lib folder, it did not magically become part of the Bootstrap class path.</li></ul><p>The delegation model keeps Java’s class loading secure and consistent by following a clear hierarchy Bootstrap → Extension → Application. This practicle shows this in action.. depending on where the Employee class is placed, a different loader takes charge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e8d50ad5105" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exception Handling in Java]]></title>
            <link>https://medium.com/@sandanimuthukumarana/exception-handling-in-java-e3b9e33282bf?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3b9e33282bf</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 06:01:21 GMT</pubDate>
            <atom:updated>2025-09-20T15:57:22.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*aJxTIgDDEhhTKJRf.jpg" /></figure><h3>What is Exception ?</h3><p>In simple term Exception is like something out of order. It is an event, that occurs during program execution. It will disturb your program normal flow.</p><h4><strong>Exception Object</strong></h4><p>When exception happen in runtime environment it creates a exception object. It have,</p><blockquote>01.What is type of exception and what is the message<br>02.stack trace</blockquote><p>and then it find the class to handling exception.</p><p>Stack tree is sequence of method call, it start from the exception object created method define from where the error happen and end in top level caller, unless it catch earlier.</p><p><strong>example-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCRzYbwW6xHbEgpOiIxxnA.png" /></figure><p>Okay. Look at the following example to understand more about exception object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzA6v36ulJeSIlC7xs9RHA.png" /></figure><p>Then the output message looked like bellow. Actually this is like printed representation of exception object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mbg5luSbhw-cPrt-24KwlQ.png" /></figure><p>Lets discuss how the exception handling in JVM.</p><h3>Internal Working of Exception Handling in JVM</h3><p>When an exception occurs in Java, the JVM (Java Virtual Machine) handles it internally through a series of low-level steps involving the call stack and the heap memory area.</p><p><strong>How JVM Handles Exceptions Internally</strong></p><p>Exception Object Creation:</p><ul><li>When an exception happens inside a method (e.g., division by zero), the JVM creates an exception object on the heap.</li><li>This object contains details about the exception type, error message, and the program state including the stack trace.</li></ul><p>Throwing the Exception:</p><ul><li>Creating and passing this exception object to the runtime system is called “throwing” an exception.</li><li>The throw instruction pauses normal execution and initiates exception handling.</li></ul><p>Searching for the Exception Handler (on Call Stack):</p><ul><li>JVM searches backwards through the call stack starting from the method where the exception occurred.</li><li>It looks for a method with an appropriate catch block that can handle this exception type.</li><li>This search moves up method calls in the reverse order they were invoked.</li></ul><p>Handling or Propagation:</p><ul><li>If the JVM finds a matching exception handler, it transfers control to that handler and passes the exception object.</li><li>If no handler is found in the entire call stack, JVM invokes the default exception handler, which: Prints the exception details and stack trace. or Terminates the program abnormally.</li></ul><p><strong>Exception Object and Heap Area</strong></p><ul><li>The exception object is allocated in the heap memory because: Heap stores all objects created during execution, including exceptions.</li><li>The object includes the stack trace, which is an array with stack frames of method calls, also stored on the heap.</li><li>The call stack stores frames of active methods but does not store the exception object itself.</li><li>Since the exception object persists until handled or program termination, the JVM manages its lifecycle and garbage collection in the heap like any other object.</li></ul><p>Now that we know how the JVM handles exceptions inside, let’s look at how Java organizes all the different kinds of exceptions. This is called the Exception Hierarchy. It helps us understand which exceptions are related and how Java groups them into categories so we can handle them better.</p><h3>Exception Hierarchy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*C2w5NTb99l5-Zfpu" /></figure><p>In Java, Throwable is the <strong>superclass</strong> of all errors and exceptions.<br>It is part of the java.lang package.<br>Error- we cant recover errors.<br>Exception- we can recover exception. exceptions are two types.<br> 01.Checked exception<br> 02.Unchecked exception</p><h3>Unchecked exception</h3><p>An unchecked exception occurs during program execution(during runtime) and the compiler does not require it to be handled. They represent programming errors or bugs, such as logic mistakes. Examples include NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticException, and IllegalArgumentException.</p><h3>Checked exception</h3><p>These exceptions are <strong>checked</strong> at compile time by the Java compiler.<br>These are exceptions that the <strong>compiler forces you to handle</strong>. That means If a checked exception is not handled or declared, the program will not compile.<br>Examples include IOException, SQLException, FileNotFoundException, and ClassNotFoundException</p><h3>Exception handling methods</h3><p>We can handle exception by using two methods.<br> 01.Using throw keyword<br> 02.Using try catch</p><p>First, try by using Throw keyword,</p><p>look at following example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xE7zCHhDIsaq2YZISG5T3g.png" /></figure><p>It give this output as a error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1ZkECJPavhJ9ljoKVOkXQ.png" /></figure><p>Lets try to fix these by adding <strong>throws,</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxiAa_XsF7S6_3S5qdr18w.png" /></figure><p>In here throws say<em> This method may throw these exceptions; so pls caller handle it appropriately.</em></p><p>caller means method who call this method. so according to our case caller is main method. So main method need to handle it. Then error line removed from method1() and then u can see the new error line in main method. To remove this we can again throw this exception like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hS1Wq2B84Yx4LmLBbzQLKw.png" /></figure><p>This main method also throw it. So then our program terminate appropriately.\</p><p>Lets try using try/catch block,<br>this is actual handling throwing is only delegate exception to handler. Here in try catch block u can see how can actually handling this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QnlBY-9wIYfJsvhKdwGpNw.png" /></figure><p>In here we don’t put throws keyword. It mean we are not delegating our handling task to main. method1() only handle it. We have put try block. inside of this try block we can put our code which there can possibility to get exception.</p><p>In above code catch check if exception method match to this it catch it. Then it goes to inside it and execute it.</p><h4>How to write Exception Handling?</h4><p>Using : try, catch, finally, throw, throws</p><p>try -</p><p>Inside this u can put the code which can throw an exception.</p><p>catch -</p><ul><li>Used to <strong>handle the exception</strong> thrown in the try block.</li><li>You can have multiple catch blocks for different exception types.</li></ul><p>finally-</p><ul><li>A block that <strong>always executes</strong>, whether an exception occurs or not.</li><li>Usually used for <strong>cleanup</strong>, like closing files or releasing resources.</li></ul><p>throw-</p><ul><li>Used to <strong>actually throw an exception</strong> from a method or a block of code.</li><li>Only <strong>one exception object</strong> can be thrown at a time.</li></ul><p>throws-</p><ul><li>Use to create any new kind of exception.</li><li>It does <strong>not handle the exception</strong>, just passes it to the caller.</li></ul><h3>Best Practices in Exception Handling</h3><p><strong>1.Don’t Catch Exceptions You Can’t Handle<br></strong>Avoid catching exceptions unless you can meaningfully handle or recover from them. Unnecessary catching can obscure errors and make debugging harder.</p><p><strong>2.Catch Specific Exceptions, Not the Parent Exception<br></strong>Always catch the most specific exception type relevant to the error instead of using a generic Exception class. This ensures precise error handling and avoids masking unrelated issues.</p><p><strong>3.Do Not Catch Errors<br></strong>because we cant handle errors.</p><p><strong>4.Do Not Swallow Exceptions<br></strong>Avoid empty try-catch blocks. Empty catches can hide errors, making it difficult to diagnose issues. Always log or handle exceptions appropriately to maintain transparency.</p><p><strong>5.Do Not Throw Exceptions from a Finally Block<br></strong>Throwing exceptions in a finally block can suppress other exceptions thrown in the try or catch blocks, leading to loss of critical error information.</p><p><strong>6.Do Not Log Every Time You Throw an Exception<br></strong>Avoid redundant logging when throwing exceptions, as it can clutter logs and confuse debugging. Log only when necessary, ensuring logs are meaningful and actionable.</p><p>This wrap up summarizes the importance of exception handling and try to apply the best practices for better code quality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3b9e33282bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Garbage Collection Algorithms in Java]]></title>
            <link>https://medium.com/@sandanimuthukumarana/garbage-collection-algorithms-in-java-4a758411750e?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a758411750e</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 05:13:29 GMT</pubDate>
            <atom:updated>2025-08-24T13:42:06.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*WWrQZ90DFoehnCcC" /></figure><p><strong>What is it?</strong><br>Garbage collection is automatic process of eliminating unnecessary objects from memory.<br>in C++ <strong>→</strong> we have to delete unwanted objects manually.<br>Java<strong> → </strong>Java Garbage collector do it for u.</p><p><strong>When garbage collection is happen?</strong></p><p>01.Making reference null<br>Car car1=new car();<br>car1=null;</p><p>02.Assign reference values to others<br>Car car1=new Car()<br>Car car2=new Car()<br>car2=car1</p><p>03.Using anonymous objects<br>myMethod(new Car());</p><p><strong>Garbage Collection Algorithms in java</strong></p><h3><strong>01.Mark and sweep</strong></h3><p>This has most natural garbage collection method. To understand this first u have to understand about heap and non heap memory.</p><p><em>Heap memory-<br>Heap is a memory area. It hold all, the objects create by using new keyword. It manage by garbage collector.<br> <br>Non heap memory-<br>This is also inside the JVM but outside the heap.It is used to store class structures, methods, and other JVM-level data.</em><br> <br>In a heap’s object are reachable from a non heap references we call it as alive method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17ktUmhO-ZldfWw5_AJ5gQ.png" /></figure><p>In Mark sweep algorithm first have to find all the non heap references. We call these as roots.(root = non heap references)<br> <br>Then we start pointer chasing. There we follow any references in any heap object we encounter and then we mark them. This part is the mark part in mark sweep algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acxfm3fWiAftfvgaSptw6Q.png" /></figure><p>Lets move to the sweep phase. now in the heap there are non mark methods we consider them as garbage and sweep them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szc6Vg3GgpeeXadFlRwjWw.png" /></figure><p>That’s how sweep part completed. In here mark and sweep algorithm, GC happen in indirect way. That means first mark all the alive methods and then identify garbage.</p><p><strong>Pros</strong></p><ul><li>Can handle cycles well (it knows when objects point to each other).</li><li>Easy to use and works well for small memory sizes.</li></ul><p><strong>Cons</strong></p><ul><li>The program has to stop for a long time during garbage collection, specially if memory is big.</li><li>Leaves memory in small scattered pieces, which makes it harder to use efficiently.</li><li>Becomes slow for large memory because it has to scan everything.</li></ul><h3>02.Generational Garbage Collection</h3><p>This is based on the idea that most objects die young (for example, temporary variables). So the heap is divided into generations <strong>Young Generation</strong> and <strong>Old Generation</strong>. Garbage collection runs more often on the Young Generation (which is small and fast to clean) and less often on the Old Generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzLF6k4AhpHRpw-jKwPTWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jaZzX1iAvtQSIU6Xe1PzUw.png" /></figure><p>When we create a new object, it is first stored in the <strong>Eden space</strong> inside the Young Generation. Since the Eden space is small, it fills up quickly. When this happens, a <strong>Minor Garbage Collection</strong> runs. In this process, the dead objects in Eden are removed, and the surviving objects are moved to a <strong>Survivor space</strong>.</p><p>There are two Survivor spaces called <strong>From space</strong> and <strong>To space</strong>. After each Minor GC, the objects that are still alive are copied between these two spaces (From → To). Every time an object survives, its age increases.</p><p>If an object survives several collections, it is promoted to the <strong>Old Generation</strong>. The Old Generation is used to store long-lived objects. When this space gets full, a <strong>Major Garbage Collection</strong> happens, which is slower compared to Minor GC.</p><h3>03.Tri-Color Algorithm</h3><p>Using White ,gray and black colors we categorize objects in the heap and using those colors we can identify is particular object is garbage or the live objects.<br> <br> <em>White-consider as not yet visited node. In starting phase all the nodes are white and then at the end if there are any white node consider them as garbage.<br> <br> Gray-object have been visited and the visited objects are not fully processed their process still have to check about their references.<br> <br> Black-Objected are fully processed</em><br> <br><strong> Process</strong></p><p>Initialization — <br> mark all objects as white.<br> Then mark all root objects (root objects means like main program data-global variables, stack references, static fields) as gray.<br> <br> Processing loop-<br> picked gray object, looks at what it point to(it s children).and if the children are still white mark them as gray.<br> After checking all the gray object children, it turns black color(it means done).</p><p>Repeat this process<br> <br> Result<br> All the white objects consider as garbage. And GC reclaim memory.</p><p>Ex-<br><strong> A →B →C<br> and there are separate object D</strong></p><p>First these all the objects are white.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rMz1isfdg_U0DUCznx4Ng.png" /></figure><p>Root mark A as gray.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iI-GFOwCif7FheQZR1y-A.png" /></figure><p>A has child call B, B mark as gray no more children to A. so it become black.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ef31i0Hm2jgPdHCQcS2aEA.png" /></figure><p>Now B has child call C, C mark as gray. And there are no more children to B, B marked as Black.<br> Then to the C there are no any children , So it mark as Black.<br> Now A,B,C are blacked and D stay white. D is garbage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*49FuPLLNG9_X5rPfkyZtdA.png" /></figure><p>Advantages-<br> This no made mistakes.<br> Pickup all the garbage and keep not garbage as it is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a758411750e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficiency of Algorithm- Time Complexity]]></title>
            <link>https://medium.com/@sandanimuthukumarana/efficiency-of-algorithm-time-complexity-4cdd168b5e6d?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cdd168b5e6d</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Fri, 15 Aug 2025 04:57:25 GMT</pubDate>
            <atom:updated>2025-08-17T14:12:16.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oB8Y0xGtkVb7dKbL" /></figure><p>When solve a problem there can be multiple ways. It mean one single case there can be multiple algorithms. then how we choose one of among them?<br> <br> As a example assume u have written two codes for same problem,</p><p><em>Approach num 1 — spend 10s to complete execution, need 128Mb space<br>Approach num 2 — spend 40s to complete execution,need 32Mb space<br> </em><br> If we more concern about Time we can choose approach no 01<br> If we more concern about space we can choose approach no 02<br> <br> That mean We can consider two factors,</p><blockquote>1.Time Complexity<br> 2.Space complexity</blockquote><p>So today we going to study about Time Complexity from very basic to high level.<br> <br><em> What is Time complexity means ?</em><br>can we say time complexity means how much time taken to complete and execute the code? No Its Wrong. Because, imagine for a execute same code we have two machine one is old Windows machine and other one is new Mac book. MacBook definitely take less time than old Windows machine. So it can’t be never equal time taken. Then what is Time complexity?<br> <br> <strong>Time complexity is a way to describe how the amount of time an algorithm takes to run changes as the size of its input increases.<br> <br></strong>Okay then time complexity is not the term of measure by time using minutes or seconds. so how we measure them?<br> then the term of Big Oh notation comes in. You cant say time complexity is 2 second likewise. We have too say it using Big -Oh notation.<br> <br> let me simply explain how Big Oh notation come<br> <br><strong>Big Oh notation</strong><br> <br> for considering time complexity we can use 3 case of scenarios.</p><blockquote>01.Best case <br> 02.Avarage case <br> 03.Worst case</blockquote><p>Imagine we have an array, and we have to find the given element</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*RpUxPbwv4n5Vo7PxbRROlA.png" /></figure><p>The best case is finding the 6 because when loop iterate and then in first attempt we can get the answer that’s why it is the best one. For find the best case we use omega-Ω<br> <br> The worst case is finding the 1 because when loop iterate we have iterate loop 7 times to find an answer. that is the worst case. For worst case we use omicron -O<br> <br> In between of best case and worst case all the rest cases are average cases. Average one we use theta -Θ</p><p>Then among all these three cases we consider Worst case to find time complexity. Because worst case analysis makes sure our algorithm is reliable in every situation, not just the easy ones. <br> <br> Big O notation is a mathematical notation used to find an upper bound on time taken by an algorithm or data structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*VjATekicSE1JdrThsJofQQ.png" /></figure><p>lets move to some practical parts. Before go there you need understand some main part which we usually use in calculating time complexity.</p><blockquote><strong>01. Drop constant factors</strong><br> Example: O(2n)→ O(n)<br> Multiplying by a constant does not change the growth rate, so constants can be ignored.</blockquote><blockquote><strong>02. Keep only the dominant term</strong><br> Example: O(n²+n) → O(n²)<br> When multiple terms are added, the one that grows the fastest (dominant term) determines the complexity.</blockquote><p>Okay lets move to some common Runing Times</p><p><strong>01.Constatnt Time O(1)</strong><br> <br>Constant time means the running time is constant, it’s not affected by the input size <br>ex- Basic Operations (arithmetic, comparisons, accessing array’s elements, assignment)</p><pre>function (n){<br> return n*n<br>}</pre><p>in here for any value of n the loop execute only one time.so time complexity is, <br> O(n) → n=1 → O(1)</p><p>This is the most efficient way can write a code when considering time complexity<br> <br> <strong>02. Linear Time O(n)</strong><br> <br>When an algorithm accepts n input size, it would perform n operations as well.<br> <br> ex1-</p><pre>for (let i=0; i&lt;n; i++){<br>print (i)<br> }</pre><p>in here this loop goes through the loop n times.so time complexity is,<br> O(n)<br> <br> ex2-</p><pre>for (let i=0; i&lt;n; i++){<br> print (i)<br> }<br> for (let j=0; j&lt;n; j++){<br>print (j)}</pre><p>in here first loop execute n time and second loop execute also n time then time complexity is<br> O(n)+O(n) → O(n+n) → O(2n) → here we drop the cons value so → O(n)</p><p><strong>03. Logarithmic Time O(log n) </strong><br> <br>In here, algorithm divides the problem into sub problems with the same size. Example: binary search algorithm, binary conversion algorithm.<br> <br> ex-<br> search the num1 in this array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*STUTzQPVMTm5ugoQC6tj9w.png" /></figure><p>we can use divide and concur technology to solve this.in there we have divide these 03 times. array size is 8 and divide 3 times so we can create below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*yFV_kVcVLjuKF7AoyKBtaQ.png" /></figure><p>so time complexity is O(n) → O(log2 n)</p><p><strong>04. Quadratic Time O(n²) </strong><br> <br> For example Bubble Sort algorithm, in other words, a loop inside a loop.<br> <br>ex-</p><pre>for (let i=0; i&lt;n; i++){<br>for (let j=0; j&lt;n; j++){<br>print (i,j)}<br>}</pre><p><strong>05. Exponential Time O(2ⁿ) </strong><br> Extremely slow for large inputs. The running time doubles with each extra input.</p><p><strong>8) Factorial Time O(n!)</strong></p><p>The slowest one grows faster than any other. Even small inputs take lot of time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImJj1DBSSFmz4-PfNIx7ew.jpeg" /></figure><p>Time complexity helps us pick the right algorithm. Some work fast even with big data, some others take too long. Knowing this lets us avoid slow solutions and make our programs run better.</p><p>When coding, try to use faster ones like <strong>O(1)</strong> or <strong>O(log n)</strong> for large inputs. Stay away from slow ones like <strong>O(n²)</strong>, <strong>O(2ⁿ)</strong>, or <strong>O(n!)</strong> unless the data is small. Use good data structures and avoid extra loops to keep things quick.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cdd168b5e6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Journey to the Internship at Fortude]]></title>
            <link>https://medium.com/@sandanimuthukumarana/my-journey-to-the-internship-at-fortude-35b293adc069?source=rss-5fac584e7d31------2</link>
            <guid isPermaLink="false">https://medium.com/p/35b293adc069</guid>
            <dc:creator><![CDATA[SandaniMuthukumarana]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 08:18:26 GMT</pubDate>
            <atom:updated>2025-08-10T08:21:03.989Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Rx3CFr-L6xRkpWv.png" /></figure><p>Sometimes, the biggest things in life happen in the most unexpected ways. Getting my internship at Fortude was like that. It all started with one YouTube video.</p><p>I was in my third year, first semester. In the second semester, we had to find an internship. I was learning new things and preparing for interviews. One day, I saw a YouTube video called <em>“Nine Strangers.”</em> It was about an internship program where past interns shared their experiences. It felt different from other software engineering internships I had heard about.</p><p>The mentor of that internship was Mr.Krishantha Dinesh. I often watched his technical videos. I felt the interns in that program were lucky to have a mentor like him. One thing he said in the video stayed in my mind <em>“Interns are like clay. They are new to everything. A good mentor can shape them into something great.”</em> At the end of the video, he said they would soon start the second stage of the internship and hire 9 or 10 more interns. From that day, I followed Fortude’s LinkedIn page, waiting for the offer. When I finally saw it posted, I applied.</p><p>A month later, I got a call from Fortude’s HR team saying I was shortlisted for the first interview. The next day, I faced a 30-minute interview that tested our basic knowledge. I didn’t hear back for a while and thought I wasn’t selected. But after three weeks, I got another call inviting me for the second interview. I was so happy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*7qoipPoPK2KGJMi6by_D1w.jpeg" /></figure><p>The second interview day started at 8:30 a.m. and went until 5:00 p.m. Thirty one candidates were there. First, they welcomed us, introduced Fortude, and did ice breaking activities. Then Krish came and explained the schedule. That was my first time meeting him, and I felt his positive energy. He said software engineers are not just coders they also need to think and design solutions for real problems.</p><p>We had two main tasks. First was the individual task, where we answered questions about DSA, web development, IQ, and critical thinking. I answered most of them, even the ones I wasn’t sure about. After lunch, we had a group task. Each group got a problem to solve, and we had 90 minutes to design and present a solution. After our presentation, Krish asked questions, gave feedback, and taught us better ways to solve problems. It was an unforgettable day, and we even got a small gift, which I still keep.</p><p>A week later, I got a call saying I was selected for the final 15 and invited to the last interview with Krish. It was a 15 minute friendly discussion, and I learned a lot from it.</p><p>After the final interview, I waited for the call from Fortude. I even called them once to ask, but they said the decision wasn’t made yet. Finally, the day came they called and told me I was selected. I was so happy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*6HJRHOYwncFJuIixO8UjDA.jpeg" /></figure><p>Now, I am working as a Software Engineer Intern at Fortude. I know I still have a lot to learn and many challenges ahead. But I’m ready to work hard with the other eight interns and make this internship a success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35b293adc069" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>