Chapter Two
Distributed system Architecture
Introduction
How to organize the collection of software
components
logical organization and
physical organization
i.e., software architectures: how they are organized
and how they communicate
We will discuss
Architectural styles
System architectures:
centralized vs decentralized ones
2
Architectural style
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.
2.1 Architectural Styles
The logical organization of distributed systems into
software components
A component is a modular unit with well-defined required
and provided interfaces that is replaceable within its
environment
There are various architectural styles
Layered architectures
Object-based architectures
Data-centered architectures
Event-based architectures
4
Layered architectures
Components are organized in a layered fashion where a
component at layer Li is allowed to call components at the
underlying layer Li-1, but not the other way around; e.g., network
layers
Note that request flow from top to bottom where as response
from bottom to top
the layered architectural style
5
Object-based architectures
Each object corresponds to a component and these components are
connected through a remote procedure call mechanism (client-
server paradigm)
the object-based architectural style
6
Event-based architectures
Processes communicate through the propagation of events
Publish/subscribe systems
Processes publish events and the middleware ensures that only those
processes that subscribed to those events will receive them
the event-based architectural style 7
Data-centered architectures
Processes communicate through a common repository; e.g., a shared
distributed file system
Shared data spaces
Event-based architectures combined with data-centered
architectures
Processes are decoupled in time
the shared data-space architectural style
8
2.2 System Architectures
The logical organization of distributed systems into software
components or how are processes organized in a system
2.2.1 Centralized Architectures
thinking in terms of clients requesting services from servers
general interaction between a client and a server
9
Communication between client and server can be
By a connectionless protocol if the underlying network is fairly
reliable; efficient since there is no much overhead
But assuring reliability is difficult
When messages are lost or corrupted let the client send the
request again; applicable only for idempotent operations
An operation is idempotent if it can be repeated multiple times
without harm; e.g., reading a record in a database
By reliable connection-oriented protocol if the underlying network is
unreliable
Establishing and terminating connections is expensive
10
Application Layering
No clear distinction between a client and a server; for instance a
server for a distributed database may act as a client when it
forwards requests to different file servers
Three levels exist
The user-interface level: implemented by clients and contains
all that is required by a client; usually through GUIs, but not
necessarily
The processing level: contains the applications
The data level: contains the programs that maintain the actual
data dealt with
11
e.g., The general organization of an Internet search engine into
three different layers
Client-Server Architectures
How to physically distribute a client-server application across
several machines
Multitiered Architectures 12
Two-tiered architecture: alternative client-server organizations
13
Three tiered architecture: an example of a server acting as a client
An example is the organization of Web sites
14
2.2.2 Decentralized Architectures
Vertical distribution: the ones discussed so far where the
different tiers correspond directly with the logical organization
of applications; place logically different components on
different machines
Horizontal distribution: physically split up the client or the
server into logically equivalent parts
An example is a peer-to-peer system where processes are
equal and hence each process acts as a client and a server at
the same time (servent).
15
Another example is the horizontal distribution of a Web service
16
Networking and Internetworking
Communication Subsystem
The hardware and software within a distributed system which
provides the communication facilities is known as the
communication subsystem.
Consists of:
Transmission media: providing the physical connectivity, e.g.
wire, cable, fibre and wireless channels;
Hardware devices: providing the linkage, e.g. routers,
bridges, hubs, repeaters, network interfaces and gateways;
Software components: managing the communication, e.g.
protocol stacks, communication handlers and drivers.
Impact on Distributed Systems
The communication impact on a distributed system will be one of the delay
introduced by the message passing.
Message passing is the most fundamental paradigm for distributed applications.
A process sends a message representing a request. The message is delivered to a
receiver, which processes the request, and sends a message in response).
The delay can be broken down into two factors:
Latency: is the time which is necessary to set up the communication, i.e. it is
the delay incurred from the time the message is sent until it starts to arrive at
the destination.
Transmission delay: determined by
the length of the message and
the data transfer rate,
the speed of data transfer between two computers in the network, usually
in bits per second.
Message transmission time = latency + length / data transfer rate
Network Types
Local Area Networks (LANs)
High-speed communication on proprietary grounds (on-campus).
Based on twisted copper wire, coaxial cable or optical fibre.
Most typical solution: Ethernet with 100 Mbps
Metropolitan Area Networks (MANs)
High-speed communication for nodes distributed over medium-
range distances, usually belonging to one organization.
Based on high bandwidth copper and optical fibre.
Providing "back-bone" to interconnect LAN's.
Technology often based on ATM, FDDI or DSL.
Wide Area Networks
Communication over long distances (cities, countries, or continents).
Covers computers of different organizations.
Involves routers to manage network and route messages to their destinations.
Speeds up to a few Mbps possible, but around 50-100 Kbps more typical.
Most prominent example: the Internet.
Wireless Networks
End user equipment accesses network through short or mid range radio or
infrared signal transmission
Wireless WANs:
GSM (up to about 20 Kbps), UMTS (up to Mbps), PCS.
Wireless LANs/MANs:
WaveLAN (2-11 Mbps, radio up to 150 meters).
Wireless Personal Area Networks:
Bluetooth (up to 2 Mbps on low power radio signal, < 10 m distance).
Internetworks
Several networks linked together to provide common data
communication facilities.
Needed for developing open distributed systems that contain very
large numbers of computers.
Interconnected by dedicated switching computers, routers, and
general purpose computers, gateways.
Networking Principles
Packet transmission
A packet is a sequence of binary data with addressing information to
identify the source and destination computers.
A network message with arbitrary length is divided before
transmission into packets of restricted length.
Switching Schemes
A switching system is required to transmit information between two
arbitrary nodes in the network using shared communications link.
Protocols
A well-known set of rules and formats used for
communication between processes to perform a given task.
A complete set of protocol layers is referred to as a protocol
suite or protocol stack.
OSI TCP/IP
Cont
No. Name Interpretation
1 Physical Layer how devices are physically connected
2 Data Link Layer how neighboring devices communicate
how non-neighboring devices
3 Network Layer
communicate
4 Transport Layer how to avoid communication errors
how devices managing ongoing
5 Session Layer
communication
6 Presentation Layer how devices agree on the format of data
how devices agree on the meaning of
7 Application Layer
data
Internetworking:
Internetworking devices:
Routers:
Responsible for forwarding the internetwork packets arrived on any
connection to the correct outgoing connection and maintain routing tables
for that purpose.
Bridges:
Link networks of different types.
Internet Protocols
TCP is a reliable connection-oriented protocol used to transport streams of
data.
UDP is used to meet traditional message-based communication.
IP is the underlying network protocol that provide the basic transmission
mechanism for the Internet and other subnets.
Con…
IP Addressing
Used scheme for assigning addresses to networks and the computers
connected to them.
IPv4 (1984): 32-bit addresses for 232 (~ 4 billion) addresses,
but insufficient due to:
i) Unforeseen growth of internet.
ii) Inefficient use of address space.
IPv6 (1994): 128-bit addresses for 2128 (~ 3x1038)
addressable nodes.
Inter Process Communication
IPC refers Communication between two different processes by message passing.
Characteristics of IPC
Message passing between a pair of processes supported by two communication
operations: Send and Receive.
A queue is associated with each message destination regarded as a buffer between
the sender and receiver:
When the buffer is empty the receiver must wait.
When the buffer is full the sender must wait, or messages will be lost.
Communication is termed as synchronous or asynchronous :
Synchronous: both send and receive are blocking operations:
Sender blocks until a receive is issued
Receiver blocks until a message arrives.
Asynchronous: send operation is non-blocking
Sender is non-blocking (copy goes to its local buffer)
Receiver blocking (ALWAYS) or non-blocking (out of control flow).
Ports and Sockets
Communication between processes is made between ports.
Each computer has 216 possible ports represented by integer numbers:
some ports have specific use but others are available for general use.
Each port corresponds to a single receiving process, but each process
may have more than one port at which it receives.
Any number of senders can send messages to a port.
Sockets are software abstractions of ports used within running
processes.
Messages are sent between a pair of sockets.
Sockets need to be bound to a port number and a host IP address in
order to be useable for sending and receiving messages.
Socket binding may be automatic (Java) or done explicitly (BSD UNIX).
Each socket is associated with a particular transport protocol, i.e. UDP
(datagrams) or TCP (streams).
IPC Communication using UDP
UDP is suitable for applications that need low
overheads and accepting occasional omission
failures.
A datagram is communicated between processes
when one process sends it and the other receives it.
Datagrams sent from socket to socket without
acknowledgement or reliability.
A server binds its socket to a specific server port
known to clients but a client binds its socket to any
free port.
IPC Communication using TCP
TCP offers the following characteristics:
No restriction about message sizes:
Guarantee message delivery using acknowledgment
scheme:
Attempt to match the speeds of reader and writer
processes:
Guarantee unduplication and ordering of messages:
Message identifiers enable the receiver to detect and
reject duplicates or to reorder messages not arrived in
sender order
A pair of communicating processes establish
a connection before they can communicate
over a stream:
Once the connection is established the processes
write to and read from the stream without needing
to use Internet addresses and ports.
TCP Client/Server Interaction
Client Server
Create a TCP socket Create a TCP socket
Communicate Repeatedly:
Close the connection Accept new connection
Communicate
Close the connection
Socket's life cycle (Java)
Server side Socket Operations
1. Open Server Socket:
ServerSocket server;
DataOutputStream os;
DataInputStream is;
server = new ServerSocket( PORT );
2. Wait for Client Request:
Socket client = [Link]();
3. Create I/O streams for communicating to clients
is = new DataInputStream( [Link]() );
os = new DataOutputStream(
[Link]() );
4. Perform communication with client
Receiive from client: String line = [Link]();
Send to client: [Link]("Hello\n");
5. Close sockets:
[Link]();
Client side Socket Operations
1. Get connection to server:
client = new Socket( server, port_id );
2. Create I/O streams for communicating to clients
is = new DataInputStream(
[Link]() );
os = new DataOutputStream(
[Link]() );
3. Perform communication with client
Receiive from client: String line =
[Link]();
Send to client: [Link]("Hello\n");
4. Close sockets:
[Link]();
Thank you for your Attention
36