Distributed Applications Software Engineering 2017 Alessio Gambi - - - PowerPoint PPT Presentation

distributed applications
SMART_READER_LITE
LIVE PREVIEW

Distributed Applications Software Engineering 2017 Alessio Gambi - - - PowerPoint PPT Presentation

Distributed Applications Software Engineering 2017 Alessio Gambi - Saarland University Based on the work of Cesare Pautasso, Christoph Dorn, and other sources ReCap Software Architecture A software systems architecture is the set of


slide-1
SLIDE 1

Distributed Applications

Software Engineering 2017 Alessio Gambi - Saarland University

Based on the work of Cesare Pautasso, Christoph Dorn, and other sources

slide-2
SLIDE 2

ReCap

slide-3
SLIDE 3

Software Architecture

A software system’s architecture is the set of principal design decisions made about the system.

  • N. Taylor et al.

Abstraction Communication Visualization and Representation Quality Attributes

slide-4
SLIDE 4

Every system a software architecture has What designers want

slide-5
SLIDE 5

Design

  • Architectural Styles
  • Architectural Patterns
  • Building Blocks
  • Software Components
  • Component API/Interfaces
  • Software Connectors
slide-6
SLIDE 6

3-Tier Architecture

Web Browser Front End App Server Back End

Business logic Presentation Data source

slide-7
SLIDE 7

Backend Parser ArticleEdit Reads Writes ArticleView Submit Logic UI Page Skinning Localization Static Resources

slide-8
SLIDE 8

Backend Parser ArticleEdit Reads Writes ArticleView Submit Logic UI Page Skinning Localization Parser Cache Static Resources Loader Cached Cached Cached Job Runner Writes Job Queue HTML File Cache Precompile/Recompile Regenerate/Invalidate

slide-9
SLIDE 9

Distributed Applications

slide-10
SLIDE 10

Client/Server

  • Many clients, active, close to users
  • One server, passive, close to data
  • Single point of failure, scalability
  • Security, scalability
slide-11
SLIDE 11

Distribution and Lifecycle

In distributed applications the lifecycle of remote

  • bjects is disjoint from the local ones.

We must explicitly design the lifecycle of those remote entities

slide-12
SLIDE 12

Distribution and Lifecycle

In distributed applications the lifecycle of remote

  • bjects is disjoint from the local ones.

We must explicitly design the lifecycle of those remote entities

Static and Lazy instances Leasing Per-request instances Pooling Client-dependent instances Passivation

slide-13
SLIDE 13

Server Process Machine Boundary Process B Client Object Server Application

n-1) shutdown n) destroy 1) create 3) invoke

Process A Client

2) invoke

Static Instances

Remote object instances exist independently of any clients They last as long as their container (server)

slide-14
SLIDE 14

Server Process Machine Boundary Servant for Obj X Server Application Process A Client

3) Invoke

  • n Obj X

Invoker

1) create 4) create 5) invoke 2) register Object “X”

Lazy Instances

Instantiate object upon first request Save computational resources

slide-15
SLIDE 15

Server Process Machine Boundary Process B Client Servant for Obj X Server Application

3) Invoke

  • n Obj X

Process A Client

2) Invoke

  • n Obj X

Invoker

1) create

Servant for Obj X

2a) create 2b) invoke 2c) destroy 3a) create 3b) invoke 3c) destroy

Per-request Instances

Each request processed by a fresh instance Provide max logical isolation (but high cost)

slide-16
SLIDE 16

Server Process Process B Client Object Server Application

5a) new Instance

Process A Client

2a) new Instance

Remote Factory

1) create

Object

2b) create 5b) create 3) invoke 4) invoke 6) invoke

Client-dependent Instances

Requests from the same client processed by the same instance (but there might be a one-to-many mapping) Remote objects extend client logic and share its state

slide-17
SLIDE 17

Server Process Object “X” Lifecycle Manager Process A Client

4) Invoke

  • n Obj X

Invoker

3) create lease 1) Create X 4) renew lease 5) invoke 2) create After lease expired: 6) destroy

Leasing

Avoid removal of per-client objects when not used by periodically renew the lease

slide-18
SLIDE 18

Pooling

Maintain a (possibly dynamic) set of generic objects to serve clients requests Clean up state before returning to the pool

Server Process Machine Boundary Servant for X Server Application Process A Client

4) Invoke

  • n Obj X

Invoker

1) create 6) invoke 3) register pooled instance “X”

Object Pool “X” Servant for X Servant for X Servant for X

2) create 7) put servant back 5) get idle servant

slide-19
SLIDE 19

Server Process Servant for “X” Lifecycle Manager Process A Client

1a,4) Invoke on Obj X

Invoker

5) activate (objId) 1b,8) invoke 7a) create 7b) activate After timeout 2a) passivate 2b) destroy 3) storeState (objId) 6) getState (objId)

Passivation

Save resources by freezing “per-client” objects Objects are reactivated upon first request

slide-20
SLIDE 20

(A)Synchronization

Remote invocations can be either synchronous

  • r asynchronous. For asynchronous invocations

we must handle the evolution of the distributed state across the nodes.

One-way Patterns Two-way Patterns

Fire and Forget Poll Object Sync with Server Callback

slide-21
SLIDE 21

Process A Process B Machine Boundary Client Requestor Invoker

1) invoke 2b) send 2a) return

Fire and Forget

Best effort (or nobody cares) semantics

slide-22
SLIDE 22

Process A Process B Client Requestor Invoker

1) invoke 2) send 3b) return

Object

3a) reply 3c) invoke

Sync with Server

Requestor ensures that the request correctly arrived 
 to server (but not processed) Delivery confirmation semantics

slide-23
SLIDE 23

Poll Object (or Future)

Local stub on client’s machine checks if results are ready

Process A Process B Client Requestor Invoker

1) invoke 2) invoke 3) isAvailable = false

Poll Object

6) getResult 4) storeResult 5) isAvailable = true

slide-24
SLIDE 24

Callback

Execute code whenever the remote request returns

Process A Process B Client Requestor Invoker

2) invoke 3) invoke

Callback Object

4) finished(result) 1) create 5) execute

slide-25
SLIDE 25

Publish/Subscribe

  • Subscription to queues or topics
  • Loose coupling
slide-26
SLIDE 26

Pub/Sub vs Event-Driven

slide-27
SLIDE 27

Pub/Sub vs Event-Driven

no specific roles local/distributed

slide-28
SLIDE 28

Pub/Sub vs Event-Driven

  • pposite roles

no specific roles mostly distributed local/distributed

slide-29
SLIDE 29

Message Bus

  • Publish
  • Subscribe
  • Notify
slide-30
SLIDE 30

MOM

Message-Oriented Middleware

Messaging Middleware Sender Receiver Receiver Receiver Queue Queue Send Message Receive Message Receive Reply Send Reply

slide-31
SLIDE 31

MOM

Message-Oriented Middleware

Messaging Middleware Sender Receiver Receiver Receiver Queue Queue Send Message Receive Message Receive Reply Send Reply

  • Processing always on

consumer

  • Queues provide

persistence and decoupling (async)

slide-32
SLIDE 32

Reply or don’t reply?

MOMs enable both request-only and request-reply interactions despite sender/receiver do not know each

  • ther addresses
slide-33
SLIDE 33

Reply or don’t reply?

MOMs enable both request-only and request-reply interactions despite sender/receiver do not know each

  • ther addresses

Uniquely identify a request message (ID) Correlation between the requests and replies MessageType=REQUEST|REPLY & MessageID = ID

+ =

slide-34
SLIDE 34

Handling Messages

  • Routing


Content-based, Dynamic

  • Filtering


Message filter

  • Transforming messages


Splitter, Aggregator

  • Transforming messages content


Normalizer, Content Enricher, Content Filter

  • Transforming message envelope


Envelope wrapper

slide-35
SLIDE 35

Content-based Routing

Destination decided using the payload

slide-36
SLIDE 36

Dynamic Routing

Destination not fixed but chosen using rules

slide-37
SLIDE 37

Message Filter

Remove un-needed messages

slide-38
SLIDE 38

Splitter

Decompose a composite message in parts

slide-39
SLIDE 39

Aggregator

Use the parts to create a composite message

slide-40
SLIDE 40

Content Filter

Filter from a composite message unneeded payload

slide-41
SLIDE 41

Content Enricher

Use additional data to augment messages

slide-42
SLIDE 42

Normalizer

Route messages to translators which transform the to a common format

slide-43
SLIDE 43

Enveloper Wrapper

Bridged delivery via wrapping messages into other messages

slide-44
SLIDE 44

Messaging Bridge

link multiple messaging systems to make messages exchanged on one also available on the others

slide-45
SLIDE 45

Pipe & Filter

  • Clean separation: filter process, pipe

transport

  • Heterogeneity and distribution
  • Only batch processing, serializable data
  • Composability, Reuse
slide-46
SLIDE 46
slide-47
SLIDE 47

Stream

  • Send
  • Receive
slide-48
SLIDE 48

Streaming

  • Infinite sequence of messages


simple/primitive, complex

  • Discrete - Messages


stock markets, twitter

  • Continuous - Data


video, audio

slide-49
SLIDE 49

Streaming Source Streaming Sink Streaming Sink Streaming Sink MW

Streaming and Data Analytics

Unicast or multicast communication channels No discrete unit of interaction (request/response) Low overhead, but mostly transport/communication

slide-50
SLIDE 50

Sync/Async Streams

  • Synchronous


Time matters (e.g., minimum transfer rate)

  • Asynchronous


Sequence matters (e.g., no specific transfer rate)

slide-51
SLIDE 51

Sync/Async Streams

  • Synchronous


Time matters (e.g., minimum transfer rate)

  • Asynchronous


Sequence matters (e.g., no specific transfer rate)

  • Isochronous


Time is essence (e.g., both min and max transfer rate)

slide-52
SLIDE 52

Incoming streams Streaming data m Output complex messages m3 m2 m1 … … … s3 s2 s1

m1 … s1 m2 … s2 m3 … s3

Streaming data s Complex stream/multiple streams data processing Application-specific data processing

Processing Model

Complex Event Processor

slide-53
SLIDE 53

Processing Model

Complex Event Processor

  • Event representation


POJO, Maps, Object-Arrays, XML, etc..

  • Continuous processing


events processes as they arrive and sent to output

  • Listeners and notifications


both incoming and outgoing events

  • Domain specific languages (DSL)


describe conditions, transformations, etc.

slide-54
SLIDE 54

EPL

Event Processing Language

https://docs.oracle.com/cd/E13157_01/wlevs/docs30/epl_guide/overview.html

Specify interests on certain types of events


event-patterns, correlations of events, and more

High-level language SQL-like

standard and new clauses

Streams replace tables; events replace rows


it’s just an analogy

Statements target single and multiple data streams

slide-55
SLIDE 55

EPL

Event Processing Language

https://docs.oracle.com/cd/E13157_01/wlevs/docs30/epl_guide/overview.html

  • Standard clauses


SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY

  • Re-casted clauses


INSERT INTO

  • New clauses


RETAIN, MATCHING, OUTPUT

slide-56
SLIDE 56

EPL

Event Processing Language

  • Retain


virtual window (constraint amount of data)

  • Matching


sequence of events (logical and temporal operators)

  • Output


control/stabilize the output rate

slide-57
SLIDE 57

Event Processing

Incoming events processed through sliding windows


  • incremental, one event

  • batched, chunks of events

Size of window limits the maximum number of events

  • r the maximum amount of time to keep them

  • time

  • length

Conditions expressed on the window and events

slide-58
SLIDE 58

Sliding Window with Length

slide-59
SLIDE 59

Filter & Slide

slide-60
SLIDE 60

Slide & Filter

slide-61
SLIDE 61

Sliding Window with Time

slide-62
SLIDE 62

Batched Window with Time

slide-63
SLIDE 63

Service Oriented

  • Components outside control
  • Standard connectors, precise interfaces
  • Interface compatibility problem
  • Loose coupling, reuse
slide-64
SLIDE 64
slide-65
SLIDE 65
slide-66
SLIDE 66

Components Services

Tight coupling

Loose coupling

Client requires library

Message exchanges

Client / Server

Peer-to-peer

Extendable

Composable

Fast

Some overhead

Small/Medium Medium/Large Buy and install

Pay-per-use

Local

Remote

slide-67
SLIDE 67

Composition/Orchestration

build systems out of the composition of existing ones

slide-68
SLIDE 68

Business Processes

  • Many alternative notations and languages


WSCI, BPML, BPEL4WS, BPSS, XPDL

  • Standard protocols and technologies


WSDL, XML, HTTP, JSON, SMTP, FTP, …

  • Two “BIG” players


SOAP + WS-*, HTTP+RESTFul

slide-69
SLIDE 69
slide-70
SLIDE 70

Messaging Bridge

link multiple messaging systems to make messages exchanged on one also available on the others

slide-71
SLIDE 71

Software Architecture

  • Work Flow Engine
  • Enterprise BUS
slide-72
SLIDE 72

https://www.slideshare.net/kumargaurav66/oracle-soaand-bpm

slide-73
SLIDE 73

Say “what what” ? In the cloud!

slide-74
SLIDE 74

Heavy vs Light

Old vs New

slide-75
SLIDE 75

https://i.stack.imgur.com/WQsEJ.jpg

Application Resource URI

HTTP GET HTTP POST HTTP PUT HTTP DEL JSON ...

Application Endpoint URI

SMTP HTTP ... MQ SOAP (WS-*)

Layered View

slide-76
SLIDE 76

http://webtechsharing.com/soap-vs-rest/

Process View

slide-77
SLIDE 77

Summary

  • Understand the size and complexity of your system

and distribute functions and data (lifecycle)

  • Embrace diversity: not only RPC, not only sync
  • Aim at satisfy your the requirements with the right

method (different patterns/styles for different parts)

slide-78
SLIDE 78

Additional Readings

  • Sam Newman, Building Microservices, 2015. http://de.slideshare.net/spnewman/

principles-of-microservices-ndc-2014

  • Markus Völter et al.: Remoting Patterns – Foundation of Enterprise, Internet and Realtime

Distributed Object Middleware, Wiley Series in Software Design Patterns, 2004

  • Thomas Erl: Service-Oriented Architecture – Concepts, Technology and Design, Prentice

Hall, 2005

  • Roy Fielding’s PhD thesis on REST: http://www.ics.uci.edu/~fielding/pubs/dissertation/

top.htm

  • Martin Fowler’s blog: https://martinfowler.com/
  • Fay Chang et al. Bigtable: a distributed storage system for structured data. (OSDI ’06)
  • Eric Redmond and Jim R. Wilson: Seven Databases in Seven Weeks – A Guide to Modern

Databases and the NoSQL Movement

  • CAP: http://www.julianbrowne.com/article/viewer/brewers-cap-theorem
  • Eventual consistency: http://queue.acm.org/detail.cfm?id=1466448
  • Java Message Service: http://www.oracle.com/technetwork/java/index-jsp-142945.html
  • Integration patterns: https://camel.apache.org/enterprise-integration-patterns.html, 


http://www.espertech.com/esper/release-5.0.0/esper-reference/html_single/index.html