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)

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...MongoDB
 
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 MeetupNatan Silnitsky
 
Microservices Coordination using Saga
Microservices Coordination using SagaMicroservices Coordination using Saga
Microservices Coordination using SagaEran Levy
 
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 Kafkaconfluent
 
ngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxMichał Michalczuk
 
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 KafkaBen Stopford
 
Supercharge Your Applications
Supercharge Your ApplicationsSupercharge Your Applications
Supercharge Your ApplicationsSean Boiling
 
Effective Akka v2
Effective Akka v2Effective Akka v2
Effective Akka v2shinolajla
 
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...MongoDB
 
SOA, Microservices and Event Driven Architecture
SOA, Microservices and Event Driven ArchitectureSOA, Microservices and Event Driven Architecture
SOA, Microservices and Event Driven ArchitectureJeppe Cramon
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2WebMatthias Noback
 
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 StreamsBen Stopford
 
Real-Time Stats for Candy Box
Real-Time Stats for Candy Box  Real-Time Stats for Candy Box
Real-Time Stats for Candy Box PubNub
 
Microservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka EcosystemMicroservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka Ecosystemconfluent
 
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 MicroservicesBen Stopford
 
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 ScyllaScyllaDB
 
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 InfrastructureConSanFrancisco123
 
Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011Cost architecting for Windows Azure - NDC2011
Cost architecting for Windows Azure - NDC2011Maarten 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

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

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