Top Banner
PostgreSQL on ZFS Bits Hopefully Structured the way you Left Them: The scary parts followed by a Happy Ending™.
43

PostgreSQL on ZFS Lightning Talk

Apr 13, 2017

Download

Internet

Sean Chittenden
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: PostgreSQL on ZFS Lightning Talk

PostgreSQL on ZFSBits Hopefully Structured the way you Left Them: The scary parts followed by a Happy Ending™.

Page 2: PostgreSQL on ZFS Lightning Talk

“All good lightning talks have a little FUD.”

Page 3: PostgreSQL on ZFS Lightning Talk

… except it’s not FUD.

Page 4: PostgreSQL on ZFS Lightning Talk

… and few care or are aware (thank you cloud providers!)

Page 5: PostgreSQL on ZFS Lightning Talk

Cloud providers have duped a generation of operators into thinking bitrot does not exist.

It does. The reality has been hidden from plain sight, but it’s there… lurking… silently, waiting…

Page 6: PostgreSQL on ZFS Lightning Talk

–Many (myself included)

"If you are not using ZFS, you are losing data."

Page 7: PostgreSQL on ZFS Lightning Talk

This has been studied recently for SSDs…

Page 8: PostgreSQL on ZFS Lightning Talk
Page 9: PostgreSQL on ZFS Lightning Talk

ECC on Flash works until it doesn’t.

Probability will rip your face if you do not acknowledge its existence and its control over your life.

Page 10: PostgreSQL on ZFS Lightning Talk
Page 11: PostgreSQL on ZFS Lightning Talk
Page 12: PostgreSQL on ZFS Lightning Talk

TL;DR: 4.2% -> 34% of SSDs have one UBER per year

Page 13: PostgreSQL on ZFS Lightning Talk

TL;DR: 4.2% -> 34% of SSDs have one UBER per year

How many SSDs in that shiny box 'ya got there?

How many boxes are running?

Page 14: PostgreSQL on ZFS Lightning Talk

TL;DR: 4.2% -> 34% of SSDs have one UBER per year

How many SSDs in that shiny box 'ya got there?

How many boxes are running?

(1-(1-uberRate)^(numDisks)) = Probability of UBER/server/year

(1-(1-0.042)^(20)) = 58%(1-(1-0.34)^(20)) = 99.975%

Page 15: PostgreSQL on ZFS Lightning Talk

External Factors for UBER on SSDs:

• Temperature • Bus Power Consumption • Data Written by the System Software • Workload changes due to SSD failure

Page 16: PostgreSQL on ZFS Lightning Talk

In a Datacenter…

…no-one can hear your bits scream.

Page 17: PostgreSQL on ZFS Lightning Talk
Page 18: PostgreSQL on ZFS Lightning Talk

Well, maybe they can…

Page 19: PostgreSQL on ZFS Lightning Talk

Take care of your bits. Your bits are taking care of you.

Page 20: PostgreSQL on ZFS Lightning Talk

Take care of your bits. Your bits are taking care of you.

Answer their cry for help.

Page 21: PostgreSQL on ZFS Lightning Talk

Similar studies and research exist for:

• Fibre Channel • SAS • SATA • Tape • SANs • Cloud Object Stores

Page 22: PostgreSQL on ZFS Lightning Talk

"Groupon’s Deal on FreeBSD" FreeBSD Journal, July/August 2015

https://www.freebsdfoundation.org/past-issues/freebsd-in-the-enterprise/ https://www.freebsdfoundation.org/wp-content/uploads/2015/12/vol2_no4_groupon.pdf

Page 23: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

Page 24: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens

Page 25: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast

Page 26: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast

2-4µs/pwrite(2)!!

Page 27: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast

Page 28: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast

Page 29: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast

P.S. This was observed on 10K RPM spinning rust.

Page 30: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL!

# zfsnap snapshot -rv -a 25h tank/pgdata # zfs list -r -t snapshot# zfs rollback -r tank/pgdata@hourly-2016-09-14_14.52.00—25h

Page 31: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL!

# zfsnap snapshot -rv -a 25h tank/pgdata # zfs list -r -t snapshot# zfs rollback -r tank/pgdata@hourly-2016-09-14_14.52.00—25h

This happens in seconds! It’s YUGE people, absolutely YUGE!

Page 32: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL! • Because compression is a performance win,

even on SSDs

# zfs set compression=lz4 tank/pgdata

(wtb publishing of benchmarks any year now… you know who you are…)

Page 33: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL! • Because compression is a performance win,

even on SSDs • Because compression is a space win (2.2:1

compression for most PG data)

Page 34: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL! • Because compression is a performance win,

even on SSDs • Because compression is a space win (2.2:1

compression for most PG data) • Because zfs snap; zfs send; ssh… ; zfs recv

Page 35: PostgreSQL on ZFS Lightning Talk

PostgreSQL and ZFS were meant for each other

• Because bitrot happens • Because its fast • Because restoring from backups is AWFUL! • Because compression is a performance win,

even on SSDs • Because compression is a space win (2.2:1

compression for most PG data) • Because zfs snap; zfs send; ssh… ; zfs recv • Because caching compressed records is win

https://www.illumos.org/issues/6950

Page 36: PostgreSQL on ZFS Lightning Talk

It even runs on Linux!

Page 37: PostgreSQL on ZFS Lightning Talk

It even runs on Linux!

Don’t become cranky and jaded and relearn the

perils of data sadness.

Page 38: PostgreSQL on ZFS Lightning Talk
Page 39: PostgreSQL on ZFS Lightning Talk

Winning Strategy

Page 40: PostgreSQL on ZFS Lightning Talk

Winning Strategy

Be aware. But take the Blue Pill.

Page 41: PostgreSQL on ZFS Lightning Talk

+

Page 42: PostgreSQL on ZFS Lightning Talk
Page 43: PostgreSQL on ZFS Lightning Talk

Not running PostgreSQL on ZFS is tantamount to professional negligence. Discuss.