Energy monitoring exercises for intro networking classes

I’m planning an energy monitoring exercise for an introductory networking class, and I’d love feedback from others who’ve tried something similar.

I teach in a digital arts grad program. The class is an introduction to networks, specifically the internet. Most of the students are not experienced programmers. I want them to know how the internet is structured, what a web server is, software-wise, and that all the internet is made of physical devices which consume resources.

I teach them to set up a virtual instance, install and customize ufw, nginx, node.js, and put an HTTPS certificate on it. This introduces them to the basics of what a web server is and how it works, from the software end. I’ve done it on other hosts, but I want to do this on CC, and be able to show them how much energy their instance is using at any point. It sounds like The Core Hours and Carbon Credits project did something very similar?

Last year I showed them energy usage of this model by setting up a single instance of this on a baremetal node, then ran the power monitoring tools Michael Sherman wrote about, while having them make client calls to the instance using a browser or curl. As they made requests, they watched the energy go up, in real time. When they did multiple requests using curl, they saw the energy go much higher as the load went higher. They were much impressed, and had lots of good questions.

Having each student run a bare metal node seems too resource intensive. So I thought perhaps I should run a hypervisor on a bare metal node, then spin off a virtual instance for each student. That way they could see their instance’s energy usage, even if not per-process. Michael Sherman suggested QEMU for this purpose (thanks Michael).

I’ve never run a hypervisor before, or even done containerization, to be honest (I’m pretty basic, my main expertise is microcontrollers and digital electronics). If anyone’s done something like this, or has advice on a setup for it that’s both effective and simple enough to explain to beginners, I’d love to hear from you.

Having each student run a bare metal node seems too resource intensive.

It depends on how many students, and how long they need it for! Particularly by reserving ahead of time, it’s very doable to get 10-20 nodes for a few days, especially the less in-demand node types. CHI@NCAR in particular has a lot of availability at the moment.

You could try the docker compose setup that scaphande provides, since it bundles scaphandre, prometheus, and grafana, and try out a few different ways of running the applications to see which ones show up well in the metrics?

For containers, any proceses running in a container will also be visible to root on the host, see About containers - Scaphandre documentation

For VMs, you can start by installing virsh and/or virt-manager to get some utilities for running and managing qemu-kvm based VMs

Scaphandre’s QEMU exporter (I think) allows doing two things

  1. measuring the power used per-vm, since each qemu-vm is/has a process on the host
  2. exporting that power in a way it can be measured inside the VM (you can skip this if you’re running one prometheus/grafana for all the students, rather than having them measure inside the VMs)

Of course, you’re not limited to containers, VMs, or scaphandre, just some thoughts.