The Rest of REST
The Rest of REST
http://roy.gbiv.com/talks/200709_fielding_rest.pdf
Tuesday, September 18, 2007
Between us, we cover all knowledge;
he knows all that can be known and I know the REST. [Mark Twain]
Overview
Representational State Transfer (REST)
• A little background
- WWW history + Roy history = REST context
- Why do we need a Web architectural style?
• A touch of theory
- Principled design
- Architectural properties
- Constraints that induce properties
• What parts of REST are missing from Ruby on Rails?
23,517
Using XMosaic
EL
libwww-
OD
perl HTTP editor
M
T
EC
J
OB
www.ics.uci.edu Relative
TP
URLs
HT
AS
NS
wwwstat
GI
BE
ST
HTML 10,022
RE
2.0
MOMspider SJ IETF
1st WWW
623
130
Software Architectures
A software architecture is an abstraction of the run-
time elements of a software system during some
phase of its operation. A system may be composed
of many levels of abstraction and many phases of
operation, each with its own software architecture.
• A software architecture is defined by a configuration of
architectural elements—components, connectors, and
data—constrained in their relationships in order to achieve
a desired set of architectural properties.
• A configuration is the structure of architectural relationships
among components, connectors, and data during a period
of system run-time.
Architectural Styles
An architectural style is a coordinated set of
architectural constraints that restricts the roles and
features of architectural elements, and the allowed
relationships among those elements, within any
architecture that conforms to that style.
• A style can be applied to many architectures
• An architecture can consist of many styles
Design at the right level of abstraction
• Styles help architects communicate architecture
• Architecture determines potential system properties
• Implementation determines actual system properties
• Architectural patterns are styles with common recipes
Browsers
Protocols
Web Implementation
Web Architecture
One abstraction level above the implementation
Components
• User agents, Intermediaries, Servers
• Browsers, Spiders, Proxies, Gateways, Origin Servers
Connectors
• HTTP: a standard transfer protocol to prefer over many
Data
• URI: one identifier standard for all resources
• HTML, XML, RDF, ...: common representation formats to
describe and bind resources
Web Requirements
Low entry barrier
- Hypermedia User Interface
- Simple protocols for authoring and data transfer
• a.k.a., must be Simple, Reusable, and Extensible
Distributed Hypermedia System
- Large data transfers
- Sensitive to user-perceived latency
• a.k.a., must be Data-driven, Streamable, and Cacheable
Multiple organizational boundaries
- Anarchic scalability
- Gradual and fragmented change (deployment)
• a.k.a, must be Scalable, Evolvable, Visible, Reliable, ...
11
REST on a slide
pro
layered
replicated gra
mm uniform interface
abl
separated e
RR CS LS VM U
i nt
pr erme
on-demand stateless oc d
es iat mobile simple
sin e
g visible
$ CSS LCS COD
the disadvantages) of the optional constraints12when they are known to be in effect for some
Tuesday, September 18, 2007
How beautiful it is to do nothing,
and then REST afterward. [Spanish Proverb]
Style = nil
WWW
13
Style += Client/Server
14
Style += Stateless
simplifies server
improves reliability
15
Style += Caching
improves scalability
16
improves visibility
decouples implementation
17
$ $
$ $ $
$ $
18
REST Style
$ $
$ $ $
$ $
19
21
24
http://roy.gbiv.com/talks/200709_fielding_rest.pdf
Tuesday, September 18, 2007
Client: Excuse me. Did you say knives?
Architect: Rotating knives, yes. [Monty Python’s Flying Circus]
Industry Practice
Meanwhile, in a parallel universe ...
• http://www.youtube.com/watch?v=-RxhkWLJH4Y
• Microsoft was selling COM+/DCOM
• IBM and friends were selling CORBA
• Sun was selling RMI
• W3C was developing XML
Then SOAP was dropped on the shower floor
as an Internet Draft
• and quickly laughed out of the IETF
• only to be picked up by IBM and renamed “Web Services”
and REST became the only counter-argument
to multi-billions in advertising
26
Industry Reaction?
Not very constructive
• proponents labeled as RESTafarians
• arguments derided as a “religion”
• excused as “too simple for real services”
Service-Oriented Architecture (SOA)
• a direct response to REST
• attempt at an architectural style for WS
- without any constraints
• What is SOA?
- Wardrobe, Musical Notes, or Legos?
- http://www.youtube.com/profile_videos?
user=richneckyogi
27
Industry Acceptance
Something has changed ...
• People started to talk about the value of URIs
(reusable resources)
• Google maps decided to encourage reuse (Mashups)
• O’Reilly began talking about Web 2.0
• Rails reminded people that frameworks can be simple
Yikes!
28
Relaxation
Clearly, it’s time to start messing with minds
• REST is not the only architectural style
• My dissertation is about Principled Design,
not the one true architecture
What do constraints really mean?
• codify a design choice at the level of architecture
• to induce certain (good) architectural properties
• at the expense of certain (bad) trade-offs
What happens when we relax a given constraint?
• Is it really the end of the world?
• Should waka (a replacement for HTTP) have its own style?
29
30
Relax client/server ?
What happens when we let servers make requests?
• lose implementation simplicity due to listening,
additional parsing requirements
• potential for confusion with mixed-protocol intermediaries
• unknown: does it impact session state?
Trade-offs aren’t as severe as the first example.
Benefits?
• peer-to-peer applications
• shared cache mesh, triggered expiration
Can we find ways to compensate for the trade-offs?
• Make message syntax more uniform
- Limit server-initiated requests to same-connection
31
Conclusion
Use your brains!
• don’t design-by-buzzword
• don’t believe everything you read
• always keep in mind that change is inevitable
• use principled design
- identify desired architectural properties
- constrain behavior to induce properties
- compensate for the inevitable design trade-offs
32