Monday, 20 May 2024

What are containers and how are they different from virtual machines

 

What are containers and how are they different from virtual machines


In this video we will discuss, what are containers and how are they different from virtual machines.

In our previous video, we discussed what are virtual machines and how they allow us to run multiple applications on a single physical server. However, with each virtual machine that we create, there is a lot of overhead, both in terms of cost and maintainability. Let's understand this with an example.

Virtual Machines and Multiple applications

Let's say we have 4 applications - App 1, App 2, App 3, and App 4. We want to be able to run all these 4 apps on one physical server - Server 1. Obviously, we cannot run applications directly on the server hardware. We need an operating system like windows or linux. This is the Host OS i.e the operating system at the server level. On top this we install a piece of software called Hypervisor. It is the Hypervisor, that creates and manages virtual machines. We have 4 apps that we want to run in isolation on this physical server, so we create 4 virtual machines.

how can we run multiple applications on virtual machines simultaneously

As we discussed in our previous video, a virtual machine virtualises the hardware of the physical server. This means each virtual machine that is created, gets a slice of the the server hardware. In our case we created 4 virtual machines, so each VM gets 25% of memory, disk space, processor and other server hardware resources.

Virtual Machine Disadvantages

Applications, i.e App 1 to App 4 cannot directly run on a virtual machine. Keep in mind, a virtual machine virtualises the server hardware. This means, in simple terms, a virtual machine is a slice of the underlying server hardware and an application cannot run directly on the hardware. So for a virtual machine to be able run a software application, it needs a full copy of its own operating system.

We have 4 virtual machines, so this means we need to install 4 operating systems, one on each virtual machine. Usually, windows or linux. This operating system that is installed on a virtual machine is usually called Guest Operating System. So, on top of this guest OS on the VM, we install our business application and any dependencies it might need.

virtual machine disadvantages

Now, just imagine the, amount of server resouces required to install and run 4 operating systems. So much of server resources like disk space, memory and processor time are wasted just to keep these VMs up and running. In addition to the wated server resources, each installation of the operating system also needs admin time. For example if there is an update or a security patch available for the OS, the admin needs to download and install it on all the VMs that has that operating system. In addition to this, we also need to pay for 4 operating system licenses.

Remember a virtual machine is like a computer with in a computer. It has it's own OS. So for a virtual machine to be up and running it's operating system must also be booted up. Booting up an entire operating system obviously consumes a lot of time.

In our example, if we want App 1 to be up and running, VM 1 operating system must be booted up, in addition to booting up the host operating system i.e the operating system at the physical server level.

What are containers

A virtual machine virtualises the server hardware where as containers virtualises the operating system, i.e it's an abstraction at the operating system level. Multiple containers can run on the same machine and share the host operating system kernel. Unlike a VM, a container does not required it's own operating system. Straight away you can see the amount of disk space, ram and processor time that is saved.

containers vs virtual machines

Each conatiner packages your application code and it's dependencies together. If you have 3 apps to run on a single physical server, you create 3 containers. Each application thinks, it is running on a dedicated OS and a dedicated server hardware. In reality all the container apps are sharing the same host operating system and hardware.

In case of VMs, admin time is required to install security patches and keep up to date host operating system and the guest operating systems on all the VMs. No matter how many containers we have on our server, there is just one host operating system that demands admin time.

From the cost standpoint, in case of VMs, we have to pay for host and the guest operating systems of all the VMS, where as in case of containers, we have to pay just for the 1 host operating system.

A container is very small compared to a VM. Since a container does not have it's own operating system to bootup, it can usually be brought online in a very less time compared to booting up and entire VM and it's operating system.

What is a virtual machine and why is it useful

 

What is a virtual machine and why is it useful


In this video we will understand what is a Virtual Machine and it's use.

why use a virtual machine

We usually cannot install more than one application on a given physical server. We discussed the reasons for this in our previous video.

deployment model before vms

Until Virtual Machines came into existence, we had a one-to-one mapping between a business application and the physical server upon which it is installed. For example, if there are 3 production apps, 3 physical servers are required. Everytime a new application is required, businesses had to procure a new physical server. There is only one production app running on the server and in most cases, I mean 9 out of 10, the app only use a fraction of the server capacity, may be 5 to 10 percent. What a waste of company money and you can see, how quickly this can become unwieldy and very expensive for the organisations.

What are Virtual Machines

With virtualization, we are able to squeeze much more from physical servers. This is a bit over-simplified, but the model worked something like the following. 

what is a virtual machine

On top of the physical server, we have the operating system installed. This is the host operating system i.e operating system at the physical server level. On top of that we install a piece of software called Hypervisor. Hypervisor is a technology from VMware that virtualises the hardware of the physical server. On top of this we create a virtual machine. In fact, we can create and run multiple virtual machines on a single physical server. My first application runs on VM1 and the second application runs on VM2. If I have a thrid application, I simply spin up a new VM and then safely and securely run it from the third VM. This is brilliant, because we are now able to make proper use of the server hardware.

There is no longer a one to one mapping between a business application and a physical server. Thanks to virtualization, we can now safely isolate and run more than one application from a given physical server. So everytime, we need a new application for the business, it is no longer the case where we have to procure a new physical server. With virtualization, we are able to safely and securely run multiple apps on a single physical server.

Because of this virtualization, each application thinks that it is running on a dedicated physical server with it's own dedicated processer, memory, drive space etc, while in reality they are running on the same physical server but on a dedicated virtual machine. You can think of a virtual machine as a computer within a computer. Multiple virtual machines can run simultaneously on the same physical server. In each virtual machine, we can install an operating system of our choice (windows, linux etc), typically we install the operating system and dependencies our production app requires.

The State of IT before Virtual Machines

 

The State of IT before Virtual Machines


In this video we will discuss the state of Information Technology before Virtual Machines came into existence.

You name any business or industry (Airlines, tourism, hotels, software, hardware, manufacturing). It is the applications that power and run these businesses. It' almost impossible for a business to withstand the pressure and competition and thereby sustain in the market without a reliant, performant and a scalable application. So, the fact is, it is the applications that power and run businesses.


As far as an application for a business is concerned, there are 2 main aspects.

  • Desiging and developing the business application itself, and then
  • Hosting this application on a server to make it available for business.

Let's discuss what we use to do in the past, prior to the technologies like virtual machines and containers came into existence. We will discuss, what virtual machines and containers are, and the problems they solve in our next video.

In the past, to host an application, a business needs to procure a physical server, but the question is, how big and fast the server has to be. It's not easy to speculate the demand for the application. So to be on the safe side, businesses procure a high end server which obviously costs a lot of money. 

In addition to this initial capital expense, i.e the cost of the physical server, we also have monthly recurring operating expenses like energy costs (both for power and cooling), hire workforce to maintain the server. Don't forget the operating license, we have to pay for that as well. In many cases only a fraction of the server capacity is used, which means obviously a lot of company money is wasted.

why we use virtualization in cloud computing

We have a physical server. On top of that we install the operating system and on top of that we install our business application. At this point we have our application up and running and users are able to use it.

Now, let's say we are launching a new product or starting another line of business and obviously this means we need another application. So, this means we need to procure another physical server and another license for the operating system, and on top of that we install our second business application. Keep in mind, in addition to the cost of this second physical server, we also have recurring operating expenses.

why do companies use virtual machinesAt this point, you might be wondering, can't we install this new application on our existing physical server, because the first application is only using a fraction of the server capacity anyway. Well, in most cases, we can't. This may be because this new application has different dependencies than the first application. May be it needs a differnt version of the framework installed. May be it needs a different operating system altogether. May be both applications need access to the same resources or devices which obviously results in resource conflicts.

what problems does virtualization solve

One way to solve this problem is to buy another physical server. So in the past, there is a one to one mapping between an application and a physical server. Everytime we need a new business application we end up buying a new physical server and keep in mind these applications are using only a fraction of the server capacity. What a waste of company money. You can see, how quickly this can become unwieldy and very expensive for the organisations. This is the model we had until virtualization came into existence.

Cloud computing tutorial for beginners

 

Cloud computing tutorial for beginners


cloud computing tutorial for beginners

In this video series we will understand, what is cloud computing and the options we had before cloud computing came into existence. Along the way, we will understand everything you need to know, to build cloud ready applications.

Cloud computing is everywhere. It is a big shift from the traditional way businesses think about IT resources. Organizations of every type, size, and industry are using the cloud for a wide variety of use cases. You’re probably, already using cloud computing right now, even if you don’t realise it. If you use an online service like GMAIL for example to send emails, edit documents using Google docs, or stream music or films online, it’s likely that, cloud computing is making it all possible behind the scenes.

Not all clouds are the same and not one type of cloud computing is right for everyone. Several different models, types and services have evolved to help offer the right solution for your needs.

cloud computing tutorial

For example, financial services companies are using the cloud to power real-time fraud detection and prevention. Healthcare companies are using it to develop more personalized treatments for patients, and video game makers are using it to deliver online games to millions of players around the world. There are many cloud related concepts like 

  • Infrastructure as a service (IaaS)
  • Platform as a service (PaaS)
  • Software as a service (SaaS)
  • Private cloud
  • Public cloud
  • Hybrid cloud
  • Serverless computing
  • and many more concepts

Cloud computing is massive. So here is what we are going to do. We will have 2 courses 

  1. Cloud computing tutorial for beginners
  2. Azure tutorial for beginners

In the market today, there are many cloud providers i.e organisations that provide cloud computing services. For example, some of the main players are Microsoft, Amazon, Google, IBM etc.

In this cloud computing tutorial, we will cover all the concepts and cloud specific technical terms that are common across all these different cloud providers. So it doesn't really matter, which cloud provider you want to go with. This course is for anyone who wants to learn and understand cloud computing in general.

Azure is the cloud computing service from Microsoft. In our second course, i.e Azure tutorial for beginners, we will discuss everything you need to know to build, deploy and scale applications using Azure.

As you know cloud computing is ever-expanding and it is here to stay. It doesn't matter whether you are a software developer, quality engineer, business analyst, software architect, project manager or head of development. This course is for anyone who wants to understand what cloud computing is and how it's changing the world of information technology.

I will do my best to cover all the cloud related concepts, but in the meantime, if you have a specific concept in mind that you want me to cover, please leave it as a comment on this video and I will surely discuss it in our upcoming videos in this series.

Finally, your feedback is really really important and means a lot. So, if you have a few minutes, please let us know your thoughts and feedback on this course.

Add api to azure api management

 

Add api to azure api management


In this video we will discuss how to add an API to Azure API Management service.

As you can see from the image below, there are several ways to do this in Azure.

Add api to azure api management

For example,

  • You can create a Blank API and manually add each API operation which is obviously tedious and time consuming
  • If you have your API deployed in Azure App Service, you may use the App Service option to add your API and all it's operations automatically
  • Similarly, if you have the OpenAPI specification document for you API, you may use it to add your API and all it's operations automatically

Imported APIs

azure api management import api

  • You will find the imported APIs on the APIs tab in the Azure portal.
  • In the middle pane, you will see all the APIs. In our example we have 3 APIs (Echo, Employee and Employee Management APIs).
  • Employee API is selected and you can see all the supported operations on the right.
  • The Test tab allows us to test the API calls.

Azure API Gateway

azure api gateway example

  • Remember azure API Gateway sits on top of our backend APIs (in this case Employee Management API).
  • It is the API Gateway that is customer facing which accepts API calls and routes them to our backend APIs.
  • Verifies API keys, JWT tokens, certificates, and other credentials
  • Enforces usage quotas and rate limits
  • Caches backend responses
  • Logs call metadata for analytics purposes
  • Transforms your API on the fly without code modifications

Create Azure API Management service instance

 

Create Azure API Management service instance


In this video we will discuss how to create a new instance of Azure API Management service. The following are the steps.

In the Azure portal serach for API Management services

create api management service in azure

Click Create

azure api management instance in the azure portal

On the next screen provide the following details and click Review + create

create azure api management

Subscription

Your azure subscription

Resource Group

Select your existing resource group or create a new one

Region

Azure region where you want this API management instance to be created

Resource name

  • Name has to be unique and can't be changed later. Both the developer portal and the API gateway uses this name.
  • API Gateway - <name>.azure-api.net
  • Developer Portal - <name>.developer.azure-api.net
  • You can use your own custom domain if you want to, for example api.pragimtech.com

Organization name

The name of your organization. This name is used in the title of the developer portal and notification emails.

Administrator email

The email address to which all the notifications from API Management will be sent.

Pricing tier

Determines the features available and the price you pay. Click here to explore all the azure API management pricing tiers.

What is azure api management service ?

 

What is azure api management service


In this video we will discuss what is azure api management service and why should we use it?

Why use Azure API Management Service

First, let's understand, why should we use azure api management service. What benefits it provides. Let's understand this with a simple example. 

Consider this openweathermap service (https://openweathermap.org/price). It's a very popular API that provides weather data like temprature, wind speed, himidity etc. To use this API, we have to pay a monthly fee. There is a free plan as well, but there are limits on it like

  • How many calls are allowed
  • What data is available and for how long etc.

With the $40 plan you can make up to 600 calls/minute and upto 10 million calls/month. This is a little less restrictive than the free plan.

To be able to use this API in the apps that we are building we need to subscribe and get an API key. We alsoe need to know the available end points, supported operations, what to pass and what we get back.

The main functionality of the API is to provide weather data. In addtion to this main functionality, the API should also have code to limit the number of calls. For example, the free plan only allows 60 calls/minute. So the API should also have code to limit the number of calls to 60/minute to prevent misuse and abuse. Like this there are several non-functional aspects that most APIs need to have, for example

  • Caching response to improve performance
  • Securing the API and providing access
  • Documentation i.e available end points, supported operations, what to pass and what we get back
  • There must be a developer portal or something that developers and partners can use to subscribe and self service i.e find documentation, code samples and even an interface to test the API calls.
  • API analytics is another important aspect which obviously let's you see API usage. For example, the most and least used end points, general health of the API etc.

All these non-functional aspects of the API are provided by the azure api management service.

What is Azure API Management Service

what is azure api management service

Well, it sits on top of your backend API services, it's like a proxy to your backedn APIs. In this example, azure api management service is on top of our two back-end APIs (Weather API and Employee API). Every call to these two back-end APIs goes through azure API management service.

Azure API Management Components

Azure API Management system is made up of three main components - Azure Portal, Developer Portal and API Gateway.

azure api management tutorial

Azure Portal

We already know what is Azure portal. We have been using it throughout this course to create various azure resources like virtual machines, app service instances, sql databases etc. We also use it to set up and do various things related to API management. For example, using the azure portal we can

  • Define or import API schema.
  • Package APIs into products.
  • Set up policies like quotas or transformations on the APIs.
  • Get insights from analytics.
  • Manage users.

We will see these in action in our upcoming videos in this series.

Developer Portal

As the name implies, the Developer portal is for the developers who want to consume your APIs in the apps that they are building. Using it they can

  • Create an account and subscribe to get API keys.
  • Test the API calls.
  • Read API documentation.
  • Access analytics on their own usage.

API Gateway

The API gateway sits on top of your backend APIs. In the example below, API Gateway sits on top of our backend APIs (Weather and Employee APIs) and it can to the following.

  • Accepts API calls and routes them to your backend APIs.
  • Verifies API keys, JWT tokens, certificates, and other credentials.
  • Enforces usage quotas and rate limits.
  • Caches backend responses where set up.
  • Logs call metadata for analytics purposes.
  • Transforms your API on the fly without code modifications.

What are the benefits of using azure api management service

  • Azure api management service provides ton of security and performance features. For example, based on the API access plan you selected (Free or paid), it limits the number of calls that are allowed as per the plan.
  • Prevents Denial of Service (DOS) attacks by using throttling.
  • Secures backend services by gating access with API keys.
  • Use advanced security policies like JWT tokens, certificates, and other credentials.

In short, Azure API Management system lets you transform your APIs on the fly without any code changes.