56
Peter Zaitsev, CEO, Percona November 1, 2014 Highload++ 2014 Moscow,Russia SSD/Flash for Modern Databases

SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

  • Upload
    doanh

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

Peter Zaitsev, CEO, Percona

November 1, 2014 Highload++ 2014

Moscow,Russia

SSD/Flash for Modern Databases

Page 2: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 2

Percona

• Percona Server

• Percona Xtrabackup

• Percona XtraDB Cluster

• Percona Toolkit

We love Open Source

Software

• Consulting

• Support

• Managed Services

We want to help you to

succeed with MySQL and

Beyond

Page 3: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 3

In this Presentation

Flash technology overview

Review some of the available technology

What does this mean for databases ?

Specific opportunities for MySQL

Page 4: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 4

Before SSDs

Page 5: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 5

There were HDDs

Good at Sequential Read/Writes

RT=Seek Time + Rotation Latency

Reads/Write – Similar Latency

No Specific Write Limits

Retain data for a long time

One IO Request in Parallel

Low cost per GB

Page 6: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 6

RAID and SAN

Page 7: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 7

Using Many HDDs together

Caching Reads

Buffering Writes (Writeback Cache)

Better Sequential Read/Write speed

Better throughput at high concurrency

Higher IO latencies for uncached IO

Page 8: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 8

Flash Revolution

Use Flash chips instead

of platters

No moving parts

No seeks

Page 9: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 9

NAND Flash

Cell

Page/Read Block

Erase Block

Write but no overwrite

Wears with writes (erases)

Page 10: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 10

Writing to the Flash

• Set all bits to “1111111…”

Erase

• Set some of the bits to 0: “0100111..”

Write

• Impossible. Do Erase, when Write

Change Zero to one

Page 11: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 11

Types of NAND Flash

From AnandTech:

Page 12: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 12

Flash Storage Design

Cache

Battery/Super Capacitor

Controller + Complex Firmware

Built-in Parallelism

Page 13: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 13

Flash Controller Tasks

Write wear leveling

Garbage collection

Error correction

Bad block mapping

Read scrubbing

Read disturb management

Encryption

Page 14: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 14

Flash Properties

Lots of IOs per device! (100K+)

Less random IO penalty

Writes more expensive than reads (but can be faster)

Limited by amount of writes

Limited retention

Concurrent execution on single device

Fast write acknowledgement (safe or not)

Can burst writes

Page 15: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 15

Flash Interface Designs

DIMM

PCI-E

SFF-8639

SATA/SAS

FC and Network

Page 16: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 16

Transitioning

AHCI NVMe

Page 17: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 17

AHCI vs NVMe

• Source: AnandTech.com

Page 18: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 18

Sandisk ULLtraDIMM

Page 19: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 19

HGST Virident

Page 20: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 20

Sandisk FusionIO

Page 21: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 21

Intel P3700

Page 22: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 22

Intel 730 (SATA)

Page 23: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 23

mSATA

Page 24: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 24

M.2 Interface

Page 25: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 25

Violin Memory

Page 26: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 26

“Consumer” vs “Enterprise”

Performance

Endurance

Durability

Retention

Encryption

Page 27: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 27

Not your HDD

All HDDs are the same; All SSDs are

different

Page 28: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 28

Evaluation

Performance changes over time

Empty Space Matters

Complex internals

Watch stability carefully

Page 29: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 29

How Flash Fails

Clear write amount defined EOL

(but often can handle a lot more)

One day… it’s gone

“Power Loss Protection”

Internal ECC and redundancy

Page 30: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 30

To RAID or not to RAID ?

More valuable for consumer grade

Watch for good Flash support

RAID controller logic may slow things down

Use a redundant array of inexpensive servers instead?

Page 31: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 31

Redundancy

Device internal redundancy

Hardware RAID

Software RAID

Filesystem “RAID”

Page 32: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 32

OS Support

Flash support is actively being improved

TRIM

Sparse Files

Page 33: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 33 www.percona.com

Flash And Databases

Page 34: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 34

Database History

Most have been designed in HDD time

Optimize for sequential IO

Count on cheap sequential writes

RAID, BBU to improve performance

Page 35: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 35

It’s time for Flash

Your OLTP Database should

live on Flash

Page 36: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 36

But What Flash ?

Pick a flash type that is right for your

application

Page 37: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 37

IO vs Memory

Page 38: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 38

Warmup

Much faster warmup times

Even if the database fits in memory, SSD might be justified

Page 39: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 39

Tolerate more IO bound load

• 5ms

• Can do 20 IO/s for 100ms response time (non parallel)

HDD

• 0.1ms

• Can do 1000 IO/s for 100ms response time (non parallel)

Flash

Page 40: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 40

Endurance

Might be a top consideration

Page 41: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 41

Endurance Math

• 4400GB/day over 5 Years

• 1400MB/sec peak writes

• 66 days at peak write throughput

HGST FlashMax III 2200GB

• 72TB total life time writes

• 400MB/sec write

• 52 hours at peak write throughput

Crucial M500

960GB

Page 42: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 42

Databases and Flash

How do we optimize databases to us

Flash best?

Page 43: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 43

“Torn Page” problem

Flash can avoid this with little cost due to internal design

FusionIO NVMFS (Atomic Writes)

Copy-on-Write File Systems

• ZFS

• BTRFS

Filesystem level data journaling less preferred

• data=journal for EXT4

Skip-Innodb-double-write

Page 44: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 44

Fast IO Path

Bypass Caching O_DIRECT

Native Asynchronous IO

Efficient Checksuming

Innodb_checksum_algorithm=crc32

Innodb_flush_method=O_DIRECT

Page 45: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 45

IO Cost Accounting

Sequential vs Random IO balance

IO vs CPU Balance

Smaller page sizes might make sense

• innodb_page_size=4K

Page 46: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 46

Less Pre-fetching

Most pre-fetched data must be used

Often best to try It out

Page 47: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 47

Less merging on flushing

Do not assume flushing multiple sequential dirty pages has same cost

Innodb_flush_neighbors=0

Page 48: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 48

Less Space on Disk

Innodb Compression (2x typical)

TokuDB Compression (5-10x typical)

Archiving data off OLTP System

Page 49: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 49

Less Writes on Flash

Hybrid Flash/SSD System

Transactional Logs, Other logs on the HDD with RAID and BBU

Small Temporary objects on tmpfs

Innodb_log_file_size=<LARGE>

Page 50: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 50

Logs on RAID can be fast

Page 51: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 51

Single Intel 730 Sysbench

Page 52: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 52

IOPS

Page 53: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 53

Consistency

• Graph by http://cloud.percona.com

Page 54: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 54

Is Flash Too Fast ?

• Multiple instances might scale better

Page 55: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 55

Other Thoughts

Host hardware and OS matter, especially with high end flash

Virtualization has higher relative overhead

Network higher relative overhead

Page 56: SSD/Flash for Modern Databases - Percona · PDF fileIn this Presentation Flash technology overview ... SSD might be justified . 39 Tolerate more IO bound load • 5ms • Can do 20

www.percona.com 56 www.percona.com

Peter Zaitsev

[email protected]

@PeterZaitsev

https://www.linkedin.com/in/peterzaitsev

Thank You!