Introduction to Distributed Architecture
-
Upload
justin-weinberg -
Category
Technology
-
view
66 -
download
1
Transcript of Introduction to Distributed Architecture
![Page 1: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/1.jpg)
Distributed Architecture
Introduction to
![Page 2: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/2.jpg)
What is Architecture? A software architecture is an abstract view of a software system distinct from the details of implementation, algorithms, and data representation.
SEI @ Carnegie Mellon
![Page 3: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/3.jpg)
Why Architecture Matters
![Page 4: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/4.jpg)
Accidental Architecture
Every… system has an architecture. While some of these architectures are intentional, most appear to be accidental
Grady Booch
![Page 5: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/5.jpg)
Requirements Analysis
Design
Code and Test
Integration
System Test
Waterfall Process
![Page 6: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/6.jpg)
Requirements Analysis
Design
Code and Test
Integration
System Test
Waterfall Process
Analysis Paralysis
MassiveIntegration
Design divorced from reality
![Page 7: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/7.jpg)
Manifesto for Agile Software Development
We are uncovering better ways of developingsoftware by doing it and helping others do it.Through this work we have come to value:
Individuals and interactions over processes and toolsWorking software over comprehensive documentationCustomer collaboration over contract negotiationResponding to change over following a plan
That is, while there is value in the items onthe right, we value the items on the left more.
![Page 8: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/8.jpg)
Scrum: An agile Process
![Page 9: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/9.jpg)
Architect Code
Techies crave Extremes
![Page 10: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/10.jpg)
Functional requirementsWhat the system should do.• Use cases, User stories, acceptance criteria• Defines passing QA• Day to day you focus on this
![Page 11: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/11.jpg)
Nonfunctional requirementsWhat the system should be.• Extremely expensive or impossible to “fix”
later on• Defined passing Production• Assumed by your customers and users
![Page 12: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/12.jpg)
Nonfunctional Requirements• Availability• Stability• Efficiency• Reliability• Maintainability• Extensibility
• Fault Tolerance• Security• Capacity• Latency• Flexibility• Scalability
![Page 13: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/13.jpg)
Functional: Passed QABeautiful site (in my opinion)Easy to use
Nonfunctional: Failed ProductionAvailability StabilityLatency CapacityThroughput
![Page 14: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/14.jpg)
![Page 15: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/15.jpg)
ArchitectureThere is no best architecture
![Page 16: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/16.jpg)
Pacemakers and Guided Missiles
![Page 17: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/17.jpg)
The Flying Buttress
![Page 18: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/18.jpg)
Patterns
![Page 19: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/19.jpg)
Example: Layered Architecture
![Page 20: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/20.jpg)
Three Tier ArchitectureThe classic 3 tier architecture
![Page 21: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/21.jpg)
N-Tier ArchitectureBecause three tiers wasn’t enough!
![Page 22: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/22.jpg)
N-Tier Architecture
SHAREPOINT
BIZTALK
SQL SERVER
Windows Server 2008
SMS
License managementIIS
![Page 23: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/23.jpg)
Questions about Architecture?
![Page 24: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/24.jpg)
Distributed ArchitectureDesigns appropriate for small brochureware websites fail outrageously when applied to thousand-user, transactional, distributed systems...
Michael T. Nygard
![Page 25: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/25.jpg)
Key Constraints on Distributed Systems
• Stability • Reliability and fault tolerance• Consistency• Capacity and Scalability• Security
![Page 26: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/26.jpg)
Scenario: StabilityYou are the lead developer on a national health care site that will register millions of users a week. You are responsible for the signup process.
Your team must verify the identity of users with a third party API. You call the service and the third party system will return a boolean true if the identity is valid or false otherwise.
![Page 27: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/27.jpg)
private string Register(RegistrationInfo registrationInfo) { try { bool validIdentity = identityService.verifyIdentity(registrationInfo);
if (validIdentity) { database.save(registrationInfo); return “register_success.htm"; }
return “register_failure.htm"; } catch (Exception) { return "errorpage.htm"; }
}
![Page 28: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/28.jpg)
6. RegisteredIdentity
Verification
Database
2. Verify
3. VerifiedSite Server
Stability
4. Save User5. User Saved
1. Register
![Page 29: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/29.jpg)
6. RegisteredIdentity
Verification
Database
2. Verify
3. VerifiedSite Server
Unbalanced Capacities
4. Save User5. User Saved
1. Register
![Page 30: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/30.jpg)
Identity Verification
Blocked Threads
Site ServerVerify sally
Verify bob
joe verified
Verify joe
Verify sally
Verify joe
Verify bobVerify bob
Verify bob
Verify bob
Verify bob
joe verified
![Page 31: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/31.jpg)
Cascading Failures
Site Server
Site Server
Site Server
Site Server
![Page 32: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/32.jpg)
private string Register(RegistrationInfo registrationInfo) { try {
identityService.Timeout = 10000; bool validIdentity = identityService.verifyIdentity(registrationInfo);
if (verified) { db.save(registrationInfo); return “register_success.htm"; }
return “register_failure.htm"; } catch (Exception) { return "errorpage.htm"; } }
Pattern 1: Timeouts
![Page 33: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/33.jpg)
Identity Verification
Pattern 1: Timeouts
Site Server
![Page 34: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/34.jpg)
private void BeginRegister(RegistrationInfo registrationInfo, Function<string> callback) { try {
identityService.EndIdentity += identityService_EndIdentity(callback) identityService.BeginIdentity(registrationInfo);
} catch (Exception) { callback("errorpage"); }
}
private void identityService_EndIdentity(bool success, Function<string> callback) { if (success) { callback("register_success.htm"); } callback("register_failure.htm"); }
Pattern 2: Non-blocking I/O
![Page 35: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/35.jpg)
Pattern 2: Non-blocking I/O
Identity VerificationSite Server
![Page 36: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/36.jpg)
For Users…
==
![Page 37: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/37.jpg)
The site is stable. We’re still failing.
![Page 38: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/38.jpg)
What’s the president recommending?
![Page 39: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/39.jpg)
What might be happeningThank you. We’ll email
you when you are verified.
![Page 40: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/40.jpg)
What might be happening
Identity Verification
![Page 41: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/41.jpg)
“The” Registration ProcessWhen two principles are pushing in opposite directions, some underlying assumption is wrong. Often the word the is the culpritUdi Dahan
![Page 42: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/42.jpg)
Read this againYou are the lead developer on a national health care site that will register millions of users a week. You are responsible for the signup process.
Your team must verify the identity of users with a third party API. You call the service and the third party system will return a boolean true if the identity is valid or false otherwise.
![Page 43: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/43.jpg)
Pattern 3: Decoupling
Site Server
Thank you. We’ll email you when you are
verified
Pending Registration
Database
![Page 44: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/44.jpg)
Pattern 3: Decoupling
Pending Registration
Database
Verification Application
Identity Verification
![Page 45: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/45.jpg)
Scenario 2: ReliabilityYou are the lead developer on a hospital’s prescription filling service. Your RX wholesaler has provided you with an HTTPS endpoint to integrate with.
It is critical a prescription is not accidently prescribed twice and that prescriptions are not lost.
![Page 46: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/46.jpg)
5. Success RX Service
2. Fill RX
3. RX IDSite Server
Reliability
1. Prescribe
Database
4. RX ID and Fill Info5. Record Updated
![Page 47: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/47.jpg)
Invoking the Service private string Prescribe(PrescriptionInfo prescriptionInfo) { try { RxService rxService = new RxService(); int rxID = rxService.Prescribe(prescriptionInfo);
database.Save(rxId, prescriptionInfo);
return "success.htm"; }
catch (Exception) { return "errorpage.htm"; }
}
![Page 48: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/48.jpg)
404 Timeout RX Service
2. Prescribe
Site Server
What if the network goes down?
1. Prescribe
![Page 49: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/49.jpg)
Invoking the Service private string Prescribe(PrescriptionInfo prescriptionInfo) { try { RxService rxService = new RxService(); int rxID = rxService.Prescribe(prescriptionInfo); database.Save(rxId, prescriptionInfo);
return "success.htm"; }
catch (Exception) { return "errorpage.htm"; }
}
![Page 50: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/50.jpg)
RX ServiceSite Server
Can I retry?
Prescribe
RX ServiceSite ServerPrescribe
Got it, but I couldn’t get Back to you.
404 Timeout
![Page 51: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/51.jpg)
RX ServiceSite Server
Pattern 1: Idempotency
Prescribe
RX ServiceSite ServerPrescribe
Got it, but I couldn’t get Back to you.
404 Timeout
Sheesh… I already got it!
![Page 52: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/52.jpg)
5. Success RX Service
2. Fill RX
3. RX IDSite Server
What if the database is down?
1. Prescribe
Database
4. Update Patient Record
![Page 53: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/53.jpg)
Invoking the Service private string Prescribe(PrescriptionInfo prescriptionInfo) { try { RxService rxService = new RxService(); int rxID = rxService.Prescribe(prescriptionInfo);
database.Save(rxId, prescriptionInfo);
return "success.htm"; }
catch (Exception) { return "errorpage.htm"; }
}
![Page 54: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/54.jpg)
Can We Guarantee this code? private string Prescribe(PrescriptionInfo prescriptionInfo) { try { RxService rxService = new RxService(); int rxID = rxService.Prescribe(prescriptionInfo);
database.Save(rxId, prescriptionInfo);
return "success.htm"; }
catch (Exception) { return "errorpage.htm"; }
}
![Page 55: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/55.jpg)
Pattern 2: Transactional Queues
![Page 56: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/56.jpg)
3. PendingSite Server
Transactional Queue
1. Prescribe
Fill RX Message Queue
![Page 57: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/57.jpg)
Inserting into a Queue private string Prescribe(PrescriptionInfo prescriptionInfo) { try { Queue.save(new RXPrescribeMessage(prescriptionInfo)); return "rxPending.htm"; }
catch (Exception) { return "errorpage.htm"; } }
![Page 58: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/58.jpg)
Transactional Queue
Queue
rxPrescribeMessage
RX Service
Fill rx
rx IDHandlerrxDBUpdateMessage
![Page 59: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/59.jpg)
Transactional Queue
QueuerxDBUpdateMessage Save rxHandler Database
![Page 60: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/60.jpg)
Message Handlers public void HandleRXPrescribeMessage(RXPrescribeMessage message) { var prescriptionInfo = message.prescriptionInfo;
RxService rxService = new RxService(); int rxID = rxService.Prescribe(prescriptionInfo); Queue.save(new RXDBUpdateMessage(rxID, prescriptionInfo)); }
public void HandleDBUpdateMessage(RXDBUpdateMessage message) { var rxId = message.rxID; var prescriptionInfo = message.prescriptionInfo
database.Update(message.rxID, message.prescriptionInfo) }
![Page 61: Introduction to Distributed Architecture](https://reader034.fdocuments.in/reader034/viewer/2022042618/58ab6a4f1a28abb54e8b47d1/html5/thumbnails/61.jpg)
Nygard, Michael T. Cynical software expects bad things to happen and is never surprised when they do. Cynical software doesn’t even trust itself.. It refuses to get too intimate with other systems, because it could get hurt.