Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course:...

31
Storage and Disks Storage and Disks

Transcript of Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course:...

Page 1: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

Storage and DisksStorage and Disks

Page 2: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.2Database System Concepts

Now Something DifferentNow Something Different

1st part of the course: Application Oriented

2nd part of the course: Systems Oriented

What is “Systems”?

A: Not Programming Not programming big things..

Systems = Efficient and safe use of limited resources (e.g., disks)

Efficient: resources should be shared, utilized as much as possible

Safe: sharing should not corrupt work of individual jobs

Page 3: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.3Database System Concepts

General OverviewGeneral Overview

Relational model - SQL Formal & commercial query languages

Functional Dependencies Normalization

Physical Design Indexing Query evaluation Query optimization ….

ApplicationOriented

Systems Oriented

Page 4: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.4Database System Concepts

The systems side of DatabasesThe systems side of Databases

What will we talk about?

1. Data Organization: physical storage strategies to support efficient updates, retrieval

2. Data retrieval: auxiliary data structures to enable efficient retrieval. Techniques for processing queries to ensure efficient retrieval

3. Data Integrity: techniques for implementing Xtions, to ensure safe concurrent access to data. Ensuring data is safe in the presence of system crashes.

Page 5: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.5Database System Concepts

Data OrganizationData Organization

Key points

1. Storage Media “Memory hierarchy”

Efficient/reliable transfer of data between disks and main memory Hardware techniques (RAID disks)

Software techniques (Buffer mgmt)

2. Storage strategies for relations-file organization Representation of tuples on disks

Storage of tuples in pages, clustering.

Page 6: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.6Database System Concepts

CPU

M C

TypicalComputer

SecondaryStorage

......

Page 7: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.7Database System Concepts

Storage Media: PlayersStorage Media: Players

Cache – fastest and most costly form of storage; volatile; managed by the computer system hardware.

Main memory:

fast access (10s to 100s of nanoseconds; 1 nanosecond = 10–9 seconds)

generally too small (or too expensive) to store the entire database

Volatile — contents of main memory are usually lost if a power failure or system crash occurs.

But… CPU operates only on data in main memory

Page 8: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.8Database System Concepts

Storage Media: PlayersStorage Media: Players

Disk Primary medium for the long-term storage of data; typically

stores entire database. random-access – possible to read data on disk in any order,

unlike magnetic tape Non-volatile: data survive a power failure or a system crash,

disk failure less likely than them

New technology: Solid State Disks and Flash disks

Page 9: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.9Database System Concepts

Storage Media: PlayersStorage Media: Players Optical storage

non-volatile, data is read optically from a spinning disk using a laser CD-ROM (640 MB) and DVD (4.7 to 17 GB) most popular forms Write-one, read-many (WORM) optical disks used for archival

storage (CD-R and DVD-R) Multiple write versions also available (CD-RW, DVD-RW, and DVD-

RAM) Reads and writes are slower than with magnetic disk

Tapes Sequential access (very slow) Cheap, high capacity

Page 10: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.10Database System Concepts

Memory HierarchyMemory Hierarchycache

Main memory

disk

Optical storage

Tapes

Hig

her

spee

d

Low

er p

rice

Traveling the hierarchy:1. speed ( higher=faster)2. cost (lower=cheaper)3. volatility (between MM and Disk)4. Data transfer (Main memory the “hub”)5. Storage classes (P=primary, S=secondary,T=tertiary)

V

NV

Page 11: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.11Database System Concepts

Memory HierarchyMemory Hierarchy

Data transfers cache – mm : OS/hardware controlled

mm – disk : <- reads, -> writes controlled by DBMS

disk – CD-Rom or DVD

disk – Tapes

Backups (off-line)

Page 12: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.12Database System Concepts

Main memory Main memory Disk Data Xfers Disk Data Xfers

Concerns:

1. Efficiency (speed)

can be improved by...

a. improving raw data transfer speed

b. avoiding untimely data transfer

c. avoiding unnecessary data transfer

2. Safety (reliability, availability)

can be improved by...

a. storing data redundantly

Page 13: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.13Database System Concepts

Main memory Main memory Disk Data Xfers Disk Data Xfers

Achieving efficiency:

1. Improve Raw data Xfer speed

1. Faster Disks

2. Parallelization (RAID)

2. Avoiding untimely data xfers

1. Disk scheduling

2. Batching

3. Avoiding unnecessary data xfers

1. Buffer Management

2. Good file organization

Page 14: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.14Database System Concepts

Hard Disk MechanismHard Disk Mechanism

Page 15: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.15Database System Concepts

Read-write head Positioned very close to the platter

surface (almost touching it)

Surface of platter divided into circular tracks

Each track is divided into sectors. A sector is the smallest unit of data that

can be read or written.

To read/write a sector disk arm swings to position head on

right track platter spins continually; data is

read/written as sector passes under head

Block: a sequence of sectors Cylinder i consists of ith track of all the

platters

Page 16: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.16Database System Concepts

“Typical” ValuesDiameter: 1 inch 15 inchesCylinders: 100 2000Surfaces: 1 or 2(Tracks/cyl) 2 (floppies) 30Sector Size:512B 50KCapacity: 360 KB (old floppy)

1.5 TB

Page 17: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.17Database System Concepts

Performance Measures of DisksPerformance Measures of DisksMeasuring Disk Speed

Access time – consists of: Seek time – time it takes to reposition the arm over the correct track.

(Rotational) latency time – time it takes for the sector to be accessed to appear under the head.

Data-transfer rate – the rate at which data can be retrieved from or stored to the disk.

Analogy to taking a bus:

1. Seek time: time to get to bus stop

2. Latency time; time spent waiting at bus stop

3. Data transfer time: time spent riding the bus

Page 18: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.18Database System Concepts

ExampleExample

ST3120022A  : Barracuda 7200.7   

Capacity:120 GB 

Interface:  Ultra ATA/100

   RPM: 7200 RPM  

Seek time: 8.5 ms avg

Latency time?: 7200/60 = 120 rotations/sec

1 rotation in 8.3 ms => So, Av. Latency = 4.16 ms

Page 19: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.19Database System Concepts

Random vs sequential i/oRandom vs sequential i/o

Ex: 1 KB Block Random I/O: 15 ms.

Sequential I/O: 1 ms.

Rule ofRule of Random I/O: ExpensiveRandom I/O: ExpensiveThumb Thumb Sequential I/O: Much less ~10-20 times Sequential I/O: Much less ~10-20 times

Page 20: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.20Database System Concepts

Performance Measures (Cont.)Performance Measures (Cont.)

Mean time to failure (MTTF) – the average time the disk is expected to run continuously without any failure. Typically 5 to 10 years

Probability of failure of new disks is quite low, corresponding to a“theoretical MTTF” of 30,000 to 1,200,000 hours for a new disk E.g., an MTTF of 1,200,000 hours for a new disk means that given 1000

relatively new disks, on an average one will fail every 1200 hours

MTTF decreases as disk ages

Page 21: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.21Database System Concepts

RAIDRAID

RAID: Redundant Arrays of Independent (Inexpensive) Disks

disk organization techniques that manage a large numbers of disks, providing a view of a single disk

Idea: cheaper to have many small disks, than few big disks

bonus: also advantageous for:

1. speed (efficiency)

2. reliability (safety)

Page 22: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.22Database System Concepts

Improvement in Performance via ParallelismImprovement in Performance via Parallelism

Choices:

D1 D2 D3 . . . . Dn

1. Distribute files (f1 D1, f2 D2, ....) or

2. Distribute parts of files (“striping”) block striping sector striping ...... bit striping

Page 23: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.23Database System Concepts

ParallelizationParallelization

File distribution

+: Availability: Many files still available if a disk goes down recovery requires fewer disks - : but still sequential read for each file

Striping +: improved ||’ism (speed) ( - : but a single disk failure catastrophic!)

Page 24: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.24Database System Concepts

Improving ReliabilityImproving Reliability

Reliability:

• Measure: MTTF•Striping reduces reliability: why?

Solution = RedundancyRedundancy: store data on more than 1 disk

E.g. “mirroring” (duplicate disks) (1 disk stored on 2)

Then, MTTF for both disks: 57,000 yrs! assuming MTTF foreach disk is 11 yrs.

logical disk

Page 25: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.25Database System Concepts

RAID LevelsRAID Levels Schemes to provide redundancy at lower cost by using disk

striping combined with parity bits Different RAID organizations, or RAID levels, have differing cost,

performance and reliability characteristics

RAID Level 1: Mirrored disks with block striping Offers good write performance.

Popular for applications such as storing log files in a database system.

RAID Level 0: Block striping; non-redundant. Used in high-performance applications where data loss is not critical.

Page 26: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.26Database System Concepts

RAID Levels (Cont.)RAID Levels (Cont.) RAID Level 2: Memory-Style Error-Correcting-Codes (ECC) with bit

striping.

RAID Level 3: Bit-Interleaved Parity a single parity bit is enough for error correction, not just detection, since

we know which disk has failed When writing data, corresponding parity bits must also be computed and

written to a parity bit disk

To recover data in a damaged disk, compute XOR of bits from other disks (including parity bit disk)

Page 27: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.27Database System Concepts

RAID Levels (Cont.)RAID Levels (Cont.) RAID Level 3 (Cont.)

Faster data transfer than with a single disk, but fewer I/Os per second since every disk has to participate in every I/O.

Subsumes Level 2 (provides all its benefits, at lower cost).

RAID Level 4: Block-Interleaved Parity; uses block-level striping, and keeps a parity block on a separate disk for corresponding blocks from N other disks. When writing data block, corresponding block of parity bits must

also be computed and written to parity disk

To find value of a damaged block, compute XOR of bits from corresponding blocks (including parity block) from other disks.

Page 28: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.28Database System Concepts

RAID Levels (Cont.)RAID Levels (Cont.)

RAID Level 4 (Cont.) Provides higher I/O rates for independent block reads than Level 3

Provides high transfer rates for reads of multiple blocks than no-striping

Before writing a block, parity data must be computed Can be done by using old parity block, old value of current block and new

value of current block (2 block reads + 2 block writes)

Parity block becomes a bottleneck for independent block writes since every block write also writes to parity disk

Page 29: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.29Database System Concepts

RAID Levels (Cont.)RAID Levels (Cont.) RAID Level 5: Block-Interleaved Distributed Parity; partitions

data and parity among all N + 1 disks, rather than storing data in N disks and parity in 1 disk. E.g., with 5 disks, parity block for nth set of blocks is stored on

disk (n mod 5) + 1, with the data blocks stored on the other 4 disks.

Page 30: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.30Database System Concepts

RAID Levels (Cont.)RAID Levels (Cont.)

RAID Level 5 (Cont.) Higher I/O rates than Level 4.

Block writes occur in parallel if the blocks and their parity blocks are on different disks.

Subsumes Level 4: provides same benefits, but avoids bottleneck of parity disk.

RAID Level 6: P+Q Redundancy scheme; similar to Level 5, but stores extra redundant information to guard against multiple disk failures. Better reliability than Level 5 at a higher cost; not used as widely.

Page 31: Storage and Disks. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course: Systems Oriented.

11.31Database System Concepts

Choice of RAID LevelChoice of RAID Level

Factors in choosing RAID level Monetary cost Performance: Number of I/O operations per second, and bandwidth during

normal operation Performance during failure Performance during rebuild of failed disk

Including time taken to rebuild failed disk

RAID 0 is used only when data safety is not important E.g. data can be recovered quickly from other sources

Level 2 and 4 never used since they are subsumed by 3 and 5 Level 3 is not used anymore since bit-striping forces single block reads

to access all disks, wasting disk arm movement, which block striping (level 5) avoids

Level 6 is rarely used since levels 1 and 5 offer adequate safety for almost all applications

So competition is between 1 and 5 only