Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Architecture Introduction to. What is Architecture? A software architecture is an abstract view of a software system distinct from the details.

Similar presentations


Presentation on theme: "Distributed Architecture Introduction to. What is Architecture? A software architecture is an abstract view of a software system distinct from the details."— Presentation transcript:

1 Distributed Architecture Introduction to

2 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

3 Why Architecture Matters

4 Accidental Architecture Every… system has an architecture. While some of these architectures are intentional, most appear to be accidental Grady Booch

5 Requirements Analysis DesignCode and TestIntegrationSystem Test Waterfall Process

6 Requirements Analysis DesignCode and TestIntegrationSystem Test Waterfall Process Analysis Paralysis Massive Integration Design divorced from reality

7 Manifesto for Agile Software Development We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan That is, while there is value in the items on the right, we value the items on the left more.

8 Scrum: An agile Process

9 ArchitectCode Techies crave Extremes

10 Functional requirements What the system should do. Use cases, User stories, acceptance criteria Defines passing QA Day to day you focus on this

11 Nonfunctional requirements What the system should be. Extremely expensive or impossible to “fix” later on Defined passing Production Assumed by your customers and users

12 Nonfunctional Requirements Availability Stability Efficiency Reliability Maintainability Extensibility Fault Tolerance Security Capacity Latency Flexibility Scalability

13 Functional: Passed QA Beautiful site (in my opinion) Easy to use Nonfunctional: Failed Production Availability Stability Latency Capacity Throughput

14

15 Architecture There is no best architecture

16 Pacemakers and Guided Missiles

17 The Flying Buttress

18 Patterns

19 Example: Layered Architecture

20 Three Tier Architecture The classic 3 tier architecture

21 N-Tier Architecture Because three tiers wasn’t enough!

22 N-Tier Architecture SHAREPOINT BIZTALK SQL SERVER Windows Server 2008 SMS License management IIS

23 Questions about Architecture?

24 Distributed Architecture Designs appropriate for small brochureware websites fail outrageously when applied to thousand- user, transactional, distributed systems... Michael T. Nygard

25 Key Constraints on Distributed Systems Stability Reliability and fault tolerance Consistency Capacity and Scalability Security

26 Scenario: Stability You 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.

27 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"; }

28 6. Registered Identity Verification Database 2. Verify 3. Verified Site Server Stability 4. Save User 5. User Saved 1. Register

29 6. Registered Identity Verification Database 2. Verify 3. Verified Site Server Unbalanced Capacities 4. Save User 5. User Saved 1. Register

30 Identity Verification Blocked Threads Site Server Verify sally Verify bob joe verified Verify joe Verify sally Verify joe Verify bob joe verified

31 Cascading Failures Site Server

32 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

33 Identity Verification Pattern 1: Timeouts Site Server

34 private void BeginRegister(RegistrationInfo registrationInfo, Function callback) { try { identityService.EndIdentity += identityService_EndIdentity(callback) identityService.BeginIdentity(registrationInfo); } catch (Exception) { callback("errorpage"); } private void identityService_EndIdentity(bool success, Function callback) { if (success) { callback("register_success.htm"); } callback("register_failure.htm"); } Pattern 2: Non-blocking I/O

35 Identity Verification Site Server

36 For Users… ==

37 The site is stable. We’re still failing.

38 What’s the president recommending?

39 What might be happening Thank you. We’ll email you when you are verified.

40 What might be happening Identity Verification

41 “The” Registration Process When two principles are pushing in opposite directions, some underlying assumption is wrong. Often the word the is the culprit Udi Dahan

42 Read this again You 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.

43 Pattern 3: Decoupling Site Server Thank you. We’ll email you when you are verified Pending Registration Database

44 Pattern 3: Decoupling Pending Registration Database Verification Application Identity Verification

45 Scenario 2: Reliability You 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.

46 5. Success RX Service 2. Fill RX 3. RX ID Site Server Reliability 1. Prescribe Database 4. RX ID and Fill Info 5. Record Updated

47 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"; }

48 404 Timeout RX Service 2. Prescribe Site Server What if the network goes down? 1. Prescribe

49 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"; }

50 RX Service Site Server Can I retry? Prescribe RX Service Site Server Prescribe Got it, but I couldn’t get Back to you. 404 Timeout

51 RX Service Site Server Pattern 1: Idempotency Prescribe RX Service Site Server Prescribe Got it, but I couldn’t get Back to you. 404 Timeout Sheesh… I already got it!

52 5. Success RX Service 2. Fill RX 3. RX ID Site Server What if the database is down? 1. Prescribe Database 4. Update Patient Record

53 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"; }

54 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"; }

55 Pattern 2: Transactional Queues

56 3. Pending Site Server Transactional Queue 1. Prescribe Fill RX Message Queue

57 Inserting into a Queue private string Prescribe(PrescriptionInfo prescriptionInfo) { try { Queue.save(new RXPrescribeMessage(prescriptionInfo)); return "rxPending.htm"; } catch (Exception) { return "errorpage.htm"; }

58 Transactional Queue Queue rxPrescribeMessage RX Service Fill rx rx ID Handler rxDBUpdateMessage

59 Transactional Queue Queue rxDBUpdateMessage Save rx Handler Database

60 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) }

61 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.


Download ppt "Distributed Architecture Introduction to. What is Architecture? A software architecture is an abstract view of a software system distinct from the details."

Similar presentations


Ads by Google