Sockets, cores and threads: what a CPU count means
Video 018 of 140 in Virtualization Foundations, in the unit “CPUs: sockets, cores, threads and caches”. 3:42, with English and Hindi audio.
A server can show ninety-six CPUs and still have only forty-eight real cores. The difference matters for planning, for software licences and for how fast a busy system really runs. To see why, you need three words: socket, core and hardware thread. This article counts a real-style example from the outside in, then shows how Linux reports the same numbers.
What you will learn
- A socket is the slot that holds one processor chip on the board.
- A core is a real worker with its own calculating units. A hardware thread shares one core.
- Logical CPUs are what the operating system counts, and they include the threads.
- Ninety-six logical CPUs can mean forty-eight real cores, so size work against the real cores.
Counting from the outside in
Take a server that runs the database of Harbor Point Logistics, an example company. This host has two processor chips, and each chip has twenty-four cores. These are real, physical parts of the machine.
- Socket: the slot on the motherboard that holds one processor chip. This host has two sockets.
- Core: an independent worker inside the chip, with its own calculating units. It can run its own stream of instructions.
- Hardware thread: a second stream of instructions that the same core can handle. The two threads share the core's units.
Why the operating system counts ninety-six CPUs
The operating system does not see chips and cores directly. It lists the CPUs it can use, and each hardware thread looks like a full CPU to it. Two sockets, times twenty-four cores, times two threads per core, gives ninety-six logical CPUs. Only forty-eight of those are real cores. The other forty-eight are threads that share them.
A logical CPU is what the operating system can schedule work on. When you count with Linux, the first command prints the number of logical CPUs it can use.
nprocTo see the three counts, ask lscpu for the thread, core and socket lines. Read them as sockets, cores and threads, and multiply them to check the total.
lscpu | grep -E 'Thread|Core|Socket'Why the difference matters for licences and sizing
Some software is licensed per socket, and some per core. The bill depends on which count is used. A hardware thread is not an extra core. When both threads of a core are busy, each gets a share of its units, not a whole core.
So when someone says ninety-six CPUs, the honest answer is forty-eight cores with ninety-six threads. A common mistake is to size a heavy database by the larger logical count. The database then runs slowly at peak, even though the number looks generous.
Note: The fix is simple: size the work against the real cores, and measure at peak time, not on a quiet afternoon.
Count the sockets, cores and threads
You need a Linux terminal on the host you want to count. You will get the logical CPU total, then the three counts that multiply into it.
Ask Linux how many logical CPUs it can use. This is the total the operating system schedules work on.
nprocWhat you should see: A single number. The example host prints 96.
Ask lscpu for the thread, core and socket counts, then multiply them to check the total from the first step.
lscpu | grep -E 'Thread|Core|Socket'What you should see: Thread(s) per core, Core(s) per socket and Socket(s). Multiply them: 2 x 24 x 2 gives 96 on the example host.
Terms
- Socket
- The slot on a motherboard that holds one processor chip.
- Core
- An independent worker inside a processor chip, with its own calculating units.
- Hardware thread
- A second stream of instructions that one core can handle, sharing that core's units.
- Logical CPU
- A processing unit that the operating system counts and schedules work on, including each thread.
Check yourself
How many real cores does a host with ninety-six logical CPUs have, if each core runs two threads?
Forty-eight real cores. The other forty-eight logical CPUs are threads that share those cores.
Why can sizing a database by the logical CPU count cause slow peaks?
The threads share the real cores, so a busy database gets less than a full core per thread and slows down at peak.
What does the nproc command print?
The number of logical CPUs that Linux can use, which counts threads as well as cores.
Previous: What a CPU does, step by step. Next: Hyper-threading: what the second thread is worth.