VPS CPU Analysis is Different
Analyzing CPU information on a VPS is not as straightforward as on a physical machine as there is both the physical machine and the virtual layer on top.
Table of Contents 📖
Analyzing CPU Information
The /proc/cpuinfo file in Linux is a virtual file that provides detailed information about the CPU(s) present in the system. However, on a VPS, this file potentially shows the number of CPUs (or cores) on the physical host machine. Consider the command and output below:
INFO: The proc filesystem is a pseudo-filesystem used to expose kernel and system information.
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz
stepping : 7
microcode : 0x5003604
cpu MHz : 2699.914
cache size : 16896 KB
physical id : 0
siblings : 24
core id : 0
cpu cores : 12
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba rsb_ctxsw ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 4400.00
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
Now, my VPS is a 1 CPU (1 core) and 1 GB RAM machine. However, the output below shows that it has 12 CPU cores. This is because the hypervisor managing the virtual machine is sharing information about the host system's hardware with the VPS.
INFO: A core is an individual processing unit within a CPU. Each core can independently execute instructions, making it capable of multitasking.
Hypervisor
A VPS runs on a virtualized layer created by a hypervisor (e.g., KVM, VMware, or Hyper-V). The hypervisor abstracts the physical hardware and provides the VPS with "virtual" hardware. The /proc/cpuinfo file relies on what the hypervisor exposes. The hypervisor often directly passes the details of the host's physical CPU to maintain consistency and compatibility.
Actual CPU Count
The actual allocation of resources (e.g., 1 vCPU) is also handled by the hypervisor. To obtain the number of vCPUs assigned to the VPS, we can use the lscpu command:
lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz
Stepping: 7
CPU MHz: 2699.914
BogoMIPS: 4400.00
Virtualization: VT-x
Hypervisor vendor: Parallels
Virtualization type: container
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 16896K
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba rsb_ctxsw ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
The lscpu command provides a high-level summary of both the virtualized and host CPU details. CPU(s) shows the actual number of vCPUs allocated (1 in this case). lscpu queries the kernel and system configuration for CPU data, focusing on what is available to the current system instance.