Physical servers are a thing of the past some would say. The way things are moving in IT in the direction of Cloud. First it was offsite hosting. Then virtualization with a Hypervisor (VMware took the torch and ran with it). Then Private cloud was a thing, think Openstack.
Now we’re supposed to dream of a future where we don’t manage physical components. We just control ones and zeros through infrastructure as code.
But but all enterprises have adopted public cloud yet. And with regulations and all, you can bet that we’ll be managing physical servers for a while to come.
So we still need to be able to answer questions such as “how many processors are in your Box?”. I was asked this question by a senior team member. Two of my buddies had said that the box had 32 CPUS because they saw that /proc/cpuinfo showed 31 lines of processor, last one being “processor :31”. They were wrong. At least partly wrong.
I thought I’d be smart and said the server had 8 processors because /proc/cpuinfo also showed that “cpu cores :8”. So nebulously I said “there is some multi-threading” being done. I go some credit but that was not a clear answer.
So here is how it works. We all looked at /proc/cpuinfo and that is the correct source. But we have to read all the details this file provides to understand the full picture of how a system is presented processors.
First understand that /proc/cpuinfo is sort of a database. Each record in this file is delimited by a blan-space-line. The line items that we want to consider in each record are:
- model name (mostly background info)
- physical ID
- core id
- cpu cores
Let’s start by giving the final solution to the question and we’ll break it down.
Physical Processors – The server actually has 2 physical processors. That means two physical sockets with a processor card on each. You can see that in the fact that there were only two “physical IDs” in the file ( 0 and 1). You can see this by grep “physical id” /proc/cpuinfo.
Number of Cores – So if there are only two physical processors why does the system show 32 “processors”? Part of the answer is that each of these two physical processors has 8 cores. Think of it like an 8 layer Oreo cookie. It’s a single cookie with 8 wafers. So when it comes to raw-physical-processing-core the system has 16. That is 2processors * 8 cores each = 16. You can see this by running grep “cpu cores” /proc/cpuinfo. You can also determine this by reading the mode name by grep “model name” /proc/cpuinfo and doing a Google search. you can find the specs which will confirm the number of cores. In my case the processor was an Intel Xeon E5-2660.
Number of threads – The server can handle 32 simultaneous threads. This means 32 execution simultaneously. You can determine this in two ways. One by grep “siblings” /procu/cpuinfo. In my Xeon server that command shows “siblings :16”. This means that on each processor there are 16siblings, aka threads. This is confirmed by the fact that the files shows 32 processors. And again if you Google the specs you’ll see that each processor supports 16 threads. So a single core can process two threads (2*8*2=32 processors).
So what we have is a play of words between the BIOS and the OS. It wants to tell the OS that it can handle 32threads so the OS represents them as processors.
As I’ve learned some Apps are really good and maximizing their threads so in that case it’d be better to disable Hyperthreading via the BIOS. In that case the OS would report only 16 processors, this would be 16 real cores.
This was a good review of basics for me. Hopefully you too can know answer when someone asks “how many processors are in your box”