Friday, June 25, 2010
Why RESTful Design for Cloud is Best
                Galder Zamarreño
                Senior Software Engineer, Red Hat
  ...
Who is Galder?


      • Core R&D engineer on Infinispan and JBoss Cache
      • Contributor and committer on JBoss AS, Hi...
Agenda


      • Brief introduction to RESTful principles
      • Cloud APIs and REST
      • Cloud storage with Infinispa...
What is REST?


      • REpresentational State Transfer (Roy Fielding)
      • An architectural style
      • Part of the ...
What it is not


      • A protocol
      • An interface
      • An API
      • A standard
      • A drop in replacement f...
What is right with REST


      • Fixed well defined verbs
           •    GET = Read only operation to query info
       ...
What is right with REST


      • Focus on resources (not services)
           • Makes “service implementors” work harder
...
Cloud APIs and REST


      • 2 categories for Cloud APIs with different requirements
           • IT/Cloud resource manag...
REST for resource management APIs


      • Short term:
           • REST reduces invalid state transition calls
         ...
What REST can't do for resource management


      • Querying: “Get all JBoss AS instances running on
           Linux tha...
Who is using REST for resource management?


      • Sun Cloud API
           • Unfortunately dropped :(
      • Rackspace...
REST for cloud storage APIs


      • REST promotes a “stateless” architecture
           • No need for maintaining sessio...
REST for cloud storage APIs


      • WebDAV is useful over an internet connection
           • … but limited to tradition...
Who is using REST for cloud storage?


      • Tons!
           • Amazon S3, Eucalyptus, Rackspace, Mezeo,
               ...
Cloud storage DYI with Infinispan


      • No need to rely on 3rd party
      • You can build your own based on Infinispa...
Cloud storage DYI with Infinispan


      • Infinispan is remotely accessible via:
           •    Hot Rod - a custom bina...
Infinispan RESTful interface


      • PUT /{cacheName}/{cacheKey}
           • Insert or update payload in cache's key
  ...
Infinispan RESTful interface


      • GET /{cacheName}/{cacheKey}
           • Return value of cached key as body in resp...
Infinispan REST Clients


      • Any HTTP client will do, example:




Friday, June 25, 2010
Applying RESTful principles to other APIs


      • Any Resource Oriented Architecture (ROA)
           • i.e. A library w...
Applying RESTful principles to other APIs


      • A resource can...
           • Be related/linked via hypermedia
      ...
Applying RESTful principles to other APIs


      • Business processes represented HTTP methods
           • i.e. Borrowin...
If REST told you to jump off a bridge, would you?


      • Complex queries with many parameters are tricky
           • i...
Demo




Friday, June 25, 2010
Summary


      • REST suits cloud management APIs
           • But remember limitations with history and queries
      • ...
Questions?

      • Personal:
           • Site: http://galder.zamarreno.com
           • Twitter: @galderz
      • Projec...
Friday, June 25, 2010
Upcoming SlideShare
Loading in...5
×

Why RESTful Design for the Cloud is Best

2,413

Published on

In this session, Galder Zamarreño, a senior software engineer at Red Hat, will:

- Provide a brief introduction to RESTful principles
Discuss how cloud-scale APIs are done best with REST

- Introduce Infinispan REST server, focusing on its cloud capabilities and simple REST API

- Detail how REST can apply to many APIs, focusing on some of the deeper principles and practices behind it and how easy it is to implement and use

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,413
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Why RESTful Design for the Cloud is Best

  1. 1. Friday, June 25, 2010
  2. 2. Why RESTful Design for Cloud is Best Galder Zamarreño Senior Software Engineer, Red Hat 25th June 2010 Friday, June 25, 2010
  3. 3. Who is Galder? • Core R&D engineer on Infinispan and JBoss Cache • Contributor and committer on JBoss AS, Hibernate, JGroups, JBoss Portal...etc Friday, June 25, 2010
  4. 4. Agenda • Brief introduction to RESTful principles • Cloud APIs and REST • Cloud storage with Infinispan REST module • Applying RESTful principles to other APIs • Demo Friday, June 25, 2010
  5. 5. What is REST? • REpresentational State Transfer (Roy Fielding) • An architectural style • Part of the web from day 1 (sort of...) • Evolved with HTTP 1.1 Friday, June 25, 2010
  6. 6. What it is not • A protocol • An interface • An API • A standard • A drop in replacement for SOAP (or RPC) Friday, June 25, 2010
  7. 7. What is right with REST • Fixed well defined verbs • GET = Read only operation to query info • PUT = Stores body sent in location • POST = Create subordinate resources • DELETE = Remove resources • HEAD = Like GET but no response body Friday, June 25, 2010
  8. 8. What is right with REST • Focus on resources (not services) • Makes “service implementors” work harder • Requests are stateless • Hypermedia As The Engine of Application State (HATEOAS) Friday, June 25, 2010
  9. 9. Cloud APIs and REST • 2 categories for Cloud APIs with different requirements • IT/Cloud resource management • Non-REST APIs: SNMP, WBEM, WMI, JMX/RMI, OSGI...etc • Cloud storage • Non-REST APIs: NFS, CIFS, WebDAV...etc • REST can provide a consistent set of principles Friday, June 25, 2010
  10. 10. REST for resource management APIs • Short term: • REST reduces invalid state transition calls • REST is to IT management protocol design what classical music training is to a rock musician • Long term: • REST enables IT management console “in the cloud” • But above all: • The API doesn't constrain the design of the URI space Friday, June 25, 2010
  11. 11. What REST can't do for resource management • Querying: “Get all JBoss AS instances running on Linux that don't have patch JBAS-1234 applied” • Links are part of resource representation, not resources of their own • Retrieving resource configuration change history • Can you guarantee that URIs will remain unchanged? • These problems beg for an RPC pattern Friday, June 25, 2010
  12. 12. Who is using REST for resource management? • Sun Cloud API • Unfortunately dropped :( • Rackspace • Multiple representation - JSON/XML...etc • EC2 • No REST; Plain HTTP or SOAP • VMWare vCloud Friday, June 25, 2010
  13. 13. REST for cloud storage APIs • REST promotes a “stateless” architecture • No need for maintaining sessions, easier to scale up • Improved network efficiency thanks to caching • Internet is highly latent • NFS or CIFS only valid in local network access Friday, June 25, 2010
  14. 14. REST for cloud storage APIs • WebDAV is useful over an internet connection • … but limited to traditional file operations • i.e. store, retrieve...etc • REST offers a solution... • … that is more flexible and robust • … and works in both remote and local access modes Friday, June 25, 2010
  15. 15. Who is using REST for cloud storage? • Tons! • Amazon S3, Eucalyptus, Rackspace, Mezeo, Nirvanix, ...etc • Cloud storage abstractions libraries ease transition • jclouds for java/clojure • Simple Cloud for PHP Friday, June 25, 2010
  16. 16. Cloud storage DYI with Infinispan • No need to rely on 3rd party • You can build your own based on Infinispan • Infinispan is an in-memory data grid platform • Consistent hash based data distribution • Built-in eviction, prevents OOMs! • GUI management and monitoring provided by JOPR Friday, June 25, 2010
  17. 17. Cloud storage DYI with Infinispan • Infinispan is remotely accessible via: • Hot Rod - a custom binary protocol • Memcached text protocol • WebSocket for javascript clients (HTML5) • RESTful interface (of course!) Friday, June 25, 2010
  18. 18. Infinispan RESTful interface • PUT /{cacheName}/{cacheKey} • Insert or update payload in cache's key • POST /{cacheName}/{cacheKey} • Same as PUT but if key exists, returns HTTP conflict • Headers for PUT/POST • Content-Type mandatory – use media/mime-types • Optional: timeToLiveSeconds, maxIdleTimeSeconds, performAsync Friday, June 25, 2010
  19. 19. Infinispan RESTful interface • GET /{cacheName}/{cacheKey} • Return value of cached key as body in response • DELETE /{cacheName}/{cacheKey} • Remove given key from cache • DELETE /{cacheName} • Remove ALL the entries from given cache Friday, June 25, 2010
  20. 20. Infinispan REST Clients • Any HTTP client will do, example: Friday, June 25, 2010
  21. 21. Applying RESTful principles to other APIs • Any Resource Oriented Architecture (ROA) • i.e. A library with books and members as resources • A resource has... • Unique ID (and hence an URI) • i.e. http://my.library.com/book/1234 Friday, June 25, 2010
  22. 22. Applying RESTful principles to other APIs • A resource can... • Be related/linked via hypermedia • Have different state and representations • i.e. Borrowed/Available, JSON/HTML/XML...etc • Systems with single entry point and rest discovered • i.e. Library as entry point and books/members linked Friday, June 25, 2010
  23. 23. Applying RESTful principles to other APIs • Business processes represented HTTP methods • i.e. Borrowing a book represented as: • PUT http://my.library.com/member/5678/book/1234 • Use self-descriptive messages • i.e. application/my.library.com.Book+json Friday, June 25, 2010
  24. 24. If REST told you to jump off a bridge, would you? • Complex queries with many parameters are tricky • i.e. “List the female Spanish members aged between 20 and 30 that borrowed books between 1980 and 1990, and never returned them” • Do not make resources out of such queries • RPC-like query operation is much better suited here Friday, June 25, 2010
  25. 25. Demo Friday, June 25, 2010
  26. 26. Summary • REST suits cloud management APIs • But remember limitations with history and queries • REST and cloud storage APIs are made for each other • Cloud storage with Infinispan REST module is simple • RESTful principles are applicable to other APIs • Don't convert queries into resources, use RPC Friday, June 25, 2010
  27. 27. Questions? • Personal: • Site: http://galder.zamarreno.com • Twitter: @galderz • Project: • Site: http://www.infinispan.org • Blog: http://blog.infinispan.org • Twitter: @infinispan • Tweet: • #infinispan, #summitjbw Friday, June 25, 2010
  28. 28. Friday, June 25, 2010
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×