[CentOS-virt] performance differences between kvm/xen

Thu Oct 14 13:16:42 UTC 2010
Bart Swedrowski <bart at timedout.org>

Hi Karanbir,

On 14 October 2010 19:59, Karanbir Singh <mail-lists at karan.org> wrote:
>
> On 10/14/2010 07:48 AM, Tom Bishop wrote:
> > I think xen is still on top in terms of performance and features....now
>
> that is indeed what it 'feels' like, but I'm quite keen on putting some
> numbers on that.

I have done some testing some time ago on one of the EQ machines that
I got from hetzner.de.  Full spec of the machine was as following:

  * Intel® Core™ i7-920
  * 8 GB DDR3 RAM
  * 2 x 750 GB SATA-II HDD

It's nothing big but even though results are quite interesting.  All
tests were performed on CentOS 5.5 x86_64 with PostgreSQL 8.4 (from
CentOS repos).

I have run some PostgreSQL PGBench tests as well as Bonnie++ tests.
The PostgreSQL tests was divided into two tests having three goes (to
get an idea of average).  The commands I used for testing were:

> dropdb pgbench && sync && sleep 3 && createdb pgbench && sync && sleep 3
> pgbench -i -s 100 -U postgres -d pgbench && sync && sleep 3
> pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null && sync \
> && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null \
> && sync && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null \
> && sync && sleep 3

Now results.  First CentOS5/x86_64 without any virtualisation, without
any PostgreSQL optimisation:

-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 141.191292 (including connections establishing)
tps = 141.196776 (excluding connections establishing)
-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 156.479561 (including connections establishing)
tps = 156.486222 (excluding connections establishing)
-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench 2>/dev/null
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 164.880109 (including connections establishing)
tps = 164.888009 (excluding connections establishing)

Now after optimisation (shared_buffers, effective_cache_size etc.):

pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 403.430951 (including connections establishing)
tps = 403.474562 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 336.060764 (including connections establishing)
tps = 336.093214 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 446.607705 (including connections establishing)
tps = 446.664466 (excluding connections establishing)

Now KVM based VM with 7GB RAM and 8 CPUs.  Using virtio and LVM
partitions as backend.

PostgreSQL results *w/o* optimisation.

-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench
2>/dev/null && sync && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U
postgres -d pgbench 2>/dev/null && sync && sleep 3 && pgbench -c 10 -t
5000 -s 100 -U postgres -d pgbench 2>/dev/null && sync && sleep 3
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 124.578488 (including connections establishing)
tps = 124.585776 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 140.451736 (including connections establishing)
tps = 140.463105 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 148.091563 (including connections establishing)
tps = 148.102254 (excluding connections establishing)

PostgreSQL tests *with* optimisation:

-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench
2>/dev/null && sync && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U
postgres -d pgbench 2>/dev/null && sync && sleep 3 && pgbench -c 10 -t
5000 -s 100 -U postgres -d pgbench 2>/dev/null && sync && sleep 3
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 230.695831 (including connections establishing)
tps = 230.734357 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 207.535243 (including connections establishing)
tps = 207.572818 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 206.664120 (including connections establishing)
tps = 206.695176 (excluding connections establishing)

And, finally, Xen based VM with 7GB RAM and 8 CPUs.  Using LVM
partitions as backend.  PostgreSQL tests results *w/o* optimisation:

-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench
2>/dev/null && sync && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U
postgres -d pgbench 2>/dev/null && sync && sleep 3 && pgbench -c 10 -t
5000 -s 100 -U postgres -d pgbench 2>/dev/null && sync && sleep 3
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 126.554719 (including connections establishing)
tps = 126.562829 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 135.472197 (including connections establishing)
tps = 135.481690 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench

... and *with* optimisation:

-bash-3.2$ pgbench -c 10 -t 5000 -s 100 -U postgres -d pgbench
2>/dev/null && sync && sleep 3 && pgbench -c 10 -t 5000 -s 100 -U
postgres -d pgbench 2>/dev/null && sync && sleep 3 && pgbench -c 10 -t
5000 -s 100 -U postgres -d pgbench 2>/dev/null && sync && sleep 3
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 312.133362 (including connections establishing)
tps = 312.186309 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 203.123398 (including connections establishing)
tps = 203.146153 (excluding connections establishing)
pghost:  pgport:  nclients: 10 nxacts: 5000 dbName: pgbench
transaction type: TPC-B (sort of)
scaling factor: 100
number of clients: 10
number of transactions per client: 5000
number of transactions actually processed: 50000/50000
tps = 279.864975 (including connections establishing)
tps = 279.910306 (excluding connections establishing)

>From my tests it came out that Xen still outperforms KVM especially in
disk IO performance.  As so and fact my applications are dependant on
databases (and which are not these days?) I have kept on using Xen.

Other thing that I like about Xen is you can easily mount LVM
partitions to the host OS and play with them should you need to.  In
KVM you've got this double LVM layer which makes it difficult to do
this.  I know there are ways around it but it just seems a bit more
easier and straight forward in Xen at the moment.

Regards.