02 en Service Models
02 en Service Models
02 en Service Models
No networking
Traditional time-sharing system
Single workstation/PC or direct connection of multiple terminals to a
computer
One or several CPUs
Not easily scalable
Limiting factor: number of CPUs in system
Contention for same resources (memory, network, devices)
CLIENT-SERVER MODEL
No reliance on servers
Machines (peers) communicate with each other
Goals
Robustness
Self-scalability
Examples
BitTorrent, Skype
HYBRID MODEL
TCP, UDP is
implemented in
transport level
Sockets are used
to implement the
connection
SOCKET
OPERATIONS
Read / Write
based
communication
SOCKET IMPLEMENTATION IN DIFFERENT LANGUAGES
Python
SOCKET BASED COMMUNICATION
Implementing RPC
No architectural support for remote procedure calls The compiler
creates code to
Simulate it with tools we have (local procedure calls) send messages to
invoke remote
Simulation makes RPC a language-level construct functions
instead of an operating system construct
The OS gives us
sockets
IMPLEMENTING RPC
Create stub functions to make it appear to the user that the call is
local
On the client
The stub function (proxy) has the function’s interface
Packages parameters and calls the server
On the server
The stub function (skeleton) receives the request and calls the local function
STUB FUNCTIONS
Parameter passing
Pass by value or pass by reference?
Pointerless representation
Service binding. How do we locate the server endpoint?
Central DB
DB of services per host
When things go wrong
Opportunities for failure
Performance
RPC is slower … a lot slower (why?)
Security
messages may be visible over network – do we need to hide them?
Authenticate client? Authenticate server?
PROGRAMMING WITH RPC
Language support
Many programming languages have no language-level concept of remote procedure calls
(C, C++, Java <J2SE 5.0, …)
These compilers will not automatically generate client and server stubs
Some languages have support that enables RPC
(Java, Python, Haskell, Go, Erlang)
But we may need to deal with heterogeneous environments (e.g., Java communicating with a Python service)
Common solution
Interface Definition Language (IDL): describes remote procedures
Separate compiler that generate stubs (pre-compiler)
INTERFACE DEFINITION LANGUAGE (IDL)
Distributed objects:
support for object-oriented languages
Client
Invokes method on remote object
Server
Process that owns the remote object
Object registry
Name server that relates objects with names
INTEROPERABILITY
Distributed objects mostly ended up in intranets of homogenous systems and low latency networks
Interoperability – different languages, OSes, hardware
Transparency – not really there
Memory access, partial failure
Firewalls – dynamic ports
State – load balancing, resources
No group communication – no replication
No asynchronous messaging
Large streaming responses not possible
Notifications of delays not possibly
No subscribe-publish models
WEB BROWSING AND WEB SERVICES
Web browser:
Dominant model for user interaction on the Internet
Web services
Remotely hosted services – that programs can use
Machine-to-machine communication
WEB SERVICES
Autonomous modules
Each module does one thing well
Supports reuse of modules across applications
Loose coupling
Requires minimal knowledge – don’t need to know implementation
Migration: Services can be located and relocated on any servers
Scalability: new services can be added/removed on demand … and on different
servers – or load balanced
Updates: Individual services can be replaced without interruption
GENERAL PRINCIPLES OF WEB SERVICES
Coarse-grained
Usually few operations & large messages
Platform neutral
Messages don’t rely on the underlying language, OS, or hardware
Standardized protocols & data formats
Payloads are text (XML or JSON)
Message-oriented
Communicate by exchanging messages
HTTP often used for transport
Use existing infrastructure: web servers, authentication, encryption, firewalls, load-balancers
WEB SERVICES VS. DISTRIBUTED OBJECTS
XML RPC
SOAP: (Simple) (Object) Access Protocol
JAX-WS: Java Web Services
AJAX & XMLHTTP
REST: REpresentational State Transfer
REST
Blog example
Get a snapshot of a user’s blogroll:
HTTP GET //example.com/listsubs
HTTP authentication handles user identification