TEST

Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.


Atomic Distributed Transactions:
a RESTful Design

Guy Pardon, ATOMIKOS [email protected] @atomikos
Cesare Pautasso, University of Lugano, Switzerland [email protected] @pautasso

Does REST need transactions?

Mike Amudsen

The Context

The Problem

Single state transfers from/to
the client are idempotent

How do we make both interactions atomic?

ACID

ATOMIC

Constraints

Try-Confirm/Cancel

TCC Participant's view

Try

POST /booking HTTP/1.1
Host: api.swiss.com
HTTP/1.1 201 Created
Location: /booking/{id}

Confirm

PUT /booking/{id} HTTP/1.1
Host: api.swiss.com
Accept: application/tcc
HTTP/1.1 204 No Content

Cancel

DELETE /booking/{id} HTTP/1.1
HTTP/1.1 204 No Content

TCC Example

Failure before Confirm

Failure after Confirm

Failure during Confirm

Timeout during Confirm

Timeout?

POST /booking/ HTTP/1.1
Host: api.swiss.com
HTTP/1.1 200 OK
Content-Type: application/json

{"participantLink": 
  { "uri":"http://api.swiss.com/booking/{id}",
    "expires":"2014-04-07T10:15:54.261+01:00", 
    "rel":"tcc" }
}

After a Timeout

PUT /booking/{id} HTTP/1.1
Host: api.swiss.com
Accept: application/tcc
HTTP/1.1 404 Not Found
Participants indicates confirmation link expired

Workflow

Try to reserve multiple resources

POST /telephone HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 201 Created
Location: /telephone/0586664302
POST /bill HTTP/1.1
Host: api.post.ch
HTTP/1.1 201 Created
Location: /bill/42

If everything is successful, confirm the bookings

PUT /telephone/0586664302 HTTP/1.1
Host: api.swisscom.ch
Accept: application/tcc
HTTP/1.1 204 No Content
PUT /bill/42 HTTP/1.1
Host: api.post.ch
Accept: application/tcc
HTTP/1.1 204 No Content

Workflow

Try to reserve multiple resources

POST /booking HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 201 Created
Location: /telephone/0586664302
POST /bill HTTP/1.1
Host: api.post.ch
HTTP/1.1 500 Internal Server Error

Incorrect billing address

If something fails, do nothing.
The reserved resources will eventually timeout.

If something fails, a polite workflow would explicitly cancel the successful reservations

DELETE /telephone/0586664302 HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 200 OK

Overview

Deployment

Deployment: Web Browser

Transactions as a Service

TaaS Coordinator API

Confirm multiple reservations atomically

PUT /coordinator/confirm HTTP/1.1 
Host: www.taas.com
Content-Type: application/tcc+json

{
  "transaction": [ {
      "uri": "http://www.example.com/part/123", 
      "expires": "2014-04-09T10:15:54.261+01:00"
    }, 
    {
      "uri": "http://www.example.com/part/234",
      "expires": "2014-04-08T10:15:54.261+01:00"
  } ] 
}
HTTP/1.1 204 No Content
HTTP/1.1 409 Conflict

TaaS Coordinator API

Cancel multiple reservations atomically

PUT /coordinator/cancel HTTP/1.1 
Host: www.taas.com
Content-Type: application/tcc+json

{
  "transaction": [ {
      "uri": "http://www.example.com/part/123", 
      "expires": "2014-04-09T10:15:54.261+01:00"
    }, 
    {
      "uri": "http://www.example.com/part/234",
      "expires": "2014-04-08T10:15:54.261+01:00"
  } ] 
}
HTTP/1.1 204 No Content

Comparison

(Jump to Conclusions)

Compensatable Workflow

Workflow models happy path + completion

The model is:

TCC Workflow

Compensation vs. TCC

TCC Benefits

Interop Risk

An interoperability risk exists if: two endpoints need to communicate, and both are outside your control

Minimize Interop Risk

Lower Coupling
Higher Autonomy

With TCC, participating services do not need to know the coordinator (unlike WS-*)

WS-*: Transaction Scope Risk

A service call can carry a transaction context, but still the service can ignore it!

WS-AT: DoS Risk

WS-AT is ACID, meaning locks

Conclusion: REST/TCC

TCC for REST

Implementation available from http://www.atomikos.com

References


Atomic Distributed Transactions:
a RESTful Design

Guy Pardon, ATOMIKOS [email protected] @atomikos
Cesare Pautasso, University of Lugano, Switzerland [email protected] @pautasso

Heuristics

A matter of timing

Agreement is reached if the confirmation phase ends before the resources undo the state transitions because of the timeouts

A matter of timing

If the confirmation runs longer than the earliest timeout, agreement cannot be guaranteed
(heuristic exception)

Use a spacebar or arrow keys to navigate