I have been running performance benchmarks using sysbench
and have noticed weird results when comparing between VMs, containers and the host.
Following is the lxc config show --expanded
of my container instance:
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 20.04 LTS amd64 (release) (20201210)
image.label: release
image.os: ubuntu
image.release: focal
image.serial: "20201210"
image.type: squashfs
image.version: "20.04"
limits.cpu: "4"
limits.memory: 8GB
user.network-config: |2-
#cloud-config
version: 1
config:
- type: physical
name: eth0
subnets:
- type: dhcp
ipv4: true
volatile.base_image: e0c3495ffd489748aa5151628fa56619e6143958f041223cb4970731ef939cb6
volatile.eth0.host_name: vethff4c6c56
volatile.eth0.hwaddr: 00:16:3e:ae:6e:1b
volatile.idmap.base: "0"
volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.power: RUNNING
volatile.uuid: ecc6db98-0ba6-491b-b7be-3aa42af65652
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:
- container-private
stateful: false
description: ""
And my VM instance:
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 20.04 LTS amd64 (release) (20201210)
image.label: release
image.os: ubuntu
image.release: focal
image.serial: "20201210"
image.type: disk-kvm.img
image.version: "20.04"
limits.cpu: "4"
limits.memory: 8000MB
user.network-config: |2-
#cloud-config
version: 1
config:
- type: physical
name: enp5s0
subnets:
- type: dhcp
ipv4: true
volatile.base_image: 5f7cb0463720be7bf5c81018f5a1cbeace78e1c38bb2e8fb9a6a545aadc43fe3
volatile.eth0.host_name: tapc22dfb36
volatile.eth0.hwaddr: 00:16:3e:0f:56:cf
volatile.last_state.power: RUNNING
volatile.uuid: 2c8edac6-9241-48fc-b6ac-e7ec2ada6b25
devices:
config:
source: cloud-init:config
type: disk
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
size: 10GB
type: disk
ephemeral: false
profiles:
- vm-private
stateful: false
description: ""
As we can see, both the VM and the container instance have 4CPUs and 8GB of RAM given.
The command used for testing was the following:
sysbench memory --threads=4 --time=10 --memory-block-size=4K --memory-total-size=100G --memory-access-mode=seq --memory-oper=read run
Following are the container’s results:
Total operations: 26214400 (7543639.57 per second)
102400.00 MiB transferred (29467.34 MiB/sec)
General statistics:
total time: 3.4697s
total number of events: 26214400
Latency (ms):
min: 0.00
avg: 0.00
max: 20.02
95th percentile: 0.00
sum: 5493.12
Threads fairness:
events (avg/stddev): 6553600.0000/0.00
execution time (avg/stddev): 1.3733/0.22
The VM’s results:
Total operations: 26214400 (8827942.22 per second)
102400.00 MiB transferred (34484.15 MiB/sec)
General statistics:
total time: 2.9669s
total number of events: 26214400
Latency (ms):
min: 0.00
avg: 0.00
max: 0.69
95th percentile: 0.00
sum: 4458.62
Threads fairness:
events (avg/stddev): 6553600.0000/0.00
execution time (avg/stddev): 1.1147/0.01
And the host’s:
Total operations: 26214400 (9292470.05 per second)
102400.00 MiB transferred (36298.71 MiB/sec)
General statistics:
total time: 2.8158s
total number of events: 26214400
Latency (ms):
min: 0.00
avg: 0.00
max: 0.46
95th percentile: 0.00
sum: 4280.78
Threads fairness:
events (avg/stddev): 6553600.0000/0.00
execution time (avg/stddev): 1.0702/0.01
I have run the tests multiple times and the values reported are within the same range. The main problem here is the results reported by the container instance. I would assume if there was any performance overhead, the VMs would show it more than anything else. However it seems that the container’s performance is considerably slower when compared to both the VM and the host.
Does anyone else have a similiar experience when it comes to memory performance?