SlideShare a Scribd company logo
1 of 22
Thoughts on
Transactions
Chained transactions for scaling ACID
@billynewport
@billynewport
1
Agenda
 Explain scenario
 Implement using a single database
 Explain concurrency issues under load
 Implement using a sharded database
 Implement using WebSphere eXtreme Scale and
chained transactions
@billynewport
2
Scenario
 Large eCommerce web site
 Problem is order checkout
 We track inventory levels for each SKU
 Orders during checkout need to adjust available
inventory.
@billynewport
3
Shopping cart metrics
 Millions of SKUs
 Cart size of 5 items for electronics/big ticket items
 Cart size of 20 items for clothing
 Expect concurrent load of 2500 checkouts per second
@billynewport
4
Database
 Begin
 For each item in cart
 Select for update where sku = item.sku
 Decrement available sku level
 If not available then rollback…
 Update level where sku = item.sku
 Commit
Cart items randomly distributed amongst all 2m items, lots
of concurrency.
Simple enough, right? All is good?
@billynewport
5
Problem: cabbage patch dolls
 Cabbage patch dolls are popular this fall…
@billynewport
6
Database killers!
 The dolls cause major
concurrency problems
 Lots of row level locks
 Contention on doll rows
 Possible table lock escalation
 App server thread issues
 Connection pools empty
 Then DEATH!
 They aren’t sweet and cuddly any
more…
@billynewport
7
Database killers
 We need a way to get locks to decrement inventory
 But, we don’t want to hold the lock for very long
 Bigger carts make the problem worse, all the locks held
for longer
 Ideally, hold locks for constant time
 Any contentious items make problem worse
@billynewport
8
Solution
 Hold lock on inventory rows for as short a time as
possible
 Decouple this from size of cart.
 How?
@billynewport
9
Chained transactions
 Programmers think of transactions in synchronous
terms.
 Begin / Do Work / Hold locks / Commit
 Easy to program, bad for concurrency.
@billynewport
10
Inspiration
 Microsoft had COM objects with apartment model
threading.
 Modern Actor support is similar. Some state with a
mailbox.
 BPEL supports flows with compensation
 Data meets actors is a good analogy
 Send a message (cart) to a group of actors identified
using their keys with a compensator
@billynewport
11
Alternative
 We need to think asynchronously in terms of flows with
compensation
 Map of <SKU Key/SKU Amount>
 Brick:
 Do
{ code to reduce inventory level for SKU }
 Undo
{ code to increase level inventory for SKU }
 Provide Map with do/undo bricks
 Easy to program, great concurrency.
@billynewport
12
Transactions and sharded
stores
 Option 1: Write transaction to one shard then
spread out asynchronously
 Option 2: 2 phase commit
 Option 3: Chained transactions
@billynewport
13
Transactions and sharded
stores
 Option 1: Write transaction to one shard then spread
out asynchronously
 Option 2: 2 phase commit
 Option 3: Chained transactions
@billynewport
14
Transactions and sharded
stores
 Option 1: Write transaction to one shard then spread
out asynchronously
 Option 2: 2 phase commit
 Option 3: Chained transactions
@billynewport
15
Implementation
 1PC only required
 Data store supporting
 Row locks
 Row oriented data
 Integrated FIFO messaging
 IBM WebSphere eXtreme Scale provides these
capabilities.
@billynewport
16
Implementation
 Application makes map and code bricks
 Submits transaction as an asynchronous job.
 Uses a Future to check on job outcome.
 Do blocks can trigger flow reversal if a problem occurs.
 Invoke undo block for each completed step
@billynewport
17
Mechanism
 Loop
 Receive message for actor key
 Process it
 Send modified cart to next ‘sku’ using local ‘transmit q’
 Commit transaction
 Background thread pushes messages in transmit q to
the destination shards using exactly once semantics.
@billynewport
18
Performance
 A single logical transaction will be slower than a 1PC
DBMS implementation.
 However, under concurrent load then it will deliver:
 Higher throughput
 Better response times
 Thru better contention management
 Each ‘SKU’ only locked for a very short period
@billynewport
19
Generalization
 This could be thought of as a workflow engine.
 But, a big difference here is that a workflow engine usually
talks with a remote store.
 Here:
 the flow state is the MESSAGE
 It moves around to where the data is for the next step
 Using a MESSAGE for flow state rather than a database
means it scales linearly.
 The message ‘store’ is integrated and scales with the data
store.
@billynewport
20
Architecture Comparison
Conventional Message oriented
@billynewport
21
Flow
DB
Appl
DB
Msg
Store
BP
Engi
ne
BP
Engi
ne
BP
Engine
Flow
State
Flow
Edge
= Msg
Integrated
Msg/Data store
Appl
DB
Write
behind
Integrated
Msg/Data store
Integrated
Msg/Data store
Sample implementation
 Coming soon.
 Running in lab
 Working with several eCommerce customers looking to
implement soon.
 Soon to be published on github as sample code.
@billynewport
22

More Related Content

Similar to Using chained transactions for maximum concurrency under load (QCONSF 2010)

Microservices Coordination using Saga
Microservices Coordination using SagaMicroservices Coordination using Saga
Microservices Coordination using Saga
Eran Levy
 
Bloom plseminar-sp15
Bloom plseminar-sp15Bloom plseminar-sp15
Bloom plseminar-sp15
Joe Hellerstein
 
No More Hops Towards A Linearly Scalable Application Infrastructure
No More Hops Towards A Linearly Scalable Application InfrastructureNo More Hops Towards A Linearly Scalable Application Infrastructure
No More Hops Towards A Linearly Scalable Application Infrastructure
ConSanFrancisco123
 
Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011
Maarten Balliauw
 

Similar to Using chained transactions for maximum concurrency under load (QCONSF 2010) (20)

MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
 
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
Exactly Once Delivery with Kafka - Kafka Tel-Aviv MeetupExactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
 
Microservices Coordination using Saga
Microservices Coordination using SagaMicroservices Coordination using Saga
Microservices Coordination using Saga
 
Building Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache KafkaBuilding Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache Kafka
 
ngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets Redux
 
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2:  Building Event-Driven Services with Apache KafkaEvent Driven Services Part 2:  Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
 
Supercharge Your Applications
Supercharge Your ApplicationsSupercharge Your Applications
Supercharge Your Applications
 
Effective Akka v2
Effective Akka v2Effective Akka v2
Effective Akka v2
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...
MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...
MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...
 
SOA, Microservices and Event Driven Architecture
SOA, Microservices and Event Driven ArchitectureSOA, Microservices and Event Driven Architecture
SOA, Microservices and Event Driven Architecture
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2Web
 
Building Event Driven Services with Kafka Streams
Building Event Driven Services with Kafka StreamsBuilding Event Driven Services with Kafka Streams
Building Event Driven Services with Kafka Streams
 
Real-Time Stats for Candy Box
Real-Time Stats for Candy Box  Real-Time Stats for Candy Box
Real-Time Stats for Candy Box
 
Microservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka EcosystemMicroservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka Ecosystem
 
Bloom plseminar-sp15
Bloom plseminar-sp15Bloom plseminar-sp15
Bloom plseminar-sp15
 
10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices
 
iFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with ScyllaiFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with Scylla
 
No More Hops Towards A Linearly Scalable Application Infrastructure
No More Hops Towards A Linearly Scalable Application InfrastructureNo More Hops Towards A Linearly Scalable Application Infrastructure
No More Hops Towards A Linearly Scalable Application Infrastructure
 
Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Using chained transactions for maximum concurrency under load (QCONSF 2010)

  • 1. Thoughts on Transactions Chained transactions for scaling ACID @billynewport @billynewport 1
  • 2. Agenda  Explain scenario  Implement using a single database  Explain concurrency issues under load  Implement using a sharded database  Implement using WebSphere eXtreme Scale and chained transactions @billynewport 2
  • 3. Scenario  Large eCommerce web site  Problem is order checkout  We track inventory levels for each SKU  Orders during checkout need to adjust available inventory. @billynewport 3
  • 4. Shopping cart metrics  Millions of SKUs  Cart size of 5 items for electronics/big ticket items  Cart size of 20 items for clothing  Expect concurrent load of 2500 checkouts per second @billynewport 4
  • 5. Database  Begin  For each item in cart  Select for update where sku = item.sku  Decrement available sku level  If not available then rollback…  Update level where sku = item.sku  Commit Cart items randomly distributed amongst all 2m items, lots of concurrency. Simple enough, right? All is good? @billynewport 5
  • 6. Problem: cabbage patch dolls  Cabbage patch dolls are popular this fall… @billynewport 6
  • 7. Database killers!  The dolls cause major concurrency problems  Lots of row level locks  Contention on doll rows  Possible table lock escalation  App server thread issues  Connection pools empty  Then DEATH!  They aren’t sweet and cuddly any more… @billynewport 7
  • 8. Database killers  We need a way to get locks to decrement inventory  But, we don’t want to hold the lock for very long  Bigger carts make the problem worse, all the locks held for longer  Ideally, hold locks for constant time  Any contentious items make problem worse @billynewport 8
  • 9. Solution  Hold lock on inventory rows for as short a time as possible  Decouple this from size of cart.  How? @billynewport 9
  • 10. Chained transactions  Programmers think of transactions in synchronous terms.  Begin / Do Work / Hold locks / Commit  Easy to program, bad for concurrency. @billynewport 10
  • 11. Inspiration  Microsoft had COM objects with apartment model threading.  Modern Actor support is similar. Some state with a mailbox.  BPEL supports flows with compensation  Data meets actors is a good analogy  Send a message (cart) to a group of actors identified using their keys with a compensator @billynewport 11
  • 12. Alternative  We need to think asynchronously in terms of flows with compensation  Map of <SKU Key/SKU Amount>  Brick:  Do { code to reduce inventory level for SKU }  Undo { code to increase level inventory for SKU }  Provide Map with do/undo bricks  Easy to program, great concurrency. @billynewport 12
  • 13. Transactions and sharded stores  Option 1: Write transaction to one shard then spread out asynchronously  Option 2: 2 phase commit  Option 3: Chained transactions @billynewport 13
  • 14. Transactions and sharded stores  Option 1: Write transaction to one shard then spread out asynchronously  Option 2: 2 phase commit  Option 3: Chained transactions @billynewport 14
  • 15. Transactions and sharded stores  Option 1: Write transaction to one shard then spread out asynchronously  Option 2: 2 phase commit  Option 3: Chained transactions @billynewport 15
  • 16. Implementation  1PC only required  Data store supporting  Row locks  Row oriented data  Integrated FIFO messaging  IBM WebSphere eXtreme Scale provides these capabilities. @billynewport 16
  • 17. Implementation  Application makes map and code bricks  Submits transaction as an asynchronous job.  Uses a Future to check on job outcome.  Do blocks can trigger flow reversal if a problem occurs.  Invoke undo block for each completed step @billynewport 17
  • 18. Mechanism  Loop  Receive message for actor key  Process it  Send modified cart to next ‘sku’ using local ‘transmit q’  Commit transaction  Background thread pushes messages in transmit q to the destination shards using exactly once semantics. @billynewport 18
  • 19. Performance  A single logical transaction will be slower than a 1PC DBMS implementation.  However, under concurrent load then it will deliver:  Higher throughput  Better response times  Thru better contention management  Each ‘SKU’ only locked for a very short period @billynewport 19
  • 20. Generalization  This could be thought of as a workflow engine.  But, a big difference here is that a workflow engine usually talks with a remote store.  Here:  the flow state is the MESSAGE  It moves around to where the data is for the next step  Using a MESSAGE for flow state rather than a database means it scales linearly.  The message ‘store’ is integrated and scales with the data store. @billynewport 20
  • 21. Architecture Comparison Conventional Message oriented @billynewport 21 Flow DB Appl DB Msg Store BP Engi ne BP Engi ne BP Engine Flow State Flow Edge = Msg Integrated Msg/Data store Appl DB Write behind Integrated Msg/Data store Integrated Msg/Data store
  • 22. Sample implementation  Coming soon.  Running in lab  Working with several eCommerce customers looking to implement soon.  Soon to be published on github as sample code. @billynewport 22