Presentation on theme: "Storage and Disks Fusheng Wang Department of Biomedical Informatics"— Presentation transcript:
1 Storage and Disks Fusheng Wang Department of Biomedical Informatics Department of Mathematics and Computer ScienceEmory University
2 The Systems Side of Databases Data Organization: physical storage strategies to support efficient updates, retrieval2. Data retrieval: auxiliary data structures to enable efficient retrieval. Techniques for processing queries to ensure efficient retrieval3. Data Integrity: techniques for implementing Xtions, to ensure safe concurrent access to data. Ensuring data is safe in the presence of system crashes.
3 Data Organization Key points: 1. Storage Media “Memory hierarchy”Efficient/reliable transfer of data between disks and main memoryHardware techniques (RAID disks)Software techniques (Buffer mgmt)2. Storage strategies for relations-file organizationRepresentation of tuples on disksStorage of tuples in pages, clustering
8 Storage Media: Cache and Main Memory 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 databaseVolatile — contents of main memory are usually lost if a power failure or system crash occurs.But… CPU operates only on data in main memory
9 Storage Media: Flash Memory Data survives power failureData can be written at a location only once, but location can be erased and written to againCan support only a limited number (10K – 1M) of write/erase cycles.Erasing of memory has to be done to an entire bank of memoryReads are roughly as fast as main memoryBut writes are slow (few microseconds), erase is slowerWidely used in embedded devices such as digital cameras, phones, and USB keys
10 Storage Media: Disk 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 tapeNon-volatile: data survive a power failure or a system crash, disk failure less likely than themNew technology: Solid State Disks and Flash disks
11 Storage Media: Players Optical storagenon-volatile, data is read optically from a spinning disk using a laserCD-ROM (640 MB) and DVD (4.7 to 17 GB) most popular formsWrite-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 diskTapesSequential access (very slow)Cheap, high capacity
12 Memory Hierarchyprimary storage: Fastest media but volatile (cache, main memory)secondary storage: next level in hierarchy, non-volatile, moderately fast access timealso called on-line storageE.g. flash memory, magnetic diskstertiary storage: lowest level in hierarchy, non-volatile, slow access timealso called off-line storageE.g. magnetic tape, optical storage
13 Memory Hierarchy: Data Transfers cache – mm : OS/hardware controlledmm – disk : <- reads, -> writes controlled by DBMSdisk – CD-Rom or DVDdisk – TapesBackups (off-line)
14 Main memory Disk Data Transfers Concerns 1. Efficiency (speed)can be improved by...a. improving raw data transfer speedb. avoiding untimely data transferc. avoiding unnecessary data transfer2. Safety (reliability, availability)a. storing data redundantly
15 Main memory Disk Data Transfers Achieving efficiency:1. Improve Raw data Transfer speed1. Faster Disks2. Parallelization (RAID)2. Avoiding untimely data transfers1. Disk scheduling2. Batching3. Avoiding unnecessary data transfers1. Buffer Management2. Good file organization
16 Hard Disk Mechanism http://www.youtube.com/watch?v=Bh80aaygIXg
17 Hard Disk Read-write head Positioned very close to the platter surface Reads or writes magnetically encoded informationSurface of platter divided into circular tracksOver 50K-100K tracks per platter on typical hard disksEach track is divided into sectors (blocks)The smallest unit of data that can be read or writtenSector size typically 512 bytes (2048 bytes for DVD/CD-ROM)Typical sectors per track: 500 to 1000 (on inner tracks) to 1000 to 2000 (on outer tracks)To read/write a sectordisk arm swings to position head on right trackplatter spins continually; data is read/written as sector passes under headHead-disk assembliesmultiple disk platters on a single spindle (1 to 5 usually)one head per platter, mounted on a common armCylinder i consists of ith track of all the platters
19 Performance Measures of Disks Access time – consists of:Seek time – time it takes to reposition the arm over the correct trackAverage: 4ms (high end), 9ms(desktop), 12ms (mobile drives)(Rotational) latency time – time it takes for the sector to be accessed to appear under the headAvg: 2ms(15k rpm), 3ms(10k rpm) 4.16ms(7200rpm)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 stop2. Latency time; time spent waiting at bus stop3. Data transfer time: time spent riding the bus
20 Data Transfer RateData transfer rate (also called throughput): min(internal rate, external rate)Internal rate: moving data between the disk surface and the controller on the driveExternal rate: moving data between the controller on the drive and the host systemA typical 7200 RPM desktop HDD: 1030 Mbit/s12x blue-ray: 432Mbit/sSATA interface: 2Gbits/s
21 Example ST3120022A : Barracuda 7200.7 Capacity:120 GB Interface: Ultra ATA/100 RPM: 7200 RPM Seek time: 8.5 ms avgLatency time?:7200/60 = 120 rotations/sec1 rotation in 8.3 ms => So, Av. Latency = 4.16 ms
22 Random vs sequential I/O Ex: 1 KB BlockRandom I/O: 15 ms.Sequential I/O: 1 ms.Rule of Random I/O: Expensive Thumb Sequential I/O: Much less ~10-20 times
29 Exercise: Disk Access Cost Estimation IBM U GB hard drive has average seek time of 3.6ms, average rotation delay of 2ms for a half rotation (15K rpm), and a transfer rate of 320MB/sec.1.Estimate access time for a 4KB block2.Estimate access time for a contiguous 64KB access3. Estimate access time for 16 random 4KB-blocks1.: I/O = 3.6ms + 2ms + 4KB/320MB/s = = ms2.: I/O = 3.6ms + 2ms + 4KB/320MB/s = KB/320MB/s = 5.8 ms3.: I/O = x 8 = 44.9 ms
30 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 yearsProbability of failure of new disks is quite low, corresponding to a “theoretical MTTF” of 30,000 to 1,200,000 hours for a new diskE.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 hoursMTTF decreases as disk ages
31 RAID: Redundant Arrays of Independent (Inexpensive) Disks disk organization techniques that manage a large numbers of disks, providing a view of a single diskIdea: cheaper to have many small disks, than few big disksbonus: also advantageous for:1. speed (efficiency)2. reliability (safety)
32 Improvement in Performance via Parallelism Choices:D D D Dn1. Distribute files (f1 D1, f2 D2, ....)or2. Distribute parts of files (“striping”) block striping sector striping...... bit striping
33 Parallelization File distribution +: Availability: Many files still available if a disk goes down+: recovery requires fewer disks- : but still sequential read for each fileStriping+: improved ||’ism (speed)( - : but a single disk failure catastrophic!)
34 Improving Reliability Measure: MTTFStriping reduces reliability: why?Solution = RedundancyRedundancy: store data on more than 1 diskE.g. “mirroring” (duplicate disks) (1 disk stored on 2)logical diskThen, MTTF for both disks: 57,000 yrs! assuming MTTF foreach disk is 11 yrs.RAID (redundant array of independent disks): a storage technology that combines multiple disk drive components into a logical unit for the purposes of data redundancy and performance improvement
35 RAID LevelsSchemes to provide redundancy at lower cost by using disk striping combined with parity bitsDifferent RAID organizations, or RAID levels, have differing cost, performance and reliability characteristicsRAID Level 0: Block striping; non-redundant.Used in high-performance applications where data loss is not critical.RAID Level 1: Mirrored disks with block stripingOffers good write performance.Popular for applications such as storing log files in a database system.
36 8 bits including parity (even) Parity BitA bit added to the end of a string of binary code that indicates whether the number of bits in the string with the value one is even or oddWith 3 drives:7 bits of data(count of 1 bits)8 bits including parity (even)3If drive 2 fails:(1) XOR (3) _____________ (2) XOR Drive 3:Drive 1: Drive 2:
37 RAID Levels (Cont.)RAID Level 2: Memory-Style Error-Correcting- Codes (ECC) with bit striping.RAID Level 3: Bit-Interleaved ParityA single parity bit is enough for error correction, not just detection, since we know which disk has failedWhen writing data, corresponding parity bits must also be computed and written to a parity bit diskTo recover data in a damaged disk, compute XOR of bits from other disks (including parity bit disk)
38 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 diskTo find value of a damaged block, compute XOR of bits from corresponding blocks (including parity block) from other disks.
39 RAID Levels (Cont.) RAID Level 4 (Cont.) Provides higher I/O rates for independent block reads than Level 3Provides high transfer rates for reads of multiple blocks than no-stripingBefore writing a block, parity data must be computedCan 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
40 RAID Level 5RAID 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 4 disks, parity block for nth set of blocks is stored on disk (n mod 4) + 1, with the data blocks stored on the other 4 disks.
41 RAID Levels (Cont.)Data is block interleaved – this allows us to get all ourdata from a single disk on a read (in case of a disk error,read all disks)Block interleaving reduces throughput for a single request (only a single disk is servicing the request), butimproves task-level parallelism as other disk drives arefree to service other requestsOn a write, we access the disk that stores the data and theparity disk – parity information can be updated simply bychecking if the new data differs from the old dataIf we have a single disk for parity, multiple writes can nothappen in parallel (as all writes must update parity info)RAID 5 distributes the parity block to allow simultaneouswrites
42 Choice of RAID Level Factors in choosing RAID level Monetary costPerformance: Number of I/O operations per second, and bandwidth during normal operationPerformance during failurePerformance during rebuild of failed diskIncluding time taken to rebuild failed diskRAID 0 is used only when data safety is not importantE.g. data can be recovered quickly from other sourcesLevel 2 and 4 never used since they are subsumed by 3 and 5Level 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) avoidsLevel 6 is rarely used since levels 1 and 5 offer adequate safety for almost all applicationsSo competition is between 1 and 5 only
43 Choice of RAID LevelLevel 1 provides much better write performance than level 5Level 5 requires at least 2 block reads and 2 block writes to write a single block, whereas Level 1 only requires 2 block writesLevel 1 preferred for high update environments such as log disksLevel 1 had higher storage cost than level 5disk drive capacities increasing rapidly (50%/year) whereas disk access times have decreased much less (x 3 in 10 years)I/O requirements have increased greatly, e.g. for Web serversWhen enough disks have been bought to satisfy required rate of I/O, they often have spare storage capacityso there is often no extra monetary cost for Level 1!Level 5 is preferred for applications with low update rate, and large amounts of dataLevel 1 is preferred for all other applications