Two KVM guests on the same host share more than a scheduler: they share the memory controller, the L3 cache slices and the interconnect. When a noisy neighbour starts streaming through a large array, your guest’s effective memory bandwidth can fall by a third even though /proc/meminfo shows plenty of free RAM and CPU steal stays near zero. The only reliable way to see this on a VPS is to measure achieved bandwidth from inside the guest, repeatedly, and watch the distribution rather than a single number.
The tool for this is STREAM, and the setup takes five minutes on any recent distribution. If you are evaluating a provider before committing, run this alongside the checks in our VPS performance guides; bandwidth variance is one of the few signals that reliably distinguishes a quiet host from a busy one.
Build a fixed-width STREAM binary
STREAM’s numbers depend entirely on array size. If the arrays fit in L3, you measure cache, not DRAM. Set the array size to roughly ten times the last-level cache so the working set cannot be resident, and compile with the same flags every time so runs are comparable.
lscpu | grep -i 'L3 cache'
git clone https://github.com/jeffhammond/STREAM.git && cd STREAM
gcc -O3 -march=native -fopenmp -DSTREAM_ARRAY_SIZE=200000000 \
-DNTIMES=20 stream.c -o stream_omp
OMP_NUM_THREADS=$(nproc) ./stream_omp | egrep 'Copy|Scale|Add|Triad'
At 200 million doubles the total footprint is about 4.8 GB across three arrays, which is comfortably above any consumer L3 and large enough that page placement across NUMA nodes averages out. On a 2 GB plan, drop to 100000000; on anything smaller, use 50000000 and note it in your results, because the smaller footprint inflates the cache fraction.
Run it as a time series, not a single shot
A single STREAM run tells you what the host looked like for eight seconds. Loop it for half an hour, keep only the Triad figure, and compute the spread. A quiet host gives a coefficient of variation under 2%; a contended one gives 10–25% with visible dips.
for i in $(seq 1 30); do
OMP_NUM_THREADS=$(nproc) ./stream_omp \
| awk -v t=$(date +%s) '/Triad:/ {printf "%s %.1f\n", t, $2}'
done | tee /tmp/triad.tsv
awk '{s+=$2; ss+=$2*$2; n++} END {
m=s/n; v=ss/n-m*m; printf "mean=%.1f sd=%.1f cv=%.1f%%\n", m, sqrt(v), 100*sqrt(v)/m
}' /tmp/triad.tsv
Triad — a[i] = b[i] + c[i]*d[i] — is the right metric because it exercises two read streams and one write stream simultaneously, which is what most application workloads do. Copy measures pure read/write and tends to be optimistic on hosts with a large write-combining buffer.
Read the pages-per-second counter as corroboration
STREAM gives you MB/s; the kernel gives you an independent view. perf stat can count uncore or core memory events depending on what the hypervisor exposes, but on most VPS plans the vPMU is masked. The portable fallback is to watch fault and reclaim behaviour during the run and confirm the working set is genuinely hitting DRAM.
perf stat -e cycles,instructions,cache-misses -a sleep 10 2>&1 | tail -5
sar -B 1 30 | awk '{print $1, $5, $6}' # pgpgin, pgpgout
cat /sys/kernel/debug/x86/amd_df_indirect_lcl 2>/dev/null || echo "vPMU masked by hypervisor"
If perf stat returns “not supported” for cache events, that is itself a finding: the provider has masked the vPMU, so branch-miss and cache-miss profiling inside the guest is impossible. Record it, and fall back to STREAM plus sar paging counters for your memory-bandwidth picture.
Single-thread versus saturated bandwidth matter differently
Most applications never saturate the memory bus, but many are limited by per-core bandwidth. Run STREAM a second time with OMP_NUM_THREADS=1 and compare against the full-thread result. A healthy host scales close to linearly up to the number of physical cores; a contended one shows poor scaling because threads queue on the same memory controller path that a neighbour is already flooding.
for t in 1 2 4 $(nproc); do
printf "threads=%s " "$t"
OMP_NUM_THREADS=$t ./stream_omp | awk '/Triad:/ {print $2" MB/s"}'
done
Record both numbers in your capacity notes. The single-thread figure is what a PHP-FPM worker or a single-threaded database connection will see, while the saturated figure predicts batch job throughput. If single-thread Triad drops below about 60% of the host’s spec-sheet figure while multi-thread stays flat, the bottleneck is contention rather than configuration and no kernel tweak will fix it.
Detect the contention pattern across the day
Memory contention from neighbours is cyclic because workloads are cyclic. A nightly backup job on the host, a batch analytics window, or another tenant’s CI runner will show up as a repeatable trough at the same hour. Run the Triad loop every 15 minutes for 48 hours with a cron entry and plot the mean per hour.
*/15 * * * * cd /root/STREAM && OMP_NUM_THREADS=2 ./stream_omp \
| awk -v t=$(date +\%s) '/Triad:/ {print t, $2}' >> /var/log/triad.log
A flat hourly profile at 90% of the host’s theoretical bandwidth means the plan is well isolated. A 30% dip every evening means a predictable neighbour, and if your own workload peaks in that same window you have found a real, provable reason for latency that CPU metrics will never explain.
Check whether huge pages change the answer
Transparent huge pages reduce TLB pressure and can lift STREAM numbers by 5–15%, but on a guest the hypervisor decides whether large pages are actually backed by large physical frames. Compare the two modes before drawing conclusions, and remember that a host giving you THP without backing is effectively faking the win.
cat /sys/kernel/mm/transparent_hugepage/enabled
grep -i AnonHugePages /proc/meminfo
echo defer > /sys/kernel/mm/transparent_hugepage/enabled # or madvise/always
OMP_NUM_THREADS=$(nproc) ./stream_omp | grep Triad:
If the Triad figure barely moves between never and always, the guest is not getting large frames and the setting is noise. Document the mode you settled on so later runs stay comparable.
Turn the numbers into a purchase or migration decision
For reference, a dedicated modern server with dual-channel DDR4-3200 delivers roughly 20–25 GB/s of Triad bandwidth per socket with near-zero variance. A shared VPS on a busy host often delivers 6–12 GB/s with a 15% coefficient of variation. Both numbers can be entirely adequate for a web application; neither will satisfy a memory-bound in-memory cache that expects consistent latency.
Measure first, then decide whether you need a bigger plan or a quieter host. A higher tier on a busy machine can still lose to a smaller tier on a quiet one, and only the time-series tells you which case you are in — so keep the triad.tsv history and re-run it whenever response times shift without a matching change in traffic.



Leave a Reply
You must be logged in to post a comment.