cs 138: distributed systemscs.brown.edu/courses/cs138/s18/lectures/l1_intro.pdffinal puddlestore •...

48
CS 138: Distributed Systems

Upload: others

Post on 09-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CS138:DistributedSystems

Page 2: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Staff• Faculty

– TheophilusBenson(AKATheo)

• HeadTAs

– SiddarthKaramcheti

• UTAs

– AmedeoFeliceAlberio– AbdullaAldilaijan

– ChristopherHarvie– BenjaminShteinfeld

– JaredSiskin

Page 3: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CourseDetails• CoursePolicies

• ClassWebsite:http://cs.brown.edu/courses/cs138/s18/index.html• Piazza:https://piazza.com/brown/spring2018/cs1380• Cheating/Collaboration

• Waitlist!!!!• Registered:~69• Waitlisted:~108• Attendclass!• Ifclassisrequiredforgraduation(2018),haveacademicadvisoremailus.

Page 4: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CourseDetails• CoursePolicies

• ClassWebsite:http://cs.brown.edu/courses/cs138/s18/index.html• Piazza:https://piazza.com/brown/spring2018/cs1380• Cheating/Collaboration

• Waitlist!!!!• Registered:~69• Waitlisted:~108• Attendclass!• Ifclassisrequiredforgraduation(2018),haveacademicadvisoremailus.

Page 5: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Workload

• Fourprograms(50%)– LiteMiner(10%)NEW!!!!!!

– Tapestry(13%)– Raft(13%)

– PuddleStore(13%)

• Fourwrittenhomeworks(15%)

• Onein-classmidtermexam(15%)

• Finalexam(20%)• Seehttp://cs.brown.edu/courses/cs138/s18/content/docs/syllabus.pdf

Page 6: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

SkillsNeeded

• Abilitytowriteanddebuglargishprogramswiththreads– CS32or33

• Abilitytoproveatheorem– therewon’tbemany

– CS22ishelpful

• Willingnesstolearnanewprogramminglanguage– Go

Page 7: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Textbook

Page 8: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

What Is A Distributed System?“Acollectionofindependentcomputersthatappearstoitsusersasasinglecoherentsystem.”

• Ideal:topresentasingle-systemimage:– Thedistributedsystem“lookslike”asinglecomputerratherthanacollectionofseparatecomputers.

Page 9: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

DistributedSystemsareHardtoBuild

• Mustdealwithfailures

• Coordinationbetweennodes

• Consistencyandpersistence

• Concurrency

Page 10: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Google Confidential and Proprietary

OFC Bug History

Page 11: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it
Page 12: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it
Page 13: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

WhyDoYouNeedADistributedSystem?

• Faulttolerance

• Scalability

• Performance

• Resourcesharing

• InformationGathering

Page 14: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• Interestedingettingfastandefficientdeeplearningframeworks

https://training.databricks.com/databricks_guide/gentle_introduction/spark_cluster_tasks.png

Page 15: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• Efficientlymanagingandcoordinatingbitcoinminers

https://medium.com/@lopp/the-future-of-bitcoin-mining-ac9c3dc39c60

Page 16: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• Designingsuccessfullargeonlineservices

http://www.ageofinnovation.org/gallery/the-benefits-of-using-online-services-pictures/The-benefits-of-using-online-services.jpg

Page 17: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• DesigningIoTplatforms

https://training.databricks.com/databricks_guide/gentle_introduction/spark_cluster_tasks.png

Page 18: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• Designingselfdrivingcars

https://training.databricks.com/databricks_guide/gentle_introduction/spark_cluster_tasks.png

Page 19: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Youwoulddesignadistributedsystemwhen…

• Designingtradingplatforms

https://3nlm2c1gjj0z2ju16293909h-wpengine.netdna-ssl.com/wp-content/uploads/2017/01/best-stock-trading-software-mac-

Page 20: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

WhyDoYouNeedADistributedSystem?

• Buildingacloud

• ScalingoutthenextAirBnB

• Designingaselfdrivingcar

• Interestedingettingfastandefficientdeeplearningframeworks

• Developingthenextgameframework

• Designingatradingplatformforahedgefundorinvestmentbank

Page 21: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CaseStudy:Facebook

Page 22: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CAVA

• Circa2007,Facebookdecidedtoaddaseconddatacentertoitsoperations

FacebookDatabaseReplication

https://www.facebook.com/notes/facebook-engineering/scaling-out/23844338919

Page 23: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Why?

• Majorreason:latency– can’tgofasterthanthespeedoflightyet

• Otherreasons– scale:needtohandlerapidlyincreasingloads– resiliency:whatifanearthquakehitsCA?– power:sometimesavailabilityofpowerlimitsthesizeofadatacenter!

Page 24: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Cachingobjects

• Facebookhandlesreadsviamemcached

Page 25: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Cachingobjects

• Cacheinvalidatedonanewwrite

Page 26: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

AddinganewDatacenter

• Initialdesignhadabug

Page 27: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

AddinganewDatacenter

Page 28: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Introduction to Go

Page 29: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Where is Go used?

● Google, of course! ● Docker (Container management) ● CloudFlare (Content Delivery Network) ● Digital Ocean (VM hosting) ● Dropbox (Cloud storage/file sharing) ● … and many more!

Page 30: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Why use Go?

● Easy concurrency w/ goroutines (green threads)

● Garbage collection and memory safety

● Libraries provide easy RPC

● Channels for communication between goroutines

Page 31: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Example: Simple Program

packagemain

import( "fmt" "os")

funcmain(){ forcount:=1;count<100;count++{ ifcount%2==0{ fmt.Printf("Foundevennumber:%v\n",count) }else{ fmt.Fprintf(os.Stderr,"Notanevennumber:%v\n",count) } }}

● No parentheses

● “for { }” will loop forever

● “for condition { }” avoids initialization/afterthought, similar to a while loop

Page 32: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Learning Go

● Project 0: Whatsup? ● Effective Go ● golang.org/doc ● tour.golang.org ● go-handout.pdf

Page 33: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

PuddleStore

• Averydistributedfilesystem– thousandsofcomputers

• allovertheworld– (oratleastthroughouttheSunLab)

• nocommonadministration

– eachholdspiecesofafewfiles

• piecesreplicatedonmanycomputers

• BasedonOceanStore– anditsPondprototype

Page 34: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

AFile

Indirect Block

Data Block 1 Data Block 4

Data Block 2 Data Block 3

Page 35: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

ADistributedFile

Indirect Block

Data Block 1

Data Block 4

Data Block 2Data Block 3

Indirect Block

Indirect Block

Indirect Block

Data Block 1

Data Block 1

Data Block 1

Data Block 2

Data Block 2

Data Block 2

Data Block 1

Data Block 1

Data Block 1

Data Block 1

Data Block 2

Data Block 2

Data Block 2

Page 36: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

HowDoYouFindthePieces?

• Hashing• But...

– nodesmaycrash

• duplicatesarerequired

• howdoyoufindthem?

– mustprovidegoodperformance

• cachingmaybenecessary

• piecesmayhavetobereassignedtootherlocations

Page 37: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

MakingItWork(sortof…)• Assigneachblockauniquen-bitID

– cryptohashofitscontents• Assigneachcomputerauniquen-bitID

• StoreblockatcomputerthathasclosestID

• Routerequestsforthatblocktothatcomputer

0x2a74ca56 0x9da6f453

0x529e02f80xd53b7621

Data Block 10x87a6df52

I want Block 1

Page 38: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

OverlayNetworks

Page 39: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

MakingIt(really)Work(withhighprobability)• Assigneachblockauniquen-bitID

– cryptohashofitscontents• Assigneachcomputerauniquen-bitID

• Storemultiplecopiesofblockseachatanumberofcomputers

• StoreblockaddressesatcomputerthathasclosestID– addressesarecachedatothernodes

• Routerequestsforthatblocktothatcomputer– requestisredirectedtonearestcomputerthathascopyofblock

0x2a74ca56 0x9da6f453

0x529e02f80xd53b7621

Data Block 10x87a6df52

0x87a6df52 locations: 0x2a74ca56 0xd53b7621

Data Block 10x87a6df52

I want Block 1

Page 40: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

PublishingD A

B

C

R ABC

A

A

A

A A

A

B

B

B

B

B BC C

C

C C

?

Page 41: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Tapestry

• Distributedobjectlocationandrouting(DOLR)– youimplementitinthesecondprogrammingassignment

Page 42: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

MorePuddleStoreIssues

• Howarefilesnamed?– fileID=CryptoHash(filename)

• Howarefilesupdated?– carefully…

Page 43: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CopyonWrite(1)

Indirect Block

Data Block 1 Data Block 4

Data Block 2 Data Block 3

Version Node

fileID

ModifiedData Block 4

Indirect Block

ModifiedData Block 3

Page 44: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

CopyonWrite(2)

Indirect Block

Data Block 1 Data Block 4

Data Block 2 Data Block 3

Version Node

fileID

ModifiedData Block 4

Indirect Block

ModifiedData Block 3

Page 45: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

MoreRedundancy

Indirect Block

Data Block 1 Data Block 4

Data Block 2 Data Block 3

fileID

ModifiedData Block 4

Indirect Block

ModifiedData Block 3

Version Node

Page 46: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Raft

• Multipleclientsupdatefileconcurrently• Eachcommunicateswithdifferentservers

– serverspropagatechangestoallcopies

• Howdoweensurethatallcopiesareupdatedinthesameorder?– ordermatters...

• Raft– thirdprogrammingassignment

Page 47: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

FinalPuddleStore

• Youputallthistogether– wegiveyoutheBdesign

• ifyouimplementitcompletely:yougetaB

– ifyouimproveit(reasonablywell):yougetanA(anditmaycountasacapstone)

• you’reencouragedtodiscussyourdesignwithclassmates

Top Secret

Page 48: CS 138: Distributed Systemscs.brown.edu/courses/cs138/s18/lectures/L1_Intro.pdfFinal PuddleStore • You put all this together – we give you the B design • if you implement it

Announcements

• CS138Social• Where:CIT3rdFloorAtrium• When:6-8pm• What:MeetTAs

• Filloutandsigncheatingpolicy• TAwillsendthisouttonight

• Project1outtonight• Writeaminerandminingpoolmanager• Due:Feb13