database hardware benchmarking

48
Database Hardware Benchmarking Greg Smith 2ndQuadrant US 03/25/2009 Greg Smith Database Hardware Benchmarking

Post on 18-Oct-2014

4.762 views

Category:

Documents


2 download

DESCRIPTION

Greg SmithCover how to use simple low-level tools such as memtest86, dd, bonnie++, and sysbench to benchmark the hardware of a server intended for database use. A heavy dose of vendor management suggestions will be included as well, for the inevitable time when your shiny new server fails to deliver the performance it should.

TRANSCRIPT

Page 1: Database Hardware Benchmarking

Database Hardware Benchmarking

Greg Smith

2ndQuadrant US

03/25/2009

Greg Smith Database Hardware Benchmarking

Page 2: Database Hardware Benchmarking

About this presentation

I The master source for these slides is

http://www.2ndquadrant.com/talks

I Slides are released under the Creative Commons Attribution3.0 United States Licensehttp://creativecommons.org/licenses/by/3.0/us

Greg Smith Database Hardware Benchmarking

Page 3: Database Hardware Benchmarking

Why should you always benchmark your hardware?

I Many useful tests will only run when the server isn’t beingused yet

I Software stacks are complicated

I Spending money on upgrades only helps if you upgrade theright thing usefully

I Vendors lie

Greg Smith Database Hardware Benchmarking

Page 4: Database Hardware Benchmarking

Systematic Benchmarking

I Memory

I CPU

I Disk

I Database server

I Application

Greg Smith Database Hardware Benchmarking

Page 5: Database Hardware Benchmarking

Memory Tests

I DOS: memtest86+ (also on many Linux CDs, like the Ubuntuinstaller)

I Windows: SiSoftware Sandra

I UNIX: sysbench, stream

Greg Smith Database Hardware Benchmarking

Page 6: Database Hardware Benchmarking

sysbench memory write and CPU tests

sysbench --test=memory --memory-oper=write

--memory-block-size=64MB --memory-total-size=1024MB

run

sysbench --test=cpu run

Greg Smith Database Hardware Benchmarking

Page 7: Database Hardware Benchmarking

stream memory read test

wget http://www.cs.virginia.edu/stream/FTP/Code/stream.c

gcc -O stream.c -o stream

./stream

Greg Smith Database Hardware Benchmarking

Page 8: Database Hardware Benchmarking

Memory test comparisons

Processor

T7200

Q6600

T9400

Xeon X5450

Xeon E5520

Xeon X5550

i7 860

Frequency

2.0GHz

2.4GHz

2.53GHz

3.00GHz

2.27GHz

2.67GHz

2.8GHz

RAM Speed

DDR2/667

DDR2/800

DDR3/1066

DDR2/1333

DDR3/1333

DDR3/1333

DDR3/1600

memtest86+

2563

3352

3743

3575

9252

10885

13716

sysbench

1360

2009

2226

2487

4230

5493

5559

stream

2818

4386

?

?

?

?

10033

Greg Smith Database Hardware Benchmarking

Page 9: Database Hardware Benchmarking

Advanced Clustering STREAM Benchmarking

http://www.advancedclustering.com/company-blog/

Greg Smith Database Hardware Benchmarking

Page 10: Database Hardware Benchmarking

Oracle Calling Center OLTP Benchmark

http://it.anandtech.com/IT/showdoc.aspx?i=3769&p=4

Greg Smith Database Hardware Benchmarking

Page 11: Database Hardware Benchmarking

Sources for slow memory results

I Single channel RAM/slot mistakes

I Incorrect SPD/timing/voltage

I Bad RAM/CPU multiplier combination

I Poor quality RAM

Greg Smith Database Hardware Benchmarking

Page 12: Database Hardware Benchmarking

PostgreSQL and the CPU

I PostgreSQL uses only a single CPU per query

I Queries executing against cached data will bottleneck on CPU

I COPY is CPU intensive

Greg Smith Database Hardware Benchmarking

Page 13: Database Hardware Benchmarking

CPU Tests

I Windows: SiSoftware Sandra

I UNIX: sysbench CPU test

I Custom test with timing and generate series

I pgbench select-only on small database

I Vary pgbench client count to test single or multiple CPUs

Greg Smith Database Hardware Benchmarking

Page 14: Database Hardware Benchmarking

sysbench CPU comparisons

Processor

Intel Q6600

Intel T7200

Intel T9400

Intel Xeon X5450

Intel Xeon E5520

Intel Xeon X5550

Intel i7 860

Frequency

2.40GHz

2.0GHz

2.53GHz

3.00GHz

2.27GHz

2.67GHz

2.8GHz

sysbench CPU seconds

19.6

18.9

12.0

8.4

11.7

8.7

9.0

Greg Smith Database Hardware Benchmarking

Page 15: Database Hardware Benchmarking

Sources for slow CPU results

I Slow memory

I Power management throttling

I Linux: /proc/cpuinfo shows 1000MHz suggests you need toadjust the CPUFreq Governor to “performance”

Greg Smith Database Hardware Benchmarking

Page 16: Database Hardware Benchmarking

Disk Tests

I Sequential write: INSERT, COPY FROM (when not CPUlimited)

I Sequential read: SELECT * FROM and similar tablesequential scans

I Seeks: SELECT using index, UPDATE

I Commit fsync rate: INSERT, UPDATE

Greg Smith Database Hardware Benchmarking

Page 17: Database Hardware Benchmarking

dd test

I Compute 2X the size of your RAM in 8KB blocks

I blocks = 250,000 * gigabytes of RAM

time sh -c "dd if=/dev/zero of=bigfile bs=8k count=X &&sync"

time dd if=bigfile of=/dev/null bs=8k

I Watch vmstat and/or iostat during disk tests

I vmstat’s bi and bo will match current read/write rate

I Note the CPU percentage required to reach the peak rate

Greg Smith Database Hardware Benchmarking

Page 18: Database Hardware Benchmarking

bonnie++

./bonnie++

bon csv2html

I Ignore the per-character and create results, look at the blockoutput/input ones

I Random Seeks:

I The test runs SeekProcCount processes (default 3) in parallel,doing a total of 8000 random seek reads to locations in thefile. In 10% of cases, the block read is changed and writtenback.

Greg Smith Database Hardware Benchmarking

Page 19: Database Hardware Benchmarking

bonnie++ ZCAV

./zcav -f/dev/sda > t500

I Must get a recent version of bonnie++ for ZCAV to scaleproperly for TB drives (1.03e works)

I ZCAV on experimental branch (1.96) gave useless results forme

I Download somewhat broken gnuplot script sample and typicalresults from:

http://www.coker.com.au/bonnie++/zcav/results.html

Greg Smith Database Hardware Benchmarking

Page 20: Database Hardware Benchmarking

Improved bonnie++ ZCAV gnuplot script

unset autoscale x

set autoscale xmax

unset autoscale y

set autoscale ymax

set xlabel "Position GB"

set ylabel "MB/s"

set key right bottom

set terminal png

set output "zcav.png"

plot "raid0" title "7200RPM RAID 0 3 Spindles",

"single" title "7200RPM Single Drive"

Greg Smith Database Hardware Benchmarking

Page 21: Database Hardware Benchmarking

bonnie++ ZCAV: Laptop 7200RPM Disk

Greg Smith Database Hardware Benchmarking

Page 22: Database Hardware Benchmarking

Scaling of 3-Disk RAID0 with 7200RPM SATA Disks

Greg Smith Database Hardware Benchmarking

Page 23: Database Hardware Benchmarking

3-Disk Short-Stroked RAID0, larger 7200RPM SATA

Greg Smith Database Hardware Benchmarking

Page 24: Database Hardware Benchmarking

Read seeks/second - sysbench

THREADS=1

GB=10

MODE=rndrd

OPTIONS="--test=fileio --num-threads=$THREADS

--file-block-size=8K --file-test-mode=$MODE

--file-num=$GB --file-total-size=${GB}G

--file-fsync-freq=0 --file-fsync-end=no"

sysbench prepare $OPTIONS

sysbench run --max-time=60 $OPTIONS

sysbench cleanup $OPTIONS

Greg Smith Database Hardware Benchmarking

Page 25: Database Hardware Benchmarking

Sample sysbench random read results

Read 78.125Mb Written 0b

Total transferred 78.125Mb (1.0059Mb/sec)

128.75 Requests/sec executed

I That’s 128.75 seeks/second over 10GB, resulting in a netthroughput of 128.75 * 8KB/s = 1.01MB/s

I Consider both the size of the disk used and the number ofclients doing seeks

Greg Smith Database Hardware Benchmarking

Page 26: Database Hardware Benchmarking

More customizable seek tests

I bonnie++ experimental (currently at 1.96)

I iozone

I fio

I Windows: HD Tune does everything but commit rate

Greg Smith Database Hardware Benchmarking

Page 27: Database Hardware Benchmarking

Sources for slow disk results

I Poor mapping to underlying hardware

I Buggy driver

I Insufficient bandwidth to storage

I Bottlenecking at CPU/memory limits

I Bad performing filesystem or filesystem misaligned with stripesizes

I Writes faster than reads? Probably low read-ahead settingssomewhere.

I Vibration: don’t shout at your JBODs! They don’t like it!

http://it.toolbox.com/blogs/database-soup/the-problem-with-iscsi-30602

http://blog.endpoint.com/2008/09/filesystem-io-what-we-presented.html

http://www.youtube.com/watch?v=tDacjrSCeq4

Greg Smith Database Hardware Benchmarking

Page 28: Database Hardware Benchmarking

fsync tests

sysbench --test=fileio --file-fsync-freq=1 --file-num=1

--file-total-size=16384 --file-test-mode=rndwr run

| grep "Requests/sec"

I pgbench insert-only test

I PostgreSQL contrib/test fsync might work, but isn’t reallyreliable

Greg Smith Database Hardware Benchmarking

Page 29: Database Hardware Benchmarking

Sample laptop disk specification

I ST9320423AS Momentus 7200.4 320GB

I 7200 RPM

I 16MB Cache

I Average seek: 11ms read/13ms write

I Average rotational latency: 4.17ms

Greg Smith Database Hardware Benchmarking

Page 30: Database Hardware Benchmarking

Computed parameters

I Rotational latency = 1 / RPM / 60 / 2

I IOPS=1/(latency+seek)

I IOPS = 1/(((1/(RPM/60))/2) + S)

I IOPS = 1/(4.17ms + 11ms) = 65.9 IOPS

Greg Smith Database Hardware Benchmarking

Page 31: Database Hardware Benchmarking

IOPS Calculators and Info

http://www.wmarow.com/strcalc/

http://www.dbasupport.com/oracle/ora10g/disk_IO_02.shtml

http://storageadvisors.adaptec.com/2007/03/20/sata-iops-measurement/

Greg Smith Database Hardware Benchmarking

Page 32: Database Hardware Benchmarking

Sample disk results

DiskCount

1

1

3

SeqRead

71

59

125

SeqWrite

58

54

119

bonnie++seeks

232 @ 4GB

177 @ 16GB

371 @ 16GB

Read-onlyseeks

194 @ 4GB

56 @ 100GB

60 @ 100GB

CommitRate

105/s

10212/s

10855/s

DriveModel

7200.4

WD160

RAID0

I Commit rate for 7200.4 laptop drive is 1048/s with unsafevolatile write cache

I Non-laptop drives include a 256MB battery-backed writecache, Linux SW RAID

Greg Smith Database Hardware Benchmarking

Page 33: Database Hardware Benchmarking

Custom PostgreSQL tests

I Quick CPU test (about 1140ms on my laptop):

\timing

select sum(generate series) from

generate series(1,1000000);

I Quick insert/plan test:

\timing

CREATE TABLE test (id INTEGER PRIMARY KEY);

INSERT INTO test VALUES (generate series(1,100000));

EXPLAIN ANALYZE SELECT COUNT(*) FROM test;

Greg Smith Database Hardware Benchmarking

Page 34: Database Hardware Benchmarking

Benchmarking functions

http://justatheory.com/computers/databases/postgresql/benchmarking_upc_validation.html

http://justatheory.com/computers/databases/postgresql/benchmarking_functions.html

I pg stat user functions handles this specific job in 8.4

I The general technique is applicable for all sorts of custombenchmarks

Greg Smith Database Hardware Benchmarking

Page 35: Database Hardware Benchmarking

pgbench select only test

\set naccounts 100000 * :scale

\setrandom aid 1 :naccounts

SELECT abalance FROM accounts WHERE aid = :aid;

Greg Smith Database Hardware Benchmarking

Page 36: Database Hardware Benchmarking

pgbench custom test: insert only, to measure commit rate

\set nbranches :scale

\set ntellers 10 * :scale

\set naccounts 100000 * :scale

\setrandom aid 1 :naccounts

\setrandom aid 1 :naccounts

\setrandom bid 1 :nbranches

\setrandom tid 1 :ntellers

\setrandom delta -5000 5000

BEGIN

INSERT INTO history (tid, bid, aid, delta, mtime)

VALUES (:tid, :bid, :aid, :delta, CURRENT TIMESTAMP);

END;

Greg Smith Database Hardware Benchmarking

Page 37: Database Hardware Benchmarking

pgbench standard test

BEGIN;

UPDATE accounts SET abalance = abalance + :delta

WHERE aid = :aid;

SELECT abalance FROM accounts WHERE aid = :aid;

UPDATE tellers SET tbalance = tbalance + :delta

WHERE tid = :tid;

UPDATE branches SET bbalance = bbalance + :delta

WHERE bid = :bid;

INSERT INTO history (tid, bid, aid, delta, mtime)

VALUES (:tid, :bid, :aid, :delta, CURRENT TIMESTAMP);

END;

Greg Smith Database Hardware Benchmarking

Page 38: Database Hardware Benchmarking

pgbench-tools

I Available from git.postgresql.org and github

I Set of shell scripts to automate running many pgbench tests

I Results are saved into a database for analysis

I Saves TPS, latency, background writer statistics

I Most of the cool features require PostgreSQL 8.3

I Inspired by the dbt2 benchmark framework

Greg Smith Database Hardware Benchmarking

Page 39: Database Hardware Benchmarking

Server configuration for pgbench results

I Quad-Core Intel Q6600

I 8GB DDR2-800 RAM

I Areca ARC-1210 SATA II PCI-e x8 RAID controller, 256MBwrite cache

I DB: 3x640GB Western Digital SATA disks, short-stroked,Linux software RAID-0

I WAL: 160GB Western Digital SATA disk

I CentOS 5.4, Linux Kernel 2.6.18-164.11.1.el5xen x86 64

I OS on separate disk

I Untuned ext3 filesystems

Greg Smith Database Hardware Benchmarking

Page 40: Database Hardware Benchmarking

PostgreSQL Configuration

I PostgreSQL 9.0-alpha4 (with multi-threaded pgbench patch)

I shared buffers = 2GB

I checkpoint segments = 32

I checkpoint completion target = 0.9

I wal buffers = 16MB

I max connections = 300

Greg Smith Database Hardware Benchmarking

Page 41: Database Hardware Benchmarking

pgbench read-only size scaling

Greg Smith Database Hardware Benchmarking

Page 42: Database Hardware Benchmarking

pgbench read-only client scaling

Greg Smith Database Hardware Benchmarking

Page 43: Database Hardware Benchmarking

pgbench TCP-B-like size scaling

Greg Smith Database Hardware Benchmarking

Page 44: Database Hardware Benchmarking

pgbench TPC-B-like client scaling

Greg Smith Database Hardware Benchmarking

Page 45: Database Hardware Benchmarking

What should you do?

I Trust no one

I Don’t start on application benchmarks until you’ve provenbasic performance

I Don’t spend too long on basic performance if you can switchto application benchmarks

I Vendors alternate among lying, misunderstanding what youwant, and trying to make you feel dumb

I Use simple, standard tools whenever possible to minimizevendor disputes

I Be prepared to translate to your vendor’s language andsubvert their agenda

I Never spend real money on hardware unless you can return itif it sucks

Greg Smith Database Hardware Benchmarking

Page 46: Database Hardware Benchmarking

Credits

I Special thanks to:

I Mark Wong and the other contributors to dbt-2

I Truviso for providing some of the test hardware included here

Greg Smith Database Hardware Benchmarking

Page 47: Database Hardware Benchmarking

For more information...

I Some slides are taken from the upcoming book:

I “High Performance PostgreSQL” by Greg Smith

I Planned for release this summer by Packt Publishing

I Performance tuning of PostgreSQL 8.1 through 9.0, fromhardware to scaling via replication

Greg Smith Database Hardware Benchmarking

Page 48: Database Hardware Benchmarking

Questions?

I Remember that your coffee break awaits you

Greg Smith Database Hardware Benchmarking