Table Of Content(cid:2)
DistributedSystems
(cid:2) (cid:2)
(cid:2)
(cid:2)
IEEEPress
445HoesLane
Piscataway,NJ08854
IEEEPressEditorialBoard
SarahSpurgeon,EditorinChief
JónAtliBenediktsson AndreasMolisch DiomidisSpinellis
AnjanBose SaeidNahavandi AhmetMuratTekalp
AdamDrobot JeffreyReed
Peter(Yong)Lian ThomasRobertazzi
AboutIEEEComputerSociety
IEEEComputerSocietyistheworld’sleadingcomputingmembershiporganization
andthetrustedinformationandcareer-developmentsourceforaglobalworkforceof
(cid:2) (cid:2)
technologyleadersincluding:professors,researchers,softwareengineers,IT
professionals,employers,andstudents.Theunmatchedsourcefortechnology
information,inspiration,andcollaboration,theIEEEComputerSocietyisthesource
thatcomputingprofessionalstrusttoprovidehigh-quality,state-of-the-artinformation
onanon-demandbasis.TheComputerSocietyprovidesawiderangeofforumsfortop
mindstocometogether,includingtechnicalconferences,publications,anda
comprehensivedigitallibrary,uniquetrainingwebinars,professionaltraining,andthe
TechLeaderTrainingPartnerProgramtohelporganizationsincreasetheirstaff’s
technicalknowledgeandexpertise,aswellasthepersonalizedinformationtoolmy
Computer.Tofindoutmoreaboutthecommunityfortechnologyleaders,visit
http://www.computer.org.
IEEE/WileyPartnership
TheIEEEComputerSocietyandWileypartnershipallowstheCSPressauthoredbook
programtoproduceanumberofexcitingnewtitlesinareasofcomputerscience,
computing,andnetworkingwithaspecialfocusonsoftwareengineering.IEEE
ComputerSocietymembersreceivea35%discountonWileytitlesbyusingtheir
memberdiscountcode.PleasecontactIEEEPressfordetails.
Tosubmitquestionsabouttheprogramorsendproposals,pleasecontactMary
Hatcher,Editor,Wiley-IEEEPress:Email:mhatcher@wiley.com,JohnWiley&Sons,
Inc.,111RiverStreet,Hoboken,NJ07030-5774.
(cid:2)
(cid:2)
Distributed Systems
Theory and Applications
Ratan K. Ghosh
FormerProfessor
IITKanpur
(cid:2) (cid:2)
Hiranmay Ghosh
FormerAdviser
TCSResearch
AdjunctProfessor
IITJodhpur
(cid:2)
(cid:2)
Copyright©2023byTheInstituteofElectricalandElectronicsEngineers,Inc.Allrights
reserved.
PublishedbyJohnWiley&Sons,Inc.,Hoboken,NewJersey.Publishedsimultaneouslyin
Canada.
Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmittedinany
formorbyanymeans,electronic,mechanical,photocopying,recording,scanning,orotherwise,
exceptaspermittedunderSection107or108ofthe1976UnitedStatesCopyrightAct,without
eitherthepriorwrittenpermissionofthePublisher,orauthorizationthroughpaymentofthe
appropriateper-copyfeetotheCopyrightClearanceCenter,Inc.,222RosewoodDrive,Danvers,
MA01923,(978)750-8400,fax(978)750-4470,oronthewebatwww.copyright.com.Requeststo
thePublisherforpermissionshouldbeaddressedtothePermissionsDepartment,JohnWiley&
Sons,Inc.,111RiverStreet,Hoboken,NJ07030,(201)748-6011,fax(201)748-6008,oronlineat
http://www.wiley.com/go/permission.
Trademarks:WileyandtheWileylogoaretrademarksorregisteredtrademarksofJohnWiley&
Sons,Inc.and/oritsaffiliatesintheUnitedStatesandothercountriesandmaynotbeused
withoutwrittenpermission.Allothertrademarksarethepropertyoftheirrespectiveowners.
JohnWiley&Sons,Inc.isnotassociatedwithanyproductorvendormentionedinthisbook.
LimitofLiability/DisclaimerofWarranty:Whilethepublisherandauthorhaveusedtheirbest
effortsinpreparingthisbook,theymakenorepresentationsorwarrantieswithrespecttothe
accuracyorcompletenessofthecontentsofthisbookandspecificallydisclaimanyimplied
warrantiesofmerchantabilityorfitnessforaparticularpurpose.Nowarrantymaybecreatedor
extendedbysalesrepresentativesorwrittensalesmaterials.Theadviceandstrategiescontained
hereinmaynotbesuitableforyoursituation.Youshouldconsultwithaprofessionalwhere
appropriate.Neitherthepublishernorauthorshallbeliableforanylossofprofitoranyother
commercialdamages,includingbutnotlimitedtospecial,incidental,consequential,orother
damages.Further,readersshouldbeawarethatwebsiteslistedinthisworkmayhavechanged
(cid:2) ordisappearedbetweenwhenthisworkwaswrittenandwhenitisread.Neitherthepublisher (cid:2)
norauthorsshallbeliableforanylossofprofitoranyothercommercialdamages,includingbut
notlimitedtospecial,incidental,consequential,orotherdamages.
Forgeneralinformationonourotherproductsandservicesorfortechnicalsupport,please
contactourCustomerCareDepartmentwithintheUnitedStatesat(800)762-2974,outsidethe
UnitedStatesat(317)572-3993orfax(317)572-4002.
Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsin
printmaynotbeavailableinelectronicformats.FormoreinformationaboutWileyproducts,
visitourwebsiteatwww.wiley.com.
LibraryofCongressCataloging-in-PublicationData
Names:Ghosh,RatanK.,author.|Ghosh,Hiranmay,author.
Title:Distributedsystems:theoryandapplications/RatanK.Ghosh,
HiranmayGhosh.
Description:Hoboken,NewJersey:Wiley,[2023]|Includesindex.
Identifiers:LCCN2022055650(print)|LCCN2022055651(ebook)|ISBN
9781119825937(cloth)|ISBN9781119825944(adobepdf)|ISBN
9781119825951(epub)
Subjects:LCSH:Electronicdataprocessing–Distributedprocessing.|
Computernetworks.
Classification:LCCQA76.9.D5G4862023(print)|LCCQA76.9.D5(ebook)|
DDC004/.36–dc23/eng/20221207
LCrecordavailableathttps://lccn.loc.gov/2022055650
LCebookrecordavailableathttps://lccn.loc.gov/2022055651
CoverDesign:Wiley
CoverImage:©ProStockStudio/Shutterstock
Setin9.5/12.5ptSTIXTwoTextbyStraive,Chennai,India
(cid:2)
(cid:2)
v
Contents
AbouttheAuthors xv
Preface xvii
Acknowledgments xxi
Acronyms xxiii
1 Introduction 1
1.1 AdvantagesofDistributedSystems 1
1.2 DefiningDistributedSystems 3
(cid:2) (cid:2)
1.3 ChallengesofaDistributedSystem 5
1.4 GoalsofDistributedSystem 6
1.4.1 SingleSystemView 7
1.4.2 HidingDistributions 7
1.4.3 DegreesandDistributionofHiding 9
1.4.4 Interoperability 10
1.4.5 DynamicReconfiguration 10
1.5 ArchitecturalOrganization 11
1.6 OrganizationoftheBook 12
Bibliography 13
2 TheInternet 15
2.1 OriginandOrganization 15
2.1.1 ISPsandtheTopologyoftheInternet 17
2.2 AddressingtheNodes 17
2.3 NetworkConnectionProtocol 20
2.3.1 IPProtocol 22
2.3.2 TransmissionControlProtocol 22
2.3.3 UserDatagramProtocol 22
2.4 DynamicHostControlProtocol 23
2.5 DomainNameService 24
(cid:2)
(cid:2)
vi Contents
2.5.1 ReverseDNSLookup 27
2.5.2 ClientServerArchitecture 30
2.6 ContentDistributionNetwork 32
2.7 Conclusion 34
Exercises 34
Bibliography 35
3 ProcesstoProcessCommunication 37
3.1 CommunicationTypesandInterfaces 38
3.1.1 SequentialType 38
3.1.2 DeclarativeType 39
3.1.3 SharedStates 40
3.1.4 MessagePassing 41
3.1.5 CommunicationInterfaces 41
3.2 SocketProgramming 42
3.2.1 SocketDataStructures 43
3.2.2 SocketCalls 44
3.3 RemoteProcedureCall 48
3.3.1 XMLRPC 52
3.4 RemoteMethodInvocation 55
(cid:2) (cid:2)
3.5 Conclusion 59
Exercises 59
AdditionalWebResources 61
Bibliography 61
4 Microservices,Containerization,andMPI 63
4.1 MicroserviceArchitecture 64
4.2 RESTRequestsandAPIs 66
4.2.1 WeatherDataUsingRESTAPI 67
4.3 CrossPlatformApplications 68
4.4 MessagePassingInterface 78
4.4.1 ProcessCommunicationModels 78
4.4.2 ProgrammingwithMPI 81
4.5 Conclusion 87
Exercises 88
AdditionalInternetResources 89
Bibliography 89
5 ClockSynchronizationandEventOrdering 91
5.1 TheNotionofClockTime 92
5.2 ExternalClockBasedMechanisms 93
(cid:2)
(cid:2)
Contents vii
5.2.1 Cristian’sAlgorithm 93
5.2.2 BerkeleyClockProtocol 94
5.2.3 NetworkTimeProtocol 95
5.2.3.1 SymmetricModeofOperation 96
5.3 EventsandTemporalOrdering 97
5.3.1 CausalDependency 99
5.4 LogicalClock 99
5.5 CausalOrderingofMessages 106
5.6 MulticastMessageOrdering 107
5.6.1 ImplementingFIFOMulticast 110
5.6.2 ImplementingCausalOrdering 112
5.6.3 ImplementingTotalOrdering 113
5.6.4 ReliableMulticast 114
5.7 IntervalEvents 115
5.7.1 ConceptualNeighborhood 116
5.7.2 SpatialEvents 118
5.8 Conclusion 120
Exercises 121
Bibliography 123
(cid:2) (cid:2)
6 GlobalStatesandTerminationDetection 127
6.1 CutsandGlobalStates 127
6.1.1 GlobalStates 132
6.1.2 RecordingofGlobalStates 134
6.1.3 ProbleminRecordingGlobalState 138
6.2 LivenessandSafety 140
6.3 TerminationDetection 143
6.3.1 SnapshotBasedTerminationDetection 144
6.3.2 RingMethod 145
6.3.3 TreeMethod 148
6.3.4 WeightThrowingMethod 151
6.4 Conclusion 153
Exercises 154
Bibliography 156
7 LeaderElection 157
7.1 ImpossibilityResult 158
7.2 BullyAlgorithm 159
7.3 Ring-BasedAlgorithms 160
7.3.1 CirculateIDsAlltheWay 161
7.3.2 AsFarasanIDCanGo 162
(cid:2)
(cid:2)
viii Contents
7.4 HirschbergandSinclairAlgorithm 163
7.5 DistributedSpanningTreeAlgorithm 167
7.5.1 SingleInitiatorSpanningTree 167
7.5.2 MultipleInitiatorsSpanningTree 170
7.5.3 MinimumSpanningTree 176
7.6 LeaderElectioninTrees 176
7.6.1 OverviewoftheAlgorithm 176
7.6.2 ActivationStage 177
7.6.3 SaturationStage 178
7.6.4 ResolutionStage 179
7.6.5 TwoNodesEnterSATURATEDState 180
7.7 LeasedLeaderElection 182
7.8 Conclusion 184
Exercises 185
Bibliography 187
8 MutualExclusion 189
8.1 SystemModel 190
8.2 Coordinator-BasedSolution 192
8.3 Assertion-BasedSolutions 192
(cid:2) (cid:2)
8.3.1 Lamport’sAlgorithm 192
8.3.2 ImprovementtoLamport’sAlgorithm 195
8.3.3 Quorum-BasedAlgorithms 196
8.4 Token-BasedSolutions 203
8.4.1 SuzukiandKasami’sAlgorithm 203
8.4.2 Singhal’sHeuristicallyAidedAlgorithm 206
8.4.3 Raymond’sTree-BasedAlgorithm 212
8.5 Conclusion 214
Exercises 215
Bibliography 216
9 AgreementsandConsensus 219
9.1 SystemModel 220
9.1.1 FailuresinDistributedSystem 221
9.1.2 ProblemDefinition 222
9.1.3 AgreementProblemandItsEquivalence 223
9.2 ByzantineGeneralProblem(BGP) 225
9.2.1 BGPSolutionUsingOralMessages 228
9.2.2 PhaseKingAlgorithm 232
9.3 CommitProtocols 233
9.3.1 Two-PhaseCommitProtocol 234
(cid:2)