Links

Тестирование виртуального сервера

В этой статье мы с вами поговорим о тестировании виртуальных серверов, что нужно посмотреть и какими способами.
Для примера мы возьмем полностью чистый сервер на Debian 11 и тарифе М4 (8 GiB RAM, 4 vCPU, 110 GiB NVMe, 250 Mbit/s) и сразу же обновим пакеты apt update && apt upgrade -y

Базовая информация о VM

Общая информация о системе, ядрах, памяти, видеокарте и так далее.
1
apt install inxi -y
2
inxi -b
Результат
root@test:~# inxi -b
System: Host: test.tver.network Kernel: 5.10.0-8-amd64 x86_64 bits: 64 Console: tty 0
Distro: Debian GNU/Linux 11 (bullseye)
Machine: Type: Kvm System: Red Hat product: KVM v: RHEL 7.6.0 PC (i440FX + PIIX, 1996) serial: N/A
Mobo: N/A model: N/A serial: N/A BIOS: SeaBIOS v: 1.11.0-2.el7 date: 04/01/2014
CPU: Info: Quad Core QEMU Virtual version 2.5+ [MCP] speed: 2300 MHz
Graphics: Device-1: Cirrus Logic GD 5446 driver: cirrus v: kernel
Display: server: No display server data found. Headless machine? tty: 125x47
Message: Advanced graphics data unavailable in console for root.
Network: Device-1: Intel 82371AB/EB/MB PIIX4 ACPI type: network bridge driver: piix4_smbus
Device-2: Red Hat Virtio network driver: virtio-pci
Drives: Local Storage: total: 110 GiB used: 4.13 GiB (3.8%)
Info: Processes: 95 Uptime: 25m Memory: 7.77 GiB used: 378.8 MiB (4.8%) Init: systemd runlevel: 5 Shell: Bash
inxi: 3.3.01
root@test:~#
Более подробная информация о процессоре.
lscpu
Результат
root@test:~# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 13
Model name: QEMU Virtual CPU version 2.5+
Stepping: 3
CPU MHz: 2300.000
BogoMIPS: 4600.00
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 128 KiB
L1i cache: 128 KiB
L2 cache: 16 MiB
L3 cache: 16 MiB
NUMA node0 CPU(s): 0-3
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Full generic retpoline, STIBP disabled, RSB filling
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 ht
syscall nx lm rep_good nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_
lm pti
root@test:~#
Информация об оперативной памяти.
cat /proc/meminfo
Результат
root@test:~# cat /proc/meminfo
MemTotal: 8147824 kB
MemFree: 5588824 kB
MemAvailable: 7781744 kB
Buffers: 28188 kB
Cached: 2331604 kB
SwapCached: 0 kB
Active: 354700 kB
Inactive: 2020560 kB
Active(anon): 256 kB
Inactive(anon): 17168 kB
Active(file): 354444 kB
Inactive(file): 2003392 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 15468 kB
Mapped: 23940 kB
Shmem: 1956 kB
KReclaimable: 112816 kB
Slab: 144964 kB
SReclaimable: 112816 kB
SUnreclaim: 32148 kB
KernelStack: 1568 kB
PageTables: 848 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 4073912 kB
Committed_AS: 98268 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 20048 kB
VmallocChunk: 0 kB
Percpu: 1952 kB
HardwareCorrupted: 0 kB
AnonHugePages: 2048 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 83824 kB
DirectMap2M: 8304640 kB
root@test:~#
И под конец информация о дисковом пространстве.
df -HT
Результат
root@test:~# df -HT
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 4.2G 0 4.2G 0% /dev
tmpfs tmpfs 835M 431k 834M 1% /run
/dev/vda1 ext4 119G 4.5G 108G 4% /
tmpfs tmpfs 4.2G 0 4.2G 0% /dev/shm
tmpfs tmpfs 5.3M 0 5.3M 0% /run/lock
tmpfs tmpfs 835M 0 835M 0% /run/user/0
root@test:~#

Скорость подключения (канал)

Для проверки скорости подключения и канала мы используем инструмент speedtest-cli
1
apt install curl -y
2
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash
3
apt install speedtest -y
4
speedtest
И после запуска мы получим следующие результаты, на которых мы можем наблюдать скорость, соответствующую тарифному плану.
Результат
root@test:~# speedtest
==============================================================================
You may only use this Speedtest software and information generated
from it for personal, non-commercial use, through a command line
interface on a personal computer. Your use of this software is subject
to the End User License Agreement, Terms of Use and Privacy Policy at
these URLs:
https://www.speedtest.net/about/eula
https://www.speedtest.net/about/terms
https://www.speedtest.net/about/privacy
==============================================================================
Do you accept the license? [type YES to accept]: YES
License acceptance recorded. Continuing.
Speedtest by Ookla
Server: Telecom Center - Moscow (id: 17091)
ISP: LLC Digital Network
Idle Latency: 0.65 ms (jitter: 0.07ms, low: 0.59ms, high: 0.76ms)
Download: 244.04 Mbps (data used: 110.4 MB)
1.10 ms (jitter: 0.28ms, low: 0.78ms, high: 2.00ms)
Upload: 253.10 Mbps (data used: 421.8 MB)
0.77 ms (jitter: 0.11ms, low: 0.60ms, high: 1.94ms)
Packet Loss: Not available.
Result URL: https://www.speedtest.net/result/c/34e7cbb3-1381-4f76-be1e-0dad6255ca1c

Процессор (CPU)

Для данного и следующих нескольких пунктов установим необходимый инструмент.
apt install sysbench
Тестирование в однопоточном режиме.
sysbench cpu --cpu-max-prime=20000 --num-threads=1 run
Результат
root@test:~# sysbench cpu --cpu-max-prime=20000 --num-threads=1 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 20000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 357.86
General statistics:
total time: 10.0014s
total number of events: 3580
Latency (ms):
min: 2.10
avg: 2.79
max: 15.50
95th percentile: 3.43
sum: 9997.62
Threads fairness:
events (avg/stddev): 3580.0000/0.00
execution time (avg/stddev): 9.9976/0.00
root@test:~#
Тестирование в многопоточном режиме.
sysbench mutex --threads=64 run
Результат
root@test:~# sysbench mutex --threads=64 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 64
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 3.2433s
total number of events: 64
Latency (ms):
min: 1715.12
avg: 3059.39
max: 3201.44
95th percentile: 3208.88
sum: 195800.92
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 3.0594/0.18
root@test:~#
Дополнительно тестирование скорости компрессии 7zip.
1
apt install p7zip-full -y
2
7za b
Результат
root@test:~# 7za b
7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C,Utf16=off,HugeFiles=on,64 bits,4 CPUs QEMU Virtual CPU version 2.5+ (6D3),ASM)
QEMU Virtual CPU version 2.5+ (6D3)
CPU Freq: - - - - - - - - 2048000000
RAM size: 7956 MB, # CPU hardware threads: 4
RAM usage: 882 MB, # Benchmark threads: 4
Compressing | Decompressing
Dict Speed Usage R/U Rating | Speed Usage R/U Rating
KiB/s % MIPS MIPS | KiB/s % MIPS MIPS
22: 12630 365 3365 12287 | 121459 383 2705 10362
23: 11471 371 3151 11688 | 119414 378 2732 10332
24: 11426 381 3226 12285 | 121905 392 2729 10702
25: 10857 382 3241 12397 | 115616 385 2673 10290
---------------------------------- | ------------------------------
Avr: 375 3246 12164 | 385 2710 10421
Tot: 380 2978 11293
root@test:~#

Оперативная память (RAM)

Следующий тест покажется скорость перезаписи 8 GiB в ОЗУ.
sysbench memory --num-threads=4 --memory-total-size=8G run
Результат
root@test:~# sysbench memory --num-threads=4 --memory-total-size=8G run
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 4
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 1KiB
total size: 8192MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 8388608 (4385629.56 per second)
8192.00 MiB transferred (4282.84 MiB/sec)
General statistics:
total time: 1.9109s
total number of events: 8388608
Latency (ms):
min: 0.00
avg: 0.00
max: 3.95
95th percentile: 0.00
sum: 6129.05
Threads fairness:
events (avg/stddev): 2097152.0000/0.00
execution time (avg/stddev): 1.5323/0.01
root@test:~#

Диск

Сейчас мы проверим производительность диска, а конкретно скорость записи и чтения.
sysbench fileio --file-total-size=12G --file-test-mode=rndrw --time=300 --max-requests=0 run
Результат
root@test:~# sysbench fileio --file-total-size=12G --file-test-mode=rndrw --time=300 --max-requests=0 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: (none)
128 files, 96MiB each
12GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 1049.06
writes/s: 699.37
fsyncs/s: 2238.14
Throughput:
read, MiB/s: 16.39
written, MiB/s: 10.93
General statistics:
total time: 300.1520s
total number of events: 1196459
Latency (ms):
min: 0.00
avg: 0.25
max: 753.40
95th percentile: 1.03
sum: 299255.68
Threads fairness:
events (avg/stddev): 1196459.0000/0.00
execution time (avg/stddev): 299.2557/0.00
root@test:~#

Скорость линейной записи (DD)

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync 2>&1 && rm -f test
Данной командой мы записали определенное количество информации последовательно и получили следующие результаты, которые вполне себе неплохие.
Результат
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.92785 s, 367 MB/s

Тестирование с помощью nench

Данный метод мы заметили на рейтинге hosting101.ru, который предлагает пользователям протестировать их VPS с помощью данного скрипта и для полноты решили добавить также и его.
Он тестирует все от сети до процессора и оверселлинга RAM.
1
apt install curl wget -y
2
(wget -qO- wget.racing/nench.sh | bash; wget -qO- wget.racing/nench.sh | bash) 2>&1 | tee nench.log
Результат
root@test:~# (wget -qO- wget.racing/nench.sh | bash; wget -qO- wget.racing/nench.sh | bash) 2>&1 | tee nench.log
-------------------------------------------------
nench.sh v2019.07.20 -- https://git.io/nench.sh
benchmark timestamp: 2023-06-21 14:56:34 UTC
-------------------------------------------------
Processor: QEMU Virtual CPU version 2.5+
CPU cores: 4
Frequency: 2300.000 MHz
RAM: 7.8Gi
Swap: -
Kernel: Linux 5.10.0-8-amd64 x86_64
Disks:
vda 110G HDD
CPU: SHA256-hashing 500 MB
3.557 seconds
CPU: bzip2-compressing 500 MB
CPU: AES-encrypting 500 MB
4.307 seconds
ioping: seek rate
min/avg/max/mdev = 47.4 us / 68.1 us / 6.06 ms / 76.6 us
ioping: sequential read speed
generated 29.7 k requests in 5.00 s, 7.24 GiB, 5.93 k iops, 1.45 GiB/s
dd: sequential write speed
1st run: 267.98 MiB/s
2nd run: 383.38 MiB/s
3rd run: 378.61 MiB/s
average: 343.32 MiB/s
IPv4 speedtests
your IPv4: 213.248.43.xxxx
Cachefly CDN: 29.10 MiB/s
Leaseweb (NL): 24.58 MiB/s
Softlayer DAL (US): 0.00 MiB/s
Online.net (FR): 25.26 MiB/s
OVH BHS (CA): 16.49 MiB/s
No IPv6 connectivity detected
-------------------------------------------------
-------------------------------------------------
nench.sh v2019.07.20 -- https://git.io/nench.sh
benchmark timestamp: 2023-06-21 14:57:22 UTC
-------------------------------------------------
Processor: QEMU Virtual CPU version 2.5+
CPU cores: 4
Frequency: 2300.000 MHz
RAM: 7.8Gi
Swap: -
Kernel: Linux 5.10.0-8-amd64 x86_64
Disks:
vda 110G HDD
CPU: SHA256-hashing 500 MB
3.509 seconds
CPU: bzip2-compressing 500 MB
CPU: AES-encrypting 500 MB
4.327 seconds
ioping: seek rate
min/avg/max/mdev = 42.7 us / 60.9 us / 9.86 ms / 91.9 us
ioping: sequential read speed
generated 33.5 k requests in 5.00 s, 8.19 GiB, 6.71 k iops, 1.64 GiB/s
dd: sequential write speed
1st run: 280.38 MiB/s
2nd run: 368.12 MiB/s
3rd run: 387.19 MiB/s
average: 345.23 MiB/s
IPv4 speedtests
your IPv4: 213.248.43.xxxx
Cachefly CDN: 29.09 MiB/s
Leaseweb (NL): 25.40 MiB/s
Softlayer DAL (US): 0.00 MiB/s
Online.net (FR): 25.68 MiB/s
OVH BHS (CA): 16.78 MiB/s
No IPv6 connectivity detected
-------------------------------------------------
root@test:~#
В статье мы затронули если не все, то большую часть способов и методов тестирования виртуального сервера, что в будущем вам поможет определиться с тарифом и понять какие именно характеристики вам наиболее важны.