SlideShare a Scribd company logo
REST
–
Theory
vs
Practice


Subbu
Allamaraju

Mike
Amundsen



                    10/06/2009
   1

About
the
Speakers


  Subbu
Allamaraju

    Architect,
Yahoo!

    Web
services
standards/practices
at
Yahoo!

    Built
web
portals,
and
web/WS
services
(SOAP
kind)

    frameworks
(BEA
Systems)

  Mike
Amundsen

    Independent
Consultant

    .NET

    Long‐time
RESTafarian


                                           10/06/2009
     2

RESTful

Web
Services

 Cookbook

  O’Reilly,
March
2010 

                    10/06/2009
   3

Objectives


  REST
is
set
of
constraints
and
not
rules

  Knowingly
relax
constraints

  Work
with
the
plumbing


  Apply
sound
software
engineering





                                       10/06/2009
   4

REST
as
Explained



1.  Identify
resources

2.  Give
a
URI
to
every
resource

3.  Design
representations
for
resources

4.  Operate
using
a
uniform
interface

5.  Use
hypermedia
as
the
engine
of
application

   state



                                         10/06/2009
   5

Address
Book
1.0


Build
a
RESTful
address
book





                         10/06/2009
   6

GET /user/subbu/address/{id}	
Host: ex.org	

200 OK ...	
PUT /user/subbu/address/{id}	
Host: ex.org	                        Address
If-Match: xyz	
                                    Resource	
200 OK ...	
DELETE /user/subbu/address/{id}	
Host: ex.org	
If-Match: xyz	

200 OK ...	
POST /user/subbu/address-book	       Address
Host: ex.org	
                                   Collection
201 Created ...	                    Resource	
                                   10/06/2009
   7

<address>	
  <link rel=“http://ex.org/rel/person” 	
    href=“http://ex.org/mike”/>	
  <street>...</street>	
  <city>...</city>	
  ...	
</address>	



<address-book>	
  <link rel=“http://ex.org/rel/owner” 	
    href=“http://ex.org/subbu”/>	
  <link rel=“next” 	
    href=“http://ex.org/subbu/address-book?p=2/”/>	
  <address>...</address>	
  <address>...</address>	
  ...	
</address-book>	


                                           10/06/2009
   8

✔
 URIs

GET /user/subbu/address/{id}	
Host: ex.org	                       ✔
    Resources

200 OK ...	
PUT /user/subbu/address/{id}	
Host: ex.org	                        Address
If-Match: xyz	
                                    Resource	
200 OK ...	
DELETE /user/subbu/address/{id}	
Host: ex.org	 Uniform
interface

            ✔

If-Match: xyz	

200 OK ...	
POST /user/subbu/address-book	       Address
Host: ex.org	                      Collection
201 Created ...	                    Resource	
                                   10/06/2009
         9

<address>	      4
 Representations

  <link rel=“http://ex.org/rel/person” 	
    href=“http://ex.org/subbu”/>	
  <street>...</street>	
  <city>...</city>	
  ...	
</address>	



<address-book>	
  <link rel=“self” 	
    href=“http://ex.org/subbu/address-book”/>	
                 5
 Application
state

  <link rel=“next” 	
    href=“http://ex.org/subbu/address-book?p=2/”/>	
  <address>...</address>	
  <address>...</address>	
  ...	
</address-book>	


                                           10/06/2009
   10

Stateless
       Uniform
          Self‐
Interactions
     Interface
       Describing





                Visibility


HTTP
goodies
–
caching,
optimistic
concurrency,

    conneg,
monitoring,
analytics
+
others


                                     10/06/2009
   11

Address
Book
1.1


[UC]
Support
address
book
sync
for












mobile
users





                             10/06/2009
   12

Address
GET /user/subbu/address-book	         Collection
                                       Resource	
For
each
address
in
the
collection

  Compare
local
copy

  PUT if different	
                                        Address
  DELETE if missing	
                                       Resource	

                                        Address
  POST if new	                        Collection
                                       Resource	

                                        10/06/2009
   13

Separation
of

                  concerns

Visibility

                  Network

                 efficiency



                   10/06/2009
   14

Better
Merge


POST /user/subbu/address-book/merge	
Host: ex.org	
Content-Length: xxx	
Content-Type: application/xml;charset=UTF-8	

<address-book>	
  <address>...</address>	
  <address>...</address>	
  ...	
</address-book>	


303 See Other	
Location: http://ex.org/user/subbu/address-book	



                                       10/06/2009
   15

POST /user/subbu/address-book/merge	
     Host: ex.org	
     Content-Type: application/xml;charset=UTF-8	
?
    Reduced
visibility

 <address-book>	
   <address>...</address>	
   <address>...</address>	
✔
 Better
separation
of
concerns

   ...	
 </address-book>	

✔
    Efficient
network
use


     303 See Other	
     Location: http://ex.org/user/subbu/address-book	




                                            10/06/2009
   16

Protocol‐level

   Visibility

                   Separation
of

                     Concerns



Tradeoffs
                 Network

                          Efficiency


                   Atomicity
and

                   Concurrency

 Infrastructure

    support


                             10/06/2009
   17

Take
a
Step
Back





                10/06/2009
   18

1.
Everything
at
the
end
of
a
URI
is
a
resource


Some
“things”


 	“person”, “address book”	


and
some
non‐“things”



 	“merge address book”, “reserve”,	
  “cancel”, “compute distance”, 	
  “reimage the virtual machine”	


                                    10/06/2009
    19

2.
Use
POST
when
in
doubt


	GET    
Safe
 
   
+
Idempotent

	PUT    
Unsafe
   
+
Idempotent

	DELETE 
Unsafe    
+
Idempotent

	POST 
Unsafe
     
+
Non‐Idempotent



        All
bets
are
off
with
POST

           POST
limits
damage

                                  10/06/2009
   20

3.
Don’t
tunnel
using
POST



POST /address-book	




Merge
an
address
book?




Fix
duplicates?




Or
something
else?



          Tunneling
=
Back
to
dark
ages


                                    10/06/2009
   21

This
is
not
a
“pedantic”
point
of
view




 Browser
           Proxy
               Web

(JS
Client)
        Server
             Server



Dev:
“We
should
find
a
way
to
make
REST

'faster'
and/or
provide
batching
support”



                                     10/06/2009
   22

A
benign
solution?
                           Batch
“end

                                                 point”

   Browser
              Proxy

  (JS
Client)
           Server

                                               Web
Server


POST /batch	
Host: ex.org	
Content-Length: xxx	
Content-Type: application/xml;charset=UTF-8	

<batch>	
  <request method=“PUT” uri=“/addr”>...</request>	
  <request method=“GET” uri=“/poi”>...</request>	
  <request method=“GET” uri=“/deals”>...</request> 	
</batch>	

                                           10/06/2009
       23

Browser
      Proxy
        Web

(JS
Client)
   Server
      Server




Bad
Guy

                           Batch
“end

                             point”

 Browser
      Proxy

(JS
Client)
   Server


                           Web
Server

                         10/06/2009
     24

✗

POST /batch	
Host: ex.org	
Content-Length: xxx	
Content-Type: application/xml;charset=UTF-8	

<batch>...</batch>	


Create
application
specific
resources

         with
distinct
URIs

POST /updateAddressGetPoiDeals	
Host: ex.org	




                                              ✓

Content-Length: xxx	
Content-Type: application/xml;charset=UTF-8	

<address>	
  ...	
</address>	

                                        10/06/2009
   25

4.
Be
creative
with
URIs


Fixed
and
known
URIs
(Cool
URIs)

 	http://ex.org/user/subbu	



Resources
with
many
URIs

  http://ex.org/user/1234/profile;t=3231231dasd	
  http://ex.org/user/1234/profile;t=3da8432stgs	


Ephemeral
URIs

(Uncool
URIs)

  http://ex.org/act/4567/status;t=rfdsf3adsd23das	
  http://ex.org/act/transfer?
    f=12&t=32&sig=a359d72d424cbd913686435bc6e7e372	

                                      10/06/2009
     26

5.
IDs
are
not
bad,
but
URIs
are
better


       How
much
“hyper”media?

          Should
you
care?


   Separation
of
concerns

                               Performance

   Loose
coupling

                             App
complexity



                                10/06/2009
    27

<album>



<photo
id=“1234”>...</photo>



<photo
id=“5678”>…</photo>

                                                   Bad?

</album>


<album
xml:base=“http://ex.org”>



<photo>





<link
href=“/photo/1234”/>...



</photo>

                                                   Good?



<photo>





<link
href=“/photo/5678”/>...



</photo>

</album>

                                     10/06/2009
            28

Schedule
interview

Candidate


                    Enter
feedback

   Candidate

                    Enter
reference
checks


                        Hire

     Candidate

                        No
hire


                                10/06/2009
   29

GET /transfer/token?from=1234&to=5678	
Host: ex.org	


 200 OK	
 Content-Type: application/xml;charset=UTF-8	

 <token>	
   <link rel=“http://ex.org/rels/transfer”	
     href=“http://ex.org/transfer;9ihrdsadas”/>	
   <from>	
    <balance>...</balance>	
   </from>	
   <to>	
     <balance>...</balance>	
   </to>	
  </token>	



                                         10/06/2009
   30

URI
decoupling
 
 
 
 
 



*****

Application
flow 
 
 
 
 



*****

Opaque
application
state 



*****




                           10/06/2009
   31

6.
Managing
concurrency


GET /subbu/address/1	

         200 OK	
         Date: Mon, 28 Sep 2009 14:30:53 GMT 	
         Etag: “8cf498a1ca3ceb67fe50d401d4759e34”	
         Last-Modified: Mon, 28 Sep 2009 01:30:53 GMT	
         Cache-Control: public,max-age=3600	

         <address>...</address>	

PUT /subbu/address/1	
If-Unmodified-Since: Mon, 28 Sep 2009 14:30:53 GMT	
If-Match: “8cf498a1ca3ceb67fe50d401d4759e34” 	

        412 Precondition Failed	


                                           10/06/2009
   32

GET /acct/1234	

         200 OK	
         ETag: "f091aae21b44c71:6b9" 	
         Content-Type: application/xml;charset=UTF-8	

         <account>	
           ...	
         </address>	

GET /acct/5678	

          ...	

POST /transfer	
Host: ex.org	
Content-Type: application/x-www-form-urlencoded	

amount=1000&from=1234&to=5678...	

                                           10/06/2009
   33

GET /acct/1234	

         200 OK	
         ETag: "f091aae21b44c71:6b9" 	
         Content-Type: application/xml;charset=UTF-8	

         <account>	
           ...	
         </address>	

GET /acct/5678	             ✗
   No
concurrency
control

          ...	

POST /transfer	
Host: ex.org	
Content-Type: application/x-www-form-urlencoded	

amount=1000&from=1234&to=5678...	

                                           10/06/2009
     34

GET /transfer/token?from=1234&to=5678	
Host: ex.org	


 200 OK	
 Content-Type: application/xml;charset=UTF-8	

 <token>	
   <link rel=“http://ex.org/rels/transfer”	
     href=“http://ex.org/transfer;9ihrdsadas”/>	
   <from>	
    <balance>...</balance>	
   </from>	
   <to>	
     <balance>...</balance>	
   </to>	
  </token>	



                                         10/06/2009
   35

POST /transfer/token;9ihrdsadas	
Host: ex.org	
Content-Type: application/x-www-form-urlencoded	

amount=1000	

 201 Created	
 Location: http://ex.org/transfer/1234	
 Content-Type: application/xml;charset=UTF-8	

 <transfer>	
   <created>2009‐09‐30T15:00:00Z</created>	
   <from>	
    <balance>...</balance>	
   </from>	
   <to>	                       ✔
 Concurrency
control

     <balance>...</balance>	
   </to>	
  </transfer>	

                                          10/06/2009
    36

7.
Caching
is
not
perfect




                             HTTP

 Client
       Cache
                            Data

                             Server



           Ideal
–
perfectly
visible



                                   10/06/2009
           37

Client


                                                        Data


                                HTTP
                   Data

 Client
      Cache

                                Server

                                                        Data


Client
    Cache
      Cache

                                                        Other

                                                        apps

                                          10/06/2009
            38

Every
row
is
a

resource





         10/06/2009
   39

Overlapping
data





        10/06/2009
   40

Some
resources
are
like
home
pages


                            10/06/2009
   41

No
conditional
reads


                            No
writes
on

Accept
staleness
           overlapping

                             resources





                                    10/06/2009
   42

Conclusion


  Focus
on
tradeoffs

  Relax
constraints
judiciously,
but
not

   accidentally
or
by
ignorance

  Put
HTTP
and
its
plumbing
to
good
use





                                        10/06/2009
   43


More Related Content

PDF
Opening up the Social Web - Standards that are bridging the Islands
PDF
Introduction to HTML5
ZIP
Web Scraping In Ruby Utosc 2009.Key
PDF
routes.rb をもう一度考えてみた #shibuyarb
PDF
Rails Gems realize RESTful modeling patterns
PDF
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
PPTX
Introduction to node.js
PDF
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
Introduction to HTML5
Web Scraping In Ruby Utosc 2009.Key
routes.rb をもう一度考えてみた #shibuyarb
Rails Gems realize RESTful modeling patterns
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
Introduction to node.js
Opening up the Social Web - Standards that are bridging the Islands

Similar to REST: Theory vs Practice (20)

PDF
Grokking REST (ZendCon 2010)
PDF
CORS review
PPTX
2012 12 best of spc - moving to the sp2013 app model
PDF
REST in peace @ IPC 2012 in Mainz
PDF
Kotlin server side frameworks
PPT
Backbone.js
PDF
Web Architectures - Web Technologies (1019888BNR)
PDF
SOA2010 SOA with REST
PPTX
Elastic search and Symfony3 - A practical approach
PDF
NoSQL Now 2013 Presentation
PPTX
Constraints Make You Sexy - What is Rest
PPT
Microsoft Azure, door Rob Brommer op de 4DotNet Developers Day
PDF
[drupalday2017] - REST in pieces
PDF
REST in pieces
KEY
Linked data: spreading data over the web
PPTX
WebRTC Conference and Expo (November 2013) - Signalling Workshop
PDF
Don't screw it up! How to build durable API
PDF
Building APIs in an easy way using API Platform
ODP
Pyramid Lighter/Faster/Better web apps
ODP
PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010
Grokking REST (ZendCon 2010)
CORS review
2012 12 best of spc - moving to the sp2013 app model
REST in peace @ IPC 2012 in Mainz
Kotlin server side frameworks
Backbone.js
Web Architectures - Web Technologies (1019888BNR)
SOA2010 SOA with REST
Elastic search and Symfony3 - A practical approach
NoSQL Now 2013 Presentation
Constraints Make You Sexy - What is Rest
Microsoft Azure, door Rob Brommer op de 4DotNet Developers Day
[drupalday2017] - REST in pieces
REST in pieces
Linked data: spreading data over the web
WebRTC Conference and Expo (November 2013) - Signalling Workshop
Don't screw it up! How to build durable API
Building APIs in an easy way using API Platform
Pyramid Lighter/Faster/Better web apps
PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010
Ad

More from Subbu Allamaraju (17)

PPTX
Five Rules
PPTX
Leading a Transformation
PPTX
Taming the Rate of Change
PDF
What Worked for Netflix May Not Work for You (OSCON-2018)
PPTX
Are We Ready for Serverless
PPTX
How to Sell Serverless to Your Colleagues
PPTX
Turning Containers into Cattle
PPTX
Keystone at the Center of Our Universe
PPTX
Journey and future of OpenStack eBay and PayPal
PPTX
Engineering operations
PDF
Open stack@ebay
PDF
Making Things Work Together
PPTX
ql.io at NodePDX
PPTX
ql.io: Consuming HTTP at Scale
PDF
Measuring REST
PDF
RESTful Web Apps - Facts vs Fiction
PDF
Pragmatic Rest
Five Rules
Leading a Transformation
Taming the Rate of Change
What Worked for Netflix May Not Work for You (OSCON-2018)
Are We Ready for Serverless
How to Sell Serverless to Your Colleagues
Turning Containers into Cattle
Keystone at the Center of Our Universe
Journey and future of OpenStack eBay and PayPal
Engineering operations
Open stack@ebay
Making Things Work Together
ql.io at NodePDX
ql.io: Consuming HTTP at Scale
Measuring REST
RESTful Web Apps - Facts vs Fiction
Pragmatic Rest
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
sap open course for s4hana steps from ECC to s4
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation

REST: Theory vs Practice