Skip to content
Thuan Bui's Blog
Go back

So sánh hiệu năng máy ảo Hypervisor Type 1 (Hyper-V) vs. Hypervisor Type 2 (VirtualBox)

Updated:

Trước đây mình thường sử dụng máy ảo Ubuntu chạy trên nền VirtualBox trong Windows 10 nhằm phục vụ phát triển web, nghiên cứu về Linux,… Tuy gặp một vài bất tiện trong quá trình sử dụng (ví dụ máy ảo không tự động chạy khi khởi động lại Windows), nhưng nói chung VirtualBox đã đáp ứng đủ nhu cầu sử dụng của mình.

Dạo gần đây ở nhà rãnh rỗi do thất nghiệp vì COVID-19, mình có thêm thời gian nghiên cứu về các công nghệ ảo hoá. Từ đó mới biết đến tính năng ảo hoá Hyper-V được tích hợp sẵn trong Windows 10 Pro mà không cần cài thêm bất cứ phần mềm nào.

Điểm mạnh là Hyper-V là nó sử dụng công nghệ ảo hoá Hypervisor Type 1, tương tự như ESXi của VMWare hay Proxmox. Còn Virtualbox chỉ là Hypervisor Type 2, giống như VMWare Player, Parrallel Desktop (MacOS). Chi tiết Type 1 vs Type 2 khác nhau ra sao các bạn Google tài liệu sẽ ra nhiều lắm, hoặc xem qua bài này.

https://pediaa.com/what-is-the-difference-between-type-1-and-type-2-hypervisor/

Khác biệt căn bản nhất giữa Type 1 và Type 2 là ở khả năng truy xuất trực tiếp vào phần cứng của máy ảo:

Nhờ khả năng truy xuất trực tiếp vào phần cứng vật lý nên máy ảo Hypervisor Type 1 sẽ mang hiệu năng vượt trội so với máy ảo Hypervisor Type 2. Vượt trội ra sao giờ phải benchmark thử mới tin.

Bài viết này mình sẽ kiểm tra thử máy ảo Hyper-V và máy ảo VirtualBox cho hiệu suất hoạt động khác biệt ra sao.

Thông số phần cứng

Dưới đây là thông số phần cứng của máy tính để bàn mình đang sử dụng để vừa chơi game vừa nghiên cứu:

Thông số máy ảo (cài đặt giống nhau trên VirtualBox và Hyper-V)

Benchmark SSD

Mình sử dụng script benchmark của tocdo.net để kiểm tra tổng quát thông số của máy ảo.

Terminal window
# Test Tốc độ & Share kết quả
curl -Lso- tocdo.net/share | bash

Hyper-V

Terminal window
System Info
----------------------------------------------------------------------
CPU model : Intel(R) Core(TM) i3-9100F CPU @ 3.60GHz
Number of cores : 1
CPU frequency : 3599.997 MHz
Total size of Disk : 42.9 GB (24.5 GB Used)
Total amount of Mem : 1940 MB (541 MB Used)
Total amount of Swap : 2912 MB (5 MB Used)
System uptime : 0 days, 0 hour 2 min
Load average : 0.51, 0.41, 0.17
OS : Ubuntu 20.04.2 LTS
Arch : x86_64 (64 Bit)
Kernel : 5.4.0-81-generic
Virt : hyperv
Date : Sat 14 Aug 2021 08:41:53 AM UTC
Disk Speed
----------------------------------------------------------------------
dd Test
I/O (1st run) : 220 MB/s
I/O (2nd run) : 233 MB/s
I/O (3rd run) : 293 MB/s
Average : 248.7 MB/s
-----------------------------------
Fio Test
Read performance : 128MB/s
Read IOPS : 31.2k
Write performance : 42.7MB/s
Write IOPS : 10.4k
Speedtest
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 17.7MB/s
Vultr, Los Angeles, CA 108.61.219.200 13.6MB/s
Vultr, Seattle, WA 108.61.194.105 9.29MB/s
Linode, Tokyo, JP 139.162.65.37 6.82MB/s
Linode, Singapore, SG 139.162.23.4 10.6MB/s
Softlayer, HongKong, CN 119.81.130.170 10.7MB/s
VNPT, Ha Noi, VN 113.164.24.102 12.5MB/s
VNPT, Da Nang, VN 113.164.16.66 14.0MB/s
VNPT, Ho Chi Minh, VN 113.164.8.250 20.7MB/s
Viettel Network, Ha Noi, VN 27.68.226.129 17.2MB/s
Viettel Network, Da Nang, VN 27.68.201.1 15.9MB/s
Viettel Network, Ho Chi Minh, VN 27.68.239.33 19.4MB/s
FPT Telecom, Ha Noi, VN 118.70.115.12
FPT Telecom, Ho Chi Minh, VN 1.55.119.18 19.6MB/s
----------------------------------------------------------------------
Share link: <https://tocdo.net/result/1365026>

Virtualbox

Terminal window
System Info
----------------------------------------------------------------------
CPU model : Intel(R) Core(TM) i3-9100F CPU @ 3.60GHz
Number of cores : 1
CPU frequency : 3599.996 MHz
Total size of Disk : 17.8 GB (12.6 GB Used)
Total amount of Mem : 1987 MB (429 MB Used)
Total amount of Swap : 2047 MB (4 MB Used)
System uptime : 0 days, 8 hour 45 min
Load average : 0.35, 0.11, 0.05
OS : Ubuntu 20.04.2 LTS
Arch : x86_64 (64 Bit)
Kernel : 5.4.0-77-generic
Virt : virtualbox
kvm
Date : Sat 14 Aug 2021 08:45:26 AM UTC
Disk Speed
----------------------------------------------------------------------
dd Test
I/O (1st run) : 242 MB/s
I/O (2nd run) : 217 MB/s
I/O (3rd run) : 241 MB/s
Average : 233.3 MB/s
-----------------------------------
Fio Test
Read performance : 9114kB/s
Read IOPS : 2225
Write performance : 3026kB/s
Write IOPS : 738
Speedtest
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 17.9MB/s
Vultr, Los Angeles, CA 108.61.219.200 11.0MB/s
Vultr, Seattle, WA 108.61.194.105 10.7MB/s
Linode, Tokyo, JP 139.162.65.37 12.2MB/s
Linode, Singapore, SG 139.162.23.4 10.7MB/s
Softlayer, HongKong, CN 119.81.130.170 14.0MB/s
VNPT, Ha Noi, VN 113.164.24.102 11.4MB/s
VNPT, Da Nang, VN 113.164.16.66 12.2MB/s
VNPT, Ho Chi Minh, VN 113.164.8.250 19.6MB/s
Viettel Network, Ha Noi, VN 27.68.226.129 18.4MB/s
Viettel Network, Da Nang, VN 27.68.201.1 12.7MB/s
Viettel Network, Ho Chi Minh, VN 27.68.239.33 19.3MB/s
FPT Telecom, Ha Noi, VN 118.70.115.12
FPT Telecom, Ho Chi Minh, VN 1.55.119.18 19.5MB/s
----------------------------------------------------------------------
Share link: <https://tocdo.net/result/5689740>

Đánh giá

Thông số cần chú ý là ở phần Fio Test: Máy ảo Hyper-V có tốc độ truy xuất ổ cứng vượt trội so với máy ảo VirtualBox.

Qua đó có thể thấy máy ảo Hypervisor 1(Hyper-V) với khả năng truy xuất trực tiếp vào SSD cho hiệu năng khác biệt rất lớn so với máy ảo Hypervisor 2 (VirtualBox)

Benchmark CPU

Phần này mình dùng Sysbench để kiểm tra hiệu năng CPU

Cài đặt Sysbench

Terminal window
curl -s <https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh> | sudo bash
sudo apt -y install sysbench

Sử dụng lệnh sau để benchmark CPU

sysbench --test=cpu --cpu-max-prime=20000 run

Hyper-V

Terminal window
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
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: 505.56
General statistics:
total time: 10.0015s
total number of events: 5057
Latency (ms):
min: 1.80
avg: 1.98
max: 8.99
95th percentile: 2.30
sum: 9992.08
Threads fairness:
events (avg/stddev): 5057.0000/0.00
execution time (avg/stddev): 9.9921/0.00

VirtualBox

Terminal window
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
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: 453.92
General statistics:
total time: 10.0026s
total number of events: 4541
Latency (ms):
min: 1.80
avg: 2.20
max: 27.96
95th percentile: 3.62
sum: 9991.39
Threads fairness:
events (avg/stddev): 4541.0000/0.00
execution time (avg/stddev): 9.9914/0.00

Đánh giá

Máy ảo Hyper-V cho tốc độ xử lý CPU nhanh hơn so với máy ảo VirtualBox. Tuy nhiên khác biệt là không đáng kể.

Benchmark RAM

Sử dụng tiếp Sysbench để benchmark RAM với lệnh sau

sysbench --test=memory --memory-block-size=1M --memory-total-size=100G --num-threads=1 run

Hyper-V

Terminal window
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 1024KiB
total size: 102400MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 102400 (18306.80 per second)
102400.00 MiB transferred (18306.80 MiB/sec)
General statistics:
total time: 5.5922s
total number of events: 102400
Latency (ms):
min: 0.05
avg: 0.05
max: 3.52
95th percentile: 0.07
sum: 5555.12
Threads fairness:
events (avg/stddev): 102400.0000/0.00
execution time (avg/stddev): 5.5551/0.00

VirtualBox

Terminal window
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 1024KiB
total size: 102400MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 102400 (16111.80 per second)
102400.00 MiB transferred (16111.80 MiB/sec)
General statistics:
total time: 6.3543s
total number of events: 102400
Latency (ms):
min: 0.05
avg: 0.06
max: 8.26
95th percentile: 0.08
sum: 6307.85
Threads fairness:
events (avg/stddev): 102400.0000/0.00
execution time (avg/stddev): 6.3078/0.00

Đánh giá

Không nằm ngoài dự đoán, máy ảo VirtualBox tiếp tục thua kém trong bài Benchmark RAM so với máy ảo Hyper-V. Tốc độ khác biệt hơn 10%.

Tổng kết

Hyper-V quá ngon, quá xịn! Nếu bạn đang sử dụng VirtualBox trên nền Windows 10 Pro, chuyển qua dùng Hyper-V ngay và luôn. Còn nếu bạn đang tìm hiểu học hỏi về cách tạo máy ảo, Hyper-V thẳng tiến, quên thằng VirtualBox đi.

Giờ mình phải lo dọn nhà đám máy ảo VirtualBox qua Hyper-V rồi xoá VirtualBox ra khỏi máy luôn đây.

Cám ơn bạn đã chịu khó đọc đến dòng cuối cùng.


Share this post on:

Previous Post
Điều chỉnh tăng dung lượng ổ đĩa ảo VDI cài Ubuntu trên VirtualBox
Next Post
Chocolatey: Công cụ quản lý ứng dụng trên Windows bằng dòng lệnh CLI