modern software architecture styles and patterns

40
MODERN SOFTWARE ARCHITECTURE styles and patterns

Upload: ganesh-samarthyam

Post on 11-Apr-2017

866 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Modern Software Architecture Styles and Patterns

MODERN SOFTWARE ARCHITECTURE

styles and patterns

Page 2: Modern Software Architecture Styles and Patterns

– Roy Fielding

“an architectural style is a co-ordinated set of architectural constraints that restricts the roles/

features of architectural elements and the allowed relationships among those elements within any

architecture that conforms to that style”

R.T.Fielding “Architectural styles and the design of network-based software architectures. PhD thesis, University of California, 2000.

Page 3: Modern Software Architecture Styles and Patterns

POSA - before and after

Page 4: Modern Software Architecture Styles and Patterns

Layered

Pipe-and-Filter

Broker

Client-Server

Peer-to-Peer

Blackboard

Page 5: Modern Software Architecture Styles and Patterns

$ cat limerick.txt There was a young lady of Niger Who smiled as she rode on a tiger. They returned from the ride With the lady inside And a smile on the face of the tiger.

Page 6: Modern Software Architecture Styles and Patterns

$ cat limerick.txt | tr -cs "[:alpha:]" "\n" | awk '{print length(), $0}' | sort | uniq1 a 2 as 2 of 2 on 3 And 3 Who 3 she 3 the 3 was 4 They 4 With 4 face 4 from 4 lady 4 ride 4 rode 5 Niger 5 There 5 smile 5 tiger 5 young 6 inside 6 smiled 8 returned

Page 7: Modern Software Architecture Styles and Patterns

List<String> lines = Files.readAllLines(Paths.get("./limerick.txt"), Charset.defaultCharset());

Map<Integer, List<String>> wordGroups = lines.stream() .map(line -> line.replaceAll("\\W", "\n").split("\n")) .flatMap(Arrays::stream) .sorted() .distinct() .collect(Collectors.groupingBy(String::length));

wordGroups.forEach( (count, words) -> { words.forEach(word -> System.out.printf("%d %s %n", count, word)); });

1 a 2 as 2 of 2 on 3 And 3 Who 3 she 3 the 3 was 4 They 4 With 4 face 4 from 4 lady 4 ride 4 rode 5 Niger 5 There 5 smile 5 tiger 5 young 6 inside 6 smiled 8 returned

Page 8: Modern Software Architecture Styles and Patterns

What architectural style is this?

Page 9: Modern Software Architecture Styles and Patterns

Real-world pipes-and-filters

sediment pre-carbon ultra-filter post-

carbonFiltered water

Page 10: Modern Software Architecture Styles and Patterns

Pipe-and-filter: Benefits

+ Flexibility by filter exchange

+ Flexibility by recombination

+ Reuse of filter components

+ Rapid prototyping of pipelines

Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. 1996. Pattern-Oriented Software Architecture: A System of Patterns. John Wiley & Sons, Inc., NY, USA.

Page 11: Modern Software Architecture Styles and Patterns

Pipe-and-filter: Liabilities

- Sharing state information is expensive or inflexible

- Efficiency gain by parallel processing is often an illusion

- Data transformation overhead

- Difficult to handle errors

Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. 1996. Pattern-Oriented Software Architecture: A System of Patterns. John Wiley & Sons, Inc., NY, USA.

Page 12: Modern Software Architecture Styles and Patterns

What is the architecture style

followed by World Wide Web

(WWW)?

Page 13: Modern Software Architecture Styles and Patterns
Page 14: Modern Software Architecture Styles and Patterns
Page 15: Modern Software Architecture Styles and Patterns

SOA (Service Oriented Architecture)

Lambda Style

Microservices

REST (Representational State Transfer)

Map-Reduce

CQRS (Command-Query Responsibility Segregation )

Software Containers

Event Sourcing

Page 16: Modern Software Architecture Styles and Patterns

List<String> lines = Files.readAllLines(Paths.get("./limerick.txt"), Charset.defaultCharset());

Map<Integer, List<String>> wordGroups = lines.parallelStream() .map(line -> line.replaceAll("\\W", "\n").split("\n")) .flatMap(Arrays::stream) .sorted() .distinct() .collect(Collectors.groupingBy(String::length));

wordGroups.forEach( (count, words) -> { words.forEach(word -> System.out.printf("%d %s %n", count, word)); });

1 a 2 as 2 of 2 on 3 And 3 Who 3 she 3 the 3 was 4 They 4 With 4 face 4 from 4 lady 4 ride 4 rode 5 Niger 5 There 5 smile 5 tiger 5 young 6 inside 6 smiled 8 returned

Page 17: Modern Software Architecture Styles and Patterns

Java: Fork-join framework

Page 18: Modern Software Architecture Styles and Patterns

Map-Reduce patternInput

Sara Booch Thayer Merlin Sara Ralph Merlin Tim Sara

Christian Ralph

Cormen …

Computer Cluster

map

map

map

Sara, 1 Ralph, 1 Merlin, 1 Tim, 1

Sara, 1 Booch, 1 Thayer, 1 Merlin, 1

Sara, 1 Christian, 1

Ralph, 1 Cormen, 1

reduce

reduce

Sara, 3 Booch, 1 Thayer,1 Merlin, 2 Ralph, 2 Tim, 1

Christian, 1 Cormen, 1

Output Sara, 1 Sara, 1 Sara, 1

Booch, 1 Thayer, 1

Merlin, 1 Merlin, 1 Ralph, 1 Ralph, 1 Tim, 1

Christian, 1 Cormen, 1

Page 19: Modern Software Architecture Styles and Patterns

Lambda style

Batch layer

Serving layerSpeed layer

Page 20: Modern Software Architecture Styles and Patterns

Lambda style

source: https://spark-summit.org/2014/wp-content/uploads/2014/07/Lambda-Architecture-Jim-Scott..pdf

Page 21: Modern Software Architecture Styles and Patterns

code-on-demand

client-server

cache

statelesslayered system

uniform interface

REST constraints (in www)

Page 22: Modern Software Architecture Styles and Patterns

Event Sourcing pattern

source: https://msdn.microsoft.com/en-us/library/dn589792.aspx

Page 23: Modern Software Architecture Styles and Patterns

Command Query Responsibility Segregation (CQRS) pattern

source: https://msdn.microsoft.com/en-us/library/jj591573.da82141c6f9950d64c1263fa4da825ec(l=en-us).png

Page 24: Modern Software Architecture Styles and Patterns

Microservices = “fine grained SOA” or “SOA 2.0”

Page 25: Modern Software Architecture Styles and Patterns

Microservices is an architectural style

Page 26: Modern Software Architecture Styles and Patterns

Complex application = composed of tiny services

Page 27: Modern Software Architecture Styles and Patterns

Communicate over REST API

HTTP GET

HTTP PUT

HTTP POST

HTTP DELETE

Page 28: Modern Software Architecture Styles and Patterns

Underlying philosophy

“do one thing and do it well”

Page 29: Modern Software Architecture Styles and Patterns

Monolithic

Page 30: Modern Software Architecture Styles and Patterns

Microservices

Page 31: Modern Software Architecture Styles and Patterns

Conway’s law“Any organization that designs a system… will inevitably produce

a design whose structure is a copy of the organization's communication structure”

Page 32: Modern Software Architecture Styles and Patterns

Conway’s lawTeam 1

Team 2Team 3

Team 4

Page 33: Modern Software Architecture Styles and Patterns

Conway’s law

Team 1 Team 2

Team 3

Team 4

Page 34: Modern Software Architecture Styles and Patterns

Monolithic to microservices

Page 35: Modern Software Architecture Styles and Patterns

Monolithic to microservices

Page 36: Modern Software Architecture Styles and Patterns

Service = manageable by “two pizza” team

Page 37: Modern Software Architecture Styles and Patterns

Service = a team can DURS (Deploy, Update, Replace, Scale)

Microservices = Damn U R Sexy

Page 38: Modern Software Architecture Styles and Patterns

Amazon case study

2-tier architecture SOA Microservices

Page 39: Modern Software Architecture Styles and Patterns