<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ virtual machine - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ virtual machine - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 27 Jun 2026 14:19:05 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/virtual-machine/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Load Balancing with Azure Application Gateway and Azure Load Balancer – When to Use Each One ]]>
                </title>
                <description>
                    <![CDATA[ You’ve probably heard someone mention load balancing when talking about cloud apps. Maybe even names like Azure Load Balancer, Azure Application Gateway, or something about Virtual Machines and Scale Sets. 😵‍💫 It all sounds important...but also a l... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/load-balancing-with-azure-application-gateway-and-azure-load-balancer/</link>
                <guid isPermaLink="false">6824f10a7d203c180e5ea4b2</guid>
                
                    <category>
                        <![CDATA[ Load Balancing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Azure ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Azure Application Gateway ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #virtual machine scale set ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Load Balancer ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Prince Onukwili ]]>
                </dc:creator>
                <pubDate>Wed, 14 May 2025 19:37:46 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747235455030/cb82bfb4-8d7b-47e5-ab31-126906f60b40.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You’ve probably heard someone mention load balancing when talking about cloud apps. Maybe even names like Azure Load Balancer, Azure Application Gateway, or something about Virtual Machines and Scale Sets. 😵‍💫</p>
<p>It all sounds important...but also a little confusing. Like, why are there so many moving parts? And what do they actually do?</p>
<p>In this guide, we’re going to break it all down – step by step – using real examples and simple language.</p>
<p>You’ll learn:</p>
<ul>
<li><p>What load balancers are (and why apps even need them)</p>
</li>
<li><p>How apps were deployed before load balancers existed (hint: everything lived on one lonely server)</p>
</li>
<li><p>How Azure Virtual Machines work – and how they let you scale up your apps</p>
</li>
<li><p>What Virtual Machine Scale Sets are, and how they help handle sudden traffic spikes</p>
</li>
<li><p>The differences between Azure Load Balancer and Azure Application Gateway, and when to use each</p>
</li>
</ul>
<p>By the end, you won’t just understand what these tools do – you’ll know <em>when</em> and <em>why</em> to use them in real-world scenarios.</p>
<p>Whether you’re a curious beginner, a hands-on builder, or someone just trying to wrap their head around Azure’s ecosystem, this guide is for you.</p>
<p>Ready to untangle the cloud spaghetti? Let’s go! 🍝🚀</p>
<h2 id="heading-table-of-contents">📚 Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-are-load-balancers">🧊 What Are Load Balancers?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-applications-were-deployed-before-load-balancers">🖥️ How Applications Were Deployed Before Load Balancers</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-azure-virtual-machines-vms-the-building-blocks">⚙️ Azure Virtual Machines (VMs) – The Building Blocks</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-need-for-scaling-vertical-vs-horizontal">📈 The Need for Scaling – Vertical vs Horizontal</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-azure-virtual-machine-scale-sets-vmss-scaling-made-simple">🔁 Azure Virtual Machine Scale Sets (VMSS) – Scaling Made Simple</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-azure-load-balancer-spreading-the-traffic">📦 Azure Load Balancer – Spreading the Traffic</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-azure-application-gateway-smart-routing-for-modern-apps">🍴 Azure Application Gateway – Smart Routing for Modern Apps</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-azure-load-balancer-vs-azure-application-gateway">🔍 Azure Load Balancer vs Azure Application Gateway</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-use-cases-when-to-use-what">🧭</a> <a class="post-section-overview" href="#heading-use-cases-when-to-use-each-one">Use Cases: When to Use Each One</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">✅ Conclusion</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-study-further">Study Further 📚</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-about-the-author">About the Author 👨‍💻</a></p>
</li>
</ol>
<h2 id="heading-what-are-load-balancers">🧊 What Are Load Balancers?</h2>
<p>Imagine you're running a small restaurant with just one chef in the kitchen. Everything goes smoothly when you have a few customers – each order is prepared one after the other, and everyone leaves satisfied.</p>
<p>But what happens when 50 people walk in all at once?</p>
<p>🍽️ One chef can’t handle that many orders at the same time.<br>⏳ People start waiting longer.<br>😤 Some customers leave.<br>💥 The chef gets overwhelmed – and eventually burns out.</p>
<p>This is what can happen to a server (the computer running your app) when too many users try to access it at the same time.</p>
<h3 id="heading-so-what-does-a-load-balancer-do">So, What Does a Load Balancer Do?</h3>
<p>A <strong>load balancer</strong> is like a smart restaurant manager. But instead of food orders, it handles user requests – the things people do when they open your app, click buttons, or load data.</p>
<p>Let’s say you now have three chefs (servers) instead of one. The load balancer’s job is to:</p>
<ul>
<li><p>👀 Watch for incoming orders (user requests)</p>
</li>
<li><p>🧠 Decide which chef (server) is available or least busy</p>
</li>
<li><p>🍽️ Send that request to the right one</p>
</li>
<li><p>🔁 Repeat this over and over, making sure things stay fast and smooth</p>
</li>
</ul>
<p>So in simple terms, a load balancer takes all the incoming traffic to your app and distributes it across multiple servers so no single server gets overloaded – cool, right? 🙂</p>
<h3 id="heading-why-were-load-balancers-introduced">Why Were Load Balancers Introduced?</h3>
<p>Back in the early days, many applications were hosted on just one machine – called a Single Server Deployment.</p>
<p>That was okay when you had a small number of users. But once things started to grow – more users, more actions, more data – single servers became a bottleneck:</p>
<ul>
<li><p>They could only handle a limited number of requests.</p>
</li>
<li><p>If they went down, your entire app would stop working.</p>
</li>
<li><p>Scaling (adding more power) was expensive and manual.</p>
</li>
</ul>
<p>💡 Enter <strong>load balancers</strong> – designed to solve this by making it possible to:</p>
<ul>
<li><p>Spread traffic across multiple servers (so no one server crashes under pressure),</p>
</li>
<li><p>Replace or restart servers without downtime,</p>
</li>
<li><p>Add or remove servers as needed, depending on how busy your app is (this is called <strong>scaling</strong>).</p>
</li>
</ul>
<h3 id="heading-a-simple-use-case-scenario">A Simple Use-Case Scenario</h3>
<p>Let’s say you're building an online store — your own mini Amazon. At first, you host your app on one Azure Virtual Machine. Things are great. But one day, you run a huge promo and suddenly…thousands of people flood in to browse, shop, and check out.</p>
<p>Your single VM starts lagging.</p>
<p>Orders fail. People complain. Your dream app? Crashing fast. 💥</p>
<p>So what do you do?</p>
<p>You spin up two more VMs to help out – but now you’ve got another problem: <em>How do you divide the traffic between the three?</em></p>
<p>This is where the load balancer steps in. It:</p>
<ul>
<li><p>Looks at every incoming user request</p>
</li>
<li><p>Figures out which VM is available and least busy</p>
</li>
<li><p>Sends the request there</p>
</li>
<li><p>Keeps rotating requests in real-time</p>
</li>
</ul>
<p>And the result?<br>✅ No single VM gets overwhelmed<br>✅ Your app stays fast and responsive<br>✅ Users are happy (and buying stuff again!)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746980088916/41be330b-8d5b-4709-b07d-3f1a19d641e7.png" alt="Load balancer illustration" class="image--center mx-auto" width="1204" height="672" loading="lazy"></p>
<h2 id="heading-how-applications-were-deployed-before-load-balancers">🖥️ How Applications Were Deployed Before Load Balancers</h2>
<p>Before cloud tools like load balancers came along, the typical way to run an application was pretty simple: You’d deploy the entire app on a single server, like running a small business from one tiny shop.</p>
<h3 id="heading-first-things-first-whats-a-server">First Things First: What’s a Server?</h3>
<p>Think of a server as a special computer that’s always connected to the internet. Its job is to “serve” your app to people when they visit your website, open your app, or use your service.</p>
<p>In cloud platforms like Azure, we usually call these Virtual Machines (VMs) – basically, software-powered servers you can spin up with a few clicks.</p>
<h3 id="heading-monoliths-vs-microservices">Monoliths vs Microservices</h3>
<p>Now, applications come in different “shapes.” The two most common are:</p>
<ul>
<li><p><strong>Monoliths</strong>: Everything is bundled together into one big app. All the code – from user login to shopping cart to checkout – lives in a single unit.</p>
</li>
<li><p><strong>Microservices</strong>: The app is broken into smaller, independent apps (services). Each service does one job – like login, payments, orders – and runs separately.</p>
</li>
</ul>
<h4 id="heading-how-were-these-apps-deployed">How Were These Apps Deployed?</h4>
<p>Whether it was a monolith or a bunch of microservices, they were all usually deployed on a single server (VM).</p>
<p>For monoliths, you just ran the entire app directly on the server. For microservices: you'd run each service in a separate space on that same server, using <strong>containers</strong>.</p>
<h4 id="heading-wait-whats-a-container">Wait — What’s a Container?</h4>
<p>A container is like a mini-computer <em>inside</em> a computer. It has everything an app needs to run – code, tools, settings – and it keeps each app isolated from the others.</p>
<p>Why use containers?</p>
<ul>
<li><p>You can run multiple services on the same server without their underlying software (software needed for each app to run) interfering with each other.</p>
</li>
<li><p>It’s faster and more efficient than installing everything directly on the server.</p>
</li>
<li><p>They make moving apps between environments (for example, test → production) super smooth (no more “But, it works on my machine…”).</p>
</li>
</ul>
<p>Popular tools like Docker make working with containers easy.</p>
<h4 id="heading-connecting-it-all-together-domains-subdomains-and-reverse-proxies">Connecting It All Together: Domains, Subdomains, and Reverse Proxies</h4>
<p>When your app lives on a server, you want people to be able to reach it. That’s where <strong>domain names</strong> come in.</p>
<ul>
<li><p>Your server has a public IP address – a set of numbers like <code>102.80.1.23</code>, that gives it a unique identifier on the public internet</p>
</li>
<li><p>But instead of asking users to type numbers, you link that IP to a domain name, like <code>mycoolapp.com</code></p>
</li>
</ul>
<p>If your app has microservices, you might even assign <strong>subdomains</strong> like:</p>
<ul>
<li><p><code>api.mycoolapp.com</code> for the backend</p>
</li>
<li><p><code>dashboard.mycoolapp.com</code> for the user interface</p>
</li>
<li><p><code>payments.mycoolapp.com</code> for payments</p>
</li>
</ul>
<p>To manage all this, you’d use a <strong>reverse proxy</strong> (like Nginx or Apache). It listens on the main domain and subdomains, and forwards traffic to the right app or service.</p>
<p>Example:</p>
<ul>
<li><p>Someone visits <code>dashboard.mycoolapp.com</code></p>
</li>
<li><p>The reverse proxy checks the domain and forwards the request to the correct container running the dashboard service</p>
</li>
</ul>
<p>And to help with all of this setup – from deploying containers to configuring reverse proxies – there are developer-friendly tools like <a target="_blank" href="https://coolify.io">Coolify</a>. Coolify is an open-source platform that makes it super easy for developers and DevOps teams to:</p>
<ul>
<li><p>Deploy apps in containers</p>
</li>
<li><p>Set up domains and subdomains</p>
</li>
<li><p>Configure reverse proxies – all from a clean dashboard, no complex terminal commands needed</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746979943646/a6525a09-f44a-4e00-a945-7bded3483b0d.jpeg" alt="Coolify dashboard example" class="image--center mx-auto" width="1788" height="853" loading="lazy"></p>
<p>All this was set up on ONE SERVER/VM. But here’s the catch: when that one server got overloaded or went down…💥 everything stopped.</p>
<p>That’s why we needed a better way. And that's where <strong>scaling</strong> and <strong>load balancing</strong> came in – to keep apps running smoothly, no matter the traffic.</p>
<h2 id="heading-azure-virtual-machines-vms-the-building-blocks">⚙️ Azure Virtual Machines (VMs) – The Building Blocks</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746980948928/eb6a7fb2-7432-42ed-8cbd-bff6c8250d4e.jpeg" alt="Virtual Machine illustration" class="image--center mx-auto" width="1280" height="640" loading="lazy"></p>
<p>When it comes to running apps in the cloud, <strong>Virtual Machines (VMs)</strong> are the basic building blocks – kind of like renting an apartment in a giant digital skyscraper.</p>
<p>You don’t need to buy the whole building (aka physical servers), you just rent the space you need, when you need it.</p>
<h3 id="heading-what-exactly-is-a-virtual-machine">What Exactly Is a Virtual Machine?</h3>
<p>A Virtual Machine is a software-based computer that runs inside a real, physical computer (a server) – hosted in a data center, like those run by Microsoft Azure.</p>
<p>It looks and behaves like a normal computer:</p>
<ul>
<li><p>It has an operating system (Windows, Linux)</p>
</li>
<li><p>You can install apps</p>
</li>
<li><p>It has memory (RAM), storage (disks), and CPU</p>
</li>
</ul>
<p>But the best part? You don’t need to worry about the hardware. Azure takes care of that behind the scenes – all you do is say:</p>
<blockquote>
<p>“Hey Azure, give me a Linux VM with 4GB RAM and 2 CPUs.”</p>
</blockquote>
<p>And boom 💥 — it spins up in minutes.</p>
<h3 id="heading-why-use-a-vm">Why Use a VM?</h3>
<p>Let’s say you’ve built a web app – it’s just a simple blog. You want to deploy it and make it accessible to the world.</p>
<p>Here's what you can do with a VM:</p>
<ul>
<li><p>Set it up with your favorite OS (for example, Ubuntu)</p>
</li>
<li><p>Install web servers like Nginx or Apache</p>
</li>
<li><p>Deploy your app</p>
</li>
<li><p>Bind it to your domain name</p>
</li>
<li><p>Let the world visit your blog at <a target="_blank" href="http://myawesomeblog.com"><code>myawesomeblog.com</code></a></p>
</li>
</ul>
<p>It’s your own personal environment – no sharing, full control.</p>
<h2 id="heading-the-need-for-scaling-vertical-vs-horizontal">📈 The Need for Scaling – Vertical vs Horizontal</h2>
<p>Imagine your app is growing. At first, it’s just a few users. Then a few hundred. Then thousands are logging in, placing orders, chatting, uploading photos – all at once 😮</p>
<p>Suddenly, your server (VM) is under pressure. It’s like trying to pour a flood through a straw.</p>
<h3 id="heading-so-what-do-you-do-when-one-server-isnt-enough">So, What Do You Do When One Server Isn’t Enough?</h3>
<p>This is where scaling comes in – the art of upgrading your app’s infrastructure to keep up with traffic.</p>
<p>There are two main ways to scale:</p>
<h4 id="heading-option-1-vertical-scaling-aka-scaling-up">🧱 Option 1: Vertical Scaling (aka Scaling Up)</h4>
<p>You take your existing VM and give it more power:</p>
<ul>
<li><p>Add more CPUs 🧠</p>
</li>
<li><p>Increase RAM 🧵</p>
</li>
<li><p>Add faster disks ⚡</p>
</li>
</ul>
<p>Think of it like upgrading from a regular car to a sports car. It’s the same vehicle, just faster and stronger.</p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Simple to do</p>
</li>
<li><p>No major changes to your app setup</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>There’s a limit to how much you can upgrade</p>
</li>
<li><p>Still a single point of failure: if the VM crashes, everything goes down 😬</p>
</li>
</ul>
<h4 id="heading-option-2-horizontal-scaling-aka-scaling-out">🧩 Option 2: Horizontal Scaling (aka Scaling Out)</h4>
<p>Instead of boosting one server, you add more servers – multiple VMs running copies of your app.</p>
<p>Now:</p>
<ul>
<li><p>Users can be distributed across all these VMs</p>
</li>
<li><p>If one goes down, others keep serving traffic</p>
</li>
<li><p>You can <em>dynamically</em> add or remove VMs based on traffic</p>
</li>
</ul>
<p>It’s like opening more checkout counters in a busy supermarket 🛒</p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>The load is evenly distributed. For example, if one server previously handled 100% of the traffic, adding two more servers would result in the traffic being split into approximately 33% to 34% for each server.</p>
</li>
<li><p>Improves both performance and reliability</p>
</li>
<li><p>You can scale based on real-time demand, that is traffic inflow</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>Needs something to split traffic between VMs – Load Balancers</p>
</li>
<li><p>More expensive. You end up paying the original amount for 1 VM (for example $30) for the number of VMs you provide – if you provide 3 VMs at $30 each, you end up paying $90 at the end of the month</p>
</li>
</ul>
<h3 id="heading-quick-real-world-example">Quick Real-World Example</h3>
<p>Let’s say you’ve launched an e-commerce site for sneakers 👟 Traffic spikes during a big sale? Your vertical scaling (bigger VM) might choke.</p>
<p>But with horizontal scaling:</p>
<ul>
<li><p>You spin up 5 VMs across different regions</p>
</li>
<li><p>Traffic is shared between them</p>
</li>
<li><p>If one VM slows down, others handle the load</p>
</li>
</ul>
<h4 id="heading-so-remember">So, remember 👇🏾</h4>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Scaling Type</td><td>Description</td><td>Pros</td><td>Cons</td></tr>
</thead>
<tbody>
<tr>
<td>🧱 Vertical Scaling</td><td>Make 1 VM more powerful (adding more CPU power, SSD, RAM, bandwidth, and so on)</td><td>Easy setup, fewer changes</td><td>Hardware limits, 1 point of failure - If that 1 server/VM goes down, so does your app :(</td></tr>
<tr>
<td>🧩 Horizontal Scaling</td><td>Add more VMs to handle traffic</td><td>Flexible, reliable</td><td>Needs traffic distribution logic (Load Balancer). Usually more expensive (the price of 1 VM times the number of VMs)</td></tr>
</tbody>
</table>
</div><h2 id="heading-azure-virtual-machine-scale-sets-vmss-scaling-made-simple">🔁 Azure Virtual Machine Scale Sets (VMSS) – Scaling Made Simple</h2>
<p>Okay – so we’ve talked about <strong>horizontal scaling</strong>: adding multiple VMs to handle growing traffic. Sounds great, right?</p>
<p>But here’s the thing: manually spinning up and configuring 5, 10, or 100 VMs... every time your app gets busy? Yeah, that’s not fun 🙃</p>
<h3 id="heading-enter-virtual-machine-scale-sets-vmss">Enter: Virtual Machine Scale Sets (VMSS)</h3>
<p>VMSS is Azure’s way of automating horizontal scaling. Instead of creating each VM one by one, you define a template, and Azure takes care of the rest:</p>
<ul>
<li><p>How many VMs to start with</p>
</li>
<li><p>How to configure them (OS, apps, settings) ⚙️</p>
</li>
<li><p>When to add or remove VMs based on traffic 📈📉</p>
</li>
</ul>
<h3 id="heading-a-simple-analogy">A Simple Analogy 🧃</h3>
<p>Think of VMSS like a juice dispenser at a party:</p>
<ul>
<li><p>At first, it pours into 2 cups (VMs)</p>
</li>
<li><p>If 10 guests show up? It starts filling 5 cups</p>
</li>
<li><p>Party slows down? Back to 2 cups again</p>
</li>
</ul>
<p>You never have to refill manually – the dispenser adjusts on its own. 🎉</p>
<h3 id="heading-how-it-works-without-the-jargon">How It Works (Without the Jargon 😌)</h3>
<ol>
<li><p><strong>You set the rules:</strong> “If CPU usage goes above 70%, add 2 more VMs.”</p>
</li>
<li><p><strong>Azure watches traffic and adjusts the number of VMs</strong> automatically.</p>
</li>
<li><p><strong>All VMs are identical</strong> – like clones, all running the same app setup.</p>
</li>
<li><p><strong>It works with Azure Load Balancer</strong> to spread traffic across all these VMs smoothly.</p>
</li>
</ol>
<h3 id="heading-real-life-example-food-delivery-app">Real-Life Example: Food Delivery App 🍕📱</h3>
<p>You’ve built an app where users order food. During lunch and dinner, traffic explodes.</p>
<p>💡 With VMSS:</p>
<ul>
<li><p>You start with 3 VMs in the morning</p>
</li>
<li><p>At 12PM, Azure sees high CPU usage, so it spins up 5 more VMs</p>
</li>
<li><p>At 3PM, traffic drops, so Azure removes the extra VMs</p>
</li>
</ul>
<p>You only pay for what you use. And users get a smooth experience – no delays, no crashes 👌🏾</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746982520998/7fe3c997-fc8f-418a-861b-e999905ca43c.png" alt="Auto-scaling illustration" class="image--center mx-auto" width="455" height="176" loading="lazy"></p>
<h2 id="heading-azure-load-balancer-spreading-the-traffic">📦 Azure Load Balancer – Spreading the Traffic</h2>
<p>By now, you know that your app can live on multiple Virtual Machines (VMs), and that you can scale them easily using Virtual Machine Scale Sets (VMSS).</p>
<p>But here's the big question: when users start accessing your app – hundreds, even thousands at once – how do you make sure that all that traffic is fairly and efficiently distributed across those VMs?</p>
<p>You don’t want one VM to be overwhelmed while others are just chilling. You need a middleman – something smart enough to balance the load.</p>
<p>That’s where <strong>Azure Load Balancer</strong> steps in. It’s Azure’s way of saying, “Don’t worry, I got this” when traffic starts rolling in.</p>
<h3 id="heading-so-what-is-azure-load-balancer">🏢 So, What Is Azure Load Balancer?</h3>
<p>Azure Load Balancer is a <strong>traffic director</strong>. It takes incoming traffic from the internet (or even internal sources within your network) and intelligently spreads it across multiple backend machines – usually VMs.</p>
<p>It's like having a well-trained receptionist who routes every customer to the next available agent, so no one waits too long and no one gets overwhelmed 😃.</p>
<p>And the best part? This entire process happens in the background – fast, silent, and seamless. Users visiting your app have no idea a traffic manager is working behind the scenes. They just see a fast, responsive experience.</p>
<h3 id="heading-the-frontend-ip-your-apps-public-face">🌐 The Frontend IP – Your App’s Public Face</h3>
<p>Every Azure Load Balancer is tied to a <strong>Frontend IP</strong>, which is basically the public IP address of your application – the one users connect to when they open <code>www.yourapp.com</code>.</p>
<p>This IP acts as the entry point. All user traffic comes through it first. But the Load Balancer doesn’t actually run your app. Instead, it accepts the traffic and forwards it to one of the VMs in the backend pool (we’ll get to that shortly).</p>
<p>You can configure this Frontend IP to be either public (accessible over the internet) or private (used for internal traffic within your cloud network – say, between microservices or internal tools).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747055268951/5afbb738-d00d-4f49-9709-2fa1fe7cffdd.png" alt="Frontend IP address illustration" class="image--center mx-auto" width="603" height="245" loading="lazy"></p>
<h3 id="heading-backend-pool-where-the-magic-happens">🗂️ Backend Pool – Where the Magic Happens</h3>
<p>Behind every Azure Load Balancer is a <strong>backend pool</strong> – a group of VMs (or VM Scale Set instances) where your actual app is running. These are the real workers, doing all the heavy lifting.</p>
<p>When traffic hits the Frontend IP, the Load Balancer takes that request and hands it off to one of the VMs in the backend pool.</p>
<p>But it doesn’t just randomly pick one. It checks a few things first – like whether the VM is healthy, whether it's already busy, and what rules you’ve set.</p>
<p>Each VM in the pool typically runs the same app or service. This means any of them can handle any incoming request, which is what makes load balancing possible in the first place.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747055337014/e831056d-7c0c-49d9-b05a-6d3dbe3edc76.png" alt="Backend pool illustration" class="image--center mx-auto" width="299" height="258" loading="lazy"></p>
<h3 id="heading-health-probes-keeping-tabs-on-the-vms">🩺 Health Probes – Keeping Tabs on the VMs</h3>
<p>Now, how does the Load Balancer know which VM is healthy or not? This is where <strong>health probes</strong> come in. Think of them as regular check-ups.</p>
<p>You configure the Load Balancer to periodically "ping" each VM – maybe by hitting a specific URL (like <code>/health</code>) or a certain port (like 80 for HTTP). If a VM doesn’t respond correctly, Azure marks it as unhealthy and temporarily removes it from the rotation.</p>
<p>This ensures users never get routed to a broken or unresponsive instance of your app. And once the VM becomes healthy again, it's automatically added back to the pool.</p>
<h3 id="heading-load-balancing-rules-who-gets-what">⚖️ Load Balancing Rules – Who Gets What?</h3>
<p>Next, we have <strong>Load Balancing Rules</strong>. These are the instructions that tell Azure Load Balancer exactly how to behave.</p>
<p>You can define rules like:</p>
<ul>
<li><p>“Forward all HTTP (port 80) traffic to backend pool VMs on port 80”</p>
</li>
<li><p>“Forward HTTPS (port 443) traffic to VMs on port 443”</p>
</li>
<li><p>“Only route traffic to healthy VMs”</p>
</li>
</ul>
<p>These rules make Azure Load Balancer highly customizable. You get to decide how traffic flows, which protocols to support, and how to handle backend ports. It's like customizing the rules of a relay race – who gets the baton and when.</p>
<h3 id="heading-real-world-example-sneaker-sale-rush">👟 Real-World Example: Sneaker Sale Rush</h3>
<p>Imagine you're running an online sneaker store at <code>www.sneakerblast.com</code>. You’re launching a flash sale, and thousands of users are hitting your website all at once.</p>
<p>Thanks to your Azure Load Balancer, here’s what happens:</p>
<ol>
<li><p>All those users land on your Frontend IP, the public face of your site.</p>
</li>
<li><p>The Load Balancer accepts the traffic and checks the health probes of all VMs in the backend pool.</p>
</li>
<li><p>Based on its rules, it forwards each user to a healthy, available VM.</p>
</li>
<li><p>One VM might serve a user in Lagos, another in Nairobi, another in Accra – all seamlessly.</p>
</li>
</ol>
<p>If one VM crashes or lags? The Load Balancer detects it instantly and stops routing traffic to it until it’s back online.</p>
<p>That’s smooth traffic management without any manual effort.</p>
<h2 id="heading-azure-application-gateway-smart-routing-for-modern-apps">🍴 Azure Application Gateway – Smart Routing for Modern Apps</h2>
<p>So far, we’ve seen how Azure Load Balancer helps you split traffic across multiple VMs running a single service – like a monolithic app or a web frontend.</p>
<p>Let’s say you have a web application deployed on a VM. It listens on port 80, and you’ve scaled it into 3 instances. The Azure Load Balancer takes requests from the internet and spreads them across all 3 instances of the same service. Easy, right?</p>
<p>You can even link the Load Balancer’s public IP address to your domain – like <code>mydomain.com</code> – so users can visit your site normally.</p>
<h3 id="heading-but-what-if-you-have-multiple-services">🧠 But What If You Have <em>Multiple</em> Services?</h3>
<p>Now imagine you’ve gone beyond just one app. You’re building something more modern, like a set of microservices.</p>
<p>You now have:</p>
<ul>
<li><p>A payment service listening on port 5000</p>
</li>
<li><p>An authentication service on port 6000</p>
</li>
<li><p>A purchase service on port 7000</p>
</li>
</ul>
<p>All deployed across the same VMs (or Virtual Machine Scale Set), just on different ports.</p>
<p>Here’s the problem: an Azure Load Balancer is designed to route traffic to <em>one</em> backend pool – basically one service – on one port. If you tie it to <code>mydomain.com</code>, it can only send traffic to one of your microservices. 😬</p>
<p>So… what do you do?</p>
<p>You might think: “Let me just create a separate Load Balancer for each service!” 🤕</p>
<p>But that means:</p>
<ul>
<li><p>You’ll have to pay for multiple load balancers</p>
</li>
<li><p>You’ll end up managing 3–5 public IP addresses</p>
</li>
<li><p>You might even need to buy multiple domains like <code>mypayment.com</code>, <code>myauth.com</code>, and so on to route users properly</p>
</li>
</ul>
<p>Yikes. That’s impractical, messy, <em>and</em> expensive 😖💸</p>
<h3 id="heading-enter-azure-application-gateway">🎉 Enter Azure Application Gateway</h3>
<p><strong>Azure Application Gateway</strong> solves this problem beautifully. It’s designed to route traffic intelligently – not just to one service, but to multiple services using just one gateway.</p>
<p>It works like this:</p>
<ol>
<li><p>You create one public-facing frontend IP (like <code>52.160.100.5</code>)</p>
</li>
<li><p>You link that IP address to your main domain, for example <code>mydomain.com</code></p>
</li>
<li><p>Then, you define multiple backend pools – one for each service:</p>
<ul>
<li><p>Payment service (port 5000)</p>
</li>
<li><p>Auth service (port 6000)</p>
</li>
<li><p>Purchase service (port 7000)</p>
</li>
</ul>
</li>
<li><p>Next, you set up routing rules that decide how to forward each request.</p>
</li>
</ol>
<h3 id="heading-two-ways-to-route-with-application-gateway">✨ Two Ways to Route with Application Gateway</h3>
<p>You can configure <strong>smart routing</strong> based on:</p>
<ul>
<li><p><strong>URL paths</strong>:</p>
<ul>
<li><p><code>mydomain.com/payment</code> → Payment service</p>
</li>
<li><p><code>mydomain.com/auth</code> → Auth service</p>
</li>
</ul>
</li>
<li><p><strong>Subdomains</strong> (host headers):</p>
<ul>
<li><p><code>payment.mydomain.com</code> → Payment service</p>
</li>
<li><p><code>auth.mydomain.com</code> → Auth service</p>
</li>
</ul>
</li>
</ul>
<p>This way, all your services share one public IP and one domain – super clean, super efficient 🙌🏾</p>
<h3 id="heading-real-life-scenario-lets-break-it-down">🤓 Real-Life Scenario (Let’s Break It Down)</h3>
<p>Let’s say you’re building a startup platform that has three key microservices:</p>
<ul>
<li><p><strong>Payment service</strong> that handles transactions</p>
</li>
<li><p><strong>Authentication service</strong> that handles login and user identity</p>
</li>
<li><p><strong>Purchase service</strong> that manages product ordering</p>
</li>
</ul>
<p>Each service is containerized and deployed on the same VM (or across several VMs using a VM Scale Set). But – and this is key – they all listen on <strong>different ports</strong> inside the VMs:</p>
<ul>
<li><p>Payment → port 3000</p>
</li>
<li><p>Auth → port 6000</p>
</li>
<li><p>Purchase → port 7000</p>
</li>
</ul>
<p>Now, without a smart routing solution, you’d be stuck trying to expose just one of these services using a standard Azure Load Balancer. But you need all three to be accessible from the internet – and you don’t want to pay for or manage 3 different Load Balancers 😅</p>
<p>So, what do you do?</p>
<h3 id="heading-using-azure-application-gateway-to-route-traffic-intelligently">🧠 Using Azure Application Gateway to Route Traffic Intelligently</h3>
<p>Here's how you can fix this using <strong>one</strong> Application Gateway:</p>
<ol>
<li><p>Deploy your microservices inside each VM:</p>
<ul>
<li><p>Each service runs on a specific port</p>
</li>
<li><p>All VMs in your scale set are identical (they contain all three services)</p>
</li>
</ul>
</li>
<li><p>Create backend pools in Application Gateway:</p>
<ul>
<li><p>A backend pool for the payment service (pointing to port 3000 on all VMs)</p>
</li>
<li><p>One for the auth service (port 6000)</p>
</li>
<li><p>Another for the purchase service (port 7000)</p>
</li>
</ul>
</li>
<li><p>Create routing rules:</p>
<ul>
<li><p>Option A (Path-based routing):</p>
<ul>
<li><p>Requests to <code>mydomain.com/payment</code> → go to the payment backend pool</p>
</li>
<li><p>Requests to <code>mydomain.com/auth</code> → go to the auth backend pool</p>
</li>
<li><p>Requests to <code>mydomain.com/purchase</code> → go to the purchase backend pool</p>
</li>
</ul>
</li>
<li><p>Option B (Subdomain-based routing):</p>
<ul>
<li><p><code>payment.mydomain.com</code> → payment service</p>
</li>
<li><p><code>auth.mydomain.com</code> → auth service</p>
</li>
<li><p><code>purchase.mydomain.com</code> → purchase service</p>
</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>You just tell the Application Gateway: “Hey, if a request comes in for this URL or subdomain, send it to this port on these VMs.” And it does just that – consistently and intelligently 🔁</p>
<h3 id="heading-so-whats-really-happening">📦 So, What’s Really Happening?</h3>
<p>Imagine a user visits <code>mydomain.com/auth</code>. Here’s what goes on behind the scenes:</p>
<ol>
<li><p>The DNS translates <code>mydomain.com</code> to your Application Gateway’s public IP</p>
</li>
<li><p>The Gateway receives the request</p>
</li>
<li><p>It checks your routing rules</p>
</li>
<li><p>It sees that <code>/auth</code> should go to the backend pool for port 6000</p>
</li>
<li><p>It forwards the request to one of the VMs running the auth service</p>
</li>
<li><p>The response goes back to the user – fast and seamless ✨</p>
</li>
</ol>
<p>This happens in milliseconds, for every request. And because the Application Gateway is aware of multiple ports and services, it can handle routing logic that a regular Load Balancer just can’t do.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747056436345/7ea97231-d2ee-4f63-aff1-50595e7c06e0.png" alt="Application Gateway Illustration" class="image--center mx-auto" width="2048" height="1255" loading="lazy"></p>
<h2 id="heading-azure-load-balancer-vs-azure-application-gateway">🔍 Azure Load Balancer vs Azure Application Gateway</h2>
<p>By now, you've seen how both tools help route traffic in Azure – but they solve different problems.</p>
<p>Let’s break down how they compare, and when you should use one over the other 👇🏾</p>
<h3 id="heading-1-routing-logic">🛣️ 1. <strong>Routing Logic</strong></h3>
<p><strong>Azure Load Balancer</strong><br>It simply distributes incoming traffic evenly across a pool of VMs. It doesn’t care <em>what</em> the request is – it just balances the load.  </p>
<p>Imagine a delivery guy who doesn't ask questions – he just drops each package at the next available house.  </p>
<p>That’s what Azure Load Balancer does: it sends traffic to one of your servers without looking inside the request.</p>
<p><strong>Azure Application Gateway</strong><br>This is the smart one. It looks at <em>what’s inside</em> each request (like the URL path or domain) and makes intelligent decisions.</p>
<p>Just like a smarter delivery guy who looks at the address and decides where to go: "Oh! This one is for the payment office, not the main office."  </p>
<p>That’s what Application Gateway does: it reads the request (like the URL or domain name) and sends it to the right place according to the routing rules.</p>
<h3 id="heading-2-protocols-handled">🌐 2. <strong>Protocols Handled</strong></h3>
<p><strong>Load Balancer</strong><br>Works at the transport layer (Layer 4 in the OSI model). It deals with TCP/UDP traffic – raw network traffic, like HTTP, video streaming, games, and so on.</p>
<p><strong>Application Gateway</strong><br>Works at the application layer (Layer 7). It handles web traffic only – like websites and apps (HTTP/HTTPS) – and it can actually read what's being asked, like:</p>
<ul>
<li><p>“Go to /login”</p>
</li>
<li><p>“Go to <a target="_blank" href="http://payment.mydomain.com">payment.mydomain.com</a>”.</p>
</li>
</ul>
<p>TL;DR: Load Balancer just pushes packets. App Gateway actually <em>reads</em> your web requests.</p>
<h3 id="heading-3-use-case-scenarios">🔁 3. <strong>Use Case Scenarios</strong></h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Situation</td><td>Best Choice</td></tr>
</thead>
<tbody>
<tr>
<td>You have one big app and just want to spread users across servers</td><td>✅ Load Balancer</td></tr>
<tr>
<td>You have multiple services (like login, payment, and so on) and need to send users to the right one</td><td>✅ Application Gateway</td></tr>
<tr>
<td>You want to use subdomains (like <a target="_blank" href="http://login.mysite.com">login.mysite.com</a>)</td><td>✅ Application Gateway</td></tr>
<tr>
<td>You want to secure your website with HTTPS and Web Application Firewall (WAF)</td><td>✅ Application Gateway</td></tr>
<tr>
<td>You want the simplest setup and lowest cost</td><td>✅ Load Balancer</td></tr>
</tbody>
</table>
</div><h3 id="heading-4-ssl-termination-amp-security-features">🔐 4. <strong>SSL Termination &amp; Security Features</strong></h3>
<p><strong>Load Balancer</strong> doesn’t handle security stuff. You’ll need to secure each server yourself (for example, set up HTTPS on each one).</p>
<p><strong>Application Gateway</strong> can secure everything in one place – you upload your SSL certificate once and it takes care of HTTPS for all services.</p>
<p>It can also protect you from hackers and bad traffic with something called <strong>WAF (Web Application Firewall)</strong>, which protects your app from threats like SQL injection, XSS, and so on (you need to set this up manually).</p>
<h3 id="heading-5-pricing-and-complexity">💰 5. <strong>Pricing and Complexity</strong></h3>
<p><strong>Load Balancer</strong> is cheaper and easier to set up. Great when you don’t need anything fancy.</p>
<p><strong>Application Gateway</strong> costs more, but gives you more control and less headache when working with complex apps and microservices.</p>
<p>Trying to use Load Balancer for multiple services? You’ll need to create one Load Balancer per service, which becomes costly and impractical.</p>
<h3 id="heading-summary-table">🧠 Summary Table</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Load Balancer</td><td>Application Gateway</td></tr>
</thead>
<tbody>
<tr>
<td>Can it understand the request?</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Can it route based on URL or subdomain?</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Can it handle secure HTTPS traffic?</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Is it good for simple apps?</td><td>✅ Yes</td><td>✅ Yes</td></tr>
<tr>
<td>Is it good for complex apps with many services?</td><td>❌ No</td><td>✅ Yes</td></tr>
<tr>
<td>Cost</td><td>💲 Lower</td><td>💰 Higher</td></tr>
</tbody>
</table>
</div><h2 id="heading-use-cases-when-to-use-each-one">🧭 Use Cases: When to Use Each One</h2>
<p>There’s no one-size-fits-all when it comes to hosting apps in the cloud. The right setup depends on what you’re building, how much traffic you expect, and how complex your app is.</p>
<p>Let’s walk through 4 different use-case scenarios, starting from the most basic setup all the way to a fully auto-scaled and smartly routed architecture.</p>
<h3 id="heading-1-single-vm-instance-for-small-projects-or-internal-tools">1️⃣ <strong>Single VM Instance – For Small Projects or Internal Tools</strong></h3>
<p><strong>Use this when:</strong><br>You're just getting started. You’ve built a small app – maybe a portfolio, a blog, or a side project – and you want to make it live, OR You’re a startup that just launched.</p>
<p><strong>How it works:</strong><br>You spin up one Azure VM, install your app on it, and open the port it listens on (for example, port 80 for a web server). You can then attach a public IP to the VM and bind it to a custom domain like <code>myawesomeapp.com</code>.</p>
<p><strong>Real-life examples:</strong></p>
<ul>
<li><p>A developer hosting a portfolio website or blog</p>
</li>
<li><p>A startup testing a new product with only a few users</p>
</li>
<li><p>An internal company tool for a small team</p>
</li>
</ul>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Super simple setup</p>
</li>
<li><p>Low cost</p>
</li>
<li><p>Full control of your environment</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>If the VM goes down, your app goes down</p>
</li>
<li><p>No auto-scaling – performance may drop with traffic spikes (the only way to adapt to increased CPU/memory usage due to traffic inflow is via manually scaling the VM vertically)</p>
</li>
<li><p>You manually maintain and monitor everything</p>
</li>
</ul>
<h3 id="heading-2-manual-horizontal-scaling-for-apps-with-medium-predictable-traffic">2️⃣ <strong>Manual Horizontal Scaling – For Apps With Medium, Predictable Traffic</strong></h3>
<p><strong>Use this when:</strong><br>Your app is growing – maybe you have a few thousand users now, and performance matters. You want more than one server so your app doesn’t crash during busy hours.</p>
<p><strong>How it works:</strong><br>You manually create 2 or 3 Azure VMs with the same app setup. You then add a Load Balancer in front to split traffic evenly across them.</p>
<p><strong>Real-life examples:</strong></p>
<ul>
<li><p>A business with a customer portal</p>
</li>
<li><p>A school website that handles regular logins, lecture video streaming, and so on during class hours</p>
</li>
<li><p>An app that gets traffic mostly during the day (predictable load)</p>
</li>
</ul>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Better performance and availability</p>
</li>
<li><p>Load is shared across multiple VMs</p>
</li>
<li><p>You can scale manually when needed</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>You must manually add or remove VMs – which takes effort</p>
</li>
<li><p>Still need to monitor performance manually</p>
</li>
<li><p>No built-in automation or auto-healing</p>
</li>
</ul>
<h3 id="heading-3-auto-scaling-with-vm-scale-sets-azure-load-balancer-for-apps-with-spiky-or-unpredictable-traffic">3️⃣ <strong>Auto-Scaling with VM Scale Sets + Azure Load Balancer – For Apps With Spiky or Unpredictable Traffic</strong></h3>
<p><strong>Use this when:</strong><br>You’re building something more serious – traffic comes in waves (for example, a fitness/coach booking app), and you don’t want to sit around scaling VMs all day. You want Azure to automatically scale your infrastructure for you.</p>
<p><strong>How it works:</strong><br>You set up a Virtual Machine Scale Set (VMSS) that can automatically create more VMs when needed (like during high traffic), and remove them when things are calm — saving money. A Load Balancer distributes traffic across all those VMs.</p>
<p><strong>Real-life examples:</strong></p>
<ul>
<li><p>A media platform where people upload videos or photos</p>
</li>
<li><p>A shopping site that gets surges during promotions, for example Black Fridays</p>
</li>
<li><p>A booking platform with peak traffic in evenings/weekends</p>
</li>
</ul>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Automatic scaling – saves time and money</p>
</li>
<li><p>High availability: VMs can be replaced if one fails</p>
</li>
<li><p>Easy to grow as your user base grows</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>Works best if your app is monolithic (one big service)</p>
</li>
<li><p>No support for routing traffic to specific services – just spreads traffic across VMs</p>
</li>
<li><p>Load Balancer can’t look at URL paths or subdomains</p>
</li>
</ul>
<h3 id="heading-4-vm-scale-set-azure-application-gateway-for-microservices-or-complex-web-apps">4️⃣ <strong>VM Scale Set + Azure Application Gateway – For Microservices or Complex Web Apps</strong></h3>
<p><strong>Use this when:</strong><br>You have a modern, multi-service app – maybe built with microservices. Each service (like payments, authentication, search, and so on) lives on a different port or even in a container.</p>
<p>You want to route traffic smartly – like <code>/login</code> goes to the auth service, <code>/pay</code> to payments, and <code>/search</code> to the search service – all on the same domain.</p>
<p><strong>How it works:</strong><br>You still use a VM Scale Set for auto-scaling, but instead of a basic Load Balancer, you add an Application Gateway. It can inspect each request and send it to the right service based on things like:</p>
<ul>
<li><p>URL path (for example, <code>/payments</code>, <code>/orders</code>)</p>
</li>
<li><p>Subdomain (for example, <code>payments.mydomain.com</code>, <code>auth.mydomain.com</code>)</p>
</li>
</ul>
<p><strong>Real-life examples:</strong></p>
<ul>
<li><p>A full-blown SaaS product with multiple services</p>
</li>
<li><p>An e-commerce site with checkout, account, orders, and admin dashboards</p>
</li>
<li><p>A business migrating from a monolith to a microservices setup</p>
</li>
</ul>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Smart routing based on path or subdomain</p>
</li>
<li><p>Everything runs under one public IP and one domain</p>
</li>
<li><p>Secure HTTPS handling + optional Web Application Firewall (WAF)</p>
</li>
<li><p>Auto-scaling and high availability</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>More complex setup</p>
</li>
<li><p>Slightly higher cost due to Application Gateway</p>
</li>
<li><p>Needs planning around port numbers and backend pools</p>
</li>
</ul>
<h3 id="heading-quick-summary-table">🧠 Quick Summary Table</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Setup</td><td>Best For</td><td>Scaling</td><td>Routing Logic</td><td>Cost</td><td>Ease</td></tr>
</thead>
<tbody>
<tr>
<td>☁️ Single VM</td><td>Small sites, personal apps</td><td>❌ (Manual)</td><td>❌ One app only</td><td>💲 (Lowest)</td><td>⭐⭐⭐⭐</td></tr>
<tr>
<td>🧱 Manual Horizontal Scaling + Load Balancer</td><td>Mid-size apps, predictable traffic</td><td>✅ (Manual)</td><td>❌ One app only</td><td>💲💲💲 (due to multiple VMs running at once without down-scaling — even with no traffic)</td><td>⭐⭐ (due to manual scaling)</td></tr>
<tr>
<td>🔁 VMSS + Load Balancer</td><td>Busy apps, spiky traffic</td><td>✅ (Auto)</td><td>❌ One app only</td><td>💲💲</td><td>⭐⭐⭐</td></tr>
<tr>
<td>🍴 VMSS + App Gateway</td><td>Microservices, modern apps</td><td>✅ (Auto)</td><td>✅ Smart routing (involving multiple microservices)</td><td>💲💲💲💲(Highest)</td><td>⭐⭐</td></tr>
</tbody>
</table>
</div><h2 id="heading-conclusion">✅ Conclusion</h2>
<p>By now, you’ve gone from simply hearing the words “load balancer” or “scale set” to understanding exactly how they work, when to use them, and what problems they solve. Whether you’re just launching a small app or scaling up a high-traffic service, Azure gives you flexible, powerful tools to grow with confidence.</p>
<p>We started from the very beginning – a single virtual machine. It’s simple and great for small apps, but it quickly becomes a bottleneck as traffic grows.</p>
<p>That’s where scaling comes in. We explored:</p>
<ul>
<li><p>🧱 <strong>Vertical scaling</strong> – Upgrading the same VM (quick fix, but limited)</p>
</li>
<li><p>🧩 <strong>Horizontal scaling</strong> – Adding more VMs to handle traffic better</p>
</li>
</ul>
<p>Then we introduced Azure Virtual Machine Scale Sets (VMSS) – which bring auto-scaling to life. No more manual intervention – Azure can scale your servers up and down based on demand.</p>
<p>But where things really get smart is with load balancers:</p>
<ul>
<li><p>📦 <strong>Azure Load Balancer</strong> helps spread traffic across your VMs — great for single-service apps</p>
</li>
<li><p>🍴 <strong>Azure Application Gateway</strong> takes it further by routing requests based on URL paths or subdomains — perfect for multi-service or microservice apps</p>
</li>
</ul>
<h3 id="heading-tldr-what-should-you-use">🎯 TL;DR – What Should You Use?</h3>
<ul>
<li><p><strong>Single VM</strong>: For side projects, portfolios, or internal tools</p>
</li>
<li><p><strong>Manual scaling + Load Balancer</strong>: For medium apps with predictable load</p>
</li>
<li><p><strong>VMSS + Load Balancer</strong>: For monolithic apps with auto-scaling needs</p>
</li>
<li><p><strong>VMSS + Application Gateway</strong>: Also includes auto-scaling but for microservices or smart routing needs</p>
</li>
</ul>
<h3 id="heading-final-thoughts">💡 Final Thoughts</h3>
<p>Cloud apps grow – fast. And with growth comes complexity. But with the right Azure setup, you can stay one step ahead of your traffic, serve users better, and keep costs under control.</p>
<p>Remember: you don’t need to start big. Start small, understand your app's traffic patterns, and scale only when you need to. Tools like Azure VM Scale Sets, Load Balancer, and Application Gateway give you the control and power to build scalable, modern applications without over-engineering.</p>
<p>Thanks for sticking with me through this deep dive. I hope this made things clearer, simpler, and maybe even a little fun 😊</p>
<h2 id="heading-study-further"><strong>Study Further 📚</strong></h2>
<p>If you would like to learn more about Azure Virtual Machines, Scale Sets, Load Balancer, and Application Gateway, you can check out the courses below:</p>
<ul>
<li><p><a target="_blank" href="https://www.coursera.org/specializations/microsoft-azure-fundamentals-az900-exam-prep">Microsoft Azure Fundamentals AZ-900 Exam Prep Specialization</a> — Microsoft, Coursera</p>
</li>
<li><p><a target="_blank" href="https://youtu.be/QOv_-xBXkpo?si=kSijmQdev5cQbRKl">Azure Virtual Machine Tutorial | Creating A Virtual Machine In Azure | Azure Training | Simplilearn</a> — YouTube</p>
</li>
<li><p><a target="_blank" href="https://youtu.be/wN4lRWHUHA0?si=kWBGXhXZTnVgzuEj">Virtual machine scale sets</a> — YouTube</p>
</li>
<li><p><a target="_blank" href="https://youtu.be/VqBGjddK5VY?si=diLGQfuW5i0lxbse">Azure Load Balancer | Azure Load Balancer Tutorial | All About Load Balancer | Edureka</a> — YouTube</p>
</li>
<li><p><a target="_blank" href="https://youtu.be/V9EP4jAg4QM?si=t7EqQjw1eNHqOtjK">Azure Application Gateway Deep dive | Step by step explained</a> — YouTube</p>
</li>
</ul>
<h2 id="heading-about-the-author"><strong>About the Author 👨‍💻</strong></h2>
<p>Hi, I’m Prince! I’m a DevOps engineer and Cloud architect passionate about building, deploying, and managing scalable applications and sharing knowledge with the tech community.</p>
<p>If you enjoyed this article, you can learn more about me by exploring more of my blogs and projects on my <a target="_blank" href="https://www.linkedin.com/in/prince-onukwili-a82143233/">LinkedIn profile.</a> You can find my <a target="_blank" href="https://www.linkedin.com/in/prince-onukwili-a82143233/details/publications/">LinkedIn articles here</a>. You can also <a target="_blank" href="https://prince-onuk.vercel.app/achievements#articles">visit my website</a> to read more of my articles as well. Let’s connect and grow together! 😊</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Turn Ubuntu 24.04 into a KVM Hypervisor – Quick Setup with Web Management ]]>
                </title>
                <description>
                    <![CDATA[ Virtualization lets you run multiple operating systems on one machine. It’s perfect for testing apps, hosting servers, or learning DevOps. A hypervisor is the software that lets you run multiple virtual machines on a single physical machine, and the ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/turn-ubuntu-2404-into-a-kvm-hypervisor/</link>
                <guid isPermaLink="false">680fa285102a9fb019d4fa34</guid>
                
                    <category>
                        <![CDATA[ KVM ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hypervisor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vm ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shamsuddoha Ranju ]]>
                </dc:creator>
                <pubDate>Mon, 28 Apr 2025 15:45:09 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1745591647377/613d9a44-cc2b-45b7-b1d1-5fc3154b9623.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Virtualization lets you run multiple operating systems on one machine. It’s perfect for testing apps, hosting servers, or learning DevOps.</p>
<p>A hypervisor is the software that lets you run multiple virtual machines on a single physical machine, and the Kernel-based Virtual Machine (KVM) is one of the best. Built into Linux, KVM is fast (near-native performance), open-source (free!), and flexible (supports Windows, Linux, and more). It’s trusted by both cloud providers and homelabbers for its stability and low overhead.</p>
<p>If you want to turn your Ubuntu 24.04 or Kubuntu 24.04 (Kubuntu is a Ubuntu variant with KDE Plasma desktop) system into a powerful hypervisor without <strong>Proxmox</strong>’s complexity, this guide is for you. With KVM, you’ll spin up virtual machines (VMs) in minutes, and with Cockpit’s web-based manager, you’ll control them from your browser.</p>
<p>In this tutorial, you’ll transform an Ubuntu 24.04 or Kubuntu 24.04 Desktop or Server – fresh or existing – into a KVM hypervisor. You’ll set up the backend (KVM, QEMU, libvirt), add Cockpit for web-based VM management, and create a guest VM to test it all. Whether you’re a coder, homelabber, or IT enthusiast, this guide is beginner-friendly.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-before-you-start-what-you-should-know">Before You Start: What You Should Know</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-youll-need">What You’ll Need</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-kvm-on-ubuntukubuntu-2404">Why KVM on Ubuntu/Kubuntu 24.04?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-check-virtualization-support">Step 1: Check Virtualization Support</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-install-kvm-and-backend-tools">Step 2: Install KVM and Backend Tools</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-set-up-a-network-bridge">Step 3: Set Up a Network Bridge</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-install-cockpit-for-web-management">Step 4: Install Cockpit for Web Management</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-create-a-guest-vm">Step 5: Create a Guest VM</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-run-and-test-your-guest-vm">Step 6: Run and Test Your Guest VM</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-keep-exploring-your-hypervisor">Keep Exploring Your Hypervisor</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ul>
<h2 id="heading-before-you-start-what-you-should-know">Before You Start: What You Should Know</h2>
<p>This guide is designed for virtualization newcomers, but you’ll need a few basic skills:</p>
<ul>
<li><p>Running terminal commands like <code>sudo apt install</code> or <code>nano</code> and so on.</p>
</li>
<li><p>Basic Linux navigation (for example, editing files in <code>/etc</code>).</p>
</li>
<li><p>Basic networking knowledge, such as understanding network interfaces (for example, <code>enp4s0</code> or <code>wlp3s0</code>), IP addresses, and concepts like bridging or NAT. You’ll use tools like <code>ip link</code> or <code>nmcli</code> to set up a network bridge in Step 3.</p>
</li>
<li><p>Optional: Experience with VMs helps but isn’t required – I’ll explain everything.</p>
</li>
</ul>
<p>No worries if terms like “libvirt” sound new. I’ll break them down as we go.</p>
<h2 id="heading-what-youll-need">What You’ll Need</h2>
<ul>
<li><p><strong>A computer</strong>: Running Ubuntu 24.04 or Kubuntu 24.04 Desktop or Server (fresh or existing). Minimum: 4GB RAM, 20GB storage, CPU with virtualization support (Intel VT-x or AMD-V). More RAM/storage for multiple VMs.</p>
</li>
<li><p><strong>Internet access</strong>: To download packages and VM ISOs.</p>
</li>
<li><p><strong>A web browser</strong>: Firefox (default on Ubuntu) or Chrome to access Cockpit.</p>
</li>
<li><p><strong>An ISO image</strong>: An ISO image for your guest VM (for example, Ubuntu 24.04 Desktop ISO from ubuntu.com or Windows ISO if you have it already).</p>
</li>
<li><p><strong>30–45 minutes</strong>: Depending on your setup speed.</p>
</li>
</ul>
<h2 id="heading-why-kvm-on-ubuntukubuntu-2404">Why KVM on Ubuntu/Kubuntu 24.04?</h2>
<p>KVM turns your Linux kernel into a hypervisor, letting you run VMs with near-native speed. Paired with QEMU (for hardware emulation) and libvirt (for management), it’s a lightweight alternative to <strong>Proxmox</strong> or <strong>VMware</strong>. Its strengths include:</p>
<ul>
<li><p><strong>Performance</strong>: Runs VMs efficiently, ideal for homelabs or dev environments.</p>
</li>
<li><p><strong>Free and Open-Source</strong>: No licenses, just like Ubuntu/Kubuntu, and so on.</p>
</li>
<li><p><strong>Flexibility</strong>: Supports diverse guest OSs (Linux, Windows, BSD).</p>
</li>
<li><p><strong>Integration</strong>: Cockpit’s web UI makes VM management a breeze, no CLI required.</p>
</li>
</ul>
<p>Here’s what each tool does:</p>
<ul>
<li><p><strong>KVM</strong>: A Linux kernel module that turns your system into a hypervisor, enabling VMs to run with near-native performance by leveraging CPU virtualization features (for example, Intel VT-x).</p>
</li>
<li><p><strong>QEMU</strong>: A powerful emulator that provides the virtual hardware (for example, CPU, disk, network) for your VMs, working with KVM for fast execution.</p>
</li>
<li><p><strong>libvirt</strong>: A management layer that simplifies VM creation, networking, and storage, offering tools like <code>virsh</code> and APIs for automation.</p>
</li>
<li><p><strong>Cockpit</strong>: A web-based interface for managing VMs, system resources, and networks, perfect for beginners who want a visual dashboard.</p>
</li>
</ul>
<p>Ubuntu 24.04 (“Noble Numbat”) brings the latest kernel and tools, ensuring top-notch KVM compatibility. Let’s build your hypervisor!</p>
<h2 id="heading-step-1-check-virtualization-support">Step 1: Check Virtualization Support</h2>
<p>First, you’ll want to confirm that your CPU supports virtualization (most modern ones do). To do that, open a terminal (like Konsole on Kubuntu) and run:</p>
<pre><code class="lang-bash">lscpu | grep Virtualization
</code></pre>
<p>Look for "VT-x" (Intel) or "AMD-V" (AMD). If present, you’re good!</p>
<p>If nothing shows, check your BIOS/UEFI:</p>
<ul>
<li><p>Reboot, enter BIOS (usually <code>F2</code>, <code>Del</code>, or <code>Esc</code>).</p>
</li>
<li><p>Enable "Intel VT-x" or "AMD-V" under CPU settings.</p>
</li>
<li><p>Save and reboot.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745226012162/337e2324-50b3-4bd9-b040-01c2ac919e7c.png" alt="Konsole terminal on Kubuntu displaying ‘lscpu | grep Virtualization’ output confirming VT-x support for KVM." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-2-install-kvm-and-backend-tools">Step 2: Install KVM and Backend Tools</h2>
<p>Let’s install KVM, QEMU, and libvirt. These will form the backbone of your hypervisor:</p>
<p>Start by updating your system (you may need to restart your computer after the update):</p>
<pre><code class="lang-bash">sudo apt update &amp;&amp; sudo apt upgrade -y
</code></pre>
<p>Then install the virtualization packages:</p>
<pre><code class="lang-bash">sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y
</code></pre>
<ul>
<li><p><code>qemu-kvm</code>: Emulates hardware for VMs.</p>
</li>
<li><p><code>libvirt-daemon-system</code>: Manages VMs.</p>
</li>
<li><p><code>libvirt-clients</code>: CLI tools like <code>virsh</code> for hypervisor management.</p>
</li>
<li><p><code>bridge-utils</code>: For network bridging.</p>
</li>
</ul>
<p>Next, verify that KVM is loaded:</p>
<pre><code class="lang-bash">lsmod | grep kvm
</code></pre>
<p>You’ll see “kvm_intel” or “kvm_amd” if successful.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745226199517/a146d89d-2894-4bbc-b241-11a8ed385758.png" alt="Konsole terminal on Kubuntu displaying ‘lsmod | grep kvm’ output showing kvm_intel module loaded for KVM." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Finally, add your (current) user to the <code>libvirt</code> group for permission:</p>
<pre><code class="lang-bash">sudo usermod -aG libvirt <span class="hljs-variable">$USER</span>
</code></pre>
<p>Log out and back in to apply these changes.</p>
<h2 id="heading-step-3-set-up-a-network-bridge">Step 3: Set Up a Network Bridge</h2>
<p>VMs need network access, so you’ll create a bridge (<code>br0</code>) to connect them to your physical network. This allows VMs to act like devices on your network (bridged networking).</p>
<p>Ubuntu 24.04 and Kubuntu 24.04 Desktop typically use NetworkManager, while Ubuntu Server may use Netplan. We’ll prioritize the NetworkManager approach, with Netplan as an alternative.</p>
<p><strong>Note</strong>: Installing libvirt (Step 2) creates a default bridge called <code>virbr0</code> for NAT-based networking, which isolates VMs from the physical network (IPs like <code>192.168.122.x</code>). For direct network access (IPs like <code>192.168.0.x</code>), use <code>br0</code> as described below, and select it in Step 5’s VM setup.</p>
<p>You can verify whether your system is using NetworkManager or Netplan. Open a console and run <code>systemctl status NetworkManager</code>. If you see the status active and running, go with NetworkManager.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745305149513/0926f09c-1748-484f-af4c-37dcb82d06a5.png" alt="Konsole terminal on Kubuntu displaying ‘systemctl status NetworkManager’ output confirming NetworkManager status." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-option-1-networkmanager-recommended-for-kubuntuubuntu-desktop">Option 1: NetworkManager (Recommended for Kubuntu/Ubuntu desktop)</h3>
<p>Check your network interface:</p>
<pre><code class="lang-bash">ip link
</code></pre>
<p>Example: <code>enp4s0</code>. Replace <code>enp4s0</code> below if yours differs.</p>
<p>First, find your Ethernet connection name:</p>
<pre><code class="lang-bash">nmcli connection show
</code></pre>
<p>Look for the <strong>NAME</strong> column where <strong>DEVICE</strong> is <code>enp4s0</code> (for example, “Wired connection 1” or “Ethernet connection”). Note this name. Ignore <code>virbr0</code>, which is libvirt’s default NAT bridge.</p>
<p>Then create a bridge named <code>br0</code>:</p>
<pre><code class="lang-bash">sudo nmcli connection add <span class="hljs-built_in">type</span> bridge ifname br0 con-name bridge-br0
</code></pre>
<p>Enslave your interface to the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection add <span class="hljs-built_in">type</span> ethernet ifname enp4s0 master br0 con-name bridge-slave-enp4s0
</code></pre>
<p>Disable the old connection (replace with your connection name identified earlier):</p>
<pre><code class="lang-bash">sudo nmcli connection down <span class="hljs-string">"Wired connection 1"</span>
sudo nmcli connection delete <span class="hljs-string">"Wired connection 1"</span>
</code></pre>
<p>Enable DHCP on the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection modify bridge-br0 ipv4.method auto
</code></pre>
<p>Activate the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection up bridge-br0
</code></pre>
<p>Verify:</p>
<pre><code class="lang-bash">ip addr show br0
nmcli connection show
</code></pre>
<p>Now you’ll want to ensure <code>br0</code> is active, <code>enp4s0</code> is enslaved, and <code>virbr0</code> is separate. First, test the internet with <code>ping 8.8.8.8</code>.</p>
<p>Then you need to define <code>br0</code> in libvirt (to appear in Cockpit’s VM network dropdown). To do this, create <code>br0.xml</code> in your home directory:</p>
<pre><code class="lang-bash">nano ~/br0.xml
</code></pre>
<p>Then add the following:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">network</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>br0<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">forward</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">'bridge'</span>/&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">bridge</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'br0'</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">network</span>&gt;</span>
</code></pre>
<p>Save and exit (<code>Ctrl+O</code>, <code>Enter</code>, <code>Ctrl+X</code>).</p>
<p>Now define and start the following:</p>
<pre><code class="lang-bash">sudo virsh net-define ~/br0.xml
sudo virsh net-start br0
sudo virsh net-autostart br0
</code></pre>
<p>Verify like this:</p>
<pre><code class="lang-bash">virsh net-list --all
</code></pre>
<p>You can now delete <code>~/br0.xml</code> after defining, as libvirt stores it in <code>/etc/libvirt/qemu/networks/</code>.</p>
<pre><code class="lang-bash">rm ~/br0.xml
</code></pre>
<h3 id="heading-option-2-netplan-for-ubuntu-server-or-if-preferred">Option 2: Netplan (For Ubuntu Server or If Preferred)</h3>
<p>If you see <code>renderer: networkd</code> in <code>/etc/netplan/???.yaml</code> or prefer Netplan, follow these steps.</p>
<p>First, check your interface:</p>
<pre><code class="lang-bash">ip link
</code></pre>
<p>Example: <code>enp4s0</code>.</p>
<p>Next, edit the Netplan config like so:</p>
<pre><code class="lang-bash">sudo nano /etc/netplan/01-netcfg.yaml
</code></pre>
<p>Use the following:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">network:</span>
  <span class="hljs-attr">version:</span> <span class="hljs-number">2</span>
  <span class="hljs-attr">renderer:</span> <span class="hljs-string">networkd</span>
  <span class="hljs-attr">ethernets:</span>
    <span class="hljs-attr">enp4s0:</span>
      <span class="hljs-attr">dhcp4:</span> <span class="hljs-literal">no</span>
  <span class="hljs-attr">bridges:</span>
    <span class="hljs-attr">br0:</span>
      <span class="hljs-attr">interfaces:</span> [<span class="hljs-string">enp4s0</span>]
      <span class="hljs-attr">dhcp4:</span> <span class="hljs-literal">yes</span>
</code></pre>
<p>Save and exit (<code>Ctrl+O</code>, <code>Enter</code>, <code>Ctrl+X</code>).</p>
<p>Now, set strict permissions to avoid errors:</p>
<pre><code class="lang-bash">sudo chmod 600 /etc/netplan/01-netcfg.yaml
</code></pre>
<p>And apply:</p>
<pre><code class="lang-bash">sudo netplan apply
</code></pre>
<p>Now verify:</p>
<pre><code class="lang-bash">ip addr show br0
</code></pre>
<p>Test the internet with <code>ping 8.8.8.8</code> (from console).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745227201229/35988335-5ff1-49bc-9809-e9c08d6798c4.png" alt="Konsole terminal on Kubuntu displaying ‘nmcli connection show’ output with bridge-br0 active, enp4s0 enslaved, and virbr0 present for KVM networking." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong>Troubleshooting</strong>:</p>
<ul>
<li><p><strong>Permissions error</strong>: If Netplan complains about “too open” permissions, recheck <code>sudo chmod 600 /etc/netplan/01-netcfg.yaml</code>.</p>
</li>
<li><p><strong>NetworkManager conflict</strong>: If using Netplan, ensure <code>/etc/netplan/01-network-manager-all.yaml</code> is backed up or deleted (<code>sudo mv /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all.yaml.bak</code>).</p>
</li>
<li><p><strong>No onternet</strong>: Restart NetworkManager (<code>sudo systemctl restart NetworkManager</code>) or reboot.</p>
</li>
<li><p><strong>Wrong bridge</strong>: If a VM uses <code>virbr0</code> (NAT, <code>192.168.122.x</code>), recheck Step 5’s network setting and select <code>br0</code>.</p>
</li>
<li><p><strong>br0 missing in Cockpit</strong>: Define <code>br0</code> in libvirt (step 9 above) or ensure <code>br0</code> is active (<code>ip addr show br0</code>).</p>
</li>
</ul>
<h2 id="heading-step-4-install-cockpit-for-web-management">Step 4: Install Cockpit for Web Management</h2>
<p>Cockpit provides a slick web UI to manage VMs. Let’s go ahead and set it up.</p>
<p>First, you’ll need to install Cockpit and its VM plugin:</p>
<pre><code class="lang-bash">sudo apt install cockpit cockpit-machines -y
</code></pre>
<p>Then you can start and enable Cockpit:</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> --now cockpit.socket
systemctl status cockpit.socket
</code></pre>
<p>Now open your browser (for example, Firefox on Ubuntu) and visit:</p>
<pre><code class="lang-plaintext">https://localhost:9090
</code></pre>
<p>Or use your KVM server’s IP (for example, <code>https://192.168.0.100:9090</code>) if remote. Log in with your username and password. Ignore the self-signed certificate warning.</p>
<p>Allow Cockpit’s port if you’re using a firewall:</p>
<pre><code class="lang-bash">sudo ufw allow 9090
</code></pre>
<p>You’ll see Cockpit’s dashboard. Turn on administrative access by clicking on “<strong>Turn on administrative access</strong>”. Then, click “<strong>Virtual Machines</strong>” to manage VMs.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745227293385/96291774-d4cf-4de2-9392-3947ade4bb8b.png" alt="Firefox on Kubuntu displaying Cockpit login page at https://localhost:9090 for web-based VM management." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-5-create-a-guest-vm">Step 5: Create a Guest VM</h2>
<p>Let’s create a guest VM using Cockpit. We’ll use an Ubuntu 24.04 Desktop ISO as an example:</p>
<p>To start, download the Ubuntu 24.04 Desktop ISO from ubuntu.com and save it (for example, <code>/home/ranju/Downloads/ubuntu-24.04.1-desktop-amd64.iso</code>).</p>
<p>In Cockpit, go to “Virtual Machines” and click “Create VM”. Here are the specs:</p>
<ul>
<li><p><strong>Name</strong>: TestVM</p>
</li>
<li><p><strong>Installation Type</strong>: Local install media (or your desired installation type)</p>
</li>
<li><p><strong>Installation Source</strong>: Browse to your ISO (for example, <code>/home/ranju/Downloads/ubuntu-24.04.1-desktop-amd64.iso</code>).</p>
</li>
<li><p><strong>OS</strong>: Select “Ubuntu 24.04” (usually Cockpit auto-detects).</p>
</li>
<li><p><strong>Storage</strong>: Create new qcow2 volume (preferred). <em>Note: disk is created in</em> <code>/var/lib/libvirt/images/</code><em>.</em></p>
</li>
<li><p><strong>Storage limit</strong>: 20GB (adjust as needed).</p>
</li>
<li><p><strong>Memory</strong>: 4GB (adjust as needed).</p>
</li>
</ul>
<p>Click “Create and Edit”. Cockpit opens an advanced dialog where there are options for customization (for example, CPU, Network Interfaces and Boot order, and so on). Make sure that <code>br0</code> has been selected as interface source. Finally, click “<strong>Install</strong>”.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745228999671/4d80faf7-d8f8-4395-985e-298b4add426c.png" alt="Cockpit web interface in Firefox on Kubuntu showing the Create VM dialog with TestVM settings." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>In Cockpit’s VM console, follow the installer to set up the guest OS (username, password, and so on).</p>
<p><strong>Troubleshooting</strong>:</p>
<ul>
<li><p><strong>Permissions error</strong>: If you have permission error for the ISO, then copy the ISO to the default temp folder (<code>/tmp/</code>) and locate the ISO from there.</p>
<pre><code class="lang-bash">  cp /home/ranju/Downloads/ubuntu-24.04.1.iso /tmp/
</code></pre>
</li>
</ul>
<h2 id="heading-step-6-run-and-test-your-guest-vm">Step 6: Run and Test Your Guest VM</h2>
<p>Your VM is running! Let’s test it:</p>
<ol>
<li><p>In Cockpit, under “Virtual Machines,” click TestVM. You’ll see its console (a live view of the VM’s screen).</p>
</li>
<li><p>Log into the guest Ubuntu using the credentials you set.</p>
</li>
<li><p>Test networking:</p>
<ul>
<li><p>Open a terminal in the VM (via Cockpit’s console).</p>
</li>
<li><p>Run <code>ip addr</code> in the console to confirm a physical network IP (for example, <code>192.168.0.x</code> with <code>br0</code>, not <code>192.168.122.x</code> with <code>virbr0</code>).</p>
</li>
<li><p>Run <code>ping 8.8.8.8</code> to confirm internet access.</p>
</li>
</ul>
</li>
<li><p>Experiment: Open a browser in the VM, visit a website, or install apps to simulate real use.</p>
</li>
</ol>
<p>If the VM boots and connects to your network, your KVM hypervisor is rocking! You can stop, restart, or delete it from Cockpit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745307664700/ed54d452-4979-4468-a7fe-1dd538844e25.png" alt="Cockpit web interface in Firefox on Kubuntu displaying the TestVM console with Ubuntu 24.04 desktop." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-keep-exploring-your-hypervisor">Keep Exploring Your Hypervisor</h2>
<p>You’ve turned your Ubuntu 24.04 into a KVM hypervisor – congrats! Try these next steps:</p>
<ul>
<li><p><strong>Add more VMs</strong>: Create Windows or other Linux VMs using different ISOs.</p>
</li>
<li><p><strong>Use virt-manager</strong>: Install virt-manager for a desktop-based alternative to Cockpit (<code>sudo apt install virt-manager</code>).</p>
</li>
<li><p><strong>Back up VMs</strong>: Export VM disks with <code>virsh</code> for safety.</p>
</li>
<li><p><strong>Scale up</strong>: Add storage or RAM for heavier workloads, like my Proxmox cluster guide.</p>
</li>
</ul>
<p>Check your VMs anytime via CLI:</p>
<pre><code class="lang-bash">virsh list --all
</code></pre>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>You’ve built a fast, free KVM hypervisor on Ubuntu 24.04, complete with Cockpit’s web UI and a running guest VM. It’s a perfect playground for coding, testing, or homelab fun.</p>
<p>Share your ideas or comments with me – I’d love to hear them!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ VM Data Protection Best Practices: How to Mitigate Risk in a Virtual Environment ]]>
                </title>
                <description>
                    <![CDATA[ Vast amounts of data flow through virtualized environments these days. And that data needs to be protected. So making sure that your virtual machines are secured, along with their associated data, is key for maintaining operational continuity and saf... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vm-data-protection-best-practices/</link>
                <guid isPermaLink="false">66bf49af410af52542e93140</guid>
                
                    <category>
                        <![CDATA[ Data security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Protection ]]>
                    </category>
                
                    <category>
                        <![CDATA[ risk management ]]>
                    </category>
                
                    <category>
                        <![CDATA[ proxmox ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vmware ]]>
                    </category>
                
                    <category>
                        <![CDATA[ risk mitigation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Risk Assessment ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vm ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Alex Tray ]]>
                </dc:creator>
                <pubDate>Fri, 16 Aug 2024 12:44:31 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723559872911/f9953e98-7948-47a0-a054-62028df854b9.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Vast amounts of data flow through virtualized environments these days. And that data needs to be protected. So making sure that your virtual machines are secured, along with their associated data, is key for maintaining operational continuity and safeguarding against cyber threats.</p>
<p>In this guide, you'll learn about VM-specific risks for data and workloads. I'll also provide some recommendations that can help you mitigate them. Implementing these data protection best practices can help you ensure production continuity, data availability, and regulatory compliance for your organization.</p>
<p><strong>Table of Contents</strong></p>
<dl>
<ul>
  <li><a href="#heading-two-of-the-main-players-vmware-and-proxmox">Two of the Main Players: VMWare and Proxmox</a></li>
  <li><a href="#heading-understanding-the-risks-of-virtual-environments">Understanding the Risks of Virtual Environments</a></li>
  <li>
    <a href="#heading-specific-risks-associated-with-virtual-environments">Specific Risks Associated with Virtual Environments</a>
    <ul>
      <li><a href="#heading-hypervisor-security-vulnerabilities">Hypervisor security vulnerabilities</a></li>
      <li><a href="#heading-vm-sprawl">VM sprawl</a></li>
      <li><a href="#heading-insecure-vm-configurations">Insecure VM configurations</a></li>
      <li><a href="#heading-snapshot-and-clone-risks">Snapshot and clone risks</a></li>
    </ul>
  </li>
  <li>
    <a href="#heading-vm-data-protection-and-secure-virtualization-best-practices">VM Data Protection and Secure Virtualization Best Practices</a>
    <ul>
      <li><a href="#heading-secure-the-virtualized-environment">Secure the Virtualized Environment</a></li>
      <li><a href="#heading-backup-and-recovery-strategies">Backup and Recovery Strategies</a></li>
      <li><a href="#heading-monitoring-and-auditing">Monitoring and Auditing</a></li>
    </ul>
  </li>
  <li>
    <a href="#heading-advanced-protection-techniques">Advanced Protection Techniques</a>
    <ul>
      <li><a href="#heading-encryption">Encryption</a></li>
      <li><a href="#heading-intrusion-detection-and-prevention-systems-idps">Intrusion Detection and Prevention Systems (IDPS)</a></li>
      <li><a href="#heading-application-and-network-security">Application and Network Security</a></li>
    </ul>
  </li></ul></dl>

<h2 id="heading-two-of-the-main-players-vmware-and-proxmox">Two of the Main Players: VMWare and Proxmox</h2>
<p>Both VMware and Proxmox offer robust solutions for virtualization, but they come with their own set of challenges and risks that can impact VM data protection.</p>
<p>VMware is the market leader in virtualization <a target="_blank" href="https://www.6sense.com/tech/virtualization/vmware-market-share#:~:text=VMware%20has%20market%20share%20of,ESXi%20with%205.99%25%20market%20share.">with almost 50% of the market share</a>, which is both a boon and a bane.</p>
<p>On the one hand, VMware has a high-end, efficient portfolio of solutions to build IT environments of any complexity and size. On the other, such popularity means that malicious actors know what they can target during cyberattacks, posing challenges in virtualization security for VMware users.</p>
<p>Proxmox, a prominent alternative to VMware, also offers robust virtualization solutions. While Proxmox may have a smaller market share compared to VMware, it provides a comprehensive set of tools for managing virtual environments. It can also be a good choice for those looking for open-source solutions with flexibility and cost-efficiency.</p>
<p>Over three-quarters of organizations that have 50+ workers <a target="_blank" href="https://smartprofile.io/analytics-papers/vmware-far-largest-server-virtualisation-market/">use server virtualization</a>. So it's hard to overestimate the importance of the data that's circulating in their virtualized workloads.</p>
<p>The workloads themselves can be mission-critical and cause global disruption and downtime in case of failures. The data can also be crucial to run efficient services and generate revenue or be subject to compliance requirements.</p>
<h2 id="heading-understanding-the-risks-of-virtual-environments">Understanding the Risks of Virtual Environments</h2>
<p>Before we proceed with VM security best practices, let’s go over some general security issues associated with virtual environments.</p>
<ul>
<li><p><strong>Data breaches</strong> are a regular issue that most IT protection systems experience. A lone hacker or an organized cybercriminal group can intrude into corporate environments to steal data. Their targets are typically clients' personal data, credit card info, credentials, and intellectual property.</p>
</li>
<li><p><strong>Insider threats</strong> are usually the most underrated yet <a target="_blank" href="https://www.ekransystem.com/en/blog/insider-threat-statistics-facts-and-figures">exceptionally dangerous issue</a>. Malicious insiders sneakily strike from the inside of an organization’s security perimeter and may have advanced access privileges. This can lead to a global IT disaster, and preventing it is a high-level challenge.</p>
</li>
<li><p><strong>Malware and ransomware attacks</strong> are an ever-evolving threat for organizations of all sizes and types.</p>
</li>
<li><p><strong>System vulnerabilities and exploits.</strong> The supply chains of today’s IT services can be complicated and consist of multiple synchronized solutions. Every solution involved in service provisioning is a potential source of vulnerabilities that malicious actors can exploit upon discovery.</p>
</li>
</ul>
<h2 id="heading-specific-risks-associated-with-virtual-environments">Specific Risks Associated with Virtual Environments</h2>
<p>Understanding the risks of virtualization – particularly with VMware, one of the most popular virtualization platforms for enterprises, and Proxmox, which has seen increasing adoption in recent times – will help you and your team build an effective data protection system in your virtualized environments.</p>
<p>The unique threats associated with these platforms dictate how you should secure your virtual machines, servers, networks, and other virtualized nodes.</p>
<p>Key factors that can weaken virtualized infrastructure security include:</p>
<h3 id="heading-hypervisor-security-vulnerabilities"><strong>Hypervisor security vulnerabilities</strong></h3>
<ul>
<li><p><strong>VMware</strong>: Because of its extensive use in enterprises, attackers frequently target VMware. Major issues can arise due to the integration and complexity of VMware's hypervisor. The "<a target="_blank" href="https://www.nakivo.com/blog/vmware-esxi-ransomware/?utm_source=Freecodecamp&amp;utm_medium=guest_post&amp;utm_campaign=free_trial">ESXiArgs</a>" ransomware strain takes advantage of VMware vulnerabilities to infiltrate computers before the distribution of updates.</p>
</li>
<li><p><strong>Proxmox</strong>: While this open-source technology does have the potential for hypervisor vulnerabilities, the community can also provide security improvements such as timely patches, vulnerability reports, and enhancements to security protocols. Insufficiently managed upgrades or third-party modules can put Proxmox users at risk of security vulnerabilities.</p>
</li>
</ul>
<h3 id="heading-vm-sprawl"><strong>VM sprawl</strong></h3>
<ul>
<li><p><strong>VMWare:</strong> The ease of deploying VMs in VMware can lead to VM sprawl, where numerous virtual machines are created but not adequately managed. IT teams can create a virtual machine, for example, to test a new feature in an isolated environment before releasing it in production. If not deleted after completing the task, the new virtual machine can remain in an environment without attention, maintenance, or security updates.</p>
</li>
<li><p><strong>Proxmox</strong>: Proxmox's flexibility in managing virtual environments causes VM sprawl, which is more likely to affect smaller teams lacking strong monitoring. Its straightforward interface and streamlined deployment processes help to make creating and managing many virtual machines (VMs) a delight. While this helps with development and testing quickly, it can also cause an influx of virtual machines (VMs) to be launched without proper management or preparation.</p>
</li>
</ul>
<h4 id="heading-insecure-vm-configurations"><strong>Insecure VM configurations</strong></h4>
<ul>
<li><p><strong>VMware</strong>: A VMWare virtual machine itself is a complex environment with multiple configurations and dependencies. Misconfiguration of VMware's resources, operating systems, or applications can lead to additional virtual desktop security risks.</p>
</li>
<li><p><strong>Proxmox</strong>: Users of Proxmox might also face security pitfalls due to misconfigured VMs, especially when utilizing custom templates or third-party integrations. Insufficient security settings can expose services and open ports, enabling unauthorized access.</p>
</li>
</ul>
<h4 id="heading-snapshot-and-clone-risks"><strong>Snapshot and clone risks</strong></h4>
<ul>
<li>Inappropriate VM snapshot retention and maintenance policies in both Proxmox and VMware environments can cause storage overload. Creating too many VM clones can eventually lead to RAM and CPU deficiencies. Insufficiency of hardware resources then causes performance degradation and disk failures, resulting in downtime and data loss.</li>
</ul>
<h2 id="heading-vm-data-protection-and-secure-virtualization-best-practices">VM Data Protection and Secure Virtualization Best Practices</h2>
<p>Data loss in virtualized environments, such as VMWare or Proxmox, can lead to fines, financial losses, and reputational damage for an organization.</p>
<p>Below are some recommendations on how to improve VM data security for virtual nodes, clusters, and infrastructures. The tips cover both virtualization-specific risks and those common to IT security, providing valuable insights for managing data protection effectively in both VMware and Proxmox environments.</p>
<h3 id="heading-secure-the-virtualized-environment">Secure the Virtualized Environment</h3>
<p>For starters, you can strengthen your environment with regular VM security practices. Consider implementing the following:</p>
<h4 id="heading-strong-access-controls-and-authentication-mechanisms"><strong>Strong access controls and authentication mechanisms.</strong></h4>
<p>Role-based access control (RBAC) is an efficient security measure that ensures users have only the access and privileges required to fulfill job duties. With roles set for every employee, their accounts become less dangerous under unauthorized access in case of, for example, compromised credentials.</p>
<p>This can help you either completely counter a security breach attempt or at least significantly mitigate the consequences of a protection failure. Two-factor authentication (2FA) added on top of that purposely complicates the login process, making regular passwords insufficient to hack and exploit an account.</p>
<h4 id="heading-regular-updates-and-patch-management"><strong>Regular updates and patch management</strong></h4>
<p>Set up regular update checks for solutions included in your supply chain. Installing updates and especially security patches on time means that your system closes known vulnerabilities. This reinforces the security perimeter and can protect your environment from random breaches and brute-force attacks, supporting secure virtualization.</p>
<h4 id="heading-network-segmentation-and-isolation"><strong>Network segmentation and isolation</strong></h4>
<p>Combined with external protection reinforcement, segmenting your network using virtual routers, firewalls and switches can be efficient in isolating critical workloads and data from major threats.</p>
<p>A complex internal environment poses an additional challenge for hackers preparing their attacks. Also, if a network scan shows that the infrastructure is ramified and segmented, some bad actors may even conclude that an attack is not worth the effort.</p>
<h3 id="heading-backup-and-recovery-strategies">Backup and Recovery Strategies</h3>
<p>Backups are essential in building an efficient VM data protection system. When all else fails, a backup can help you restore critical data and workloads with little to no downtime.</p>
<p>An efficient VM backup and recovery system includes:</p>
<p><strong>Regular and automated VM backups.</strong> To ensure minimal downtime, you need a backup with a “fresh” recovery point recorded. Given the complexity of even the smallest corporate virtualized environments, only automation and scheduling backups can ensure their regularity.</p>
<p><strong>Offsite and cloud-based backup solutions.</strong> In addition to onsite backups, consider sending data copies to offsite and cloud repositories. This helps you avoid a single point of failure and keep up with the 3-2-1 backup rule.</p>
<p>In case your main infrastructure is down due to a disruption, offsite backups in two different destinations can remain recoverable and accessible.</p>
<p><strong>Disaster recovery planning and testing.</strong> Virtualized environments can include hundreds and thousands of virtual machines, servers and clusters to provide stable and efficient services.</p>
<p>To minimize downtime after global failures, you need to <a target="_blank" href="https://www.nakivo.com/blog/components-disaster-recovery-plan-checklist/">plan disaster recovery</a> (DR) sequences and test them regularly. Set up a scheduled testing workflow to ensure checks.</p>
<p>Also, you might want to conduct disaster recovery testing sessions every time you introduce changes into your main virtualized environment.</p>
<p>Advanced <a target="_blank" href="https://www.cybersecurity-insiders.com/proxmox-backup-by-nakivo-powerful-vm-data-protection/">VM data protection</a> solutions for secure virtualization, such as <a target="_blank" href="https://www.nakivo.com/proxmox-backup/">NAKIVO Backup &amp; Replication</a>, provide the set of features and functions required to implement the above-mentioned VM backup recommendations.</p>
<p>As a regular user of the NAKIVO solution, specifically for protecting virtualized environments, I’ve experienced firsthand the benefits of its robust features. I highly recommend taking advantage of the <a target="_blank" href="https://www.nakivo.com/resources/download/trial-download/?utm_source=Freecodecamp&amp;utm_medium=guest_post&amp;utm_campaign=free_trial">free version</a> of this solution, which is available until the end of 2024.</p>
<h3 id="heading-monitoring-and-auditing">Monitoring and Auditing</h3>
<p>One of the most efficient VM data protection best practices for virtualized environments is to monitor resource usage, VM health, and behavior. This includes the following:</p>
<p><strong>Continuous monitoring of virtualized environments.</strong> Sufficient hardware resources are crucial for production continuity in virtualized environments. You may want to keep track of infrastructures in general and mission-critical VMs in particular. Thus, you can know the current resource consumption and predict scaling needs and budgets to support system stability as your organization grows.</p>
<p><strong>Audit trails and logging.</strong> Audit trails and logging help you get a sequential record of specific activities and data within systems and their components. This includes failed and successful logins, MAC addresses and IPs of involved devices, access locations, data transactions as well as VM and policy changes.</p>
<p><strong>Anomaly detection and response.</strong> With monitoring and logging established and functioning, you can detect anomalies in the behavior of users and VMs, and resource consumption changes within system nodes. With such behavioral data, you can timely react to potential security threats.</p>
<h2 id="heading-advanced-protection-techniques">Advanced Protection Techniques</h2>
<p>Advanced threat protection tips for virtual machines describe techniques related to encryption, intrusion detection and prevention systems, and additional security of applications and networks. Let’s review every technique in detail.</p>
<h3 id="heading-encryption">Encryption</h3>
<p>In a modern IT landscape where any user is able to download and use traffic interception tools, unencrypted data is most likely public data. To enhance your VM data protection for secure virtualization, you can ensure:</p>
<ul>
<li><p><strong>Encrypting data at rest and in transit.</strong> Encrypt data during transmission (in flight) and throughout retention (at rest). Such all-round data encryption enables you to enhance protection from unauthorized access in most situations.</p>
</li>
<li><p><strong>Implementing secure key management.</strong> For additional security, consider setting up an encryption key management system. This includes regular generation, secure exchange, storage and use, timely destruction and replacement of encryption keys.</p>
</li>
</ul>
<h3 id="heading-intrusion-detection-and-prevention-systems-idps">Intrusion Detection and Prevention Systems (IDPS)</h3>
<p>Intrusion detection and prevention systems are designed to scan and monitor networks and automatically take action to counter possible breaches.</p>
<ul>
<li><p><strong>Integrating IDPS with VMs.</strong> IDPS integration is about revealing the key nodes of your virtual environment and installing program “sensors” that track the situation around them. You can then count on software automation to take the first actions to counter possible intrusions as they occur.</p>
</li>
<li><p><strong>Real-time threat detection and response.</strong> Consider developing specialized workflows for responding to intrusions after the IDPS detects them and stops the most obvious malicious activities. Keep in mind that modern cyberattacks can involve a multi-layered series of smaller hits to distract and deceive the defenders.</p>
</li>
</ul>
<h3 id="heading-application-and-network-security">Application and Network Security</h3>
<p>In addition to supply chain control, network segmentation, and isolation, you can make your VM data protection system more reliable with additional app and network security enhancements. For instance, consider the following steps:</p>
<ul>
<li><p><strong>Hardening VM applications.</strong> As apps can become weak links in your protection chain, consider hardening their protection. For example, remove unnecessary components and disable unwanted services that such applications might run. Also, you can set reliable passwords, regular code reviews and role-based access controls within apps.</p>
</li>
<li><p><strong>Implementing firewall and VPN solutions.</strong> These are additional VM data protection best practices that specifically harden networks. External and internal firewalls can prevent unauthorized access to system elements, while VPN connections ensure secure access for authorized users.</p>
</li>
</ul>
<h2 id="heading-future-trends-in-vm-data-protection">Future Trends in VM Data Protection</h2>
<p>The future of secure virtualization mainly depends on the evolution of relevant threats. The popularity of virtualization solutions, such as VMWare and Proxmox, defines the close attention that hackers pay to VM vulnerabilities and specifics.</p>
<p>Malicious actors also shape their ransomware, interception, and intrusion tools to become more dangerous to virtualized IT infrastructure. Sophisticated malware enables deeply customized attacks that exploit the VM security weaknesses of the organization’s infrastructure.</p>
<p>The improvement of AI algorithms can bring additional challenges to the field, making malware spread faster, becoming less detectable, and targeting priority nodes with efficient strikes.</p>
<p>However, the same idea works for VM security best practices. AI-driven cyber defense solutions can help detect and counter specific threats in VM environments with significantly better performance and efficiency.</p>
<p>Advanced VM threat detection based on behavioral analysis throughout the entire infrastructure can help reveal malware earlier. Prevention tools independently reacting to potentially dangerous changes in an environment can enable quick response and counter cyberattacks right after they begin.</p>
<p>Lastly, AI can learn how to enhance protection flexibility and introduce defensive changes in an environment depending on how a cyberattack develops. The boosted speed and variety of <a target="_blank" href="https://www.hostpapa.com/blog/web-hosting/what-small-businesses-need-to-know-about-cybersecurity/">cybersecurity</a> moves then promote virtualized security (and data protection as a whole) to notably higher effectiveness levels.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thorough VM security is crucial for any organization that's using virtualized IT environments. Consider implementing strong access controls, patch management, network segmentation, monitoring, auditing and app security to counter key threats and mitigate their outcomes.</p>
<p>You might also want to build an advanced <a target="_blank" href="https://www.nakivo.com/blog/proxmox-backup/">Proxmox replication</a> or <a target="_blank" href="https://www.nakivo.com/blog/vmware-backup/">VMware backup</a> system to have a swift data recovery option in case of a breach or system failure.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Ethical Hacking 101 – How to Set Up Metasploitable on Your Computer ]]>
                </title>
                <description>
                    <![CDATA[ Ladies and Gentlemen, welcome to the world of Virtual Machines 🖥️ So you’ve discovered the world of ethical hacking and you want to try your hands on something. Trouble is, doing some ‘practical application’ on the wrong thing could get you fined, a... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-set-up-metasploitable/</link>
                <guid isPermaLink="false">66bb90185d242388375d387e</guid>
                
                    <category>
                        <![CDATA[ cybersecurity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ethical Hacking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ VirtualBox  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Daniel Iwugo ]]>
                </dc:creator>
                <pubDate>Tue, 12 Mar 2024 12:39:45 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/08/pexels-mati-6330644.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Ladies and Gentlemen, welcome to the world of Virtual Machines 🖥️</p>
<p>So you’ve discovered the world of ethical hacking and you want to try your hands on something. Trouble is, doing some ‘practical application’ on the wrong thing could get you fined, arrested, and even undesired jail time.</p>
<p>You don’t have to give up your dreams just yet though. There is a legal, ethical way to sharpen your cyber offensive skills: Vulnerable Virtual Machines.</p>
<p>In this tutorial, we’ll take a look at the following:</p>
<ol>
<li><a class="post-section-overview" href="#heading-what-is-a-virtual-machine">What is a Virtual Machine?</a></li>
<li><a class="post-section-overview" href="#heading-what-is-metasploitable">What is Metasploitable?</a></li>
<li><a class="post-section-overview" href="#heading-how-to-set-up-metasploitable">How to Set Up Metasploitable</a></li>
<li><a class="post-section-overview" href="#heading-a-quick-word-on-vulnerable-machines">A Quick Word on Vulnerable VMs</a></li>
</ol>
<p>So without further ado, let’s jump in.</p>
<h2 id="heading-what-is-a-virtual-machine">What is a Virtual Machine?</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-38.png" alt="Image" width="600" height="400" loading="lazy">
<em>Virtual Machines ¦ Credit: [Hackersarts](https://www.deviantart.com/hackersarts" rel="noopener noreferrer)</em></p>
<p>A Virtual Machine (VM) is an emulation of a computer system. Think of it like a mini disposable environment where you can play around with different operating systems and software. </p>
<p>On a VM, you can delete critical system files, test software, or even install a virus (not recommended), and nothing will happen to your actual system.</p>
<p>All this is made possible with a hypervisor, a software that takes some of your ‘host’ system’s hardware resources, and makes it available for the ‘guest’ machine. A hypervisor allows you to determine things like how much RAM, storage, and even screens (if you have multiple displays), you want to hand over to the VM.</p>
<p>There are 2 types of hypervisors, namely:</p>
<ul>
<li>Type 1 hypervisors</li>
<li>Type 2 hypervisors</li>
</ul>
<p>Mind blowing naming scheme, I know.</p>
<p>Type 1 hypervisors run directly on the physical host machine and have direct access to hardware resources. They tend to be used for servers and enterprise-level infrastructure. They are considered more efficient because of their direct access to the host resources. Examples of type 1 hypervisors include Microsoft Hyper-V and VMware ESXi.</p>
<p>Type 2 hypervisors, on the other hand, are installed on the host OS, and manages the hardware resources for the guest. You would find these on personal computers and they make hardware resource management pretty easy for the average user. Examples of type 2 hypervisors are Oracle VirtualBox (my personal favourite 😌) and VMware Workstation.</p>
<p>We’ll be using Oracle VirtualBox, a type 2 hypervisor, for simplicity (and because I don’t have a server randomly lying around the house). Now, let’s find an appropriate vulnerable VM to install.</p>
<h2 id="heading-what-is-metasploitable">What is Metasploitable?</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-39.png" alt="Image" width="600" height="400" loading="lazy">
<em>A mere box ¦ Credit: [Rostislav Uzunov](https://www.pexels.com/@rostislav/" rel="noopener noreferrer)</em></p>
<p>Metasploitable is an ‘intentionally vulnerable virtual machine’ by Rapid7, owners of the popular security project, Metasploit. Note that Metasploitable and Metasploit are two different things entirely. The previous is a VM while the latter is a cyber offense tool (which may or may not be covered in a later article 😉).</p>
<p>VMs, much like any other computer, need to be as secure as possible. Metasploitable does the complete opposite. It comes out of the box with enough vulnerabilities to give the cybersecurity professionals at <a target="_blank" href="https://cysed.org">CYSED</a> serious nightmares. The VM is a Linux-based system with various ports open, insecure configurations, and outdated software.</p>
<p>Now, let’s figure out how to install it securely on our systems.</p>
<h2 id="heading-how-to-set-up-metasploitable">How to Set Up Metasploitable</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-40.png" alt="Image" width="600" height="400" loading="lazy">
<em>The metasploitable interface ¦ Credit: Author</em></p>
<p>Before we go further, you’re going to need a few things:</p>
<ul>
<li>An Internet Connection</li>
<li>A Computer with at least 8 GB RAM and 20 GB free storage</li>
<li>A flair to be an awesome geek</li>
</ul>
<p>And with those boxes checked, let’s get started.</p>
<p>To download the VM, head over to Google and type in ‘Metasploitable download’. Click on the first link by <a target="_blank" href="https://sourceforge.net/projects/metasploitable/">SourceForge</a>, and hit download. The file is about 800 megabytes so feel free to pull up an episode of Scooby-Doo while that’s downloading.</p>
<p>You should have a zip file like this once that is done:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-41.png" alt="Image" width="600" height="400" loading="lazy">
<em>The metasploitable zip file ¦ Credit: Author</em></p>
<p>Right-click and hit ‘Extract All…’ to get the VM Disk. You should see some files like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-42.png" alt="Image" width="600" height="400" loading="lazy">
<em>The zip file contents ¦ Credit: Author</em></p>
<p>We’re going to need VirtualBox to install our VM. You can quickly setup VirtualBox using this <a target="_blank" href="https://www.freecodecamp.org/news/what-is-a-virtual-machine-and-how-to-setup-a-vm-on-windows-linux-and-mac/">tutorial</a> by <a target="_blank" href="https://www.freecodecamp.org/news/author/beau/">Beau Carnes</a>. To import Metasploitable, open VirtualBox and click on ‘New’. Set the following options:</p>
<p>Name: Metasploitable (or whatever you like)</p>
<p>Type: Linux</p>
<p>Version: Other Linux (64-bit)</p>
<p>You don't have to select an ISO image because the OS is already in the virtual hard disk which will be installed as we go along.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-43.png" alt="Image" width="600" height="400" loading="lazy">
<em>Setting up the VM ¦ Credit: Author</em></p>
<p>Click on ‘Next’, which should take you to the hardware section. As mentioned before, a VM is a simulation of the real system, which requires resources like RAM and a Processor. You can change the amount of RAM and logical processors your VM uses. </p>
<p>Keep in mind that the more resources you allocate to the VM, the less resources you have for your system.</p>
<p>On that note, I would suggest leaving the default hardware settings.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-44.png" alt="Image" width="600" height="400" loading="lazy">
<em>Deciding how much hardware we need ¦ Credit: Author</em></p>
<p>Quick lesson: Your system likely only has 1 physical processor but can have as many as 8 or more logical processors. This is because of something called <strong>hyperthreading</strong>, where a computer basically converts it’s physical cores into multiple smaller virtual ones. Now back to the tutorial.</p>
<p>Click ‘Next’ and you’ll be directed to the ‘Virtual Hard disk’ section. Normally, you’d create a virtual hard disk for your VM but we already have one.</p>
<p>Click on ‘Use an Existing Virtual Hard Disk File’ and hit ‘Add’ at the top right.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-45.png" alt="Image" width="600" height="400" loading="lazy">
<em>Selecting a Virtual hard disk ¦ Credit: Author</em></p>
<p>This will open up File Explorer, where you will proceed to select the ‘Metasploitable.vmdk’ file. Once that is done, Metasploitable should appear under the ‘Not Attached’ list.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-46.png" alt="Image" width="600" height="400" loading="lazy">
<em>Selecting the Metasploitable hard disk ¦ Credit: Author</em></p>
<p>Select it, hit ‘Choose’ and click on ‘Next’. You will be led to a ‘Summary’ section which will give you information about the VM before it is finally setup.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-47.png" alt="Image" width="600" height="400" loading="lazy">
<em>Putting in the final touches ¦ Credit: Author</em></p>
<p>Let’s finish it up by literally hitting ‘Finish’ and you should get a screen like so.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-48.png" alt="Image" width="600" height="400" loading="lazy">
<em>Metasploitable installed on VirtualBox ¦ Credit: Author</em></p>
<p>Congratulations on setting up Metasploitable 🎉. Now you can build your cybersecurity skills without risking a trip to your local prison 😉.</p>
<p>The credentials for the machine are <code>msfadmin:msfadmin</code>. Feel free to boot up your Kali machine, ping the machines, and start hacking. Here, I’ll give you a hint: It starts with ‘nmap’ 👁️.</p>
<h2 id="heading-a-quick-word-on-vulnerable-machines">A Quick Word on Vulnerable Machines</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/03/image-49.png" alt="Image" width="600" height="400" loading="lazy">
<em>A network of sorts ¦ Credit: [AcatXIo](https://pixabay.com/users/acatxio-20233758/" rel="noopener noreferrer)</em></p>
<p>Just like a real system, a virtual machine is vulnerable to real world attacks. Try not to leave Metasploitable up when not in use and definitely do not expose it to an untrusted network. </p>
<p>By default, the VM is set to use NAT (Network Address Translation) which adds a layer of security by isolating it from the external network while providing it access to the internet.</p>
<p>However, this may not be a comprehensive solution. One common alternative is to change the network adapter settings to ‘Host-Only’, which shuts the VM off from the Internet but allows it to communicate with other VMs and the host.</p>
<p>If you’re wondering what the other options are, here is a quick summary for each:</p>
<ul>
<li><strong>NAT:</strong> Shares host network, provides internet access to VM.</li>
<li><strong>Bridged Adapter:</strong> VM connects directly to the physical network.</li>
<li><strong>Internal Network:</strong> Isolated network for VMs on the same host.</li>
<li><strong>Host-Only Adapter:</strong> VMs communicate with host and among themselves.</li>
<li><strong>Generic Driver:</strong> Allows using custom, non-standard network drivers.</li>
<li><strong>NAT Network:</strong> Similar to NAT but allows defining network properties.</li>
<li><strong>Cloud Network:</strong> Experimental feature for cloud-based networking.</li>
<li><strong>Not Attached:</strong> No network connection for the virtual machine.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>And now, let’s summarize what you’ve learned in this tutorial:</p>
<ol>
<li>What a Virtual Machine is and how it works</li>
<li>What Metasploitable is</li>
<li>How to install Metasploitable and any other VM</li>
<li>What different network adapters do in VirtualBox</li>
</ol>
<p>Playing with Metasploitable is a great way to practice offensive cybersecurity skills and the defensive if you want to try and patch it up. <a target="_blank" href="https://www.vulnhub.com">Vulnhub</a> is a great place to download more virtual machines if you want to move beyond Metasploitable.</p>
<p>You could also use platforms like <a target="_blank" href="https://tryhackme.com/">TryHackMe</a> and <a target="_blank" href="https://www.hackthebox.com">HackTheBox</a> which are gamified and make things more fun if you want something a little different.</p>
<p>Good luck and Happy Hacking 🙃</p>
<h2 id="heading-resources">Resources</h2>
<ol>
<li><a target="_blank" href="https://cysed.org">Learn more about Cybersecurity in Africa</a></li>
<li><a target="_blank" href="https://docs.rapid7.com/metasploit/metasploitable-2-exploitability-guide/">The Metasploitable Exploitability Guide from Rapid7</a></li>
</ol>
<h2 id="heading-acknowledgements">Acknowledgements</h2>
<p>Thanks to <a target="_blank" href="https://www.linkedin.com/in/a-n-u-o/">Anuoluwapo Victor</a>, <a target="_blank" href="https://www.linkedin.com/in/chinaza-nwukwa-22a256230/">Chinaza Nwukwa</a>, <a target="_blank" href="https://www.linkedin.com/in/mercy-holumidey-88a542232/">Holumidey Mercy</a>, <a target="_blank" href="https://www.linkedin.com/in/favour-ojo-906883199/">Favour Ojo</a>, <a target="_blank" href="https://www.linkedin.com/in/georgina-awani-254974233/">Georgina Awani</a>, and my family for the inspiration, support and knowledge used to put this post together. You’re all amazing.</p>
<p>Cover image credit: <a target="_blank" href="https://www.pexels.com/@googledeepmind/">Google DeepMind</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How Docker Containers Work – Explained for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software. And one of the most popular tools for working with containers is Docker. Docker is both the name of the company (Doc... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-docker-containers-work/</link>
                <guid isPermaLink="false">66d45e144a7504b7409c336a</guid>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker Containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Daniel Adetunji ]]>
                </dc:creator>
                <pubDate>Mon, 23 Oct 2023 16:45:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/10/cover-final.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software.</p>
<p>And one of the most popular tools for working with containers is Docker.</p>
<p>Docker is both the name of the company (Docker Inc) and the software they have created which packages software into containers.</p>
<p>To understand how containers work and why they are incredibly useful for software development, you need to understand two seemingly unrelated topics – shipping containers and virtual machines.</p>
<h2 id="heading-a-brief-history-of-shipping-containers">A Brief History of Shipping Containers</h2>
<p>"The Box: How the Shipping Container Made the World Smaller and the World Economy Bigger" is a book by <a target="_blank" href="https://www.amazon.co.uk/Box-Shipping-Container-Smaller-Economy/dp/0691170819/ref=sr_1_1?crid=14VL4VEQHDVNL&amp;keywords=the+box+book&amp;qid=1694037660&amp;sprefix=the+box+book%2Caps%2C97&amp;sr=8-1">Marc Levinson</a>. It explores the profound impact of the shipping container on global trade and the world economy.</p>
<p>While the history of the shipping container may seem irrelevant in a discussion about Docker containers, they have more in common than you would expect.</p>
<p>Before shipping containers, cargo handling was labor-intensive and time-consuming, leading to inefficiencies and delays in global trade. Cargo arrived in various shapes and sizes, and the lack of standardised packaging made it challenging to stack and secure items efficiently.</p>
<p>Without standardised containers, cargo was often stored haphazardly in the holds of ships or in dockyards. This inefficient use of space meant that ships were not carrying as much cargo as they could potentially hold, leading to higher transportation costs.</p>
<p>The adoption of uniform container dimensions and handling procedures allowed for seamless transfer of cargo between different modes of transportation – ships, trucks, trains, and the cranes used to move the containers around.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ac7826e-ebd0-4062-8f49-d48a6f9ef9ce_1886x946.png" alt="Image" width="1456" height="730" loading="lazy"></p>
<p><em>Image showing how standardised container sizes allow them to be easily moved between ships, trains and trucks.</em></p>
<p>This standardisation was the key to the success of shipping containers. After all, if one company’s containers didn't fit on another company's ship, truck, or freight train, they couldn't be properly transported. Every company would need its own fleet of containers to be able to send things to each of their customers – which would be an operational nightmare.</p>
<p>Standardisation of shipping containers makes them portable, that is easy to move from one place to another. This portability is a key feature of Docker containers as well, which we'll discuss shortly.</p>
<h2 id="heading-what-are-virtual-machines">What are Virtual Machines?</h2>
<p>Virtual machines (VMs) are created through a process called virtualisation.</p>
<p>Virtualisation is a technology that allows you to create multiple simulated environments or virtual versions of something, such as an operating system, a server, storage, or a network, on a single physical machine.</p>
<p>These virtual environments behave as if they are independent, separate entities, even though they share the resources of the underlying physical system.</p>
<p>Virtualisation is like having a magician's hat that can conjure up multiple hats within it. Just as the magician's hat creates the illusion of many hats appearing from just a single physical hat, virtualisation allows a single physical computer or server to appear as multiple virtual machines (VMs), each with its own operating system and resources.</p>
<p>VMs virtualise the hardware. This simply means that a VM takes a single piece of hardware – a server – and creates virtual versions of other servers running their own operating systems. Physically, it is just a single piece of hardware.</p>
<p>Logically, multiple virtual machines can run on top of a single piece of hardware. This is essentially one or more computers running within a computer, as shown below.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9733d44-d0c7-49e6-8978-da253cf9c3a9_1650x966.png" alt="Image" width="1456" height="852" loading="lazy"></p>
<p><em>Image showing how virtualisation creates several virtual machines (VMs) from a single physical server</em></p>
<h3 id="heading-how-does-virtualisation-work">How does virtualisation work?</h3>
<p>So you might be wondering – how exactly does virtualisation work? Have a look at the image below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cd74b32-e3d1-430f-bbd6-e0daf2150b82_1084x576.png" alt="Image" width="1084" height="576" loading="lazy"></p>
<p><em>Image showing how virtualisation works by virtualising a single piece of hardware to create multiple virtual machines</em></p>
<p>At the base, you have the host hardware and OS. This is the physical machine that is used to create the virtual machines. On top of this, you have the hypervisor. This allows multiple virtual machines, each with their own operating systems (OS), to run on a single physical server.</p>
<p>VMs have a few downsides, though, which containers address. Two downsides particularly stand out:</p>
<ol>
<li><p>VMs consume more resources: VMs have a higher resource overhead due to the need to run a full OS instance for each VM. This can lead to larger memory and storage consumption. This in turn can have a negative effect on performance and startup times of the virtual machine.</p>
</li>
<li><p>Portability: VMs are typically less portable due to differences in underlying OS environments. Moving VMs between different hypervisors or cloud providers can be more complex.</p>
</li>
</ol>
<p>The major cloud providers all have VMs. For AWS, it's EC2, GCP has Compute Engine, and Azure has Azure Virtual Machines.</p>
<h2 id="heading-what-are-containers">What are Containers?</h2>
<p>A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, system tools, and libraries.</p>
<p>Containers are designed to isolate applications and their dependencies, ensuring that they can run consistently across different environments. Whether the application is running from your computer or in the cloud, the application behaviour remains the same.</p>
<p>Unlike VMs which virtualise the hardware, <a target="_blank" href="https://aws.amazon.com/compare/the-difference-between-containers-and-virtual-machines/#:~:text=Containers%20virtualize%20the%20operating%20system,use%20your%20hardware%20resources%20efficiently.">containers virtualise the operating system</a>. This simply means that a container uses a single OS to create a virtual application and its libraries. Containers run on top of a shared OS provided by the host system.</p>
<p>This is illustrated below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55e6ff35-1917-4374-8006-80aa8668a772_1160x470.png" alt="Image" width="1160" height="470" loading="lazy"></p>
<p><em>Image showing how containers works by virtualising the OS</em></p>
<p>The container engine allows you to spin up containers. It provides the tools and services necessary for building, running, and deploying containerised applications.</p>
<p>Containers have several benefits:</p>
<ol>
<li><p><strong>Portability</strong>: Containers are designed to be platform-independent. They can run on any system that supports the container runtime, such as Docker, regardless of the underlying operating system. This makes it easier to move applications between different environments, including local development machines, testing servers, and different cloud platforms.</p>
</li>
<li><p><strong>Efficiency</strong>: Containers share the host system's operating system, which reduces the overhead of running a virtual machine with multiple operating systems. This leads to more efficient resource utilization and allows for a higher density of applications that can run on a single host.</p>
</li>
<li><p><strong>Consistency</strong>: Containers package all the necessary components, including the application code, runtime, libraries, and dependencies, into a single unit. This eliminates the "it works on my machine" problem and ensures that the application runs consistently across different environments, from development to production.</p>
</li>
<li><p><strong>Isolation</strong>: Containers provide a lightweight and isolated environment for running applications. Each container encapsulates the application and its dependencies, ensuring that they do not interfere with each other. This isolation helps prevent conflicts and ensures consistent behaviour across different environments.</p>
</li>
<li><p><strong>Fast Deployment</strong>: Containers can be created and started quickly, often in a matter of seconds. This rapid deployment speed is particularly beneficial for applications that need to rapidly scale up or down based on demand.</p>
</li>
</ol>
<h2 id="heading-what-is-docker">What is Docker?</h2>
<p>Now that we have covered VMs and containers, what exactly is Docker? Docker is simply a tool for creating and managing containers.</p>
<p>At its core, Docker has two concepts that are useful to understand: the Dockerfile and Docker Images.</p>
<p>A Dockerfile contains the set of instructions for building a Docker Image.</p>
<p>A Docker Image serves as a template for creating Docker containers. It contains all the necessary code, runtime, system tools, libraries, and settings required to run a software application.</p>
<p>So, a Dockerfile is used to build a Docker Image which is then used as the template for creating one or more Docker containers. This is illustrated below.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f5a703a-0a08-48a0-be54-46ca4a29a9dc_1974x534.png" alt="Image" width="1456" height="394" loading="lazy"></p>
<p><em>Image showing the steps to create a docker container. First you create the Dockerfile which is used to build the Docker Image which is finally used to run a Docker container</em></p>
<p>If this explanation still causes you to scratch your head, consider the following analogy using shipping containers.</p>
<p>Imagine you need to build multiple shipping containers to transport items all over the world. You start with a document listing out the requirements for your shipping container. This will contain information like the container dimensions, type of seals, door locking mechanisms, ventilation and refrigeration requirements (if you are shipping food that needs a temperature controlled environment, for example), and so on.</p>
<p>This requirement document will then be used to create a detailed template for the container which will include engineering drawings showing the dimensions and other specifications.</p>
<p>From this template, the physical containers will then be built. This single template can be used to build one or many physical containers which will all be identical and match the specifications in the container template.</p>
<p>This is illustrated below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa1ac249-4fd1-49f2-8b7b-e52914017f89_1944x830.png" alt="Image" width="1456" height="622" loading="lazy"></p>
<p><em>Image showing a shipping container analogue for docker containers</em></p>
<p>The Dockerfile is analogous to the requirements document, which simply has a set of instructions for building the container template.</p>
<p>The Docker Image is analogous to the container template, which details all the instructions needed for building the physical container.</p>
<p>Once created, Docker images are immutable, meaning they cannot be changed. If you need to make changes to an application, you need to modify the Dockerfile and create a new image. This immutability ensures consistency and reproducibility in application deployment.</p>
<p>And finally, the Docker container is analogous to the physical shipping container.</p>
<h2 id="heading-bringing-it-together">Bringing it Together</h2>
<p>In summary, containers provide a <strong>portable</strong> and <strong>efficient</strong> way to package applications and their dependencies, ensuring consistency across various environments. The benefits they bring to software development is similar to the benefits brought to the global economy by the humble shipping container.</p>
<h3 id="heading-portability">Portability</h3>
<p>Shipping containers, through standardisation, ensure that any container, anywhere in the world, can be seamlessly used to move items across various modes of transportation – ships, trucks, trains and the cranes used to load them on and off different forms of transport.</p>
<p>Similarly, Docker containers allow for portability. They ensure that applications can run consistently across different environments, from development laptops to production servers, and across different cloud providers.</p>
<h3 id="heading-increased-efficiency">Increased Efficiency</h3>
<p>With standard container sizes, the packing density of goods you can move increases. Now, you can squeeze more things into a single shipping container, compared to the days before the shipping container existed where you had cargo in non standard shapes and sizes stored haphazardly in the holds of ships or on dockyards. So, every ship, freight train or truck can carry more goods during every trip, making it cheaper to move goods around the world.</p>
<p>With Docker containers, better efficiency comes from the fact that containers share the host operating system, making them lightweight compared to VMs. This leads to rapid container startup times and less CPU, memory, and storage use.</p>
<p>Less resource utilisation also means that containers can increase the application density when compared to VMs. With containers, you can run more applications on the same hardware without a significant drop in performance.</p>
<p>To conclude, the shipping container by itself is not magical. After all, it is just a metal box. It is the standardisation of shipping containers which made them portable and a cheap and efficient way to move goods around the world.</p>
<p>In application development, containers benefit from standardisation in the same way. Containers provide a portable and efficient way to package applications and their dependencies, ensuring consistency across various environments.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Create and Manage Virtual Machines with the Vagrant Command Line Tool ]]>
                </title>
                <description>
                    <![CDATA[ Creating and managing virtual machines used to be a tedious and time-consuming process. Replicating the VM on a different server can also be challenging, and it gets harder if you have to replicate multiple VMs. But then Vagrant came along, a command... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/create-and-manage-virtual-machines-with-vagrant/</link>
                <guid isPermaLink="false">66d45f31246e57ac83a2c76b</guid>
                
                    <category>
                        <![CDATA[ command line ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eti Ijeoma ]]>
                </dc:creator>
                <pubDate>Mon, 03 Apr 2023 20:15:11 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/04/Screenshot-2023-04-01-at-23.42.01-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Creating and managing virtual machines used to be a tedious and time-consuming process. Replicating the VM on a different server can also be challenging, and it gets harder if you have to replicate multiple VMs.</p>
<p>But then Vagrant came along, a command-line or shell tool that generally works with <a target="_blank" href="https://en.wikipedia.org/wiki/Hypervisor#:~:text=Type%2D2%20or%20hosted%20hypervisors">Type 2 hypervisors</a>. You use it to create and manage virtual machines. It is a powerful tool that can help simplify the setup and management of your development environment.</p>
<p>Vagrant can be really helpful if you work on a team or with multiple people. This is because it guarantees consistency in your development environment by ensuring that everyone utilizes the same environment, preventing compatibility issues.</p>
<p>This tutorial will guide you through the process of setting up a single Ubuntu Linux virtual machine with Vagrant and configuring a web server inside it.</p>
<h3 id="heading-prerequisites-for-this-tutorial-include">Prerequisites for this tutorial include:</h3>
<ul>
<li><p>A computer with at least 8GB of RAM</p>
</li>
<li><p>Basic knowledge of the Linux operating system</p>
</li>
</ul>
<h3 id="heading-required-tools-and-installation">Required Tools and Installation</h3>
<ul>
<li><p><strong>Oracle VirtualBox:</strong> Go to the <a target="_blank" href="https://www.virtualbox.org/wiki/Downloads">Oracle VirtualBox</a> website, find the version of VirtualBox that is compatible with your operating system, and follow the instructions to download and install it. Virtual Box will provide the virtual environment, while Vagrant will set it up and manage it.</p>
</li>
<li><p><strong>Vagrant:</strong> Visit the <a target="_blank" href="https://www.vagrantup.com/">Vagrant website</a> and follow the instructions to download and install the binary that is suitable for your operating system. In this tutorial, we'll be utilizing the open-source Vagrant binary.</p>
</li>
</ul>
<p>To check if the installation was successful, launch your preferred command line tool and enter the following command to output the installed version number:</p>
<pre><code class="lang-bash">$ vagrant --version
</code></pre>
<h2 id="heading-how-to-create-a-development-environment-with-vagrant">How to Create a Development Environment with Vagrant</h2>
<p>To create a Vagrant project, start by creating a new project directory in your preferred location for Vagrant configuration and related files.</p>
<pre><code class="lang-bash">$ mkdir vagrant-project &amp;&amp; <span class="hljs-built_in">cd</span> vagrant-project
</code></pre>
<p>Within this directory, create a new Vagrantfile. Vagrant uses the configuration in the Vagrantfile to build the VM. By default, Vagrant syncs the project directory where the Vagrantfile is initialized to /vagrant. This eliminates the need to worry about volumes for persisting data.</p>
<p>Vagrant uses the concept of boxes. Boxes are a complete base image of an operating system. The public <a target="_blank" href="https://app.vagrantup.com/boxes/search">vagrant box repository</a> contains a list of possible boxes. Choosing a box that matches the operating system used in your production environment is good practice.</p>
<p>A Vagrant box has the name of the user or organization that created it and the box name <code>user/boxname</code>. To initialize the Vagrant configuration file with an Ubuntu box, run the command:</p>
<pre><code class="lang-bash">$ vagrant init ubuntu/trusty64
</code></pre>
<p>This generates a Vagrantfile with a Ubuntu/trusty64 box in the current directory. The Vagrantfile, which is written in Ruby, contains the kind of VM to be used and various additional commented options such as network, port forwarding, disc capacity, and so on to assist in configuring the development environment.</p>
<p>You can add the <code>--minimal</code> flag to the initialization command of the Vagrantfile to generate a Vagrantfile without any additional settings.</p>
<p>Open the Vagrantfile with any editor of your choice. I will use the Vim editor in this tutorial.</p>
<pre><code class="lang-bash"> $ vim Vagrantfile
</code></pre>
<p>Removing the informational comments and some advanced configurations will leave the file like this:</p>
<pre><code class="lang-ruby"><span class="hljs-comment"># -*- mode: ruby -*-</span>
<span class="hljs-comment"># vi: set ft=ruby :</span>

Vagrant.configure(<span class="hljs-string">"2"</span>) <span class="hljs-keyword">do</span> <span class="hljs-params">|config|</span>
  config.vm.box = <span class="hljs-string">"ubuntu/xenial64"</span>
    config.vm.network <span class="hljs-string">"forwarded_port"</span>, <span class="hljs-symbol">guest:</span> <span class="hljs-number">8000</span>, <span class="hljs-symbol">host:</span> <span class="hljs-number">8000</span>
    config.vm.provider <span class="hljs-string">"virtualbox"</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|vb|</span> vb.memory = <span class="hljs-string">"1024"</span>
 <span class="hljs-keyword">end</span>
  config.vm.provision <span class="hljs-symbol">:shell</span>, <span class="hljs-symbol">path:</span> <span class="hljs-string">"simple-node-project.sh"</span>, <span class="hljs-symbol">privileged:</span> <span class="hljs-literal">false</span>
<span class="hljs-keyword">end</span>
</code></pre>
<p>The <code>simple-node-project.sh</code> is a bash script that installs Node.js and Git, clones a project that creates a simple Node.js web server, and starts the server.</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

 sudo apt-get update -y

 <span class="hljs-comment">## Git ##</span>
 <span class="hljs-built_in">echo</span> <span class="hljs-string">'###Installing Git..'</span>
 sudo apt-get install git -y

 git <span class="hljs-built_in">clone</span> https://github.com/Aijeyomah/simple-node-app.git

<span class="hljs-comment"># Installing latest Node and npm version</span>
 sudo apt-get install -y curl software-properties-common

<span class="hljs-comment"># Add Node.js PPA</span>
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

<span class="hljs-comment"># Install Node.js and npm</span>
sudo apt-get install -y nodejs

<span class="hljs-comment"># Verify installation</span>
node -v
npm -v

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Node.js has been installed successfully."</span>

<span class="hljs-comment"># navigate to app directory and start app</span>
<span class="hljs-built_in">cd</span> simple-node-app
node index.js &amp;
</code></pre>
<p>This Vagrant configuration sets up the following:</p>
<ul>
<li><p><code>ubuntu/trusty64</code> is specified as the virtual box base image</p>
</li>
<li><p>Forwards port 8000 of the VM to port 8000 of the host machine.</p>
</li>
<li><p>Allocates 1GB of memory to the VM</p>
</li>
<li><p>Runs <code>simple-node-project</code> to provision the VM</p>
</li>
<li><p>For the shell provisioner to run the script as a non-root user in a login shell, <code>privileged</code> is set to <code>false</code></p>
</li>
</ul>
<p>Save the <code>Vagrantfile</code> and start the virtual machine by running the following command:</p>
<pre><code class="lang-bash">$ vagrant up
</code></pre>
<p>The first time this command is run, it will download the latest version of the specified box, and it will configure and start the VM. This process might take some time, but when the Ubuntu box exists in the local machine the VM will start immediately.</p>
<p>Once the VM is running, you can access the web page by opening a web browser and navigating to <a target="_blank" href="http://localhost:8080"><code>http://localhost:8000</code></a>. You should see the <code>Hello World</code> message page if everything was set up correctly.</p>
<h2 id="heading-how-to-manage-vagrant">How to Manage Vagrant</h2>
<p>You can use Vagrant to manage the running virtual machine. Here are some useful Vagrant commands:</p>
<p><code>vagrant up</code>: Launches the virtual machine and provisions it according to the settings in the Vagrantfile. This command will simply connect to the virtual machine if it is already running.</p>
<p><code>vagrant halt</code>: Stops the virtual machine by delivering a shutdown signal to the guest operating system. This command is similar to shutting down a real computer.</p>
<p><code>vagrant reload</code>: Restarts the virtual machine and re-provisions it depending on any changes in the Vagrantfile.</p>
<p><code>vagrant ssh</code>: Connects to the virtual machine via SSH. This command is useful for accessing the command line interface of the virtual machine.</p>
<p><code>vagrant status</code>: Shows the current status of the virtual machine, including whether it's running, stopped, or suspended.</p>
<p><code>vagrant destroy</code>: Deletes the virtual machine and all associated resources. This command is useful for cleaning up your development environment.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, we have learned how to utilize Vagrant to set up a reproducible and consistent development environment.</p>
<p>Using Vagrant can help you set up a virtual development environment that closely mimics your production environment. This allows you to test and develop your code in a consistent and isolated environment.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Docker vs Virtual Machine (VM) – Key Differences You Should Know ]]>
                </title>
                <description>
                    <![CDATA[ In this guide, you'll learn the differences between a virtual machine and a Docker container. Both virtual machines and containers help replicate the development environment, and manage dependencies and configurations better. But there are certain di... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/docker-vs-vm-key-differences-you-should-know/</link>
                <guid isPermaLink="false">66bb8b26c332a9c775d15b68</guid>
                
                    <category>
                        <![CDATA[ container ]]>
                    </category>
                
                    <category>
                        <![CDATA[ containerization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bala Priya C ]]>
                </dc:creator>
                <pubDate>Tue, 04 Oct 2022 16:48:57 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/07/docker-vs-vm-diff.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this guide, you'll learn the differences between a <strong>virtual machine</strong> and a <strong>Docker</strong> container.</p>
<p>Both virtual machines and containers help replicate the development environment, and manage dependencies and configurations better. But there are certain differences you should be aware of that will help you choose a VM or a Docker container depending on the application.</p>
<p>Over the next few minutes, we'll go over how virtual machines and Docker containers work, and then summarize the key differences between the two.</p>
<p>Let's begin!</p>
<h2 id="heading-challenges-in-application-development-and-deployment">Challenges in Application Development and Deployment</h2>
<p>When you work as part of a development team, each application requires installation of multiple third-party software and packages. In order to collaborate and work together, every developer on the team should configure their local development environment.</p>
<p>However, setting up the development environment is a tedious process. The installation steps can be potentially different depending on the operating system and system configuration. Even during deployment, you have to configure the same environment on the server.</p>
<p>Different applications also require multiple versions of a specific software, say, PostgreSQL. In such cases, managing dependencies across applications becomes difficult.</p>
<p>To address the above challenges, it really helps if the applications run in isolated environments that you can replicate easily—independent of the system configuration. Both Virtual Machines (VMs) and Docker containers help you achieve this. Let's learn how!</p>
<h2 id="heading-how-does-a-virtual-machine-work">How Does a Virtual Machine Work?</h2>
<p>A <strong>Virtual Machine</strong> or <strong>VM</strong> is the emulation of a physical computer inside a host machine. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/1.png" alt="Image" width="600" height="400" loading="lazy">
<em>How a VM works (image by the author)</em></p>
<p>Running on top of the host operating system is a piece of software called a hypervisor that controls the VM instances. Each VM instance has its own guest operating system. The applications run inside this isolated environment. </p>
<p>You can have multiple VMs, each running a different application on a different operating system.</p>
<h2 id="heading-how-does-a-docker-container-work">How Does a Docker Container Work?</h2>
<p>Recently, container technology has revolutionized the software development process and the way development and operation teams work together. With time, Docker has become the go-to choice for containerizing applications.</p>
<p>Dockers containers are analogous to physical containers that you can use to store, package, and transport goods. But instead of tangible goods, they’re containers for software applications. 🙂</p>
<p>A docker container is a portable unit of software—that has the application—along with the associated dependency and configuration. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/2.png" alt="Image" width="600" height="400" loading="lazy">
<em>How containers work (image by the author)</em></p>
<p>Unlike a VM, Docker containers <em>do not</em> boot up their own guest OS. Rather, they run on top of the host operating system. This is facilitated by a container engine.</p>
<h2 id="heading-docker-vs-vm-a-comprehensive-comparison">Docker vs VM – A Comprehensive Comparison</h2>
<h3 id="heading-1-virtualization">1️⃣ Virtualization</h3>
<p>From our understanding thus far, both virtual machines and Docker containers provide isolated environments to run applications. The key difference between the two is in <em>how</em> they facilitate this isolation.</p>
<p>Recall that a VM boots up its own guest OS. Therefore, it virtualizes both the operating system kernel and the application layer. </p>
<p>A Docker container virtualizes <em>only</em> the application layer, and runs on top of the host operating system.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/3.png" alt="Image" width="600" height="400" loading="lazy">
<em>Container vs VM (image by the author)</em></p>
<h3 id="heading-2-compatibility">2️⃣ Compatibility</h3>
<p>A virtual machine uses its own operating system and is <em>independent</em> of the host operating system that it’s running on.  Therefore, a VM is compatible with all operating systems. </p>
<p>A Docker container, on the other hand, is compatible with <em>any</em> Linux distribution. You may run into some problems running Docker on a Windows machine or an older Mac.</p>
<h3 id="heading-3-size">3️⃣ Size</h3>
<p>A Docker image is lightweight and is typically in the order of kilobytes. </p>
<p><strong>💡 Note</strong>: A Docker image denotes the artifact containing the application, its associated dependencies, and configuration. A running instance of the Docker image is called a container.</p>
<p>A VM instance can be as large as a few gigabytes or even terabytes.</p>
<h3 id="heading-4-performance">4️⃣ Performance</h3>
<p>In terms of performance, Docker containers provide near-native performance. Because they are lightweight, you can start them in a few milliseconds. </p>
<p>Starting a VM is equivalent to setting up a standalone machine inside your computer. It can take as long as a few minutes to start a VM instance.</p>
<h3 id="heading-5-security">5️⃣ Security</h3>
<p>Docker containers run on top of the host operating system. Therefore, if the host OS is susceptible to security vulnerabilities, so are the Docker containers.</p>
<p>Virtual machines, on the other hand, boot up their own operating system, and are more secure. Recall: each virtual machine is a fully blown machine running inside another. If you have stringent security constraints to be met for sensitive applications, you should consider using a virtual machine instead.</p>
<h3 id="heading-6-replicability">6️⃣ Replicability</h3>
<p>The next factor we'll consider is the ease with which you can replicate the isolated environments provided by VMs and containers. We can infer the ease of replicability from our earlier discussions on <strong>size</strong> and <strong>performance</strong>. </p>
<p>When there are multiple applications, each of which should run on a VM instance, using VMs can be <strong>inefficient</strong> and <strong>resource intensive</strong>. Docker containers, by virtue of being lightweight and performant, are preferred when you need to run multiple applications. ✅</p>
<h2 id="heading-summing-up">Summing Up</h2>
<p>I hope this tutorial helped you understand how Docker containers and VMs work, and the key differences between the two. </p>
<p>Here's a summary of what you've learned:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Docker</td><td>Virtual Machine (VM)</td></tr>
</thead>
<tbody>
<tr>
<td>Compatibility</td><td>Works best with Linux distributions</td><td>All operating systems</td></tr>
<tr>
<td>Size</td><td>Light in weight</td><td>Substantially larger – of the order of Gigabytes or more</td></tr>
<tr>
<td>Virtualization</td><td>Only the applications layer</td><td>Both the OS kernel and applications layers</td></tr>
<tr>
<td>Performance</td><td>Easy to start containers (typically takes milliseconds)</td><td>Takes longer to start a VM instance</td></tr>
<tr>
<td>Security</td><td>Less secure</td><td>Relatively more secure</td></tr>
<tr>
<td>Replicability</td><td>Easy to replicate. You can pull Docker images corresponding to the various applications</td><td>Difficult to replicate, especially with increasing number of VM instances</td></tr>
</tbody>
</table>
</div><p>Thank you for reading this far. See you all soon in another tutorial! 😄</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Run Android Games on Linux with Android-x86 ]]>
                </title>
                <description>
                    <![CDATA[ In this article, you'll learn how you can use virtual machines on Linux while having fun with vintage games. If you have an Android phone, one of your guilty pleasures might be playing some very entertaining games. Or it could be that there is an app... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/run-android-games-on-linux/</link>
                <guid isPermaLink="false">66d851497211ea6be29e1b7f</guid>
                
                    <category>
                        <![CDATA[ Android ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Games ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jose Vicente Nunez ]]>
                </dc:creator>
                <pubDate>Wed, 17 Aug 2022 16:09:12 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/08/jose-article-photo.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, you'll learn how you can use virtual machines on Linux while having fun with vintage games.</p>
<p>If you have an Android phone, one of your guilty pleasures might be playing some very entertaining games. Or it could be that there is an application that only runs on your phone.</p>
<p>And then you think – what if you could run the same games on your desktop PC?</p>
<p>To simplify the scenario, let's assume the applications run on Android.</p>
<p>One approach to solve your problem is to run an Android emulator on your PC. But some of them, like <a target="_blank" href="https://www.android-x86.org/download.html">Android-x86</a>, require rebooting your machine so they can take control of the hardware.</p>
<p>If you don't mind a small performance hit you can run a virtual machine at the same time as your native operating system. Specifically on Linux, there are several choices, like <a target="_blank" href="https://www.qemu.org/">QEMU</a> and <a target="_blank" href="https://www.virtualbox.org/">VirtualBox</a>, to name a few.</p>
<p>By the end of this article you will be able to do the following:</p>
<ul>
<li><p>Install VirtualBox on Fedora Linux</p>
</li>
<li><p>Run android-x86 and finish the basic setup</p>
</li>
<li><p>Install an application from the Google Play Store, just like on your phone.</p>
</li>
</ul>
<h2 id="heading-basic-requirements"><strong>Basic Requirements</strong></h2>
<p>Before you start, I assume that you have the following:</p>
<ul>
<li><p>Ability to run commands as the superuser (like <a target="_blank" href="https://www.sudo.ws/">SUDO</a>)</p>
</li>
<li><p>An account on Google.com, so you can use the Play store from within the virtual machine.</p>
</li>
</ul>
<h1 id="heading-how-to-install-virtualbox"><strong>How to Install VirtualBox</strong></h1>
<p>The first step is to install VirtualBox. For practical purposes, our installation will be basic, just enough to run our games:</p>
<pre><code class="lang-python">sudo dnf install -y kernel-devel kernel-devel<span class="hljs-number">-5.14</span><span class="hljs-number">.18</span><span class="hljs-number">-100.</span>fc33.x86_64
curl --remote-name --location https://www.virtualbox.org/download/oracle_vbox.asc
sudo rpm --<span class="hljs-keyword">import</span> ./oracle_vbox.asc
sudo dnf install -y https://download.virtualbox.org/virtualbox/<span class="hljs-number">6.1</span><span class="hljs-number">.36</span>/VirtualBox<span class="hljs-number">-6.1</span><span class="hljs-number">-6.1</span><span class="hljs-number">.36</span>_152435_fedora33<span class="hljs-number">-1.</span>x86_64.rpm
sudo dnf install -y virtualbox-guest-additions.x86_64
sudo /sbin/vboxconfig
</code></pre>
<h2 id="heading-how-to-install-the-android-x86-iso"><strong>How to Install the Android-x86 ISO</strong></h2>
<p>The first step is to download the ISO image from <a target="_blank" href="https://sourceforge.net/projects/android-x86/">Android-x86</a>. This ISO contains the Android operating system that will be installed on our virtual hard drive.</p>
<p>After that we can set up our virtual machine like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/virtualbox-androidx86.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>How a finished virtual machine looks like on VirtualBox</em></p>
<p><img src="http://localhost:63342/4f800f8a-bbed-4dd8-b03c-00449c9f6698/1437651526/fileSchemeResource/59ea74abf47f101ded05f883e4d4c256-virtualbox-androidx86.png?_ijt=r1jlidvb50q7p9rgbjri12egof" alt="Image" width="600" height="400" loading="lazy"></p>
<p>A few things to note:</p>
<ul>
<li><p>After booting the first time, I found that 1GB for the Android image was not enough. Performance improved a lot after I bumped the ram to 3GB.</p>
</li>
<li><p>Another change was the 'Graphics Controller'. Originally it was VMSVGA but then Android refused to start in graphic mode, so I switched to VboxVGA and it worked.</p>
</li>
<li><p>2 CPUS and 8GB of disk space were enough for my game.</p>
</li>
<li><p>Finally, I specified that the IDE controller was the android-x86 ISO.</p>
</li>
</ul>
<p>To start the virtual machine, you click the 'Start' button on the GUI, and then you will have to make a few decisions like bootable partition:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/androidx86-partition.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Partitioning your virtual disk. We assign 8 GB and make sure the partition can boot</em></p>
<p>Once this is done you can choose your new partition to perform the installation:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/androidx86-newpartition.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>After the new partition is created, you can choose it and you can install the Android OS there</em></p>
<p>Then the installation will proceed:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/androidx86-install.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>The installer copies the files from the Android ISO image into the virtual hard drive</em></p>
<p>After the installation is complete, you can shut down the virtual machine.</p>
<h2 id="heading-first-boot"><strong>First Boot</strong></h2>
<p>Now you'll need to go to the advanced options and select the virtual disk (instead of the ISO image) to boot:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/android-x86-boot-from-disk.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>You can either boot from disk on this menu or change the boot order on the virtual machine</em></p>
<p>After that, Android will ask you some basic setup information, just like it does on your phone. The final result may look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/androidx86-running.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>The virtual machine looks exactly like your Android phone.</em></p>
<h2 id="heading-how-to-install-games-from-the-google-play-store"><strong>How to Install Games from the Google Play Store</strong></h2>
<p>In my case I decided to install a game where I can fight forces of evil as 1970 <a target="_blank" href="https://en.wikipedia.org/wiki/Mazinger_Z">Mazinger Z/ Tranzor Z</a> (Yes, I love <a target="_blank" href="https://en.wikipedia.org/wiki/Go_Nagai">Go Nagai</a> Mazinger Z). To do that, search on the play store and install the game:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/android-x86-play-store.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>After Android is running and your credentials are set you can download and install any Android program you want.</em></p>
<p>And now, success! We got the game up and running.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/androidx86-mazingerz.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Sorry, but now it is time to play as Mazinger Z!</em></p>
<h1 id="heading-what-did-we-learn-here"><strong>What Did We Learn Here?</strong></h1>
<ul>
<li><p>We managed to install a virtual machine engine and successfully run the Android operating system along with our regular Fedora OS</p>
</li>
<li><p>You saw how you can try and discard whole operating systems' setup, without going through the hassle of setting up a dual boot system with Grub on Linux</p>
</li>
</ul>
<p>Another nice feature of running the game inside a virtual machine is that you can fully freeze the game, then come back and restore it at exactly the same point where you left it.</p>
<p>Finally, you can do many more things with a virtual machine than just running games, for example:</p>
<ul>
<li><p>You can <a target="_blank" href="https://www.varonis.com/blog/malware-analysis-tools">analyze malware safely</a>, run un-trusted applications, and contain any damage they can cause.</p>
</li>
<li><p>Try a new operating system version before deciding to commit a proper installation (not a big issue these days as most of them provide a lice CD you can boot to try), but this is still very convenient.</p>
</li>
<li><p>Be able to run multiple operating systems simultaneously, without rebooting your machine. You most likely will start trying more advanced options of your virtual machine of choice, like <a target="_blank" href="https://www.virtualbox.org/manual/ch09.html">VirtualBox</a>.</p>
</li>
</ul>
<p>Playing games on your PC is a gateway for learning more complex stuff later. Also the fun factor is undeniable. Enjoy!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JVM Tutorial - Java Virtual Machine Architecture Explained for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ By Siben Nayak Whether you have used Java to develop programs or not, you might have heard about the Java Virtual Machine (JVM) at some point or another.  JVM is the core of the Java ecosystem, and makes it possible for Java-based software programs t... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/jvm-tutorial-java-virtual-machine-architecture-explained-for-beginners/</link>
                <guid isPermaLink="false">66d46155182810487e0ce1bc</guid>
                
                    <category>
                        <![CDATA[ architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Java ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 08 Jan 2021 23:35:48 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/01/JVM.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Siben Nayak</p>
<p>Whether you have used Java to develop programs or not, you might have heard about the Java Virtual Machine (JVM) at some point or another. </p>
<p>JVM is the core of the Java ecosystem, and makes it possible for Java-based software programs to follow the <em>"write once, run anywhere"</em> approach. You can write Java code on one machine, and run it on any other machine using the JVM.</p>
<p>JVM was initially designed to support only Java. However, over the time, many other languages such as Scala, Kotlin and Groovy were adopted on the Java platform. All of these languages are collectively known as JVM languages.</p>
<p>In this article, we will learn more about the JVM, how it works, and the various components that it is made of.</p>
<p>#What is a Virtual Machine?</p>
<p>Before we jump into the JVM, let's revisit the concept of a Virtual Machine (VM).</p>
<p>A virtual machine is a <em>virtual representation of a physical computer</em>. We can call the virtual machine the guest machine, and the physical computer it runs on is the host machine.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-37.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>A single physical machine can run multiple virtual machines, each with their own operating system and applications. These virtual machines are isolated from each other.</p>
<p>#What is the Java Virtual Machine?</p>
<p>In programming languages like C and C++, the code is first compiled into platform-specific machine code. These languages are called <em>compiled languages</em>. </p>
<p>On the other hand, in languages like JavaScript and Python, the computer executes the instructions directly without having to compile them. These languages are called <em>interpreted languages</em>.</p>
<p>Java uses a combination of both techniques. Java code is first compiled into byte code to generate a <em>class</em> file. This <em>class</em> file is then interpreted by the Java Virtual Machine for the underlying platform. The same <em>class</em> file can be executed on any version of JVM running on any platform and operating system.</p>
<p><em>Similar to virtual machines,</em> the JVM creates an isolated space on a host machine. This space can be used to execute Java programs irrespective of the platform or operating system of the machine.</p>
<p>#Java Virtual Machine Architecture</p>
<p>The JVM consists of three distinct components:</p>
<ol>
<li>Class Loader</li>
<li>Runtime Memory/Data Area</li>
<li>Execution Engine</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-39.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Let's take a look at each of them in more detail.</p>
<h2 id="heading-class-loader">Class Loader</h2>
<p>When you compile a <code>.java</code> source file, it is converted into byte code as a <code>.class</code> file. When you try to use this class in your program, the class loader loads it into the main memory. </p>
<p>The first class to be loaded into memory is usually the class that contains the <code>main()</code> method.</p>
<p>There are three phases in the class loading process: loading, linking, and initialization.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-40.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-loading">Loading</h3>
<p>Loading involves taking the binary representation (bytecode) of a class or interface with a particular name, and generating the original class or interface from that.</p>
<p>There are three built-in class loaders available in Java:</p>
<ul>
<li><strong>Bootstrap Class Loader</strong> <strong>-</strong> This is the root class loader. It is the superclass of Extension Class Loader and loads the standard Java packages like <code>java.lang</code>, <code>java.net</code>, <code>java.util</code>, <code>java.io</code>, and so on. These packages are present inside the <code>rt.jar</code> file and other core libraries present in the <code>$JAVA_HOME/jre/lib</code> directory.</li>
<li><strong>Extension Class Loader -</strong> This is the subclass of the Bootstrap Class Loader and the superclass of the Application Class Loader. This loads the extensions of standard Java libraries which are present in the <code>$JAVA_HOME/jre/lib/ext</code> directory. </li>
<li><strong>Application Class Loader -</strong> This is the final class loader and the subclass of Extension Class Loader. It loads the files present on the classpath. By default, the classpath is set to the current directory of the application. The classpath can also be modified by adding the <code>-classpath</code> or <code>-cp</code> command line option.</li>
</ul>
<p>The JVM uses the <code>ClassLoader.loadClass()</code> method for loading the class into memory. It tries to load the class based on a fully qualified name. </p>
<p>If a parent class loader is unable to find a class, it delegates the work to a child class loader. If the last child class loader isn't able to load the class either, it throws <code>NoClassDefFoundError</code> or <code>ClassNotFoundException</code><em>.</em> </p>
<h3 id="heading-linking">Linking</h3>
<p>After a class is loaded into memory, it undergoes the linking process. Linking a class or interface involves combining the different elements and dependencies of the program together. </p>
<p>Linking includes the following steps:</p>
<p><strong>Verification:</strong> This phase checks the structural correctness of the <code>.class</code> file by checking it against a set of constraints or rules. If verification fails for some reason, we get a <code>VerifyException</code>.</p>
<p>For example, if the code has been built using Java 11, but is being run on a system that has Java 8 installed, the verification phase will fail.</p>
<p><strong>Preparation:</strong> In this phase, the JVM allocates memory for the static fields of a class or interface, and initializes them with default values. </p>
<p>For example, assume that you have declared the following variable in your class:</p>
<pre><code class="lang-java"><span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">boolean</span> enabled = <span class="hljs-keyword">true</span>;
</code></pre>
<p>During the preparation phase, JVM allocates memory for the variable <code>enabled</code>     and sets its value to the default value for a boolean, which is <code>false</code>.</p>
<p><strong>Resolution:</strong> In this phase, symbolic references are replaced with direct references present in the runtime constant pool. </p>
<p>For example, if you have references to other classes or constant variables present in other classes, they are resolved in this phase and replaced with their actual references.</p>
<h3 id="heading-initialization">Initialization</h3>
<p>Initialization involves executing the initialization method of the class or interface (known as <code>&lt;clinit&gt;</code>). This can include calling the class's constructor, executing the static block, and assigning values to all the static variables. This is the final stage of class loading.</p>
<p>For example, when we declared the following code earlier:</p>
<pre><code class="lang-java"><span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">boolean</span> enabled = <span class="hljs-keyword">true</span>;
</code></pre>
<p>The variable <code>enabled</code> was set to its default value of <code>false</code> during the preparation phase. In the initialization phase, this variable is assigned its actual value of <code>true</code>.</p>
<p><strong>Note:</strong> the JVM is multi-threaded. It can happen that multiple threads are trying to initialize the same class at the same time. This can lead to concurrency issues. You need to handle thread safety to ensure that the program works properly in a multi-threaded environment.</p>
<h2 id="heading-runtime-data-area">Runtime Data Area</h2>
<p>There are five components inside the runtime data area:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-32.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Let's look at each one individually.</p>
<h3 id="heading-method-area">Method Area</h3>
<p>All the class level data such as the run-time constant pool, field, and method data, and the code for methods and constructors, are stored here. </p>
<p>If the memory available in the method area is not sufficient for the program startup, the JVM throws an <code>OutOfMemoryError</code>.</p>
<p>For example, assume that you have the following class definition:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Employee</span> </span>{

  <span class="hljs-keyword">private</span> String name;
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> age;

  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Employee</span><span class="hljs-params">(String name, <span class="hljs-keyword">int</span> age)</span> </span>{

    <span class="hljs-keyword">this</span>.name = name;
    <span class="hljs-keyword">this</span>.age = age;
  }
}
</code></pre>
<p>In this code example, the field level data such as <code>name</code> and <code>age</code> and the constructor details are loaded into the method area.</p>
<p>The method area is created on the virtual machine start-up, and there is only one method area per JVM.</p>
<h3 id="heading-heap-area">Heap Area</h3>
<p>All the objects and their corresponding instance variables are stored here. This is the run-time data area from which memory for all class instances and arrays is allocated. </p>
<p>For example assume that you are declaring the following instance:</p>
<pre><code class="lang-java">Employee employee = <span class="hljs-keyword">new</span> Employee();
</code></pre>
<p>In this code example, an instance of <code>Employee</code> is created and loaded into the heap area.</p>
<p>The heap is created on the virtual machine start-up, and there is only one heap area per JVM.</p>
<p><strong>Note:</strong> Since the Method and Heap areas share the same memory for multiple threads, the data stored here is not thread safe.</p>
<h3 id="heading-stack-area">Stack Area</h3>
<p>Whenever a new thread is created in the JVM, a separate runtime stack is also created at the same time. All local variables, method calls, and partial results are stored in the stack area. </p>
<p>If the processing being done in a thread requires a larger stack size than what's available, the JVM throws a <code>StackOverflowError</code>.</p>
<p>For every method call, one entry is made in the stack memory which is called the Stack Frame. When the method call is complete, the Stack Frame is destroyed.</p>
<p>The Stack Frame is divided into three sub-parts:</p>
<ul>
<li><strong>Local Variables –</strong> Each frame contains an array of variables known as its <em>local variables</em>. All local variables and their values are stored here. The length of this array is determined at compile-time.</li>
<li><strong>Operand Stack –</strong> Each frame contains a last-in-first-out (LIFO) stack known as its <em>operand stack</em>. This acts as a runtime workspace to perform any intermediate operations. The maximum depth of this stack is determined at compile-time.</li>
<li><strong>Frame Data –</strong> All symbols corresponding to the method are stored here. This also stores the catch block information in case of exceptions.</li>
</ul>
<p>For example assume that you have the following code:</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">double</span> <span class="hljs-title">calculateNormalisedScore</span><span class="hljs-params">(List&lt;Answer&gt; answers)</span> </span>{

  <span class="hljs-keyword">double</span> score = getScore(answers);
  <span class="hljs-keyword">return</span> normalizeScore(score);
}

<span class="hljs-function"><span class="hljs-keyword">double</span> <span class="hljs-title">normalizeScore</span><span class="hljs-params">(<span class="hljs-keyword">double</span> score)</span> </span>{

  <span class="hljs-keyword">return</span> (score – minScore) / (maxScore – minScore);
}
</code></pre>
<p>In this code example, variables like <code>answers</code> and <code>score</code> are placed in the Local Variables array. The Operand Stack contains the variables and operators required to perform the mathematical calculations of subtraction and division.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-36.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><strong>Note:</strong> Since the Stack Area is not shared, it is inherently thread safe. </p>
<h3 id="heading-program-counter-pc-registers">Program Counter (PC) Registers</h3>
<p>The JVM supports multiple threads at the same time. Each thread has its own PC Register to hold the address of the currently executing JVM instruction. Once the instruction is executed, the PC register is updated with the next instruction.</p>
<h3 id="heading-native-method-stacks">Native Method Stacks</h3>
<p>The JVM contains stacks that support <em>native</em> methods. These methods are written in a language other than the Java, such as C and C++. For every new thread, a separate native method stack is also allocated.</p>
<h2 id="heading-execution-engine">Execution Engine</h2>
<p>Once the bytecode has been loaded into the main memory, and details are available in the runtime data area, the next step is to run the program. The Execution Engine handles this by executing the code present in each class.</p>
<p>However, before executing the program, the bytecode needs to be converted into machine language instructions. The JVM can use an interpreter or a JIT compiler for the execution engine.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-33.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-interpreter">Interpreter</h3>
<p>The interpreter reads and executes the bytecode instructions line by line. Due to the line by line execution, the interpreter is comparatively slower. </p>
<p>Another disadvantage of the interpreter is that when a method is called multiple times, every time a new interpretation is required.</p>
<h3 id="heading-jit-compiler">JIT Compiler</h3>
<p>The JIT Compiler overcomes the disadvantage of the interpreter. The Execution Engine first uses the interpreter to execute the byte code, but when it finds some repeated code, it uses the JIT compiler. </p>
<p>The JIT compiler then compiles the entire bytecode and changes it to native machine code. This native machine code is used directly for repeated method calls, which improves the performance of the system. </p>
<p>The JIT Compiler has the following components:</p>
<ol>
<li><strong>Intermediate Code Generator -</strong> generates intermediate code</li>
<li><strong>Code Optimizer -</strong> optimizes the intermediate code for better performance</li>
<li><strong>Target Code Generator -</strong> converts intermediate code to native machine code</li>
<li><strong>Profiler -</strong> finds the hotspots (code that is executed repeatedly)</li>
</ol>
<p>To better understand the difference between interpreter and JIT compiler, assume that you have the following code:</p>
<pre><code class="lang-java"><span class="hljs-keyword">int</span> sum = <span class="hljs-number">10</span>;
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span> ; i &lt;= <span class="hljs-number">10</span>; i++) {
   sum += i;
}
System.out.println(sum);
</code></pre>
<p>An interpreter will fetch the value of <code>sum</code> from memory for each iteration in the loop, add the value of <code>i</code> to it, and write it back to memory. This is a costly operation because it is accessing the memory each time it enters the loop.</p>
<p>However, the JIT compiler will recognize that this code has a HotSpot, and will perform optimizations on it. It will store a local copy of <code>sum</code> in the PC register for the thread and will keep adding the value of <code>i</code> to it in the loop. Once the loop is complete, it will write the value of <code>sum</code> back to memory.</p>
<p><strong>Note:</strong> a JIT compiler takes more time to compile the code than for the interpreter to interpret the code line by line. If you are going to run a program only once, using the interpreter is better.</p>
<h3 id="heading-garbage-collector">Garbage Collector</h3>
<p>The Garbage Collector (GC) collects and removes unreferenced objects from the heap area. It is the process of reclaiming the runtime unused memory automatically by destroying them. </p>
<p>Garbage collection makes Java memory efficient because because it removes the unreferenced objects from heap memory and makes free space for new objects. It involves two phases:</p>
<ol>
<li><strong>Mark -</strong> in this step, the GC identifies the unused objects in memory</li>
<li><strong>Sweep -</strong> in this step, the GC removes the objects identified during the previous phase</li>
</ol>
<p>Garbage Collections is done automatically by the JVM at regular intervals and does not need to be handled separately. It can also be triggered by calling <code>System.gc()</code>, but the execution is not guaranteed. </p>
<p>The JVM contains 3 different types of garbage collectors:</p>
<ol>
<li><strong>Serial GC -</strong> This is the simplest implementation of GC, and is designed for small applications running on single-threaded environments. It uses a single thread for garbage collection. When it runs, it leads to a "stop the world" event where the entire application is paused. The JVM argument to use Serial Garbage Collector is <code>-XX:+UseSerialGC</code></li>
<li><strong>Parallel GC -</strong> This is the default implementation of GC in the JVM, and is also known as Throughput Collector. It uses multiple threads for garbage collection, but still pauses the application when running. The JVM argument to use Parallel Garbage Collector is <code>-XX:+UseParallelGC</code>.</li>
<li><strong>Garbage First (G1) GC -</strong> G1GC was designed for multi-threaded applications that have a large heap size available (more than 4GB). It partitions the heap into a set of equal size regions, and uses multiple threads to scan them. G1GC identifies the regions with the most garbage and performs garbage collection on that region first. The JVM argument to use G1 Garbage Collector is <code>-XX:+UseG1GC</code></li>
</ol>
<p><strong>Note:</strong> There is another type of garbage collector called <strong>Concurrent Mark Sweep (CMS) GC</strong>. However, it has been deprecated since Java 9 and completely removed in Java 14 in favour of G1GC.</p>
<h2 id="heading-java-native-interface-jni">Java Native Interface (JNI)</h2>
<p>At times, it is necessary to use native (non-Java) code (for example, C/C++). This can be in cases where we need to interact with hardware, or to overcome the memory management and performance constraints in Java. Java supports the execution of native code via the Java Native Interface (JNI). </p>
<p>JNI acts as a bridge for permitting the supporting packages for other programming languages such as C, C++, and so on. This is especially helpful in cases where you need to write code that is not entirely supported by Java, like some platform specific features that can only be written in C.</p>
<p>You can use the <code>native</code> keyword to indicate that the method implementation will be provided by a native library. You will also need to invoke <code>System.loadLibrary()</code> to load the shared native library into memory, and make its functions available to Java.</p>
<h2 id="heading-native-method-libraries">Native Method Libraries</h2>
<p>Native Method Libraries are libraries that are written in other programming languages, such as C, C++, and assembly. These libraries are usually present in the form of <code>.dll</code> or <code>.so</code> files. These native libraries can be loaded through JNI.</p>
<p>#Common JVM Errors</p>
<ul>
<li><strong>ClassNotFoundExcecption</strong> - This occurs when the Class Loader is trying to load classes using <code>Class.forName()</code>, <code>ClassLoader.loadClass()</code> or <code>ClassLoader.findSystemClass()</code> but no definition for the class with the specified name is found.</li>
<li><strong>NoClassDefFoundError</strong> - This occurs when a compiler has successfully compiled the class, but the Class Loader is not able to locate the class file at the runtime.</li>
<li><strong>OutOfMemoryError</strong> - This occurs when the JVM cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.</li>
<li><strong>StackOverflowError</strong> - This occurs if the JVM runs out of space while creating new stack frames while processing a thread.</li>
</ul>
<p>#Conclusion</p>
<p>In this article, we discussed the Java Virtual Machine's architecture and its various components. Often we do not dig deep into the internal mechanics of the JVM or care about how it works while our code is working. </p>
<p>It is only when something goes wrong, and we need to tweak the JVM or fix a memory leak, that we try to understand its internal mechanics.</p>
<p>This is also a very popular interview question, both at junior and senior levels for backend roles. A deep understanding of the JVM helps you write better code and avoid pitfalls related to stack and memory errors.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/jnpuRvRdTgI" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>Thank you for staying with me so far. Hope you liked the article. You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/theawesomenayak/">LinkedIn</a> where I regularly discuss technology and life. Also take a look at some of <a target="_blank" href="https://www.freecodecamp.org/news/author/theawesomenayak/">my other articles</a> and my <a target="_blank" href="https://www.youtube.com/channel/UCmWAaPgfWAkl-Jep5mY-NNg?sub_confirmation=1">YouTube channel</a>. Happy reading. 🙂</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to create and connect to Google Cloud Virtual Machine with SSH ]]>
                </title>
                <description>
                    <![CDATA[ By Nezar Assawiel Google Cloud offers many tools and services. One of these services is creating highly customizable virtual machines. If you are not familiar with what a virtual machine is, here is a definition from Microsoft: A virtual machine is ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-create-and-connect-to-google-cloud-virtual-machine-with-ssh-81a68b8f74dd/</link>
                <guid isPermaLink="false">66c35130a1d481faeda49bb4</guid>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 02 Nov 2018 16:45:23 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/0*uGmqUMo3h7NHNCkP.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Nezar Assawiel</p>
<p>Google Cloud offers many tools and services. One of these services is creating highly customizable virtual machines. If you are not familiar with what a virtual machine is, here is a definition from Microsoft:</p>
<blockquote>
<p>A virtual machine is a computer file, typically called an image, that behaves like an actual computer. In other words, creating a computer within a computer. It runs in a window, much like any other program, giving the end user the same experience on a virtual machine as they would have on the host operating system itself. The virtual machine is sandboxed from the rest of the system, meaning that the software inside a virtual machine can’t escape or tamper with the computer itself.</p>
</blockquote>
<p>Virtual machines are needed in many situations to test applications against other operating systems, to access virus-infected data, or to experiment with other operating systems. You can install virtual machines on your computer. You can also create them in the cloud and simply connect to them.</p>
<p>In this tutorial, I will walk you through how to create a virtual machine in Google Cloud. We can connect to it with SSH from your computer.</p>
<ol>
<li>If you don’t have one already, create a Google Cloud account from <a target="_blank" href="https://cloud.google.com/">here</a>.</li>
</ol>
<p>You will get $300 credit to play around with for a year! It is more than enough to learn and play with everything Google Cloud offers.</p>
<ol start="2">
<li>Create a new project or use an existing one. You can create a new project called <strong>project1</strong>, for example, as in the following gif:</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/d8N926cdgrmskacPUiCBS-8j3E26n3wZKJMz" alt="Image" width="1429" height="728" loading="lazy"></p>
<ol start="3">
<li>Now you are set to create a virtual machine. Go to the top left corner of your Google Cloud home page, click on the triple bar icon ≡ and select <strong>Compute Engine -&gt;VM insta<em>n</em></strong>ce and cli<strong>ck Cre</strong>ate.</li>
</ol>
<p>Enter whatever name you want in the <strong>Name</strong> field as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/qBdgjOVIiVQwafsecV7Gx0LmggEy2LkxHEec" alt="Image" width="790" height="268" loading="lazy"></p>
<p>Keep the default region and zone. Any region/zone will do for this tutorial. If you are curious about what they mean, you can read Google Cloud’s documentation about them <a target="_blank" href="https://cloud.google.com/compute/docs/regions-zones/">here</a>.</p>
<p>You can keep default machine type or click <strong>Customize</strong> to select the number of CPU cores, memory, and GPUs you would like your virtual machine to have. You will see the cost on the right side changes!</p>
<p>For your first experiments with Google Cloud, you can be conservative with the $300 credit for some actual work. In such a case, you can choose the following configuration:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1dxebYaNuExfqZ8pfqh0xVbo2AM5mJVXWn9H" alt="Image" width="474" height="509" loading="lazy"></p>
<p>Next choose a boot disk. For example, you can choose <strong>20 GB, SSD, Ubuntu 16.04 LTS</strong> as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/yYCIobWt-a0d4u2CobgwkpqHuxKnrAfSb3Ur" alt="Image" width="470" height="186" loading="lazy"></p>
<p>Then set the <strong>Service Account</strong> under <strong>Identity and API access</strong> to <strong>No service account</strong> as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/GFhEp7kU2Q4w8vIAmGG8mVWsYf5EehrZ-qM4" alt="Image" width="470" height="158" loading="lazy"></p>
<p>Finally, go to the <strong>Security</strong> tab under <strong>Firewall</strong>. You will see an <strong>SSH Key</strong> field as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/xgqwfK55ZoSZYLrKQ863EgDD42iW37KVo9mu" alt="Image" width="455" height="500" loading="lazy"></p>
<p>This where you are going to connect your computer to the virtual machine using your SSH Key!</p>
<p>If you are not familiar with SSH (Secure Shell) and why you may want to use it, it is a network protocol that provides encrypted data communication between two computers (your computer and Google’s servers, in this case) which are connected over an insecure network (the Internet here).</p>
<p>To establish an SSH connection, you <em>may</em> need an application that can do that, depending on your operating system. <strong>Follow the rest of this post depending on your operating system (Windows or Mac/Linux).</strong></p>
<h4 id="heading-windows"><strong>Windows</strong></h4>
<p>I recommend <strong>PuTTY</strong>. It is an open-source and easy to use SSH client. You can download PuTTY and install it from <a target="_blank" href="https://www.putty.org/">here</a>.</p>
<p>After installing PuTTY, open <strong>PuTTY Key Generator</strong> and click <strong>create</strong>. It will generate a random key by <strong>you</strong> moving the mouse over the blank area. After it is done, you will get something like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/j6FJhRY3ijIeF2UOCU6rXR6hlxgXxDoJ-yJE" alt="Image" width="479" height="470" loading="lazy"></p>
<p>Change the <strong>key comment</strong> field to something recognizable and easy to type, as this will become a user name later!</p>
<p>Then save both the public and private keys by clicking the corresponding icons shown in the picture above.</p>
<p>Highlight the whole <strong>Key</strong> field from the PuTTY Key Generator, and copy and paste it in the <strong>key data</strong> field in Google Cloud:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Wl6IzBYOc7UgC7MtV-A6wbPe1x5aHKeuN38l" alt="Image" width="465" height="335" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/S9zZ0zEE-wcbiUTyA-NQh5onxHushq3ENrFF" alt="Image" width="470" height="336" loading="lazy"></p>
<p>Click <strong>create</strong> and wait for the virtual machine instance to be created.</p>
<p>In the meantime, you can go to PuTTY. Go to <strong>SSH -&gt;A</strong>uth and browse for the private key file that you saved.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/7MbOpAr9WTaSj-hqcIjvv1xihat-FRPryrUv" alt="Image" width="453" height="438" loading="lazy"></p>
<p>Next, go to Google Cloud and copy the external IP from the virtual machine instance that you just created as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/OSZMJ8Lqd1SyxuVYZFZcNTef3-ChxBFUSF6y" alt="Image" width="559" height="66" loading="lazy"></p>
<p>And paste it on the Host field under <strong>Sessions</strong> in PuTTY and hit <strong>Enter</strong>:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/7rKBTabUWQ4bwJPEXMPhhjNxSEAJuEZ0iq4F" alt="Image" width="455" height="439" loading="lazy"></p>
<p>Note: you might get an error message. Ignore it and click <strong>yes</strong>. (It just says the key is not already in the registry. Are you sure you want to connect?)</p>
<p>Then enter the username you created when generating the key (<strong>key comment</strong> above). Boom! you are in the virtual machine that you just created.</p>
<p>You can install python and Google APIs on it, for example, to start making some magic! Don’t forget to shut it down in Google Cloud after you are done to be economic with your credit :)</p>
<h4 id="heading-maclinux"><strong>Mac/Linux</strong></h4>
<p>Mac and Linux support SSH connection natively. You just need to generate an SSH key pair (public key/private key) to connect securely to the virtual machine.</p>
<p>The private key is equivalent to a password. Thus, it is kept private, residing on your computer, and should not be shared with any entity. The public key is shared with the computer or server to which you want to establish the connection. To generate the SSH key pair to connect securely to the virtual machine, follow these steps:</p>
<p>Enter the following command in Terminal: <code>ssh-keygen -t rsa</code> . It will start the key generation process. You will be prompted to choose the location to store the SSH key pair. Press ENTER to accept the default location as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/R3w3esMPp0ClobIdopPztKXJKS9VBB3tmEmo" alt="Image" width="703" height="128" loading="lazy"></p>
<p>Next, choose a password for your login to the virtual machine or hit ENTER if you wish not to use a password. The private key (i.e. identification) and the public key will be generated as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/b8KjgTG8JFeY38Lvdp3jdytUxcCQ71UnVo7K" alt="Image" width="701" height="349" loading="lazy"></p>
<p>Now run the following command: <code>cat ~/.ssh/id_rsa.pub</code> . It will display the public key in the terminal as shown below. Highlight and copy this key:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/fsKg95sN2WmbA7zWAkOc23K3xWxmKuqnOyL2" alt="Image" width="747" height="350" loading="lazy"></p>
<p>and paste it in the SSH key field in Google Cloud and hit <strong>Create</strong>:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/REYZEUmTlmkyKvRdSNb6TYjGXp2LEdbhSPoN" alt="Image" width="477" height="557" loading="lazy"></p>
<p>Now you can use the <strong>External IP</strong> of the virtual machine you just created:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/FwkOZXHdOi8xv9XMeE9V4J4vo2BjVHgmzO2k" alt="Image" width="661" height="86" loading="lazy"></p>
<p>to <em>ssh</em> to it as follows:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/fN1tFu7LE0uQOrNrSPJCILOjiysC4xyc7U4i" alt="Image" width="699" height="38" loading="lazy"></p>
<p>You will get “The authenticity of host…etc.” warning as shown in the picture below. This is normal. Whenever SSH connects to a system it hasn’t seen before, it will generate a warning like this. Reply <strong>yes</strong> to connect, and bingo! You are in the virtual machine, as you can see from host name <strong>instance-3.</strong> To exit the virtual machine, just type <strong>exit.</strong></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/60u5MB5wOQP9RAsG-KhrQgoJ5NB36YZKBYbG" alt="Image" width="748" height="301" loading="lazy"></p>
<p>Don’t forget to shut the virtual machine in Google Cloud after you are done to save that $300 credit!</p>
<p><em>Originally published at <a target="_blank" href="http://www.assawiel.com/blog">assawiel.com/blog</a> on December 23, 2017. Updated: Oct 10, 2018</em></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
