193
REST in peace Bengaluru, 20-22 November 2011

REST in peace @ Osidays 2011 India 11-21-2011

Embed Size (px)

DESCRIPTION

Presentation given at OSIDays 2011 in Bangalore, dealing wiith understanding the 5 main principles of REST and how to produce scalable and durable web architectures.

Citation preview

Page 1: REST in peace @ Osidays 2011 India 11-21-2011

RESTin peace

Bengaluru, 20-22 November 2011

Page 2: REST in peace @ Osidays 2011 India 11-21-2011

Sorry for the ugly slide.

There will be others.Really sorry.

Bengaluru, 20-22 November 2011

Page 3: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

REST in a nutshell

Page 4: REST in peace @ Osidays 2011 India 11-21-2011

2000Fielding's dissertation:

REpresentational

State

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

Bengaluru, 20-22 November 2011

Page 5: REST in peace @ Osidays 2011 India 11-21-2011

REST in a nutshell:

1. Client <> ServerBengaluru, 20-22 November 2011

Page 6: REST in peace @ Osidays 2011 India 11-21-2011

REST in a nutshell:

2. Stateless

Bengaluru, 20-22 November 2011

Page 7: REST in peace @ Osidays 2011 India 11-21-2011

Servers do not keep anyinformations the clients uses

during different requests.

Bengaluru, 20-22 November 2011

Page 8: REST in peace @ Osidays 2011 India 11-21-2011

So the architecture scales well.

Bengaluru, 20-22 November 2011

Page 9: REST in peace @ Osidays 2011 India 11-21-2011

3. Cacheable

REST in a nutshell:

Bengaluru, 20-22 November 2011

Page 10: REST in peace @ Osidays 2011 India 11-21-2011

Client has access to resources stored betweenit and the origin server.

Bengaluru, 20-22 November 2011

Page 11: REST in peace @ Osidays 2011 India 11-21-2011

So communication is faster.

Bengaluru, 20-22 November 2011

Page 12: REST in peace @ Osidays 2011 India 11-21-2011

REST in a nutshell:

4. Layered systemBengaluru, 20-22 November 2011

Page 13: REST in peace @ Osidays 2011 India 11-21-2011

Intermediary nodes can beused along our architecture.

Bengaluru, 20-22 November 2011

Page 14: REST in peace @ Osidays 2011 India 11-21-2011

So you efficiently implement point 3.

Bengaluru, 20-22 November 2011

Page 15: REST in peace @ Osidays 2011 India 11-21-2011

REST in a nutshell:

5. Uniform interface

Bengaluru, 20-22 November 2011

Page 16: REST in peace @ Osidays 2011 India 11-21-2011

Communicate using well-knownverbs and providing all the

informations needed toconsume a service.

Bengaluru, 20-22 November 2011

Page 17: REST in peace @ Osidays 2011 India 11-21-2011

So fallbacks are easy.

Bengaluru, 20-22 November 2011

Page 18: REST in peace @ Osidays 2011 India 11-21-2011

this was a bit difficult to understand

so, obviously...

Bengaluru, 20-22 November 2011

Page 19: REST in peace @ Osidays 2011 India 11-21-2011

nobody had a clue

Bengaluru, 20-22 November 2011

Page 20: REST in peace @ Osidays 2011 India 11-21-2011

ANTIPATTERNS

Bengaluru, 20-22 November 2011

Page 21: REST in peace @ Osidays 2011 India 11-21-2011

1URIs

Bengaluru, 20-22 November 2011

Page 22: REST in peace @ Osidays 2011 India 11-21-2011

"REST is about

cool URI design"

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

Bengaluru, 20-22 November 2011

Page 23: REST in peace @ Osidays 2011 India 11-21-2011

"REST is about

cool URI design"

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

Bengaluru, 20-22 November 2011

Page 24: REST in peace @ Osidays 2011 India 11-21-2011

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

is OK too

Bengaluru, 20-22 November 2011

Page 25: REST in peace @ Osidays 2011 India 11-21-2011

but, enter simple rule of thumb

Bengaluru, 20-22 November 2011

Page 26: REST in peace @ Osidays 2011 India 11-21-2011

cool URIs help youthink in term of resources

- David Zuelke

Bengaluru, 20-22 November 2011

Page 27: REST in peace @ Osidays 2011 India 11-21-2011

2URIs (bis)

Bengaluru, 20-22 November 2011

Page 28: REST in peace @ Osidays 2011 India 11-21-2011

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

REST follows a URI schema

Bengaluru, 20-22 November 2011

Page 29: REST in peace @ Osidays 2011 India 11-21-2011

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

REST follows a URI schema

Bengaluru, 20-22 November 2011

Page 30: REST in peace @ Osidays 2011 India 11-21-2011

what if you change yourURL?

Bengaluru, 20-22 November 2011

Page 31: REST in peace @ Osidays 2011 India 11-21-2011

client is broken

Bengaluru, 20-22 November 2011

Page 32: REST in peace @ Osidays 2011 India 11-21-2011

RESTful clients shouldbe driven by service'shypermedia controls

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

Bengaluru, 20-22 November 2011

Page 33: REST in peace @ Osidays 2011 India 11-21-2011

HATEOAS

Bengaluru, 20-22 November 2011

Page 34: REST in peace @ Osidays 2011 India 11-21-2011

3POST is cool

Bengaluru, 20-22 November 2011

Page 35: REST in peace @ Osidays 2011 India 11-21-2011

said SOAP 1.1

Bengaluru, 20-22 November 2011

Page 36: REST in peace @ Osidays 2011 India 11-21-2011

said SOAP 1.1

Bengaluru, 20-22 November 2011

Page 37: REST in peace @ Osidays 2011 India 11-21-2011

loosing meaningful verbs at the protocol level

Bengaluru, 20-22 November 2011

Page 38: REST in peace @ Osidays 2011 India 11-21-2011

loosing meaningful verbs at the protocol level

nothing cacheable by default

Bengaluru, 20-22 November 2011

Page 39: REST in peace @ Osidays 2011 India 11-21-2011

loosing meaningful verbs at the protocol level

nothing cacheable by default

what about bookmarking?

Bengaluru, 20-22 November 2011

Page 40: REST in peace @ Osidays 2011 India 11-21-2011

4500 is your friend

Bengaluru, 20-22 November 2011

Page 41: REST in peace @ Osidays 2011 India 11-21-2011

said SOAP( again )

Bengaluru, 20-22 November 2011

Page 42: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 43: REST in peace @ Osidays 2011 India 11-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

Bengaluru, 20-22 November 2011

Page 44: REST in peace @ Osidays 2011 India 11-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

Bengaluru, 20-22 November 2011

Page 45: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 46: REST in peace @ Osidays 2011 India 11-21-2011

404 Not Found

Bengaluru, 20-22 November 2011

Page 47: REST in peace @ Osidays 2011 India 11-21-2011

404 Not Found

OMG Link is broken?

Bengaluru, 20-22 November 2011

Page 48: REST in peace @ Osidays 2011 India 11-21-2011

202 Accepted

Bengaluru, 20-22 November 2011

Page 49: REST in peace @ Osidays 2011 India 11-21-2011

202 Accepted

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

Bengaluru, 20-22 November 2011

Page 50: REST in peace @ Osidays 2011 India 11-21-2011

Pause

Bengaluru, 20-22 November 2011

Page 51: REST in peace @ Osidays 2011 India 11-21-2011

The WWW

Bengaluru, 20-22 November 2011

Page 52: REST in peace @ Osidays 2011 India 11-21-2011

the largest data-exchange network on the planet

Bengaluru, 20-22 November 2011

Page 53: REST in peace @ Osidays 2011 India 11-21-2011

And meanwhile, at Facebook...

12TB of new data every day(1 year ago)

500 million users

Bengaluru, 20-22 November 2011

Page 54: REST in peace @ Osidays 2011 India 11-21-2011

And meanwhile, at Google...

1 billion unique monthly googlers

Bengaluru, 20-22 November 2011

Page 55: REST in peace @ Osidays 2011 India 11-21-2011

via HTTP, baby!

Bengaluru, 20-22 November 2011

Page 56: REST in peace @ Osidays 2011 India 11-21-2011

HTTP in a nutshell:

1. Client <> ServerBengaluru, 20-22 November 2011

Page 57: REST in peace @ Osidays 2011 India 11-21-2011

HTTP in a nutshell:

2. Stateless

Bengaluru, 20-22 November 2011

Page 58: REST in peace @ Osidays 2011 India 11-21-2011

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

3. widespread cache spec

HTTP in a nutshell:

Bengaluru, 20-22 November 2011

Page 59: REST in peace @ Osidays 2011 India 11-21-2011

HTTP in a nutshell:

4. Layered systemOrigin server

Reverse proxy

Great chinese (fire)wall

Company proxy

Lao Tze Song using Firefox 6

Bengaluru, 20-22 November 2011

Page 60: REST in peace @ Osidays 2011 India 11-21-2011

HTTP in a nutshell:

5. it is the uniform interfacebetween clients and servers

Bengaluru, 20-22 November 2011

Page 61: REST in peace @ Osidays 2011 India 11-21-2011

HTTP bleeds REST

Bengaluru, 20-22 November 2011

Page 62: REST in peace @ Osidays 2011 India 11-21-2011

How do Iimplement

thisgoodness?

Bengaluru, 20-22 November 2011

Page 63: REST in peace @ Osidays 2011 India 11-21-2011

1. caching & scalability

Bengaluru, 20-22 November 2011

Page 64: REST in peace @ Osidays 2011 India 11-21-2011

HTTP cache

Bengaluru, 20-22 November 2011

Page 65: REST in peace @ Osidays 2011 India 11-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Bengaluru, 20-22 November 2011

Page 66: REST in peace @ Osidays 2011 India 11-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Bengaluru, 20-22 November 2011

Page 67: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 68: REST in peace @ Osidays 2011 India 11-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Bengaluru, 20-22 November 2011

Page 69: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 70: REST in peace @ Osidays 2011 India 11-21-2011

Local

Shared/proxy

Shared/reverse proxy

Types of cache

Bengaluru, 20-22 November 2011

Page 71: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 72: REST in peace @ Osidays 2011 India 11-21-2011

on the server side

Bengaluru, 20-22 November 2011

Page 73: REST in peace @ Osidays 2011 India 11-21-2011

Caching withExpiration(example)

Bengaluru, 20-22 November 2011

Page 74: REST in peace @ Osidays 2011 India 11-21-2011

HTTP/1.1 200 OKHost: www.example.comExpires: 0

Bengaluru, 20-22 November 2011

Page 75: REST in peace @ Osidays 2011 India 11-21-2011

HTTP/1.1 200 OKHost: www.example.comExpires: 0

Bengaluru, 20-22 November 2011

Page 76: REST in peace @ Osidays 2011 India 11-21-2011

HTTP/1.1 200 OKHost: www.example.comExpires: Tue, 31 Jan 2011 01:00 GMT

Bengaluru, 20-22 November 2011

Page 77: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 78: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 79: REST in peace @ Osidays 2011 India 11-21-2011

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

Cacheable for 60 seconds

Bengaluru, 20-22 November 2011

Page 80: REST in peace @ Osidays 2011 India 11-21-2011

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

Cacheable by both local and shared caches

Bengaluru, 20-22 November 2011

Page 81: REST in peace @ Osidays 2011 India 11-21-2011

You can also cache with validation

(Etags, If-None-Match, ...)

Bengaluru, 20-22 November 2011

Page 82: REST in peace @ Osidays 2011 India 11-21-2011

Why HTTP cachingis so

important?

Bengaluru, 20-22 November 2011

Page 83: REST in peace @ Osidays 2011 India 11-21-2011

Ask yourself:as a developer, what do I want

on my application?

Bengaluru, 20-22 November 2011

Page 84: REST in peace @ Osidays 2011 India 11-21-2011

Evolve

Loose coupling

Work less

Bengaluru, 20-22 November 2011

Page 85: REST in peace @ Osidays 2011 India 11-21-2011

Evolve Because you want your platform to extensible

Loose coupling

Work less

Bengaluru, 20-22 November 2011

Page 86: REST in peace @ Osidays 2011 India 11-21-2011

Evolve Because you want your platform to extensible

Loose coupling Because you want it to be easy to integrate with, evolve, plug and mantain

Work less

Bengaluru, 20-22 November 2011

Page 87: REST in peace @ Osidays 2011 India 11-21-2011

Evolve Because you want your platform to extensible

Loose coupling Because you want it to be easy to integrate with, evolve, plug and mantain

Work less

Because every LoC is bug-prone and our man-day is a hard-to-scale cost

Bengaluru, 20-22 November 2011

Page 88: REST in peace @ Osidays 2011 India 11-21-2011

enters our Hero #1

Bengaluru, 20-22 November 2011

Page 89: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 90: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 91: REST in peace @ Osidays 2011 India 11-21-2011

enters our Hero #2

Bengaluru, 20-22 November 2011

Page 92: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 93: REST in peace @ Osidays 2011 India 11-21-2011

http://www.lullabot.com/articles/a-beginners-guide-to-caching-data

Bengaluru, 20-22 November 2011

Page 94: REST in peace @ Osidays 2011 India 11-21-2011

2007

Bengaluru, 20-22 November 2011

Page 95: REST in peace @ Osidays 2011 India 11-21-2011

2011?

Bengaluru, 20-22 November 2011

Page 96: REST in peace @ Osidays 2011 India 11-21-2011

it supportsHTTP caching!

http://drupal.org/node/147310

Bengaluru, 20-22 November 2011

Page 97: REST in peace @ Osidays 2011 India 11-21-2011

it supportsHTTP caching!

http://drupal.org/node/147310

( people is supposed to clap their hands here )

Bengaluru, 20-22 November 2011

Page 98: REST in peace @ Osidays 2011 India 11-21-2011

but

Bengaluru, 20-22 November 2011

Page 99: REST in peace @ Osidays 2011 India 11-21-2011

wait.... how?

Bengaluru, 20-22 November 2011

Page 100: REST in peace @ Osidays 2011 India 11-21-2011

Default headers

Expires = 'Sun, 19 Nov 1978 05:00:00 GMT',

Cache-Control = 'no-cache, must-revalidate',

ETag = $_SERVER['REQUEST_TIME'],

Bengaluru, 20-22 November 2011

Page 101: REST in peace @ Osidays 2011 India 11-21-2011

Default headers

Expires = 'Sun, 19 Nov 1978 05:00:00 GMT',

Cache-Control = 'no-cache, must-revalidate',

ETag = $_SERVER['REQUEST_TIME'],

Bengaluru, 20-22 November 2011

Page 102: REST in peace @ Osidays 2011 India 11-21-2011

Default headers

Expires = 'Sun, 19 Nov 1978 05:00:00 GMT',

Cache-Control = 'no-cache, must-revalidate',

ETag = $_SERVER['REQUEST_TIME'],

Bengaluru, 20-22 November 2011

Page 103: REST in peace @ Osidays 2011 India 11-21-2011

Default headers

Expires = 'Sun, 19 Nov 1978 05:00:00 GMT',

Cache-Control = 'no-cache, must-revalidate',

ETag = $_SERVER['REQUEST_TIME'],

Bengaluru, 20-22 November 2011

Page 104: REST in peace @ Osidays 2011 India 11-21-2011

is that even legal?

Bengaluru, 20-22 November 2011

Page 105: REST in peace @ Osidays 2011 India 11-21-2011

"but you can redefine them!"

Bengaluru, 20-22 November 2011

Page 106: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header()

Bengaluru, 20-22 November 2011

Page 107: REST in peace @ Osidays 2011 India 11-21-2011

function drupal_add_http_header(){ ...

...

drupal_send_headers($headers);}

Bengaluru, 20-22 November 2011

Page 108: REST in peace @ Osidays 2011 India 11-21-2011

so, what

drupal_send_headers()

can do so evil?

Bengaluru, 20-22 November 2011

Page 109: REST in peace @ Osidays 2011 India 11-21-2011

header(),

of course

Bengaluru, 20-22 November 2011

Page 110: REST in peace @ Osidays 2011 India 11-21-2011

which means

Bengaluru, 20-22 November 2011

Page 111: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', 'I\'m not');

var_dump(headers_list());

Bengaluru, 20-22 November 2011

Page 112: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', 'I\'m not');

var_dump(headers_list());

array 0 => string 'X-Powered-By: PHP/5.3.2-1ubuntu4.7' 1 => string 'Dump-Header: I'm not'

Bengaluru, 20-22 November 2011

Page 113: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', false);

var_dump(headers_list());

Bengaluru, 20-22 November 2011

Page 114: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', false);

var_dump(headers_list());

array 0 => string 'X-Powered-By: PHP/5.3.2-1ubuntu4.7' 1 => string 'Dump-Header: I'm batman'

Bengaluru, 20-22 November 2011

Page 115: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', ' ');

var_dump(headers_list());

Bengaluru, 20-22 November 2011

Page 116: REST in peace @ Osidays 2011 India 11-21-2011

drupal_add_http_header('Dumb-Header', 'I\'m batman!');...// other logic...drupal_add_http_header('Dumb-Header', ' ');

var_dump(headers_list());

array 0 => string 'X-Powered-By: PHP/5.3.2-1ubuntu4.7' 1 => string 'Dumb-Header:'

Bengaluru, 20-22 November 2011

Page 117: REST in peace @ Osidays 2011 India 11-21-2011

or

Bengaluru, 20-22 November 2011

Page 118: REST in peace @ Osidays 2011 India 11-21-2011

you can use header_remove()

( PHP 5.3 )

Bengaluru, 20-22 November 2011

Page 119: REST in peace @ Osidays 2011 India 11-21-2011

and create a new class to manage/keep track of

headers and caching directives

Bengaluru, 20-22 November 2011

Page 120: REST in peace @ Osidays 2011 India 11-21-2011

but we're lazy

and

we don't want to reinvent the wheel

Bengaluru, 20-22 November 2011

Page 121: REST in peace @ Osidays 2011 India 11-21-2011

Goals

Work lessevolve

loose coupling

Bengaluru, 20-22 November 2011

Page 122: REST in peace @ Osidays 2011 India 11-21-2011

Goals

Work lessevolve

loose coupling

Bengaluru, 20-22 November 2011

Page 123: REST in peace @ Osidays 2011 India 11-21-2011

everything is done for us!

:)

but....

Bengaluru, 20-22 November 2011

Page 124: REST in peace @ Osidays 2011 India 11-21-2011

tmp files, cache tables, procedural code...

mmmmh....

gotta be something better

Bengaluru, 20-22 November 2011

Page 125: REST in peace @ Osidays 2011 India 11-21-2011

Frameworks

Bengaluru, 20-22 November 2011

Page 126: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 127: REST in peace @ Osidays 2011 India 11-21-2011

ONE

Bengaluru, 20-22 November 2011

Page 128: REST in peace @ Osidays 2011 India 11-21-2011

Cache is used for compiling routes, autoloading, ...

Bengaluru, 20-22 November 2011

Page 129: REST in peace @ Osidays 2011 India 11-21-2011

Cache is used for compiling routes, autoloading, ...

...but also for storing the view

Bengaluru, 20-22 November 2011

Page 130: REST in peace @ Osidays 2011 India 11-21-2011

Goals

Work lessevolve

loose coupling

Bengaluru, 20-22 November 2011

Page 131: REST in peace @ Osidays 2011 India 11-21-2011

Goals

Work lessevolve

loose coupling

Bengaluru, 20-22 November 2011

Page 132: REST in peace @ Osidays 2011 India 11-21-2011

at least because we use a framework

Bengaluru, 20-22 November 2011

Page 133: REST in peace @ Osidays 2011 India 11-21-2011

HTTP

Page 134: REST in peace @ Osidays 2011 India 11-21-2011

Less work

Bengaluru, 20-22 November 2011

Page 135: REST in peace @ Osidays 2011 India 11-21-2011

because the hard work is delegated to the browser/proxy

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

Bengaluru, 20-22 November 2011

Page 136: REST in peace @ Osidays 2011 India 11-21-2011

Evolve

Bengaluru, 20-22 November 2011

Page 137: REST in peace @ Osidays 2011 India 11-21-2011

because cache is abstracted from the application

Bengaluru, 20-22 November 2011

Page 138: REST in peace @ Osidays 2011 India 11-21-2011

Loose coupling

Bengaluru, 20-22 November 2011

Page 139: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 140: REST in peace @ Osidays 2011 India 11-21-2011

but hey, you say

Bengaluru, 20-22 November 2011

Page 141: REST in peace @ Osidays 2011 India 11-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 )

Bengaluru, 20-22 November 2011

Page 142: REST in peace @ Osidays 2011 India 11-21-2011

Nope

Nope

Bengaluru, 20-22 November 2011

Page 143: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 144: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 145: REST in peace @ Osidays 2011 India 11-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 146: REST in peace @ Osidays 2011 India 11-21-2011

<esi:include src="http://osidays.com/talks/1" />

Bengaluru, 20-22 November 2011

Page 147: REST in peace @ Osidays 2011 India 11-21-2011

<esi:include src="http://osidays.com/talks/1" />

Bengaluru, 20-22 November 2011

Page 148: REST in peace @ Osidays 2011 India 11-21-2011

<esi:include src="http://osidays.com/talks/1" />

Bengaluru, 20-22 November 2011

Page 149: REST in peace @ Osidays 2011 India 11-21-2011

1s (tweets)

3600 (post)

Bengaluru, 20-22 November 2011

Page 150: REST in peace @ Osidays 2011 India 11-21-2011

<esi:include src='tweets.html' />

<esi:include src='article/12.html' />

Bengaluru, 20-22 November 2011

Page 151: REST in peace @ Osidays 2011 India 11-21-2011

2. adaptability & durability

Bengaluru, 20-22 November 2011

Page 152: REST in peace @ Osidays 2011 India 11-21-2011

Hypermediaanother long-time friend

Bengaluru, 20-22 November 2011

Page 153: REST in peace @ Osidays 2011 India 11-21-2011

Linksoutrageously semplifying

Bengaluru, 20-22 November 2011

Page 154: REST in peace @ Osidays 2011 India 11-21-2011

<img src="..." />

<a href="..." />

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

Bengaluru, 20-22 November 2011

Page 155: REST in peace @ Osidays 2011 India 11-21-2011

<img src="..." />

<a href="..." />

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

Bengaluru, 20-22 November 2011

Page 156: REST in peace @ Osidays 2011 India 11-21-2011

<img src="..." />

<a href="..." />

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

Bengaluru, 20-22 November 2011

Page 157: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 158: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 159: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 160: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 161: REST in peace @ Osidays 2011 India 11-21-2011

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

POST /usersHost: www.example.com

Bengaluru, 20-22 November 2011

Page 162: REST in peace @ Osidays 2011 India 11-21-2011

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

POST /usersHost: www.example.com

Bengaluru, 20-22 November 2011

Page 163: REST in peace @ Osidays 2011 India 11-21-2011

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

POST /usersHost: www.example.com

Bengaluru, 20-22 November 2011

Page 164: REST in peace @ Osidays 2011 India 11-21-2011

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

POST /usersHost: www.example.com

Bengaluru, 20-22 November 2011

Page 165: REST in peace @ Osidays 2011 India 11-21-2011

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

Bengaluru, 20-22 November 2011

Page 166: REST in peace @ Osidays 2011 India 11-21-2011

Client knows how to consume the service based on the informationsauto-provided by the service itself

Bengaluru, 20-22 November 2011

Page 167: REST in peace @ Osidays 2011 India 11-21-2011

No WSDL.

Bengaluru, 20-22 November 2011

Page 168: REST in peace @ Osidays 2011 India 11-21-2011

No URI templates.

Bengaluru, 20-22 November 2011

Page 169: REST in peace @ Osidays 2011 India 11-21-2011

No easily-outdated documentation.

Bengaluru, 20-22 November 2011

Page 170: REST in peace @ Osidays 2011 India 11-21-2011

No assumptions.

Bengaluru, 20-22 November 2011

Page 171: REST in peace @ Osidays 2011 India 11-21-2011

Less WTFs.

Bengaluru, 20-22 November 2011

Page 172: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 173: REST in peace @ Osidays 2011 India 11-21-2011

This does not easily break.

Bengaluru, 20-22 November 2011

Page 174: REST in peace @ Osidays 2011 India 11-21-2011

HATEOASHypermedia As The Engine Of Application State

Bengaluru, 20-22 November 2011

Page 175: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

6

Page 176: REST in peace @ Osidays 2011 India 11-21-2011

everything seems eventually

cool

Recap: why REST?Bengaluru, 20-22 November 2011

Page 177: REST in peace @ Osidays 2011 India 11-21-2011

Pros

PerformancesBengaluru, 20-22 November 2011

Page 178: REST in peace @ Osidays 2011 India 11-21-2011

Pros

Scalability

Bengaluru, 20-22 November 2011

Page 179: REST in peace @ Osidays 2011 India 11-21-2011
Page 180: REST in peace @ Osidays 2011 India 11-21-2011

Pros

Durability

Bengaluru, 20-22 November 2011

Page 181: REST in peace @ Osidays 2011 India 11-21-2011

Not RESTful?

Bengaluru, 20-22 November 2011

Page 182: REST in peace @ Osidays 2011 India 11-21-2011

Simply don't care

Bengaluru, 20-22 November 2011

Page 183: REST in peace @ Osidays 2011 India 11-21-2011

Rules of architectural design

Bengaluru, 20-22 November 2011

Page 184: REST in peace @ Osidays 2011 India 11-21-2011

Follow them accordingto your needs

Bengaluru, 20-22 November 2011

Page 185: REST in peace @ Osidays 2011 India 11-21-2011

amazon.com

Bengaluru, 20-22 November 2011

Page 186: REST in peace @ Osidays 2011 India 11-21-2011

So...

Bengaluru, 20-22 November 2011

Page 187: REST in peace @ Osidays 2011 India 11-21-2011

Bengaluru, 20-22 November 2011

Page 188: REST in peace @ Osidays 2011 India 11-21-2011

Alessandro Nadalin

Bengaluru, 20-22 November 2011

Page 189: REST in peace @ Osidays 2011 India 11-21-2011

odino.org

Bengaluru, 20-22 November 2011

Page 190: REST in peace @ Osidays 2011 India 11-21-2011

a

Bengaluru, 20-22 November 2011

Page 191: REST in peace @ Osidays 2011 India 11-21-2011

a

Bengaluru, 20-22 November 2011

@_odino_ #osidays

Page 192: REST in peace @ Osidays 2011 India 11-21-2011

a

Bengaluru, 20-22 November 2011

@_odino_

Thank YOU!

Page 193: REST in peace @ Osidays 2011 India 11-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/

Bengaluru, 20-22 November 2011