Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Can My Inventory Survive Eventual Consistency?


Published on

Let’s explore an inventory use case and discover how it’s possible to use an eventually consistent data store like Cassandra / Datastax Enterprise to support scalability, consistency, continuous availability. Combine that with analytics and I’ll show you how to build an inventory system for the future.

Published in: Software
  • You can hardly find a student who enjoys writing a college papers. Among all the other tasks they get assigned in college, writing essays is one of the most difficult assignments. Fortunately for students, there are many offers nowadays which help to make this process easier. The best service which can help you is ⇒ ⇐
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Can My Inventory Survive Eventual Consistency?

  1. 1. Jeff Carpenter Can My Inventory Survive Eventual Consistency?
  2. 2. Who am I? • Developer • Architect • Author • Evangelist • Defense • Hospitality • R&D • Distributed Systems • Large Scale • Cassandra © DataStax, All Rights Reserved. 2
  3. 3. DataStax Enterprise / Cassandra Use Cases • Customer 360 • Personalization • IoT/Sensors • Security • Inventory Management! © DataStax, All Rights Reserved. 3
  4. 4. What Is Inventory? A tangible object that can be sold… Shirt, Clif Bar, Used Car CREATE TABLE physical_inventory (product_id uuid PRIMARY KEY, int amount_available, int amount_consumed ); A space that can be used for some time Hotel Room, My house, Restaurant table CREATE TABLE temporal_inventory (product_id uuid, date date, int amount_available, int amount_consumed, PRIMARY KEY ((product_id), date) ); © DataStax, All Rights Reserved. 4
  5. 5. Inventory in Context © DataStax, All Rights Reserved. 5 rates temporal inventory products reservations physical inventory purchase orders prices Retail Reservation and rental
  6. 6. Why use DSE/Cassandra for inventory? • Effortless scale • Geographic distribution • Real-time access / Low latency • Continuous availability • Consistency © DataStax, All Rights Reserved. 6
  7. 7. Design Considerations • Systems of Record • Microservices • Tuneable Consistency • Compensating Transactions • Data Maintenance via TTL (for Temporal Inventory) © DataStax, All Rights Reserved. 7
  8. 8. Systems of Record • Are there other systems that track this inventory data? • What is the level of uncertainty in my system vs. external systems? © DataStax, All Rights Reserved. 8 Property Management System Reservation Systeminventory synchronization Walk-in customer Online customerProperty manager
  9. 9. Notional Microservice Architecture – Temporal Inventory © DataStax, All Rights Reserved. 9 Product Service Booking Service Rates Service Shopping Service Data Maintenance Apps Inventory Service Reservation Service Inventory keyspace Rates keyspace Product keyspace Reservations keyspace
  10. 10. Consistency Error Cases • Undercounting sold inventory – Reservations – Overbooking • Bumping, walking – Retail • Back order, cancel order • Overcounting sold inventory – Lost opportunity to sell, wasted resource • Inconsistencies across data types – Booked reservation without decrementing inventory © DataStax, All Rights Reserved. 10
  11. 11. Inventory Service Instance 1 Strong Consistency via Quorum on Read/Write © DataStax, All Rights Reserved. 11 C* node node node node Inventory keyspace Replication Factor = 3 Inventory Service Instance 2 Write @ QUORUM (2 nodes) Read @ QUORUM (2 nodes)
  12. 12. Distributed Transaction? Consistencies Across Data Types © DataStax, All Rights Reserved. 12 Commit the contract Reserve the inventory Booking Service Inventory Service Reservation Service inventoryreservations Monolithic Reservation System
  13. 13. Tuneable Consistency Revisited © DataStax, All Rights Reserved. 13 Approach Example Scope Lightweight Transaction Updating inventory counts Data Tier Logged Batch Writing to multiple denormalized tables Data Tier Retrying failed calls Data synchronization, reservation processing Service Compensating processes Verifying reservation processing System Eventual consistency Strong consistency
  14. 14. Compensating Transactions • Technical – Run repairs more frequently – Consistency checking apps • Business Processes – Reservation: reschedule, “walk” – Retail: back order, refund It’s all about the tradeoffs… © DataStax, All Rights Reserved. 14 Development and operations cost Customer satisfaction and retention cost
  15. 15. TTL for Temporal Inventory Cleanup © DataStax, All Rights Reserved. 15 Now Time Yesterday’s data is ancient history Rate + Inventory Data
  16. 16. Tomorrow’s Inventory Management System • Leverage DSE Search / Analytics / Graph for value added real-time use cases © DataStax, All Rights Reserved. 16 Identify undersold product Personalize shopping experience Upsell popular products Offer discount
  17. 17. Plug © DataStax, All Rights Reserved. 17 Cassandra: The Definitive Guide, 2nd Edition Completely reworked for Cassandra 3.X: • Data modeling in CQL • SASI indexes • Materialized views • Lightweight Transactions • DataStax drivers • New chapters on security, deployment, and integration
  18. 18. Contact © DataStax, All Rights Reserved. 18 @jscarp jeffreyscarpenter