SlideShare a Scribd company logo
1 of 22
Atomic Transactions for the
        REST of us

              Cesare Pautasso
           Faculty of Informatics
      University of Lugano, Switzerland

            c.pautasso@ieee.org
         http://www.pautasso.info
                 @pautasso
Acknowledgements
            This is joint work with Guy Pardon, Atomikos




                          http://www.atomikos.com



©2010 - Cesare Pautasso                                     2
Does REST need transactions?
    If you find yourself in need of a distributed
     transaction protocol, then how can you possibly say
     that your architecture is based on REST? I simply
     cannot see how you can get from one situation (of
     using RESTful application state on the client and
     hypermedia to determine all state transitions) to the
     next situation of needing distributed agreement of
     transaction semantics wherein the client has to tell
     the server how to manage its own resources.
    ...for now I consider "rest transaction" to be an
     oxymoron.

                          Roy Fielding, REST discuss, June 9th, 2009


©2010 - Cesare Pautasso                                                3
Does REST need transactions?
    The typical conversation thread, real or virtual, about
     transactions over HTTP goes something like this
     (elided for brevity):
            "You don't want transactions over HTTP"
            But I need to organize number of steps into a single unit I
             can deal with easily.
            "OK, but you don't need transactions over HTTP"
            But I need the ability to back out changes in multiple
             locations safely and consistently.
            "OK, but you can't do transactions over HTTP!"
            Really?
    And here the topic usually dies or descends into a
     heated debate.
                                           Mike Amudsen,
              http://amundsen.com/blog/archives/1024
©2010 - Cesare Pautasso                                                    4
Context
           PUT
                                                              
                          R      RESTful Web Service               Persistent
                                                                    Storage



?
              GET

                   POST
                              DELETE
                                                                              Backend 1

                                                                  
            PUT


              GET
                          S      RESTful Web Service                          Backend 2

                   POST                                                       Database 3
                              DELETE


                                 Adapted from Stefan Tilkov, Using REST for SOA, QCon SFO 2010
©2010 - Cesare Pautasso                                                                          5
The problem

                                       PUT

            Client         State transfer
                                        GET
                                                  R      RESTful Web Service


                                             POST
                                                      DELETE

                          State transfer PUT

                                            GET
                                                  S      RESTful Web Service


                                             POST
                                                      DELETE
    Thanks to the idempotency of GET/PUT,
      each individual state transfer is reliable and atomic
©2010 - Cesare Pautasso                                                        6
The problem

                                       PUT

                           State transfer
                                        GET
                                                  R      RESTful Web Service


            Client                           POST
                                                      DELETE

                          State transfer PUT

                                            GET
                                                  S      RESTful Web Service


                                             POST
                                                      DELETE

    How to we make both interactions atomic?
©2010 - Cesare Pautasso                                                        7
Constraints
             Interoperability:
               No changes/extensions to HTTP
               • No additional verbs
               • No special/custom headers

             Loose Coupling:
                  REST shifts all the “work” to the client
                  RESTful Web services should remain unaware
                   they are participating in a transaction

             Simplicity:
                  Transactions will not be adopted in practice
                   unless they can be made simple enough
©2010 - Cesare Pautasso                                           8
Assumption: Try-Confirm/Cancel
            Resource state transitions follow the TCC pattern
                          Cancel

  Initial                   Try      Confirm          Final
  State                             Reserved          State
                          Timeout   State
            Before they are made permanent state transitions
             go through an intermediate “reserved” state
             which either will be confirmed or canceled
             by a client within a given time
            Hint: Cancel/Confirm are idempotent
©2010 - Cesare Pautasso                                          9
Example: Flight Booking Resource
   Try                    Reserve the flight
    POST /booking
    302 Location: /booking/X              URI of the
                                           reserved state
   Confirm
    PUT /booking/X
                                  Pay and confirm
    200                             the flight

   Cancel
                                         Cancel the
    DELETE /booking/X                   reservation
    200

©2010 - Cesare Pautasso                                     10
Protocol
  1. A client interacts with multiple RESTful Web services.
     Interactions may lead to state transitions
     (the intermediate state is identified by a URI known to
     the client)
  2. Once the client has completed all interactions, it uses
     the URIs identifying the intermediate states to
     confirm the state transitions (and thus commit the
     transaction)

  Note: If the client stops before step 2, the state
     transitions will eventually be undone by the services
     themselves (after a timeout).
     As an optimization, the client can use the same URIs
     to cancel the state transitions (and thus explicitly
     rollback the transaction).
©2010 - Cesare Pautasso                                        11
Simple Example
                  POST www.swiss.ch/booking
  1.              302 Location: /booking/1

                  POST www.ezyj.com/booking
                  302 Location:/booking/X

                  PUT www.swiss.ch/booking/1
  2.

   Confirm
                  200

                  PUT www.ezyj.com/booking/X
                  200
©2010 - Cesare Pautasso                        12
What if something fails?
                    POST www.swiss.ch/booking
  1.                     Whatever
                    302happens, these
                        Location: /booking/1
                       state transitions   If something fails,
                        are temporary.
                    POST www.ezy.com/booking before moving
                                          stop
                    302 Location:/booking/X        to phase 2


                    PUT www.swiss.ch/booking/1
  2.                    Only idempotent




   Confirm
                    200 methods
                        are allowed in the
                          confirmation
                    PUT www.ezy.com/booking/X
                                            If something fails,
                              phase.       retry as many times
                    200
                                                 as necessary
©2010 - Cesare Pautasso                                           13
A matter of timing
                                                    Timeouts
          State transitions




                              1.      2.
                              Try   Confirm

                                                            Time
      Agreement is reached if the confirmation phase ends before the
      resources undo the state transitions because of the timeouts
©2010 - Cesare Pautasso                                                14
A matter of timing
                                                      Timeouts
          State transitions




                              1.           2.
                              Try        Confirm

                                                               Time
      If the confirmation runs longer than the earliest timeout we
      cannot guarantee agreement
©2010 - Cesare Pautasso                                               15
Timeouts and heuristics
   Bad News: As with every distributed agreement
    protocol, it is impossible to avoid heuristics
   Good News:
      thanks to the REST uniform interface we can always
       do a GET on the URI of the reserved resource to see
       how much time we have left before it cancels
      Avoid starting phase 2 if there is not enough time
       left to confirm with every service
   More complex preparation: if the resource allows it,
    extend the reservation time (also idempotent) before
    starting phase 2.
   In any case, use a lightweight transaction coordinator
    to log everything for recovery and human diagnosis of
    heuristics
©2010 - Cesare Pautasso                                      16
Architecture (Client-side Transaction)
                                                     Try
                                              1
                            Client                Confirm    2
                          Application         1
                                                      Try
                                3             1
                                                  Confirm
                           5        Confirm   4              2
                          Transaction         4
                            Library                  Try
                                              4

                                                  Confirm    2
                               Client
                                                          TCC
                                                        Resources
©2010 - Cesare Pautasso                                             17
Architecture (Service Composition)
                                                            Try

                                                     1
                          0                              Confirm
   Client                          Workflow                            2
                              6     Engine           1
                                                             Try
                                       3             1
                                                         Confirm
                                   5       Confirm   4                 2
                                  Transaction        4
                                  Coordinator               Try
                                                     4

                                                         Confirm       2
                                  Composite
                                   RESTful                          TCC
                                   Service                        Resources
©2010 - Cesare Pautasso                                                       18
Conclusion
            The protocol guarantees atomicity in the
             event of failures among multiple interactions
             with RESTful Web services that comply with
             the TCC pattern.
            (We are not interested in isolation)
            No HTTP extension is required
            Fits very nicely with the REST uniform
             interface and the idempotency of the
             PUT/DELETE methods
            Hypermedia can be easily built in to guide
             the discovery of the
             cancellation/confirmation URIs
             (e.g., with HTTP Link Headers)
©2010 - Cesare Pautasso                                      19
References
    G. Pardon, C. Pautasso, Towards Distributed Atomic Transactions over
     RESTful Services, in: REST: from Research to Practice, Springer (to appear)
    Cesare Pautasso, RESTful Web Service Composition with JOpera, Proc. Of
     the International Conference on Software Composition (SC 2009), Zurich,
     Switzerland, July 2009.




©2010 - Cesare Pautasso                                                            20
WS-REST 2011




                          http://ws-rest.org/2011

            @WWW2011, Hyderabad, India
            28 March 2011
            Paper Submission is open (deadline: 31 Jan 2011)

©2010 - Cesare Pautasso                                         21
©2010 Cesare Pautasso   22

More Related Content

Viewers also liked

The New Way of Developing with AEM 6.0 | Sightly | Beautiful Markup
The New Way of Developing with AEM 6.0 | Sightly | Beautiful MarkupThe New Way of Developing with AEM 6.0 | Sightly | Beautiful Markup
The New Way of Developing with AEM 6.0 | Sightly | Beautiful MarkupSenol Tas
 
Adobe Sneak Peak - Introducing HTL @ Evovle'13
Adobe Sneak Peak - Introducing HTL @ Evovle'13Adobe Sneak Peak - Introducing HTL @ Evovle'13
Adobe Sneak Peak - Introducing HTL @ Evovle'13Senol Tas
 
Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPubPeter Keane
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsMartin Gutenbrunner
 
Security for netflix billing & payments (meetup)
Security for netflix billing & payments (meetup)Security for netflix billing & payments (meetup)
Security for netflix billing & payments (meetup)Poornaprajna Udupi
 
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the CloudMathieu Chauvin
 
Escape From PCI Land
Escape From PCI LandEscape From PCI Land
Escape From PCI LandRahul Dani
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsStormpath
 

Viewers also liked (9)

The New Way of Developing with AEM 6.0 | Sightly | Beautiful Markup
The New Way of Developing with AEM 6.0 | Sightly | Beautiful MarkupThe New Way of Developing with AEM 6.0 | Sightly | Beautiful Markup
The New Way of Developing with AEM 6.0 | Sightly | Beautiful Markup
 
Adobe Sneak Peak - Introducing HTL @ Evovle'13
Adobe Sneak Peak - Introducing HTL @ Evovle'13Adobe Sneak Peak - Introducing HTL @ Evovle'13
Adobe Sneak Peak - Introducing HTL @ Evovle'13
 
Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPub
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environments
 
Security for netflix billing & payments (meetup)
Security for netflix billing & payments (meetup)Security for netflix billing & payments (meetup)
Security for netflix billing & payments (meetup)
 
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud
3/18/15 Billing&Payments Eng Meetup II - Payments Processing in the Cloud
 
Escape From PCI Land
Escape From PCI LandEscape From PCI Land
Escape From PCI Land
 
IBM Bluemix Overview
IBM Bluemix OverviewIBM Bluemix Overview
IBM Bluemix Overview
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
 

Similar to Atomic Transactions for the REST of us

RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOperaCesare Pautasso
 
Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Cesare Pautasso
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesCesare Pautasso
 
WS-* vs. RESTful Services
WS-* vs. RESTful ServicesWS-* vs. RESTful Services
WS-* vs. RESTful ServicesCesare Pautasso
 
Composing RESTful Services with JOpera
Composing RESTful Services with JOperaComposing RESTful Services with JOpera
Composing RESTful Services with JOperaCesare Pautasso
 
Composing REST Services
Composing REST ServicesComposing REST Services
Composing REST Serviceselliando dias
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservicelonegunman
 
Web of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebWeb of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebDominique Guinard
 
Cesare Pautasso R E S T V1
Cesare  Pautasso    R E S T V1Cesare  Pautasso    R E S T V1
Cesare Pautasso R E S T V1SOA Symposium
 
Protecting Multi-Interfaced Mobile Web Services using Agreements
Protecting Multi-Interfaced Mobile Web Services using Agreements Protecting Multi-Interfaced Mobile Web Services using Agreements
Protecting Multi-Interfaced Mobile Web Services using Agreements Dr. Fahad Aijaz
 

Similar to Atomic Transactions for the REST of us (18)

BPM with REST
BPM with RESTBPM with REST
BPM with REST
 
RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOpera
 
SOA2010 SOA with REST
SOA2010 SOA with RESTSOA2010 SOA with REST
SOA2010 SOA with REST
 
Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009
 
SOA with REST
SOA with RESTSOA with REST
SOA with REST
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business Processes
 
BPMN for REST
BPMN for RESTBPMN for REST
BPMN for REST
 
Www2008 Restws Pautasso Talk
Www2008 Restws Pautasso TalkWww2008 Restws Pautasso Talk
Www2008 Restws Pautasso Talk
 
WS-* vs. RESTful Services
WS-* vs. RESTful ServicesWS-* vs. RESTful Services
WS-* vs. RESTful Services
 
Composing RESTful Services with JOpera
Composing RESTful Services with JOperaComposing RESTful Services with JOpera
Composing RESTful Services with JOpera
 
Composing REST Services
Composing REST ServicesComposing REST Services
Composing REST Services
 
REST vs. SOAP
REST vs. SOAPREST vs. SOAP
REST vs. SOAP
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservice
 
Web of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebWeb of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the Web
 
Cesare Pautasso R E S T V1
Cesare  Pautasso    R E S T V1Cesare  Pautasso    R E S T V1
Cesare Pautasso R E S T V1
 
WebSocket protocol
WebSocket protocolWebSocket protocol
WebSocket protocol
 
Protecting Multi-Interfaced Mobile Web Services using Agreements
Protecting Multi-Interfaced Mobile Web Services using Agreements Protecting Multi-Interfaced Mobile Web Services using Agreements
Protecting Multi-Interfaced Mobile Web Services using Agreements
 
Take a REST!
Take a REST!Take a REST!
Take a REST!
 

More from Cesare Pautasso

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteCesare Pautasso
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?Cesare Pautasso
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Cesare Pautasso
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremCesare Pautasso
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software ConnectorCesare Pautasso
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Cesare Pautasso
 
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...Cesare Pautasso
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesCesare Pautasso
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionCesare Pautasso
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiCesare Pautasso
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresCesare Pautasso
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate MemberCesare Pautasso
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Cesare Pautasso
 
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Cesare Pautasso
 
Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Cesare Pautasso
 

More from Cesare Pautasso (20)

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 Keynote
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC Theorem
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software Connector
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...
 
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web Services
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process Execution
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service Geografici
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate Member
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)
 
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
 
Mashups09
Mashups09Mashups09
Mashups09
 
Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)
 
Composing REST Services
Composing REST ServicesComposing REST Services
Composing REST Services
 
Mashup Ecosystem
Mashup EcosystemMashup Ecosystem
Mashup Ecosystem
 
Mashup Atelier
Mashup AtelierMashup Atelier
Mashup Atelier
 
MetaCDN
MetaCDNMetaCDN
MetaCDN
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Atomic Transactions for the REST of us

  • 1. Atomic Transactions for the REST of us Cesare Pautasso Faculty of Informatics University of Lugano, Switzerland c.pautasso@ieee.org http://www.pautasso.info @pautasso
  • 2. Acknowledgements  This is joint work with Guy Pardon, Atomikos http://www.atomikos.com ©2010 - Cesare Pautasso 2
  • 3. Does REST need transactions?  If you find yourself in need of a distributed transaction protocol, then how can you possibly say that your architecture is based on REST? I simply cannot see how you can get from one situation (of using RESTful application state on the client and hypermedia to determine all state transitions) to the next situation of needing distributed agreement of transaction semantics wherein the client has to tell the server how to manage its own resources.  ...for now I consider "rest transaction" to be an oxymoron. Roy Fielding, REST discuss, June 9th, 2009 ©2010 - Cesare Pautasso 3
  • 4. Does REST need transactions?  The typical conversation thread, real or virtual, about transactions over HTTP goes something like this (elided for brevity):  "You don't want transactions over HTTP"  But I need to organize number of steps into a single unit I can deal with easily.  "OK, but you don't need transactions over HTTP"  But I need the ability to back out changes in multiple locations safely and consistently.  "OK, but you can't do transactions over HTTP!"  Really?  And here the topic usually dies or descends into a heated debate. Mike Amudsen, http://amundsen.com/blog/archives/1024 ©2010 - Cesare Pautasso 4
  • 5. Context PUT  R RESTful Web Service Persistent Storage ? GET POST DELETE Backend 1  PUT GET S RESTful Web Service Backend 2 POST Database 3 DELETE Adapted from Stefan Tilkov, Using REST for SOA, QCon SFO 2010 ©2010 - Cesare Pautasso 5
  • 6. The problem PUT Client State transfer GET R RESTful Web Service POST DELETE State transfer PUT GET S RESTful Web Service POST DELETE Thanks to the idempotency of GET/PUT, each individual state transfer is reliable and atomic ©2010 - Cesare Pautasso 6
  • 7. The problem PUT State transfer GET R RESTful Web Service Client POST DELETE State transfer PUT GET S RESTful Web Service POST DELETE How to we make both interactions atomic? ©2010 - Cesare Pautasso 7
  • 8. Constraints  Interoperability:  No changes/extensions to HTTP • No additional verbs • No special/custom headers  Loose Coupling:  REST shifts all the “work” to the client  RESTful Web services should remain unaware they are participating in a transaction  Simplicity:  Transactions will not be adopted in practice unless they can be made simple enough ©2010 - Cesare Pautasso 8
  • 9. Assumption: Try-Confirm/Cancel  Resource state transitions follow the TCC pattern Cancel Initial Try Confirm Final State Reserved State Timeout State  Before they are made permanent state transitions go through an intermediate “reserved” state which either will be confirmed or canceled by a client within a given time  Hint: Cancel/Confirm are idempotent ©2010 - Cesare Pautasso 9
  • 10. Example: Flight Booking Resource Try Reserve the flight  POST /booking  302 Location: /booking/X URI of the reserved state Confirm  PUT /booking/X Pay and confirm  200 the flight Cancel Cancel the  DELETE /booking/X reservation  200 ©2010 - Cesare Pautasso 10
  • 11. Protocol 1. A client interacts with multiple RESTful Web services. Interactions may lead to state transitions (the intermediate state is identified by a URI known to the client) 2. Once the client has completed all interactions, it uses the URIs identifying the intermediate states to confirm the state transitions (and thus commit the transaction) Note: If the client stops before step 2, the state transitions will eventually be undone by the services themselves (after a timeout). As an optimization, the client can use the same URIs to cancel the state transitions (and thus explicitly rollback the transaction). ©2010 - Cesare Pautasso 11
  • 12. Simple Example POST www.swiss.ch/booking 1. 302 Location: /booking/1 POST www.ezyj.com/booking 302 Location:/booking/X PUT www.swiss.ch/booking/1 2. Confirm 200 PUT www.ezyj.com/booking/X 200 ©2010 - Cesare Pautasso 12
  • 13. What if something fails? POST www.swiss.ch/booking 1. Whatever 302happens, these Location: /booking/1 state transitions If something fails, are temporary. POST www.ezy.com/booking before moving stop 302 Location:/booking/X to phase 2 PUT www.swiss.ch/booking/1 2. Only idempotent Confirm 200 methods are allowed in the confirmation PUT www.ezy.com/booking/X If something fails, phase. retry as many times 200 as necessary ©2010 - Cesare Pautasso 13
  • 14. A matter of timing Timeouts State transitions 1. 2. Try Confirm Time Agreement is reached if the confirmation phase ends before the resources undo the state transitions because of the timeouts ©2010 - Cesare Pautasso 14
  • 15. A matter of timing Timeouts State transitions 1. 2. Try Confirm Time If the confirmation runs longer than the earliest timeout we cannot guarantee agreement ©2010 - Cesare Pautasso 15
  • 16. Timeouts and heuristics  Bad News: As with every distributed agreement protocol, it is impossible to avoid heuristics  Good News:  thanks to the REST uniform interface we can always do a GET on the URI of the reserved resource to see how much time we have left before it cancels  Avoid starting phase 2 if there is not enough time left to confirm with every service  More complex preparation: if the resource allows it, extend the reservation time (also idempotent) before starting phase 2.  In any case, use a lightweight transaction coordinator to log everything for recovery and human diagnosis of heuristics ©2010 - Cesare Pautasso 16
  • 17. Architecture (Client-side Transaction) Try 1 Client Confirm 2 Application 1 Try 3 1 Confirm 5 Confirm 4 2 Transaction 4 Library Try 4 Confirm 2 Client TCC Resources ©2010 - Cesare Pautasso 17
  • 18. Architecture (Service Composition) Try 1 0 Confirm Client Workflow 2 6 Engine 1 Try 3 1 Confirm 5 Confirm 4 2 Transaction 4 Coordinator Try 4 Confirm 2 Composite RESTful TCC Service Resources ©2010 - Cesare Pautasso 18
  • 19. Conclusion  The protocol guarantees atomicity in the event of failures among multiple interactions with RESTful Web services that comply with the TCC pattern.  (We are not interested in isolation)  No HTTP extension is required  Fits very nicely with the REST uniform interface and the idempotency of the PUT/DELETE methods  Hypermedia can be easily built in to guide the discovery of the cancellation/confirmation URIs (e.g., with HTTP Link Headers) ©2010 - Cesare Pautasso 19
  • 20. References  G. Pardon, C. Pautasso, Towards Distributed Atomic Transactions over RESTful Services, in: REST: from Research to Practice, Springer (to appear)  Cesare Pautasso, RESTful Web Service Composition with JOpera, Proc. Of the International Conference on Software Composition (SC 2009), Zurich, Switzerland, July 2009. ©2010 - Cesare Pautasso 20
  • 21. WS-REST 2011 http://ws-rest.org/2011  @WWW2011, Hyderabad, India  28 March 2011  Paper Submission is open (deadline: 31 Jan 2011) ©2010 - Cesare Pautasso 21