Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

40
Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro

description

Important addresses Class URL: –Check regularly for schedule+reading questions We’ll use Piazza.com for class discussion

Transcript of Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Page 1: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Distributed systems [Fall 2012]

G22.3033-001

Lec 1: Course Introduction & Lab Intro

Page 2: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Know your staff

• Instructor: Prof. Jinyang Li (me)– [email protected]– Office Hour: Thu 4-5pm (715 Bway Rm 708)

• Instructional Assistant: Russell Power– [email protected]– Office Hour: TBA (715 Bway Rm 707)

Page 3: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Important addresses• Class URL: http://www.news.cs.nyu.edu/~jinyang/fa12

– Check regularly for schedule+reading questions

• We’ll use Piazza.com for class discussion

Page 4: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

This class will teachyou …• Basic tools of distributed systems

– Abstractions, algorithms, implementation techniques– System designs that worked

• Build a real system!– Synthesize ideas from many areas to build working

systems

Page 5: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Who should take this class?• Pre-requisite:

– Undergrad systems class (OS, compiler etc.)– Programming experience in C or C++

• Fast paced and a lot of work– Labs due every two weeks– Final project– Midterm + Final– 2~3 readings every week + reading question

• If you are not sure, do Lab1 asap.

Page 6: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Course readings• No official textbook• Lectures are based on research papers

– Check webpage for schedules• Useful reference books

– Principles of Computer System Design. (Saltzer and Kaashoek)

– Distributed Systems (Tanenbaum and Steen)– Advanced Programming in the UNIX environment

(Stevens)– UNIX Network Programming (Stevens)

Page 7: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Course structure

• Lectures – Read assigned papers before class– Submit your answer to assigned reading question on

Piazza– Participate in class discussion

• 5 programming Labs – Build a networked file system with detailed guidance!

• Project (or 2 additional labs)

Page 8: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

How are you evaluated?

• Class participation 5%– Participate in discussions, hand in answers

• Labs 40%• Project 25%• Quizzes 30%

– mid-term and final (90 minutes each)

Page 9: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Questions?

Page 10: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

What are distributed systems?

• Examples?

Multiple hosts

A local or wide area network

Hosts cooperate to provide a unified service

Page 11: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Why distributed systems?for ease-of-use

• Handle geographic separation• Provide users (or applications) with location

transparency:– Web: access information with a few “clicks”– Network file system: access files on remote

servers as if they are on a local disk, share files among multiple computers

Page 12: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Why distributed systems?for availability

• Build a reliable system out of unreliable parts– Hardware can fail: power outage, disk failures,

memory corruption, network switch failures…– Software can fail: bugs, mis-configuration,

upgrade …– To achieve 0.999999 availability, replicate

data/computation on many hosts with automatic failover

Page 13: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Why distributed systems?for scalable capacity

• Aggregate resources of many computers– CPU: Dryad, MapReduce, Grid computing– Bandwidth: Akamai CDN, BitTorrent– Disk: Frangipani, Google file system

Page 14: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Why distributed systems?for modular functionality

• Only need to build a service to accomplish a single task well. – Authentication server– Backup server.

• Compose multiple simple services to achieve sophisticated functionality– Our programming lab: file service = lock service +

block service

Page 15: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

The downside

A distributed system is a system in which I can’t do my work because some computer that I’ve never even heard of has failed.”

-- Leslie Lamport

• Much more complex

Page 16: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topics in this course

Page 17: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Case Study: Distributed file system

Server(s)

Client 1 Client 2 Client 3

A distributed file system provides:• location transparent file accesses • sharing among multiple clients

$ echo “test” > f2$ ls /dfsf1 f2

$ ls /dfsf1 f2$ cat f2test

Page 18: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

A simple distributed FS design

• A single server stores all data and handles clients’ FS requests.

Client 1 Client 2 Client 3

Page 19: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: System Design• What is the right interface?

– possible interfaces of a storage system • Disk• File system• Database

• Run over local cluster or wide area?• Scale of operation?

– Must the system handle a large user population?– Store peta-bytes of data?

Page 20: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: Implementation

• Build it out of single machine components.– How do clients/server communicate?– Hide network communication from app logic

• RPC, RMI, ZeroMQ

• Build it out of other distributed software/services.– Run on top of MongoDB, Amazon’s S3?

Page 21: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: performance

• Optimize for single server performance:– serve multiple clients concurrently– Challenges of multithreaded server

• Race, deadlock etc.

• Scale out using many machines– Ideal scenario: Nx servers Nx performance– How to distribute a file server’s load?

• Split by user? Split by file name?– Load imbalance destroy perfect scalability

Page 22: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: Fault Tolerance

• How to keep the system running when some file server is down?– Replicate data at multiple servers

• How to update replicated data?• How to fail-over among replicas?• How to incorporate recovered machine

correctly?

Page 23: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: Consistency• Contract with apps/users about meaning of

operations. Difficult due to:– Partial failure, replication/caching, concurrency

• Problem: keep 2 replicas “identical”– If one is down, it will miss updates– If net is broken, both might process different updates

• Problem: atomicity of multiple operations– When Alice moves file f1 from /d1 to /d2, do other clients

see intermediate results?

Page 24: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Topic: Security• Adversary can manipulate messages

– How to authenticate?• Adversary may compromise machines

– Can the FS remain correct despite a few compromised nodes?

– How to audit for past compromises?• Which parts of the system to trust?

– System admins? Physical hardware? OS? Your software?

Page 25: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Intro to programming Lab:Yet Another File System (yfs)

Page 26: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

YFS is inspired by Frangipani

• Frangipani goals:– Aggregate many disks from many servers– Incrementally scalable– Automatic load balancing – Tolerates and recovers from node, network,

disk failures

Page 27: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Frangipani Design

Petal virtual disk

Petal virtual disk

lock server

lock server

FrangipaniFile server

FrangipaniFile server

FrangipaniFile server

Client machines

server machines

Page 28: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Frangipani Design

FrangipaniFile server

Petal virtual disk

• aggregate disks into one big virtual disk•interface: put(addr, data), get(addr)•replicated for fault tolerance •Incrementally scalable with more servers

• serve file system requests• use Petal to store data• incrementally scalable with more servers

• ensure consistent updates by multiple servers• replicated for fault tolerance

lock server

Page 29: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Frangipani security

• Simple security model:– Runs as a cluster file system– All machines and software are trusted!

Page 30: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Frangipani server implements FS logic

• Application program:creat(“/d1/f1”, 0777)

• Frangipani server:1. GET root directory’s data from Petal2. Find inode # or Petal address for dir “/d1”3. GET “/d1”s data from Petal4. Find inode # or Petal address of “f1” in “/d1”5. If not exists alloc a new block for “f1” from Petal add “f1” to “/d1”’s data, PUT modified “/d1” to Petal

Page 31: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Concurrent accesses cause inconsistency

App: creat(“/d1/f1”, 0777)Server S1:…GET “/d1” Find file “f1” in “/d1”If not exists … PUT modified “/d1”

time

App: creat(“/d1/f2”, 0777)Server S2:

GET “/d1”

Find file “f2” in “/d1”If not exists … PUT modified “/d1”

What is the final result of “/d1”? What should it be?

Page 32: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Solution: use a lock service to synchronize access

App: creat(“/d1/f1”, 0777)Server S1:..

GET “/d1”Find file “f1” in “/d1”If not exists … PUT modified “/d1”

time

App: creat(“/d1/f2”, 0777)Server S2:…

GET “/d1”…

LOCK(“/d1”)

UNLOCK(“/d1”)

LOCK(“/d1”)

Page 33: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Putting it together

FrangipaniFile server

Petal virtual disk

lock server

Petal virtual disk

lock server

FrangipaniFile server

create (“/d1/f1”)

1. LOCK “/d1”

3. PUT “/d1”

2. GET “/d1”

4. UNLOCK “/d1”

Page 34: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

NFS (or AFS) architecture

• Simple clients– Relay FS calls to the server– LOOKUP, CREATE, REMOVE, READ, WRITE …

• NFS server implements FS functions

NFS client NFS client

NFS server

Page 35: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

NFS messages for reading a file

Page 36: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Why use file handles in NSF msg, not file names?

• What file does client 1 read? – Local UNIX fs: client 1 reads dir2/f– NFS using filenames: client 1 reads dir1/f– NFS using file handles: client 1 reads dir2/f

• File handles refer to actual file object, not names

Page 37: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Frangipani vs. NFS

Frangipani NFS

Scale storage

Scale serving capacity

Fault tolerance

Add Petal nodes Buy more disks

Add Frangipani Manually partition servers FS namespace among multiple servers

Data is replicated Use RAIDOn multiple PetalNodes

Page 38: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

User-level

kernel

App

FUSE

syscall

YFS: simplified Frangipani

Extent server

yfs server

lock server

yfs server

Single extent server to store data

Communication using remote procedure calls (RPC)

Page 39: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

Lab schedule

• L1: lock server– Programming w/ threads– RPC semantics

• L2: basic file server• L3: Locking• L4: Caching locks• L5: Caching extend server+consistency• L6: Paxos• L7: Replicated lock server

Page 40: Distributed systems [Fall 2012] G22.3033-001 Lec 1: Course Introduction & Lab Intro.

L1: lock server

• Lock service consists of:– Lock server: grant a lock to clients, one at a time– Lock client: talk to server to acquire/release locks

• Correctness:– At most one lock is granted to any client

• Additional Requirement:– acquire() at client does not return until lock is granted