• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
REST in peace @ IPC 2012 in Mainz
 

REST in peace @ IPC 2012 in Mainz

on

  • 715 views

Presentation given at the International PHP Conference 2012 in Mainz, about the REST architectural style.

Presentation given at the International PHP Conference 2012 in Mainz, about the REST architectural style.

Statistics

Views

Total Views
715
Views on SlideShare
697
Embed Views
18

Actions

Likes
2
Downloads
15
Comments
0

4 Embeds 18

http://www.linkedin.com 12
http://odino.org 3
https://twitter.com 2
https://si0.twimg.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    REST in peace @ IPC 2012 in Mainz REST in peace @ IPC 2012 in Mainz Presentation Transcript

    • Alessandro Nadalin | NAMSHI.comREST in peace
    • AGENDA●Vol. 1: REST in a nutshell ○Tenets ○Antipatterns●Vol. 2: To the rescue ○HTTP cache ○HATEOAS
    • Sorry for the ugly slide. There will be others. Really sorry.
    • REST in a nutshell:1. Client <> Server
    • REST in a nutshell: 2. Stateless
    • REST in a nutshell: 3. Cacheable
    • REST in a nutshell:4. Layered system
    • REST in a nutshell: 5. Uniform interface
    • And obviously nobody had a clue
    • ANTIPATTERNS
    • 1URIs
    • "REST is about cool URI design"http://apple.com/users/1/licenses/4.json
    • "REST is about cool URI design"http://apple.com/users/1/licenses/4.json
    • http://apple.com/site/en_US/showUsers.jsp? uid=1&license=4 is OK too
    • but
    • cool URIs help youthink in term of resources David Zuelke
    • 2URIs (bis)
    • REST follows a URI schema GET /users POST /users PUT /users/{id} DELETE /users/{id} ...
    • REST follows a URI schema GET /users POST /users PUT /users/{id} DELETE /users/{id} ...
    • what if you change your URL?
    • Yeah,client isbroken
    • RESTful clients should be driven by services hypermedia controlsRoy Fielding : http://roy.gbiv.com/untangled/2008/rest-apis-must-be- hypertext-driven
    • HATEOAS
    • 3POST is cool
    • said SOAP 1.1
    • said SOAP 1.1
    • loosing meaningful verbs at the protocol level
    • loosing meaningful verbs at the protocol level nothing cacheable by default
    • loosing meaningful verbs at the protocol level nothing cacheable by default what about bookmarking?
    • 4500 is your friend
    • said SOAP ( again )
    • GET /users/300Host: www.example.com
    • GET /users/300 Host: www.example. comHTTP/1.1 500 Internal ServerErrorEtag: 1234X-Powered-By: php/5.3...The record cannot be found
    • GET /users/300 Host: www.example. comHTTP/1.1 500 Internal ServerErrorEtag: 1234X-Powered-By: php/5.3...The record cannot be found
    • The HTTP protocol is awesome,and lets you return meaningful anduniversally-understood status codes
    • 404 Not Found
    • 202 Accepted
    • 202 AcceptedYou get an immediate OK, and the operation will hopefully complete
    • Pause
    • World Wide Web
    • the largest data-exchange network on the planet
    • And meanwhile, at Facebook...12TB of new data every day (2 years ago) 500 million users
    • And meanwhile, at Google... 1 billionunique monthly googlers
    • via HTTP , baby!
    • HTTP in a nutshell:1. Client <> Server
    • HTTP in a nutshell: 2. Stateless
    • HTTP in a nutshell: 3. widespread cache spechttp://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
    • HTTP in a nutshell: Firefox Company proxy Great chinese (fire)wall Reverse proxy Origin server 4. Layered system
    • HTTP in a nutshell: 5. it is the uniform interface between clients and servers
    • HTTP bleeds REST
    • 1.caching & scalability
    • Types of cache Local Shared/proxy Shared/reverse proxy
    • Types of cache Local Shared/proxy Shared/reverse proxy
    • Types of cache Local Shared/proxy Shared/reverse proxy
    • Types of cache Local Shared/proxyShared/reverse proxy
    • on the server side
    • Caching with Expiration (example)
    • HTTP/1.1 200 OKHost: www.example.comExpires: 0
    • HTTP/1.1 200 OKHost: www.example.comExpires: 0
    • HTTP/1.1 200 OKHost: www.example.comExpires: Tue, 31 Jan 2013 01:00 GMT
    • HTTP/1.1 200 OKHost: www.example.comCache-Control: max-age=60, public
    • HTTP/1.1 200 OKHost: www.example.comCache-Control: max-age=60, public
    • HTTP/1.1 200 OKHost: www.example.comCache-Control: max-age=60, public Cacheable for 60 seconds
    • HTTP/1.1 200 OK Host: www.example.com Cache-Control: max-age=60, publicCacheable by both local and shared caches
    • but hey, you say
    • HTTPs cache fails when dealing with really dynamicpages, because consumers will always have to hit the origin server, although a part of the page would be cacheable ( header and footer, for example )
    • NopeNope
    • ESI was built for that http://www.w3.org/TR/esi-lang
    • <esi:include src="http://php2start.com/talks/1" />
    • <esi:include src="http://php2start.com/talks/1" />
    • <esi:include src="http://php2start.com/talks/1" />
    • 1s (tweets)3600 post
    • <esi:include src=tweets.html /><esi:include src=article/12.html />
    • So what does HTTP cache is meant to solve?
    • Less work
    • http://www.flickr.com/photos/snakphotography/5004775320/sizes/o/in/photostream/because the hard work is delegated to the browser/proxy
    • evolve
    • because cache is abstracted from the application
    • loose coupling
    • because caching is bound to the protocol, HTTP, notto your implementation ( Sf, RoR, Django )
    • 2.adaptability & durability
    • Hypermedia another long-time friend
    • Linksoutrageously simplifying
    • <link rel="payment" href="/checkout" type="text/html" ... />
    • <link rel="payment" href="/checkout" type="text/html" ... />
    • <link rel="payment" href="/checkout" type="text/html" ... />
    • <link rel="payment" href="/checkout" type="text/html" ... />
    • POST /users Host: www.example. comHTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /users/1
    • POST /users Host: www.example. comHTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /users/1
    • POST /users Host: www.example. comHTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /new-users-db/1
    • POST /users Host: www.example. comHTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /new-users-db/1
    • consumers of your API are able to follow the changes of your design
    • everything seems cool But why REST?
    • ProsPerformances
    • ProsScalability
    • Pros Durability
    • amazon.com
    • Alex Nadalin
    • Alex Nadalin odino.org
    • Alex Nadalin odino.org @_odino_
    • Alex Nadalin odino.org @_odino_
    • Alex Nadalin odino.org @_odino_
    • Alex Nadalin odino.org DXB @_odino_
    • Alex Nadalin odino.org DXB @_odino_
    • Were hiring!
    • In Dubai.
    • In Dubai.alex.nadalin@namshi.com
    • In Dubai.alex.nadalin@namshi.com @_odino_
    • In Dubai.alex.nadalin@namshi.com @_odino_ TALK TO ME!
    • Credits http://www.flickr.com/photos/larachris/16564077/sizes/o/in/photostream/ http://www.flickr.com/photos/ashatenbroeke/4367373081/sizes/z/in/photostream/ http://www.flickr.com/photos/yourdon/3140270189/sizes/l/in/photostream/ http://www.flickr.com/photos/jox1989/4964706072/sizes/l/in/photostream/ http://www.flickr.com/photos/brainfg/168506259/sizes/o/in/photostream/ http://www.flickr.com/photos/norte_it/3897091546/sizes/o/in/photostream/ http://www.zdnet.com/blog/service-oriented/soap-versus-rest-a-matter-of-style/3568http://www.flickr.com/photos/turtlemom_nancy/2046347762/sizes/l/in/photostream/ http://www.flickr.com/photos/juanpg/3333385784/sizes/z/in/photostream/ http://www.flickr.com/photos/congvo/301678287/sizes/l/in/photostream/ http://www.flickr.com/photos/ihasb33r/2573196546/sizes/z/in/photostream/ http://www.flickr.com/photos/martin_heigan/4544138976/sizes/o/in/photostream/ http://www.flickr.com/photos/cknara/4195099999/sizes/o/in/photostream/ http://www.flickr.com/photos/1080p/3076529265/sizes/l/in/photostream/ http://www.flickr.com/photos/adamrice/280300202/sizes/l/in/photostream/ http://www.flickr.com/photos/tomer_a/541411897/sizes/o/in/photostream/ http://www.flickr.com/photos/subpra/4514008262/sizes/l/in/photostream/ http://www.flickr.com/photos/lippincott/2539720043/sizes/l/in/photostream/ http://www.flickr.com/photos/rawryder/5086090931/sizes/l/in/photostream/ http://www.flickr.com/photos/robboudon/5312731161/sizes/l/in/photostream/ http://www.flickr.com/photos/bc-burnslibrary/4158243488/sizes/o/in/photostream/http://www.flickr.com/photos/13606325@N08/2416993706/sizes/o/in/photostream/ http://www.flickr.com/photos/neothezion/5135841069/sizes/l/in/photostream/ http://www.flickr.com/photos/planetschwa/2494067809/ http://www.flickr.com/photos/thomasthomas/258931782/ http://www.flickr.com/photos/rustyboxcars/2629631562/sizes/l/in/photostream/ http://www.flickr.com/photos/ell-r-brown/4138727474/sizes/l/in/photostream/ http://www.flickr.com/photos/noah123/5082076630/sizes/z/in/photostream/ http://www.flickr.com/photos/jungle_boy/220181177/sizes/l/in/photostream/ http://www.flickr.com/photos/prettydaisies/872539081/sizes/l/in/photostream/ http://www.flickr.com/photos/kaptainkobold/76256150/sizes/o/in/photostream/ http://www.flickr.com/photos/uomoincravatta/1438372865/sizes/z/in/photostream/