Hello frens, celt here to talk about how CloudWatch gets to the CPUUtilization number you see on your screen in console. This question is actually deceptively difficult, if you were thinking that Cloudwatch agent just reports this number back to CloudWatch, you are mistaken. But I do not blame you for being wrong.
AWS CloudWatch CPUUtilization
CPU Crash Course
Let’s start with what is a CPU? At a high level a CPU is made of up 3 components: arithmetic logical unit, one or more registers, and a control unit. So logically speaking 1 core == those 3 components. When customers select and EC2 you select something called vCPUs, which is how many cores of the CPU the customer is allocated. On an EC2 physical host (not an instance) the hypervisor (installed on the bare metal host) allocates resources to the EC2 instances. Resource allocation can be done with Linux concepts such as cgroups or namespaces (which we also saw used in Lambda). Something important to note later on is that this hypervisor software also takes resources to run. Customer’s EC2 runs on this isolated VM created by these technologies and has allocated resources.
Keep reading with a 7-day free trial
Subscribe to Software Architecture with BowTiedCelt to keep reading this post and get 7 days of free access to the full post archives.