Design Patterns in
Distributed System
Tom Huynh
tom.huynh@thfins.com
Agenda
O What is distributed system?
O CAP theorem
O Fallacies of Distributed system
O Some distributed design problems and solutions
O CQRS & Event Sourcing
O Enterprise Service Bus
O Publisher/Subscriber pattern
O Demo pub/sub pattern in AngularJS SPA
O QA
What is Distributed System?
N1 N2
N3 N4
LAN/WAN Fiber, cable,
satellite, etc
CAP theorem
O Consistency
O Availability
O Partition Tolerance
1
4
2
3
Can have ONLY maximum 2 promises
at same time
CAP theorem - Proof
1 2
Fallacies of Distributed system
O Network is reliable.
O Latency is zero.
O Bandwidth in infinite.
O Network is secure.
O Topology does not change.
O There is one administrator.
O Transport cost is zero.
O Network is homogeneous.
CAP Theorem - Fallacies
O Network not reliable
O Latency is zero
O Bandwidth is infinite
O Network is secure
O Topology doesn’t change
O 1 administrator
O Transport cost is zero
O Network is homogeneous
O Consistency
O Availability
O Partition Tolerance
CAP Theorem - Fallacies
Agenda
O What is distributed system?
O CAP theorem
O Fallacies of Distributed system
O Some distributed design problems and solutions
O CQRS & Event Sourcing
O Enterprise Service Bus
O Publisher/Subscriber pattern
O Demo pub/sub pattern in AngularJS SPA
O QA
CQRS
O A pattern
O Not an architecture
O Not an architectural style
O Not a principle
O Command Query Responsibility Segregation
O Domain applicable
CQRS - Durability (Cont.)
CQRS - Scaling (Cont.)
Event Sourcing
Enterprise Service Bus
ESB – 2 kinds
O Decentralized
O Independently configurable
services
O Collaboration among teams
O Services make all decisions
O NServiceBus
O MassTransit
O Rhino Service Bus
O Brokered
O Single point of config
O Single governing body
O Middleware makes some
decisions
O TIBCO
O BizTalk
O Web Sphere
Publisher/Subscriber pattern
O Problem:
O How an application send messages to other
applications that are interested in receiving
the messages without knowing the identities
of the receivers?
O Tight coupling of sender and receiver
applications
O Solution: P/S
Sender
Receiver 2
Receiver 1
Publisher/Subscriber pattern
Publisher
Event 1
Event 2
SubScriber1
SubScriber1
SubScriber1
Pub/sub demo
O AngularJS
O Controllers
Root scope
Scope 2Scope 1
Scope 4Scope 3
Reference
O Farm Credit Service of America knowledge
base.
O Presentations of Michael L Perry, Dino
Esposito, Greg Young, etc.
Q&A

Design patterns in distributed system

  • 1.
    Design Patterns in DistributedSystem Tom Huynh tom.huynh@thfins.com
  • 2.
    Agenda O What isdistributed system? O CAP theorem O Fallacies of Distributed system O Some distributed design problems and solutions O CQRS & Event Sourcing O Enterprise Service Bus O Publisher/Subscriber pattern O Demo pub/sub pattern in AngularJS SPA O QA
  • 3.
    What is DistributedSystem? N1 N2 N3 N4 LAN/WAN Fiber, cable, satellite, etc
  • 4.
    CAP theorem O Consistency OAvailability O Partition Tolerance 1 4 2 3 Can have ONLY maximum 2 promises at same time
  • 5.
    CAP theorem -Proof 1 2
  • 6.
    Fallacies of Distributedsystem O Network is reliable. O Latency is zero. O Bandwidth in infinite. O Network is secure. O Topology does not change. O There is one administrator. O Transport cost is zero. O Network is homogeneous.
  • 7.
    CAP Theorem -Fallacies O Network not reliable O Latency is zero O Bandwidth is infinite O Network is secure O Topology doesn’t change O 1 administrator O Transport cost is zero O Network is homogeneous O Consistency O Availability O Partition Tolerance
  • 8.
    CAP Theorem -Fallacies
  • 9.
    Agenda O What isdistributed system? O CAP theorem O Fallacies of Distributed system O Some distributed design problems and solutions O CQRS & Event Sourcing O Enterprise Service Bus O Publisher/Subscriber pattern O Demo pub/sub pattern in AngularJS SPA O QA
  • 10.
    CQRS O A pattern ONot an architecture O Not an architectural style O Not a principle O Command Query Responsibility Segregation O Domain applicable
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
    ESB – 2kinds O Decentralized O Independently configurable services O Collaboration among teams O Services make all decisions O NServiceBus O MassTransit O Rhino Service Bus O Brokered O Single point of config O Single governing body O Middleware makes some decisions O TIBCO O BizTalk O Web Sphere
  • 16.
    Publisher/Subscriber pattern O Problem: OHow an application send messages to other applications that are interested in receiving the messages without knowing the identities of the receivers? O Tight coupling of sender and receiver applications O Solution: P/S Sender Receiver 2 Receiver 1
  • 17.
    Publisher/Subscriber pattern Publisher Event 1 Event2 SubScriber1 SubScriber1 SubScriber1
  • 18.
    Pub/sub demo O AngularJS OControllers Root scope Scope 2Scope 1 Scope 4Scope 3
  • 19.
    Reference O Farm CreditService of America knowledge base. O Presentations of Michael L Perry, Dino Esposito, Greg Young, etc.
  • 20.