0% found this document useful (0 votes)
76 views27 pages

Vsphere ICM 8 Lab 23

NDG lab

Uploaded by

seher khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views27 pages

Vsphere ICM 8 Lab 23

NDG lab

Uploaded by

seher khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

VMWARE VSPHERE 8.

0
INSTALL, CONFIGURE, MANAGE

Lab 23: Controlling VM Resources

Document Version: 2023-03-08

Copyright © 2023 Network Development Group, Inc.


www.netdevgroup.com

NETLAB+ is a registered trademark of Network Development Group, Inc.

VMware is a registered trademark of VMware, Inc.


95BLab 23: Controlling VM Resources

Contents
Introduction .............................................................................................................................................. 3
Objectives ................................................................................................................................................. 3
Lab Topology ............................................................................................................................................. 4
Lab Settings ............................................................................................................................................... 5
1 Prepare the Lab Environment ........................................................................................................... 6
2 Create CPU Contention ................................................................................................................... 14
3 Verify the CPU Share Functionality ................................................................................................. 23

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 2


95BLab 23: Controlling VM Resources

Introduction

In this lab, you will observe the behavior of Virtual Machines (VMs) with different CPU share values.

Controlling VM resources is important because it helps in optimizing the use of available resources and
ensuring that VMs operate effectively and efficiently. This includes managing CPU, memory, storage,
and network resources, and balancing the allocation of these resources among multiple VMs. By
controlling VM resources, the performance and stability of the virtual infrastructure can be improved,
and resource utilization can be optimized. This in turn helps ensure that VMs meet their business
requirements, provide a better user experience, and improve overall infrastructure utilization.

To create CPU contention, you will use stress-ng. Stress-ng is a Linux tool that is used to stress test a
computer's hardware, including its CPU. It creates CPU contention by generating a high load on the
system and making the CPU work to its maximum capacity. This allows administrators to evaluate the
system's performance under heavy load, and determine if there are any potential performance issues,
such as CPU contention. By using stress-ng to create CPU contention, administrators can determine if
the system can handle peak loads, and if additional hardware or optimizations are required to improve
performance.

Objectives

• Create CPU Contention


• Verify the CPU Share Functionality

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 3


95BLab 23: Controlling VM Resources

Lab Topology

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 4


95BLab 23: Controlling VM Resources

Lab Settings

The information in the table below will be needed to complete the lab. The task sections further below
provide details on the use of this information.

Virtual Machine IP Address Account Password

sa-student eth0: 172.20.10.80 sysadmin NDGlabpass123!

sa-vcsa eth0: 172.20.10.94 [email protected] NDGlabpass123!

sa-esxi-01 eth0: 172.20.10.51 root NDGlabpass123!

sa-esxi-02 eth0: 172.20.10.52 root NDGlabpass123!

sa-aio eth0: 172.20.10.10 sysadmin NDGlabpass123!

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 5


95BLab 23: Controlling VM Resources

1 Prepare the Lab Environment

In this task, you will migrate LinuxGUI-01 and LinuxGUI-02 compute to sa-esxi-01.vclass.local and the
storage to the iSCSI-Datastore.

1. Launch the sa-student VM to access the graphical login screen.

To launch the console window for a VM, either click on the machine’s
graphic image from the topology page, or click on the machine’s
respective tab from the Navigator.

2. Launch the Mozilla Firefox web browser by either clicking on the icon found in the bottom toolbar
or by navigating to Start Menu > Internet > Firefox Web Browser.

3. In Firefox, click LAUNCH VSPHERE CLIENT.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 6


95BLab 23: Controlling VM Resources

If the VMware Getting Started webpage does not load, please wait an
additional 3 - 5 minutes, and refresh the page to continue. This is
because the vCenter Server Appliance is still booting up and requires
extra time to initialize.

4. To log in to the vCenter Server Appliance, enter [email protected] as the username and
NDGlabpass123! as the password. Click LOGIN.

You may ignore the “browser-OS combination” warning message


presented on the VMware vCenter Single Sign-On page and continue
moving forward with the lab.

5. In the Navigator, ensure you are viewing the Hosts and Clusters tab, and select sa-
vcsa.vclass.local. In the right pane, select Datastores and right-click on iSCSI-Datastore. In the
Actions pull-down menu, click Increase Datastore Capacity….

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 7


95BLab 23: Controlling VM Resources

6. In the Increase Datastore Capacity window on the Select Device step, select LUN 3 and click NEXT.

7. On the Specify Configuration step, leave the defaults, and click NEXT.

8. On the Ready to Complete step, review the information, and click FINISH.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 8


95BLab 23: Controlling VM Resources

9. Repeat steps 5 – 8, and expand the iSCI-Datastore using LUN 4 and Lun 2. For Lun 2, you will only
increase the size by 10 GB for lab purposes.

10. Ensure you are still viewing the Datastores tab. Verify that iSCSI-Datastore is showing a capacity of
59 GB and at least 32 GB of free space.

11. In the Recent Tasks pane, verify that the iSCSI-Datastore tasks have successfully completed.

12. In the Navigator, select ICM-Datacenter.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 9


95BLab 23: Controlling VM Resources

13. In the ICM-Datacenter main workspace, click the Virtual Machines tab, and select LinuxGUI-01 and
LinuxGUI-02.

14. Right-click the two LinuxGUI VMs and click Migrate.

15. In the Migrate window, click YES.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 10


95BLab 23: Controlling VM Resources

16. In the 2 Virtual Machines – Migrate window on the Select a migration type, select Change both
compute resource and storage. Click NEXT.

17. On the Select a compute resource step, expand ICM-Datacenter and select sa-esxi-01.vclass.local.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 11


95BLab 23: Controlling VM Resources

18. On the Select storage step, select the iSCSI-Datastore. In the Select virtual disk format drop-down
menu, select Thin Provision. Click NEXT.

19. On the Select Networks step, verify that VM Network is selected for the Destination Network. Click
NEXT.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 12


95BLab 23: Controlling VM Resources

20. On the Ready to complete, review the information, and click FINISH.

21. Monitor the Recent Tasks pane, and confirm the that both Linux-GUI VMs have successfully
migrated. This will take 2 - 4 minutes to complete.

Confirm that the LinuxGUI-01 and LinuxGUI-02 VMs are located on sa-esxi-
01.vclass.local and utilizing the iSCSI-Datastore as their storage source.

22. Leave the vSphere Client open, and continue to the next task.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 13


95BLab 23: Controlling VM Resources

2 Create CPU Contention

In this task, you will create CPU contention between the LinuxGUI-01 and LinuxGUI-02 VMs for testing
your lab environment. You will use CPU scheduling affinity to force both VMs to be scheduled on the
same logical CPU, and you will utilize the stress-ng tool on both VMs to generate CPU activity. By
creating contention, you force the VMs to compete for and share the limited logical CPU resources on
the ESXi host. This approach might lead to performance degradation.

CPU scheduling affinity is a mechanism that binds a process to a specific set of CPU cores. While it may
be tempting to use this feature to intentionally create CPU contention in a production environment,
this is generally not recommended. Using CPU scheduling affinity to create contention can have several
negative effects, including:

• Unpredictable performance: CPU contention can lead to variable and unpredictable


performance, making it difficult to ensure consistent service levels for applications and users.
• Resource waste: If CPU contention is not managed properly, it can result in CPU cores being
overutilized and other cores being underutilized. This can result in wasted resources and higher
costs for the organization.
• Complexity: Creating and managing CPU contention can be complex and error-prone, especially
in large, dynamic production environments.
• Scalability: If the CPU affinity configuration is not flexible enough to adapt to changing
workloads and resource requirements, it can limit the scalability of the environment and make
it more difficult to respond to changes.

It is generally recommended to avoid using CPU scheduling affinity in production environments for the
purpose of creating CPU contention. Instead, it is better to use more sophisticated resource
management and workload scheduling techniques, such as CPU capping or Quality of Service (QoS)
controls, to manage CPU utilization and ensure predictable performance.

CPU contention in vSphere refers to a situation where there is high demand for CPU resources from
VMs running on a vSphere host, and the available CPU resources are not enough to meet the demand.
This results in the VMs having to wait for CPU time, leading to decreased performance and potential
service disruptions. To prevent CPU contention, it is important to monitor CPU utilization, configure
resource reservations and limits for VMs, and overprovision CPU resources on the host to ensure that
sufficient CPU resources are available.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 14


95BLab 23: Controlling VM Resources

1. Click the VMs and Templates tab, and expand sa-vcsa.vclass.local and ICM-Datacenter. Right-click
on LinuxGUI-01 and select Edit Settings.

2. In the Edit Settings window, expand CPU. In the Scheduling Affinity text box, enter 0. Click OK.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 15


95BLab 23: Controlling VM Resources

The Scheduling Affinity setting forces the LinuxGUI-01 machine to run on


logical CPU 0. CPU affinity is used mainly to create CPU contention for training
purposes only. VMware strongly discourages the use of this feature in a
production environment.

3. Ensure LinuxGUI-01 is selected, and power on the LinuxGUI-01 VM.

4. Right-click on LinuxGUI-02 and select Edit Settings.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 16


95BLab 23: Controlling VM Resources

5. In the Edit Settings window, expand CPU. In the Scheduling Affinity text box, enter 0. Click OK.

The Scheduling Affinity setting forces the LinuxGUI-02 machine to run on


logical CPU 0. CPU affinity is used mainly to create CPU contention for training
purposes only. VMware strongly discourages the use of this feature in a
production environment.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 17


95BLab 23: Controlling VM Resources

6. Ensure LinuxGUI-02 is selected, and power on the LinuxGUI-02 VM.

7. In the Navigator, select LinuxGUI-01 and click the Monitor tab. Select Utilization and verify that
the Shares value is Normal (1000).

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 18


95BLab 23: Controlling VM Resources

8. In the Navigator, select LinuxGUI-02 and click the Monitor tab. Select Utilization and verify that
the Shares value is Normal (1000).

9. Select the LunuxGUI-01 VM and select the Summary tab. In the Guest OS pane, click LAUNCH WEB
CONSOLE. If the LinuxGUI-01 VM is sleeping, click inside the web console to wake it up.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 19


95BLab 23: Controlling VM Resources

10. On the Desktop, double-click the QTerminal icon to open it.

11. In the Terminal window, enter the command below and press Enter.

sysadmin@linuxGUI-01:~$ stress-ng -–shm 0 -v

The stress-ng command with the option --shm 0 will initiate a stress test on all
currently active CPU cores, with each core running a separate shared memory
stressor. For example, if machine has 4 threads, the command will run 4
shared memory stressors simultaneously.

The -v option is a flag used in the stress-ng command line tool. Stress-ng is a
stress testing tool that can be used to test the stability and performance of
Linux systems. The -v option stands for verbose and it enables verbose output
mode. When the verbose option is enabled, stress-ng will display detailed
information about the stress tests that are being performed, including the test
name, the number of instances running, and the duration of the tests.

12. Return to the vSphere Client by clicking the vSphere-LinuxGUI-01-*** tab in Firefox.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 20


95BLab 23: Controlling VM Resources

13. Select the LunuxGUI-02 VM and select the Summary tab. In the Guest OS pane, click LAUNCH WEB
CONSOLE. If the LinuxGUI-02 VM is sleeping, click inside the web console to wake it up.

14. On the Desktop, double-click the QTerminal icon to open it.

15. In the Terminal window, enter the command below and press Enter.

sysadmin@linuxGUI-02:~$ stress-ng -–shm 0 -v

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 21


95BLab 23: Controlling VM Resources

16. Return to the vSphere Client by clicking the vSphere-LinuxGUI-02-*** tab in Firefox.

17. After 2 - 4 minutes, return to the LinuxGUI-01 and LinuxGUI-02 VMs. Select the Monitor tab and
click Utilization. Notice the CPU Consumed is in blue and the CPU Active is in green.

Contention of VMs can occur when multiple VMs are competing for the same
physical resources, such as CPU, memory, or storage. This competition can
result in increased latency, decreased CPU utilization, and reduced
performance of the VMs. When this occurs, you may notice that the VMs are
not running at their full potential, and that their performance is being
impacted by the competition for resources. The level of performance
degradation will depend on the extent of the contention and the workloads of
the VMs. If contention is severe, it may become necessary to allocate more
resources or balance the workloads to resolve the issue.

18. Review the amount of Consumed and Active CPU values between LinuxGUI-01 and LinuxGUI-02.
Results may slightly vary.

19. Leave the vSphere Client open, and continue to the next task.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 22


95BLab 23: Controlling VM Resources

3 Verify the CPU Share Functionality

In this task, you will verify that the VMs receive the correct CPU allocation during contention. CPU
allocation is based on the number of shares given to the VM.

CPU Shares is a functionality in vSphere that allows administrators to allocate CPU resources to VMs
based on relative importance. It enables prioritization of VMs, so that when CPU resources are limited,
more important VMs receive a larger share of the available resources, while less important VMs
receive a smaller share. This helps ensure that critical VMs receive the resources they need to operate
properly, while non-critical VMs do not consume an excessive amount of resources.

1. Right-click on LinuxGUI-01 and select Edit Settings.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 23


95BLab 23: Controlling VM Resources

2. In the Edit Settings window, expand CPU. From the Shares drop-down menu, verify that High is
selected. Click OK.

3. Right-click on LinuxGUI-02 and select Edit Settings.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 24


95BLab 23: Controlling VM Resources

4. In Edit Settings window, expand CPU. From the Shares drop-down menu, verify that Low is
selected. Click OK.

Before proceeding to the next step, allow 2 - 4 minutes for the LinuxGUI VMs
to normalize from changing the amount of shares value.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 25


95BLab 23: Controlling VM Resources

5. In the Navigator, select LinuxGUI-01 and click the Monitor tab. Select Utilization and verify the
Shares value is High (2000). The warning icon is advising that CPU usage is high in the VM. You may
disregard the warning for this lab.

A VM CPU usage high warning message typically indicates that the CPU
utilization of a VM has reached a level that may cause performance issues. This
message is typically generated by virtualization software or a virtualization
management tool, and is used to alert administrators that one or more VMs
are consuming an excessive amount of CPU resources.

The high CPU usage could be caused by a number of factors, including:

• Over-provisioning of virtual CPU resources: If a VM has been allocated


more virtual CPU resources than it needs, it may result in high CPU
utilization.
• Resource-intensive applications: Applications that are CPU-intensive,
such as database servers, can cause high CPU utilization.
• CPU-bound processes: Processes that are waiting for CPU time can
cause high CPU utilization.
• CPU contention: When multiple VMs are competing for the same
physical CPU resources, it can result in high CPU utilization and slow
performance.

In a production environment, it is important to address high CPU utilization


warnings promptly, as this can impact the performance and availability of
other VMs and the underlying physical infrastructure.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 26


95BLab 23: Controlling VM Resources

6. In the Navigator, select LinuxGUI-02 and click the Monitor tab. Select Utilization and verify that
the Shares value is Low (500).

7. Notice the CPU Consumed values are in blue and the CPU Active values are in green.

8. Changing the Shares value has impacted the performance on each LinuxGUI VM.

9. Shut down the LinuxGUI VMs by clicking the Shutdown Guest OS icon.

10. The lab is now complete; you may end your reservation.

3/13/2023 Copyright © 2023 Network Development Group, Inc. www.netdevgroup.com Page 27

You might also like