Performance, Scalability, and Troubleshooting

Introduction

Our journey begins with a major challenge; the annual "Mega-Sale Monday" event. Our flagship e-commerce website, now partially migrated to VM-based services on OpenShift Virtualization, is anticipating an unprecedented surge in traffic. Last year, our website crashed due to unexpected traffic spikes, leading to significant lost sales and frustrated customers. This year, while we are determined to be prepared, we need to know how to recognize unexpected issues in our environment and how to address them to ensure that the scenario from last year does not repeat itself. In this module you will learn how to discover a high-load scenario on your cluster, how to mitigate and remediate the cluster by scaling resources both vertically and horizontally, and finally learn how to balance the resources on your cluster for future events.

Credentials for the Red Hat OpenShift Console

Your OpenShift cluster console is available here.

Your local admin login is available with the following credentials:

  • User: username

  • Password: password

You will first see a page that asks you to choose an authenication provider, click on htpasswd_provider.

00 htpasswd login
Figure 1. OpenShift Authentication

You will then be presented with a login screen where you can copy/paste your credentials.

01 openshift login
Figure 2. OpenShift Login

Module Setup

  1. Using the left side navigation menu click on Workloads followed by Deployments.

  2. Make sure to ensure you are in Project: webapp-vms.

  3. You should see one pod deployed here called loadmaker.

    01 select loadmaker
    Figure 3. Loadmaker Deployment
  4. Click on loadmaker and it will bring up the Deployment details page.

    02 deploy details
    Figure 4. Deployment Details
  5. Click on Environment, you will see a field for REQUESTS_PER_SECOND, change the value in the field to 75 if it is not already set, and click the Save button at the bottom.

    03 lm pod config
    Figure 5. LM Pod Config
  6. Now lets go check on the VMs that we are generating load against.

  7. On the left side navigation menu click on Virtualization and then VirtualMachines. Select the windows-vms project in the center column. You should see three virtual machines: winweb01, winweb02, and database.

    04 windows vms
    Figure 6. Windows VMs
    At this point in the lab only database and winweb01 should be powered on. If they are off, please power them on now. Do not power on winweb02 for the time being.

Enable and Explore Alerts, Graphs, and Logs

Another important task for administrators is often to be able to assess cluster performance. These performance metrics can be gathered from the nodes themselves, or the workloads that are running within the cluster. OpenShift has a number of built-in tools that assist with generating alerts, aggregating logs, and producing graphs that can help an administrator visualize the performance of their cluster.

Node Alerts and Graphs

To begin, lets look at the metrics for the nodes that make up our cluster.

  1. On the left side navigation menut click on Compute, and then click on Nodes.

  2. From the Nodes page, you can se each node in your cluster, their status, role, the number of pods they are currently hosting, and physical attributes like memory and cpu utilization.

    39 node list
    Figure 7. Nodes
  3. Click on your worker node 4 in your cluster. The Node details page comes up where you can see more detailed information about the node.

  4. The page shows alerts that are being generated by the node at the top-center of the screen, and provides graphs to help visualize the utilization of the node by displaying CPU, Memory, Storage, and Network Throughput graphs at the bottom-center of the screen.

  5. You can change the review period for these graphs to periods of 1, 6, or 24 hours by clicking on the dropdown at the top-right of the utilization panel.

    40 node example
    Figure 8. Node Details

Virtual Machine Graphs

Outside of the physical cluster resources, it’s also very important to be able to visualize what’s going on with our applications and workloads like virtual machines. Lets examine the information we can find out about these.

For this part of the lab, we are going to use an application to generate additional load on some of our virtual machines so that we can see how graphs are generated.
  1. Using the left side navigation menu click on Workloads followed by Deployments.

  2. Make sure to ensure you are in Project: windows-vms.

  3. You should see one pod deployed here called loadmaker.

    41 select loadmaker
    Figure 9. Loadmaker Deployment
  4. Click on loadmaker and it will bring up the Deployment details page.

    42 deploy details
    Figure 10. Deployment Details
  5. Click on Environment, you will see a field for REQUESTS_PER_SECOND, change the value in the field to 75 and click the Save button at the bottom.

    43 lm pod config
    Figure 11. LM Pod Config
  6. Now lets go check on the VM’s that we are generating load against.

  7. On the left side navigation menu click on Virtualization and then VirtualMachines. Select the windows-vms project in the center column. You should see three virtual machines: winweb01, winweb02, and database.

    44 windows vms
    Figure 12. Windows VMs
    At this point in the lab only database and winweb01 should be powered on. If they are off, please power them on now. Do not power on winweb02 for the time being.
  8. Once the virtual machines are running, click on winweb01. This will bring you to the VirtualMachine details page.

  9. On this page there is a a Utilization section that shows the following information:

    • The basic status of the VM resources (cpu, memory, storage, and network transfer) which are updated every 15 seconds.

    • A number of small graphs which detail the VM performance over a recent time period, by default this is the last 5 minutes, but we can select a value up to 1 week from the drop down menu.

      45 vm details
      Figure 13. VM Details
  10. Taking a closer look at Network Transfer by clicking on Breakdown by network you can see how much network traffic is passing through each network adapter assigned to the virtual machine. In this case, the one default network adapter.

    46 select network
    Figure 14. Select Network
  11. When you are done looking at the network adapter, click on the graph showing CPU utilization.

    47 select cpu
    Figure 15. Select CPU
  12. This will launch the Metrics window which will allow you to see more details about the CPU utilization. By default this is set to 30 minutes, but you can click on the drop down and change that to 1 hour to see the spike in the graph once we turned on the load generator.

    48 cpu metrics
    Figure 16. CPU Metrics
  13. You can also modify the refresh timing in the upper right corner.

    49 change refresh
    Figure 17. Change Refresh Interval
  14. You can also see the query that is being run against the VM in order to generate this graph, and create your own using the Add Query button.

    50 add query
    Figure 18. Add_Query
  15. As an exercise, lets add a custom query that will show the amount of vCPU time spent in IO/wait status.

  16. Click the Add Query button, and on the new line that appears, paste the following query:

    sum(rate(kubevirt_vmi_vcpu_wait_seconds_total{name='winweb01',namespace='windows-vms'}[5m])) BY (name, namespace)
  17. Click the Run queries button and see how the graph updates. A new line graph will appear showing that the vCPU on the guest is never not under load.

    51 example query
    Figure 19. Sample Custom Query

Examining Dashboards

Another powerful feature of OpenShift is being able to use the Cluster Observability Operator to display detailed dashboards of cluster performance. Lets check some of those out now.

  1. From the left side navigation menu, click on Observe, and then Dashboards.

    52 dashboards
    Figure 20. Dashboards
  2. Click on API Performance and search for KubeVirt/Infrastructure Resources/Top Consumers

    53 kubevirt dashboard
    Figure 21. KubeVirt Dashboard
  3. This dashboard will display the top consumers for all of the virtual machines running on your cluster. Look at the Top Consumers of CPU by virt-launcher Pods panel and click the Inspect link in the upper right corner.

    54 cpu inspect
    Figure 22. CPU Inspect
  4. You can can select the VMs you want to see in the graph by checking the boxes next to each VM displayed.

  5. Try it now by turning some of the lines off. The associated colored line will disappear from the graph when disabled.

    55 metrics select
    Figure 23. Select Metrics

Now that we have completed this section determining how to locate and display alerts, performance metrics, and graphs about our nodes and workloads, we can leverage these skills in the future in order to troubleshoot our own OpenShift Virtualization environments.

Examining Resource Utilization on Virtual Machines

The winweb01, winweb02, and database servers work together to provide a simple web-based application that load-balances web requests between the two web servers to reduce load and increase performance. At this time, only one webserver is up, and is now under high demand. In this lab section we will see horizontally scaling the webservers can help reduce load on the VMs, and how to diagnose this using metrics, and graphs that are native to OpenShift Virtualization.

  1. Click on winweb01 which should currently be running. This will bring you to the VirtualMachine details page.

    05 vm details
    Figure 24. VM Details
  2. Click on the metrics tab and take a quick look at the CPU utilization graph, it should be maxed out.

    06 vm metrics
    Figure 25. VM Metrics
  3. Click on the CPU graph itself to see an expanded version. You will notice that the load on the server is much higher than 1.0, which indicates 100% CPU utilization, and means that the webserver is severely overloaded at this time.

    07 cpu util load
    Figure 26. CPU Utilization and Load

Horizontally Scaling VM Resources

  1. Return to the list of virtual machines by clicking on VirtualMachines in the left side navigation menu, and click on the winweb02 virtual machine. Notice the VM is still in the Stopped state. Use the Play button in the upper right corner to start the virtual machine.

    08 power on
    Figure 27. Power On Winweb02
  2. Return to the Metrics tab of the winweb01 virtual machine, and click on it’s CPU graph again. We should see the load begin to gradually come down.

    09 load reducing
    Figure 28. Load Reducing
  3. Add a query to also graph the load on winweb02 at the same time by clicking the Add query button, and pasting the following syntax:

    sum(rate(kubevirt_vmi_cpu_usage_seconds_total{name='winweb02',namespace='windows-vms'}[5m])) BY (name, namespace)
  4. Click the Run queries button and examine the updated graph that appears.

    10 load sharing
    Figure 29. Load Sharing

We can see by examining the graphs that winweb02 is now under much more load than winweb01 but over the next 5 minutes or so the load will level out and balance on the two virtual machines.

Vertically Scaling VM Resources

Even with the load evening out on the VM’s over a 5 minute interval, we can still see that they are under fairly high load. Without the ability to scale further horizontally the only option that remains is to scale vertically by adding CPU and Memory resources to the VMs. Luckily as we explored in the previous module, this can be done by hot-plugging these resources, and not affect the workload as it’s currently running.

  1. Start by examining the graph on the metrics page from the previous section. You can set the refresh interval to the last 5 minutes with the dropdown in the upper left corner. Note that the load on the two virtual guests is holding steady near 1.0, which signifies that both guests are still pretty overwhelmed.

    11 balanced load
    Figure 30. Balanced Load
  2. Navigate back to the virtual machine list by clicking on VirtualMachines on the left side navigation menu, and click on winweb01.

    12 select vm
    Figure 31. Select VM
  3. Click on the Configuration tab for the VM, and under VirtualMachine details find the section for CPU|Memory and click the pencil icon to edit.

    13 edit vm
    Figure 32. Edit VM
  4. Increase the vCPUs to 4 and click the Save button.

    14 update specs
    Figure 33. Update Specs
  5. Click back on the Overview tab. You will see that the CPU | Memory section in the details has been updated to the new value, and that the CPU utilization on the guest gradually drops quite quickly.

    15 vm new spec
    Figure 34. New VM Spec
  6. Repeat these steps for winweb02.

  7. Once both vms are upgraded, click on windows-vms project. You will see that the CPU usage dropped dramatically.

    16 updated usage
    Figure 35. Updated Utilization
  8. Click on winweb01 and then click on the Metrics tab and the CPU graph to view how the utilization graph now looks. You can also re-add the query from winweb02 and see that both graphs came down quite rapidly after the resources on each guest were increased, and the load on each VM is so much less than before.

    17 updated usage verify
    Figure 36. Verify Metrics

Discussing Swap/Memory Overcommit

This section of the lab is just informative for what we may do in a scenario where we find ourselves out of physical cluster resources. Please read the following information.

Some times you don’t have the ability to increase CPU or memory resources to a specific workload because you have exhausted all of your physical resources. By default, OpenShift has an overcommit ratio of 10:1 for CPU, however memory in a Kubernetes environment is often a finite resource.

When a normal kubernetes cluster encounters an out of memory scenario due to high workload resource utilization, it begins to kills pods indescriminately. In a container-based application environment, this is usually mitigated by having multiple replicas of an application behind a load balancer service. The application stays available served by other replicas, and the killed pod is reassigned to a node with free resources.

This doesn’t work that well for virtual machine workloads which in most cases are not composed of many replicas, and need to be persistently available.

If you have exhausted the physical resources in your cluster the traditional option is to scale the cluster, but many times this is much easier said than done. If you don’t have a spare physical node on standby to scale, and have to order new hardware, you can often be delayed by procurement procedures or supply chain disruptions.

One workaround for this is to temporarily enable SWAP/Memory Overcommit on your nodes so that you can buy time until the new hardware arrives, this allows for the worker nodes to SWAP and use hard disk space to write application memory. While writing to hard disk is much much slower than writing to system memory, it does allow to preserve workloads until additional resources can arrive.

Scaling a Cluster By Adding a Node.

The primary recourse when you have run out of physical resources on the cluster is the scale the cluster by adding additional worker nodes. This can then allow for workloads that are failing or cannot be assigned to be assigned successfully. This section of the lab is dedicated to just this idea, we will overload our cluster, and then add a new node to allow all VMs to run successfully.

In this lab environment we are not actually adding an additional physical node, we are simulating the behavior by having a node on standby which is tainted to not allow VM workloads. At the appropriate time we will remove this taint, thus simulating the addition a new node to our cluster.
  1. In the left side navigation menu, click on Virtualization and then VirtalMachines.

  2. Ensure that all VMs in vms-aap-day2 and windows-vms projects are powered on.

    18 verify oc
    Figure 37. Verify Running VMs
  3. Click on the mass-vm project to list the virtual machines there. Click on 1 - 15 of 30 drop down and change it to 50 per page to display all of the VMs.

    19 project mass
    Figure 38. Mass VMs Project
  4. Click on the Check box under the Filter dropdown to select all VMs in the project. Click on the Actions button and select Start from the dropdown menu.

    20 select all start
    Figure 39. Start All VMs
  5. Once all of the VMs attempt to power on, there should be approximently 6-7 VMs that are currently in an error state.

    21 after start
    Figure 40. VMs After Startup
  6. Click on the number of errors to see an explanation for the error state.

    22 num errors
    Figure 41. Error Details
  7. Each of these VMs will show a ErrorUnschedulable in the status column, because the cluster is out of resources to schedule them.

  8. In the left side navigation menu, click on Compute then click on Nodes. See that three of the worker nodes (nodes 2-4) have a large number of assigned pods, and a large amount of used memory, while worker node 1 is using much less by comparison.

    23 worker nodes
    Figure 42. Nodes
    In an OpenShift environment, the memory available is calculated based on memory requests submitted by each pod, i n this way the memory a pod needs is guaranteed, even if the pod is not using that amount at the time. This is why each of these worker nodes are considered "full" even though they only show about 75% utilization when we look.
  9. Click on worker node 2, you will be taken to the Node details page. Notice there are warnings about limited resources available on the node. You can also see the graph of memory utilization for the node, which shows the used memory in blue, and the requested amount as an orange dashed line as well.

    24 worker node 2
    Figure 43. Worker Node 2 Details
  10. Click on the Pods tab at the top, and in the search bar, type virt-launcher to search for VMs on the node.

    25 vms on node 2
    Figure 44. VMs On Worker Node 2
  11. Now, click on Nodes in the left-side navigation menu, and then click on worker node 1 which will bring you to it’s Node details page. Notice there are no CPU or Memory warnings currently on the node.

    26 worker node 1
    Figure 45. Worker Node 1 Details
  12. Click on the Pods tab at the top, and in the search bar, type virt-launcher to search VMs on the node. Notice that there are currently none.

    27 vms on node 1
    Figure 46. VMs On Worker Node 1
  13. Click on the Details tab, and scroll down until until you see the Taints section where there is one taint defined.

    28 node details
    Figure 47. Node Details
    29 select taints
    Figure 48. Select Taints
  14. Click on the pencil icon to bring up a box to edit the current Taint on the node. When the box appears, click on the - next to the taint definition to remove it and click the Save button.

    30 remove taint
    Figure 49. Remove Taint
  15. Once the taint is removed, scroll back to the top and click on the Pods tab again and type virt-launcher into the search bar once more, you will see the unscheduleable VMs are being assigned to this node now.

    31 vms node1 untainted
    Figure 50. VMs On Worker Node 1
  16. Return to the list of VMs in the mass-vms project by clicking on Virtualization and then clicking on VirtualMachines in the left side navigation menu to see all of the VMs now running.

    32 mass vms running
    Figure 51. Mass VMs Running

Load Aware Cluster Rebalancing

<WRITE THIS SECTION>

Summary

In this module you have worked as an OpenShift Virtulization administrator dealing with a high load scenario which you were able to remediate by horizontally and vertically scaling virtual machine resources. You also were able to solve an issue where you had run low on physical cluster resources and were unable to provision new virtual machines by scaling up your cluster to provide additional resources.