Chapter02 - Part 01
Chapter02 - Part 01
Architectural styles
Basic idea
A style is formulated in terms of
• (replaceable) components with well-defined interfaces
• the way that components are connected to each other
• the data exchanged between components
• how these components and connectors are jointly configured into a
system.
Connector
A mechanism that mediates communication, coordination, or cooperation
among components. Example: facilities for (remote) procedure call,
messaging, or streaming.
Architectures Architectural styles
Layered architecture
Different layered organizations
Layered architectures
Architectures Architectural styles
Layered architectures
Architectures Architectural styles
Two-party communication
Server
1 from sock et import *
2
3 s = socket(AF_INET, SOCK_STREAM)
4 (co nn, ad d r) = s . a c c e p t ( ) # re t u r n s new s o c k e t and addr. c l i e n t
5 while True: # fo rever
6 d a t a = conn.recv(1024) # r e cei ve data from c l i e n t
7 i f not d a t a : break # s t o p i f c l i e n t stopped
8 msg = data.decode()+" * " # process t h e incoming d ata i n t o a response
9 conn.send(msg.encode()) # r e t u r n t h e response
10 conn.close() # c l o s e t h e connection
Client
1 from sock et import *
2
3 s = socket(AF_INET, SOCK_STREAM)
4 s.connect((HOST, PORT)) # connect t o s e r v e r (blo ck u n t i l accepted)
5 msg = "Hello World" # compose a message
6 s.send(msg.encode()) # send t h e message
7 d a t a = s.recv(1024) # r ec ei ve t h e response
8 print(data.decode()) # print the result
9 s.close() # c l o s e t h e connection
Layered architectures
Architectures Architectural styles
Application Layering
Traditional three-layered view
• Application-interface layer contains units for interfacing to users or
external applications
• Processing layer contains the functions of an application, i.e., without
specific data
• Data layer contains the data that a client wants to manipulate through the
application components
Layered architectures
Architectures Architectural styles
Application Layering
Traditional three-layered view
• Application-interface layer contains units for interfacing to users or
external applications
• Processing layer contains the functions of an application, i.e., without
specific data
• Data layer contains the data that a client wants to manipulate through the
application components
Observation
This layering is found in many distributed information systems, using traditional
database technology and accompanying applications.
Layered architectures
Architectures Architectural styles
Application Layering
Example: a simple search engine
Layered architectures
Architectures Architectural styles
Object-based style
Essence
Components are objects, connected to each other through procedure calls.
Objects may be placed on different machines; calls can thus execute across a
network.
Encapsulation
Objects are said to encapsulate data and offer methods on that data without
revealing the internal implementation.
Service-oriented architectures
Architectures Architectural styles
Object-based style
Common organization of a remote object with client-side proxy
Service-oriented architectures
Architectures Architectural styles
RESTful architectures
Essence
View a distributed system as a collection of resources, individually managed by
components. Resources may be added, removed, retrieved, and modified by
(remote) applications.
1. Resources are identified through a single naming scheme
2. All services offer the same interface i.e. the 4 basic operations
3. Messages sent to or from a service are fully self-described
4. After executing an operation at a service, that component forgets
everything about the caller i.e. stateless execution.
Basic operations
Operation Description
POST Create a new resource
GET Retrieve the state of a resource in some representation
DELETE Delete a resource
PUT Modify a resource by transferring a new state
Service-oriented architectures
Architectures Architectural styles
http://BucketName.s3.amazonaws.com/ObjectName
Typical operations
All operations are carried out by sending HTTP requests:
• Create a bucket/object: PUT, along with the URI
• Listing objects: GET on a bucket name
• Reading an object: GET on a full URI
Service-oriented architectures
Architectures Architectural styles
On interfaces
Issue
Many people like RESTful approaches because the interface to a service is so
simple. The catch is that much needs to be done in the parameter space.
Service-oriented architectures
Architectures Architectural styles
On interfaces
Simplifications
Assume an interface bucket offering an operation create , requiring an input
string such as mybucket, for creating a bucket “mybucket.”
Service-oriented architectures
Architectures Architectural styles
On interfaces
Simplifications
Assume an interface bucket offering an operation create , requiring an input
string such as mybucket, for creating a bucket “mybucket.”
SOAP
import bucket
bucket.create("mybucket")
Service-oriented architectures
Architectures Architectural styles
On interfaces
Simplifications
Assume an interface bucket offering an operation create , requiring an input
string such as mybucket, for creating a bucket “mybucket.”
SOAP
import bucket
bucket.create("mybucket")
RESTful
PUT "https://mybucket.s3.amazonsws.com/"
Service-oriented architectures
Architectures Architectural styles
On interfaces
Simplifications
Assume an interface bucket offering an operation create , requiring an input
string such as mybucket, for creating a bucket “mybucket.”
SOAP
import bucket
bucket.create("mybucket")
RESTful
PUT "https://mybucket.s3.amazonsws.com/"
Conclusions
Are there any to draw?
Service-oriented architectures
Architectures Architectural styles
Coordination
Temporal and referential coupling
Temporally coupled Temporally decoupled
Referentially coupled Direct Mailbox
Referentially decoupled Event-based Shared data space
Publish-subscribe architectures
Architectures Architectural styles
More details
• Calling o u t ( t ) twice in a row, leads to storing two copies of tuple t a
tuple space is modeled as a multiset.
• Both i n and r d are blocking operations: the caller will be blocked until a
matching tuple is found, or has become available.
Publish-subscribe architectures
Architectures Architectural styles
Observation
Content-based subscriptions may easily have serious scalability problems
(why?)
Publish-subscribe architectures