Mid Term 1
Mid Term 1
Virtualization
It assigns a logical name for a physical resource and then provides a pointer
to that physical resource when a request is made.
When an application makes a request to the virtual resource using its logical
name, the virtualization layer translates this request by looking up the
mapping to the corresponding physical resource and provides a pointer to that
physical resource for processing the request.
Types of Virtualization
Access: A client can request access to a cloud service from any location
using any device with Internet connectivity.
Application: Cloud environment hosts multiple instances of same application
and requests are directed to a specific instance based on predefined
conditions/routing algorithms.
These predefined conditions could be workload, availability, or proximity
to users.
This type of virtualization enhances scalability, performance, and fault
tolerance.
It uses popular round robin, weighted round robin, fastest response time,
least connections and weighted least connections Load balancing algorithms
when a service request arrives.
The session ticket could be created using session data stored in database, or
use client’s browser to store client side cookie, or use rewrite engine that
modifies URL.
Out of all these methods session cookie method has least amount of overhead
as it allows load balancer an independent selection of resources.
The objectives of load balancing in cloud computing are as follows:
Resource Utilization Optimization:
Optimize the utilization of computing resources such as virtual machines,
servers, and network bandwidth.
Cost Optimization:
Optimize costs by enabling efficient resource utilization and avoiding
unnecessary resource provisioning.
By dynamically allocating resources based on workload demands, load
balancing reduces the need for over-provisioning and minimizes idle
resources, leading to cost savings for cloud service providers and users.
Layer 4 load balancers offer high performance and scalability but lack
application-awareness and content-based routing capabilities.
Layer 7 Load Balancing:
Layer 7 load balancing operates at the application layer (HTTP/HTTPS) of
the OSI model and can make routing decisions based on application-specific
parameters such as URL, HTTP headers, cookies, and payload content.
Layer 7 load balancers provide more granular control over traffic routing
and can optimize application performance, security, and user experience.
Each type of load balancing has its advantages and limitations, and the choice
depends on factors such as the nature of workloads, scalability requirements,
performance goals, budget constraints, and deployment environment.
Many cloud providers offer load balancing services that integrate different
types of load balancing to meet various customer needs.
Load balancing algorithms
Least Connection:
The Least Connection algorithm directs incoming requests to the server
with the fewest active connections or sessions.
This algorithm aims to minimize user perceived latency and improve overall
application performance.
Servers with higher capacities are assigned higher weights, allowing them
to handle a greater proportion of incoming requests.
These weights are based on the relative processing power and available
resources of each server.
If there are multiple servers with the lowest number of connections, the
server with the highest weight is preferred for load balancing.
Cloud providers often offer load balancing services with built-in support for
these algorithms, allowing users to configure and customize load balancing
behavior according to their needs.
Load balancing architecture
This architecture typically involves the following key components:
Load Balancer:
The load balancer is a central component responsible for receiving incoming
requests from clients and distributing them.
The VMM switches between running these VM, saving their contexts, and
then switching to others as needed, much like an OS switch between
processes.
When running inside a VM, a guest OS expects full access to hardware and
the ability to execute privileged instructions independently.
Additionally, since VMs should be isolated from each other, the VMM needs
to ensure they share resources safely, including hardware.
For instance, CPUs like x86 have different privilege levels, or "rings,"
typically four of them.
In this setup, user processes operate in the least privileged ring (ring
three), while the operating system resides in the most privileged ring (ring
zero), where it executes privileged instructions.
The guest OS applications run in ring three, just like regular user
processes.
The VMM and the host OS, however, operate in ring zero, providing them
with the highest level of privilege.
However, in the case of "trap and emulate," where the guest OS operates
at a lower privilege level, these actions are redirected to the VMM instead.
The guest OS, equipped with functions to handle such traps, processes the
action as if it were a regular system call.
After handling the trap, if the guest OS needs to return to the user
application, it executes a privileged instruction like Iret.
This instruction also traps to the VMM, which then knows to direct the
execution flow back to the guest user code.
The underlying principle is straightforward: whenever the guest OS needs
to perform a privileged action, it traps to the VMM.
The VMM then handles the action on behalf of the guest OS, whether it
involves returning to the user process or handling input/output operations.
One major issue is that the guest OS may detect that it's operating at a
lower privilege level than expected.
Guest OS are typically designed to operate at the highest privilege level
available.
A major issue arises with certain x86 instructions when they are
executed at a lower privilege level.
However, when the guest OS operates in ring one, they execute without
trapping to the VMM.
During the development of the x86 instruction set architecture,
virtualization was not a primary consideration.
It was widely assumed that operating systems would always run at the
highest privilege level, rendering these corner cases inconsequential.
For example, consider the "popf" instruction in x86, which writes values
from the stack into CPU registers like "eflags".
When executed in ring zero (privileged mode), all flags are correctly set.
However, in ring one (unprivileged mode), only accessible flags are set,
omitting crucial ones like the interrupt flag.
So, what exactly is this VMX mode of execution? Well, in x86 architecture,
there are typically four privilege levels, known as rings, in the regular
non-VMX mode, also called root mode.
Additionally, there exists another set of four rings in a special VMX mode
for virtualization.
In this setup, the guest OS operates at ring zero within this special VMX
mode, while the guest applications run at ring three.
This arrangement eliminates the need to run the guest OS at ring one, thus
avoiding potential issues encountered previously.
But how does the VMM maintain control? The VMM operates at ring zero in
the non-VMX mode, also known as the root mode of the CPU.
When the VMM needs to execute a guest OS, it switches to the VMX mode
and runs the guest OS at ring zero within this special mode.
However, it's essential to note that this ring zero in VMX mode isn't as
powerful as the regular ring zero.
The VMM can configure specific points at which the guest OS must trap
back into the VMM, allowing it to maintain some control.