rest in ( a mobile ) peace @ whymca 05-21-2011

200
REST in (a mobile) peace Alessandro Nadalin May, 21st 2011

Upload: alessandro-nadalin

Post on 08-May-2015

3.240 views

Category:

Technology


0 download

DESCRIPTION

RESTful architectures and the advantage for HTTP consumers.Focused on what matters to the mobile world: performances & scalability.

TRANSCRIPT

Page 1: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

RESTin (a mobile) peace

Alessandro Nadalin

May, 21st 2011

Page 2: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

AgendaRest in a nutshellREST antipatternREST for the mobile world

HowHTTP cache fault-tolerance, downtime-availabilityESI Atom + Hypermedia controls

Whyperformancesevolution costadaptability

Page 3: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Sorry for the ugly slide.

There will be others.Really sorry.

Page 4: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

A nutshellin (a mobile) peace

Page 5: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Let's go back!

Page 6: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

2000Fielding's dissertation:

REpresentational

State

Transfer

Page 7: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST in a nutshell:

Page 8: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST in a nutshell:

1. Client <> Server

Page 9: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST in a nutshell:

2. Stateless

Page 10: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

easy toscale

Page 11: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Recover andfailoverparadise

Page 12: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

What about the user session?

Page 13: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Must die

Page 14: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

3. Cacheable

REST in a nutshell:

Page 15: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

When dealing with safe methods,the response should be able to tell the client,

or whatever stands behind the request,how to cache it.

REST in a nutshell:

Page 16: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST in a nutshell:

4. Layered system

Page 17: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST in a nutshell:

5. Uniform interface

Page 18: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Uniform interfacehierarchic resource identification

Verbs to perform operations

manipulation through representation

HATEOAS

Page 19: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

manipulation through representation

HATEOAS

Really well explained by Fowler: http://martinfowler.com/articles/richardsonMaturityModel.html#level0

Page 20: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

HATEOAS

mess

Page 21: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

HATEOAS

mess0.

Page 22: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

0Using HTTP

Page 23: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Without giving a f***

Page 24: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

HATEOAS

mess0.1.

Page 25: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

1mytastyproduct.com/users

mytastyproduct.com/users/1/licenses/4

Page 26: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

HATEOAS

mess0.1.2.

Page 27: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

2

Page 28: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

3.

Richardson maturity model

hierarchic resource identification

Verbs to perform operations

HATEOAS

mess0.1.2.

Page 29: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

3. GOD

http://www.slideshare.net/trilancer/why-hateoas-1547275

Page 30: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Hyperlinks

Page 31: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Hypermedia formats

http://amundsen.com/hypermedia/

Page 32: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Single entry point

Page 33: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Uniform interface is interesting.

Everyone seem to have its own RESTful "service".

But no one seem to entirely implement a uniform interface.

Page 34: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Uniform interface is interesting.

Everyone seem to have its own RESTful "service".

But no one seem to entirely implement a uniform interface.

That means... ...?

Page 35: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

No RESTful

stuff

Page 36: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

But don't be too religious.

REST gets raped everyday, get over it.

Page 37: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

( a few ) ANTIPATTERNSin (a mobile) peace

Page 38: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

1URIs

Page 39: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

"REST is about

cool URI design"

http://apple.com/users/1/licenses/4.json

Page 40: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

"REST is about

cool URI design"

http://apple.com/users/1/licenses/4.json

Page 41: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

http://apple.com/site/en_US/showUsers.jsp?uid=1&license=4

is OK too

Page 42: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

but

Page 43: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

"cool URIs help youthink in term of resources"

- David Zuelke

Page 44: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and, by the way

Page 45: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

a URI should neverlocate different resources

Page 46: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

a URI should neverlocate different resources

while a resource could belocated by different URIs

Page 47: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

2URIs (bis)

Page 48: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST follows a URI schema

Page 49: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST follows a URI schema

GET /users POST /users PUT /users/{id} DELETE /users/{id} ...

Page 50: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST follows a URI schema

GET /users POST /users PUT /users/{id} DELETE /users/{id} ...

Page 51: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

URI templates suck, some say

Page 52: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

what if you change yourURL?

Page 53: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Yeah, client is broken

Page 54: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

RESTful clients shouldbe driven by service'shypermedia controls

Roy Fielding : http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven

Page 55: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

3Formats

Page 56: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST

=

XML

Page 57: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

REST

=

XML

Page 58: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

a representation variesbased on the format

Page 59: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Can be:application/xmlapplication/jsonaudio/mp4image/png

Page 60: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Can be:application/xmlapplication/jsonaudio/mp4image/png

but also:text/dnsvideo/vnd.motorola.videotext/uri-list

Page 61: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

dear JSON, by the way

Page 62: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

JSON is evil

Page 63: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

{ "date": "2011-01-01", "stock": "100", "price": "12"}

Page 64: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

The business evolves

Page 65: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

{ "date": "2011-01-01", "stock": "100", "price": [ {"currency": "EUR", "amount": "12"}, {"currency": "USD", "amount": "10"} ]}

Credits: http://twitter.com/#!/odracci

Page 66: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Yeah, client is broken

Page 67: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Everything is a tradeoff

Page 68: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

4POST is cool

Page 69: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

said SOAP 1.1

Page 70: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

said SOAP 1.1

Page 71: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

loosing meaningful verbs at the protocol level

Page 72: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

loosing meaningful verbs at the protocol level

nothing cacheable by default

Page 73: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

loosing meaningful verbs at the protocol level

nothing cacheable by default

what about bookmarking?

Page 74: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

5500 is your friend

Page 75: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

said SOAP( again )

Page 76: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET /users/300Host: www.example.com

Page 77: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 500 Internal Server ErrorEtag: 1234X-Powered-By: php/5.3...

The record cannot be found

GET /users/300Host: www.example.com

Page 78: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 500 Internal Server ErrorEtag: 1234X-Powered-By: php/5.3...

The record cannot be found

GET /users/300Host: www.example.com

Page 79: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

The HTTP protocol is awesome,and lets you return meaningful anduniversally-understood status codes

Page 80: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

404 Not Found

Page 81: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

404 Not Found

OMG Link is broken?

Page 82: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

202 Accepted

Page 83: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

202 Accepted

You get an immediate OK, and the operation will hopefully complete

Page 84: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

412 Precondition Failed

Page 85: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

412 Precondition Failed

Want money?.. Got money?

Page 86: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

The serious s**tin (a mobile) peace

Page 87: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

How do Iimplement

thisgoodness?

Page 88: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

1.

caching & scalability

Page 89: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTPyour long-time friend

Page 90: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Page 91: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Page 92: REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Page 93: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Page 94: REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Page 95: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Page 96: REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Page 97: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

on the server side

Page 98: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Proxy Reverse proxy

http://www.codeproject.com/KB/aspnet/ExploringCaching.aspx

Page 99: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

There is something cool about caching softwares.

Page 100: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Free as free beer

Page 101: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

...but the server should take advantage of them

( the boring part were you need to write code )

Page 102: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here are a few ways to do so, using

Page 103: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here are a few ways to do so, using

expiration

Page 104: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here are a few ways to do so, using

expiration

validation

Page 105: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here are a few ways to do so, using

expiration

validation

invalidation

Page 106: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here are a few ways to do so, using

expiration

validation

invalidationwe will se why

Page 107: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Expiration

Page 108: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comExpires: 0

Page 109: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comExpires: 0

Page 110: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comExpires: Tue, 15 Nov 1994 01:00 GMT

Page 111: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Page 112: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Page 113: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Cacheable for 60 seconds

Page 114: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Cacheable by both local and shared caches

Page 115: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

Page 116: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

fault-tolerant

Page 117: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

available during downtime

Page 118: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

available during revalidation

Page 119: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Validation

Page 120: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comEtag: 1234

Page 121: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comEtag: 1234

an identifier for your response

Page 122: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comIf-None-Match: 1234

the browsers asks you if it has been modified

Conditional requests

Page 123: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Relax

Page 124: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Calculating an Etag is cheaper than generating a full MVC response

Page 125: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 304 Not Modified

Page 126: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT

Page 127: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT

tell the client about the latest change

Page 128: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

GET / HTTP/1.1Host: www.example.comIf-Modified-Since: Tue, 15 Jan 2011 12:00:00 GMT

the client asks you if it has been modified since the last time

Conditional requests

Page 129: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Relax

Page 130: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Calculating a date is cheaper than retrieving an entire object

Page 131: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 304 Not Modified

Page 132: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Invalidation

Page 133: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

The web is not meant for invalidating data.

Server should not be able to keep clients' state, otherwise they wont scale well.

That's why long-polling and endless connections haven't had big success dealing with caching.

Page 134: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

but hey, you say

Page 135: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP's cache fails when dealing with really dynamic pages, because consumers will always have to hit the origin server, although a part of the page would be cacheable ( header and

footer, for example )

Page 136: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Nope

Nope

Page 137: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

ESI was built for thathttp://www.w3.org/TR/esi-lang

Page 138: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Edge Side IncludesA de facto standard for bla bla bla...

Page 139: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Edge Side IncludesA de facto standard for bla bla bla...

Server side includes ( not SSI! ) usually handled by the architecture's ESI processor.

http://www.w3.org/TR/esi-langhttp://www.w3.org/TR/edge-arch

Page 140: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<esi:include src="http://whymca.org/talks/1" />

Page 141: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<esi:include src="http://whymca.org/talks/1" />

Page 142: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<esi:include src="http://whymca.org/talks/1" />

Page 143: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

This is a response

Page 144: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

15 seconds cache

30 minutes cache

Page 145: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and hey, Varnish is a reverse proxy implementing what you need of the ESI specification

take 2, pay for 1

Page 146: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

So what does HTTP cache is meant to solve?

Page 147: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Less work

Page 148: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

because the hard work is delegated to the browser/proxy

http://www.flickr.com/photos/snakphotography/5004775320/sizes/o/in/photostream/

Page 149: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

evolve

Page 150: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

because cache is abstracted from the application

Page 151: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

loose coupling

Page 152: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

because caching is bound to the protocol, HTTP, not to your implementation ( Sf, RoR, Django )

Page 153: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

2.

adaptability & durability

Page 154: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Hypermediaanother long-time friend

Page 155: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Linksoutrageously semplifying

Page 156: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<img src="..." />

<a href="..." />

<link rel="payment" ... />

Page 157: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<img src="..." />

<a href="..." />

<link rel="payment" ... />

Page 158: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<img src="..." />

<a href="..." />

<link rel="payment" ... />

Page 159: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Atomis your friend

http://www.xml.com/lpt/a/1434

Page 160: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<link rel="payment" href="/checkout" type="text/html" ... />

Page 161: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<link rel="payment" href="/checkout" type="text/html" ... />

Page 162: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<link rel="payment" href="/checkout" type="text/html" ... />

Page 163: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

<link rel="payment" href="/checkout" type="text/html" ... />

Page 164: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

POST /usersHost: www.example.com

Page 165: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /users/1

POST /usersHost: www.example.com

Page 166: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /users/1

POST /usersHost: www.example.com

Page 167: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

POST /usersHost: www.example.com

Page 168: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 301 Moved permanentlyHost: www.example.comLocation: /users

POST /usersHost: www.example.com

Page 169: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

POST /usersHost: www.example.com

Page 170: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /newusersdatabase/1

POST /usersHost: www.example.com

Page 171: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /newusersdatabase/1

POST /usersHost: www.example.com

Page 172: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

HTTP/1.1 201 CreatedHost: www.example.comEtag: 1234X-Powered-By: php/5.3Location: /newusersdatabase/1

POST /usersHost: www.example.com

Helps refactoring legacy stuff indeed :)

Page 173: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

consumers of your API are able to followthe changes of your design

Page 174: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Clients are too importantto break'em

Page 175: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

and here comes a controversial part...

Page 176: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Like it or not,

XML is a friend of the non BC-breaking evolution

http://www.slideshare.net/Wombert/xml-versus-the-new-kids-on-the-block-phpbnl11-20110129http://www.odino.org/320/long-live-xml-too-sorry-for-json-fanboyz

Page 177: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

BTW<xml...> <product...> <price>25</price> </product></xml>

Page 178: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

BTW<xml...> <product...> <price currency="EUR">25</price> <price currency="USD">23</price> </product></xml>

Page 179: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

As said, everything is a tradeoff

Page 180: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Choose the media typefor your needs

Page 181: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

No need to be religious. Ever.

Page 182: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Why beingin (a mobile) peace?

Page 183: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

everything seems cool

Page 184: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

everything seems cool

but

why REST?

Page 185: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Pros

Performances

Page 186: REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Page 187: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Pros

Scalability

Page 188: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

http://articles.sfgate.com/2011-02-20/opinion/28613184_1_news-network-cable-and-satellite-website

http://tech.groups.yahoo.com/group/rest-discuss/message/17370

+2.500%traffic

Page 189: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Pros

Durability

Page 190: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

"REST is software design on the scale of decades: every detail is intended to promote software longevity and independent evolution. Many of the constraints are directly

opposed to short-term efficiency. Unfortunately, people are fairly good at short-term design, and usually awful at long-term design. "

Roy Fielding

Page 191: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Put a bit of REST

everywhere

Page 192: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Rules of good design

Page 193: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

amazon.it

Page 194: REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Page 195: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Alessandro Nadalin

Page 196: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Alessandro Nadalinodino.org

Page 197: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Alessandro Nadalinodino.org

@_odino_

Page 198: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Alessandro Nadalinodino.org

@_odino_

Page 199: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Thanks

Alessandro Nadalinodino.org

@_odino_

Page 200: REST in ( a mobile ) peace @ WHYMCA 05-21-2011

Creditshttp://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/3568

http://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/