n i e l s b o h r i n s t i t u t e university of copenhagen Concurrent Composition of I/O Redundancy Be- haviors in Go Klaus Birkelund Jensen and Brian Vinter {birkelund,vinter}@nbi.ku.dk eScience , X-Ray and Neutron Scattering Niels Bohr Institute, University of Copenhagen CPA 2017 Malta August 22, 2017 Slide 1/24
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Outline 1 Redundant I/O Behaviors A short introduction to redundant and fault-tolerant I/O. 2 Go Interfaces and I/O Some background on interfaces in Go and the standard library io package. 3 Composable Stream Behaviors Description of the streammux package. 4 Implementation Details 5 Conclusions Slide 2/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Redundant I/O Behaviors Redundancy through high availability and/or increased durability . • Hardware level; multipath I/O . • Software/hardware, well-known example for disks; RAID : Redundant Array of Inexpensive Disks . Behaviors are inherently concurrent and parallel . Slide 3/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID Levels RAID types are divided into levels . Slide 4/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID Levels RAID types are divided into levels . • RAID-0 ; striping . Not a real RAID level, no redundancy. Allows increased performance by parallelizing I/O. Slide 4/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID Levels RAID types are divided into levels . • RAID-0 ; striping . Not a real RAID level, no redundancy. Allows increased performance by parallelizing I/O. • RAID-1 ; mirroring . Replicates writes to multiple devices ⇒ increased durability . Slide 4/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID Levels RAID types are divided into levels . • RAID-0 ; striping . Not a real RAID level, no redundancy. Allows increased performance by parallelizing I/O. • RAID-1 ; mirroring . Replicates writes to multiple devices ⇒ increased durability . • RAID-4/5/6 ; parity-based redundancy. Combines striping with parity data to increase utilizating of devices. • RAID-4 ; striping with dedicated parity on one device. • RAID-5 ; striping with distributed or rotating parity. • RAID-6 ; RAID-5 with an extra parity block ⇒ increased redundancy. Slide 4/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID-0 Striping, data blocks ( A i ) is split between N devices. A split A 1 A 2 A 3 A 4 Fast reads and writes but cannot tolerate any failure. Slide 5/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID-1 Mirroring, written data is replicated to N devices. A copy A 1 A 1 A 2 A 2 Tolerates N − 1 failed devices. Low utilization. Slide 6/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID-4 Striping with parity data stored on one device. A , B , . . . xor split A 1 A 2 A 1 ⊕ A 2 B 2 B 2 B 1 ⊕ B 2 Tolerates 1 failure. High utilization. Slide 7/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Composition Levels can be composed. An example striped mirror (RAID-1+0). A split copy copy A 1 A 1 A 2 A 2 A 3 A 3 A 4 A 4 Slide 8/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID State Machines err err start O D F err new done err R Slide 9/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e RAID State Machines err err start O D F err new done err R The state machine for stripes are a bit less interesting... err start O F Slide 9/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e I/O Redundancy Behaviors Because this work is focused on streams , we restate the RAID levels in terms of I/O redundancy behaviors . • Striping , RAID-0 (again, not really a redundancy behavior) • Mirroring , RAID-1 • Dedicated parity , RAID-4 • Distributed parity , RAID-5/6 (not part of this work) Slide 10/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Go Interfaces Go allows any user defined type to implement interfaces that define behavior . The Go io package includes two very useful interfaces; the io.Reader and io.Writer . type Reader i n t e r f a c e { Read ( p [ ] byte ) ( n int , e r r e r r o r ) } type Writer i n t e r f a c e { Write ( p [ ] byte ) ( n int , e r r e r r o r ) } Slide 11/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Go Interfaces Go allows any user defined type to implement interfaces that define behavior . The Go io package includes two very useful interfaces; the io.Reader and io.Writer . type Reader i n t e r f a c e { Read ( p [ ] byte ) ( n int , e r r e r r o r ) } type Writer i n t e r f a c e { Write ( p [ ] byte ) ( n int , e r r e r r o r ) } Used a lot in the standard library $ guru implements ~/ l o c a l /go/ s r c / i o / i o . go:#3309 | wc − l 207 $ guru implements ~/ l o c a l /go/ s r c / i o / i o . go:#3800 | wc − l 184 Slide 11/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Go Interfaces Interfaces are satisfied by implementing the corresponding methods. type PanicReader s t r u c t {} func ( PanicReader ) Read ( p [ ] byte ) ( n int , e r r e r r o r ) { panic ( "im j u s t gonna crash " ) } Note It is not explicitly stated that an interface is being implemented, but PanicReader can now be used whenever an io.Reader is expected by a function. Slide 12/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e streammux The streammux package provides redundancy behaviors for arbitrary I/O types. • Works with types implementing the io.ReadWriteCloser interface (e.g. regular files and network connections). • Provides stripe , mirror and dedicated parity behaviors. • Supports spare pools . Slide 13/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e streammux, basic abstraction The member is the basic abstraction. • Wraps types implementing the io.ReadWriteCloser interface. • func Open() State readies the device for use and optionally opens the underlying device if it implements the streammux.Opener interface. • func write(idx int, p []byte, ch chan rwT) writes the byte slice p to the underlying device and signals completion (including errors) on the ch channel. • func read(idx int, p []byte, ch chan rwT) reads len(p) bytes from the underlying device and signals completion (including errors) on the ch channel. type rwT s t r u c t { idx , n int , p [ ] byte e r r e r r o r } Slide 14/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e streammux, behaviors Each redundancy behavior implemented by streammux implements the io.ReadWriteCloser interface and thus allows building of arbitrary redundancy networks. • Striped mirrors • Mirrored stripes Slide 15/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
u n i v e r s i t y o f c o p e n h a g e n n i e l s b o h r i n s t i t u t e Striping and Mirroring The striping behavior is built from other members directly Slide 16/24 — Birkelund — Concurrent Composition of I/O Redundancy Behaviors in Go — August 22, 2017
Recommend
More recommend