SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Último

Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneUiPathCommunity
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 

Último (20)

Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyone
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 

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