SlideShare una empresa de Scribd logo
1 de 161
MongoDB
  E-commerce
and Transactions
My name is
Steve Francia

     @spf13
• 15+ years building the
  internet

• Father, husband, skateboarder
• Chief Solutions Architect @
  10gen

• Author of upcoming O’Reilly
  publication
  “MongoDB and PHP”
Before 10gen I
worked
    for

     http://opensky.com
OpenSky was the first
e-commerce site built
    on MongoDB
 ... also the first e-commerce site built on
                  Symfony2
Introduction to
   MongoDB
Why MongoDB?
MongoDB Goals
• Open source
• Designed for today
 • Today’s hardware / environments
 • Today’s challenges
• Great developer experience
• Reliable
• Scalable
• Company behind MongoDB
 • AGPL license, own copyrights, engineering
    team
  • support, consulting, commercial license
    revenue
• Management
 • Google/DoubleClick, Oracle, Apple, NetApp
 • Funding: Sequoia, Union Square, Flybridge
 • Offices in NYC, Redwood Shores & London
 • 60+ employees
A bit of history
1974
The relational database is created
1979
1979   1982-1996
1979   1982-1996   1995
Computers in 1995

•Pentium 100 mhz
•10base T
•16 MB ram
•200 MB HD
Cloud in 1995
(Windows 95 cloud wallpaper)
Cell Phones in 2011

•Dual core 1.5 Ghz
•WiFi 802.11n (300+ Mbps)
•1 GB ram
•64GB Solid State
How about a DB
designed for today?
MongoDB philosophy
• Keep functionality when we can (key/
  value stores are great, but we need more)
• Non-relational (no joins) makes scaling
  horizontally practical
• Document data models are good
• Database technology should run
  anywhere VMs, cloud, metal, etc
MongoDB is:
          Application      Document
                           Oriented
                           { author: “steve”,
    High                     date: new Date(),
                             text: “About MongoDB...”,
Performance                  tags: [“tech”, “database”]}




                             Fully
                           Consistent

   Horizontally Scalable
Under the hood

•Written in C++
•Runs on nearly anything
•Data serialized to BSON
•Extensive use of memory-mapped files
Database Landscape
This has led
    some to say

“
MongoDB has the best
features of key/ values
stores, document databases
and relational databases in
one.
               John Nunemaker
Use Cases
CMS / Blog
Needs:
• Business needed modern data store for rapid development and
  scale

Solution:
• Use PHP & MongoDB

Results:
• Real time statistics
• All data, images, etc stored together, easy access, easy
  deployment, easy high availability
• No need for complex migrations
• Enabled very rapid development and growth
Photo Meta-Data
Problem:
• Business needed more flexibility than Oracle could deliver

Solution:
• Use MongoDB instead of Oracle

Results:
• Developed application in one sprint cycle
• 500% cost reduction compared to Oracle
• 900% performance improvement compared to Oracle
Customer Analytics
Problem:
• Deal with massive data volume across all customer sites

Solution:
• Use MongoDB to replace Google Analytics / Omniture options

Results:
• Less than one week to build prototype and prove business case
• Rapid deployment of new features
Online Dictionary
Problem:
• MySQL could not scale to handle their 5B+ documents

Solution:
• Switched from MySQL to MongoDB

Results:
• Massive simplification of code base
• Eliminated need for external caching system
• 20x performance improvement over MySQL
E-commerce
Problem:
• Multi-vertical E-commerce impossible to model (efficiently) in
  RDBMS

Solution:
• Switched from MySQL to MongoDB

Results:
•   Massive simplification of code base
•   Rapidly build, halving time to market (and cost)
•   Eliminated need for external caching system
•   50x+ improvement over MySQL
Tons more
Pretty much if you can use a RDMBS or Key/Value
             MongoDB is a great fit
In Good Company
Why NoSQL for
   e-commerce?


Using the right solution for each situation
Data dilemma of
  e-commerce
     Pick One
Data dilemma of
     e-commerce
              Pick One


•Stick to one vertical (Sane schema)
•Flexibility (Insane schema)
Sane schema
Sane schema

•Works ... for a while
•Fine for a few types of products
•Not possible when more product types
  introduced
Let’s Use an Example
Let’s Use an Example
   How about we start with books
Book Product Schema
Product {

id:
sku:                                    General Product
product dimensions:
shipping weight:
                                        attributes
MSRP:
price:
description:
...
author:           Orson Scott Card
title:            Enders Game
binding:          Hardcover
publication date: July 15, 1994         Book Specific
publisher name:   Tor Science Fiction   attributes
number of pages: 352
ISBN:             0812550706
language:         English
...
Seems simple enough
What happens when we add another vertical...
             say music albums
Album Product Schema
Product {

id:
sku:                               General Product
product dimensions:                attributes stay
shipping weight:
MSRP:
                                   the same
price:
description:
...
artist:         MxPx
title:          Panic              Album Specific
release date:   June 7, 2005
label:          Side One Dummy
                                   attributes are
track listing: [ The Darkest ...   different
language:       English
format:         CD
...
Okay, it’s getting
  hairy but is still
manageable, right?
  Now the business want to sell jeans
Jeans Product Schema
Product {

id:                           General Product
sku:                          attributes stay the
product dimensions:           same
shipping weight:
MSRP:
price:
description:
...
brand:         Lucky          Jeans specific
gender:        Mens           attributes are
make:          Vintage
                              totally different ...
style:         Straight Cut
length:        34             and not consistent
width:         34             across brands &
color:         Hipster
                              make
material:      Cotten Blend
...
Now we’re screwed
Now we’re screwed
We need a flexible
schema in RDBMS
We need a flexible
schema in RDBMS


    We got this ... right?
Many approaches
dealing with unknown
 unknowns in RDBMS
Many approaches
dealing with unknown
 unknowns in RDBMS


      None work well
EAV
         as popularized by Magento
“For purposes of flexibility, the Magento database heavily
utilizes an Entity-Attribute-Value (EAV) data model.

As is often the case, the cost of flexibility is complexity -
Magento is no exception.

The process of manipulating data in Magento is often
more “involved” than that typically experienced using
traditional relational tables.”
                     - Varien
EAV
• Crazy SQL queries
• Hundreds of joins in a
  query... or

• Hundreds of queries joined
  in the application

• No database enforced
  integrity
Did I say crazy SQL
(this is a single query)
Did I say crazy SQL
(this is a single query)




You may have trouble reading this in the back
Selecting a single
     product
Single Table Inheritance
         (insanely wide tables)

• No data integrity enforcement
• Only can use FK for common
  elements

• Very wasteful (but disk is
  cheap!)

• Can’t effectively index
Generic Columns
• No data integrity enforcement
• No data type enforcement
• Only can use FK for common
  elements

• Wasteful (but disk is cheap!)
• Can’t index
Serialized in Blob
• Not searchable
• No integrity
• All the disadvantages of a
  document store, but none of the
  advantages

• Never should be used
• One exception is Oracle XML
  which operates similar to a
  document store
Concrete Table Inheritance
  (a table for each product attribute set)

• Allows for data integrity
• Querying across attribute
  sets quite hard to do (lots
  of joins, OR statements
  and full table scanning)

• New table needs to be
  created for each new
  attribute set
Class table inheritance
              (single product table,
         each attribute set in own table)
• Likely best of SQL within the
  constraint
              solution


• Supports data type enforcement
• No data integrity enforcement
• Easybrowse pages) since
  (for
       querying across categories
  common data in single table

• Every set needs a new table
• Requiresare very complicated
  changes
           a ton of forsight, as
MongoDB to the
   Rescue
MongoDB to the
      Rescue
•Flexible (and sane) Schema
MongoDB to the
      Rescue
•Flexible (and sane) Schema
•Easily searchable
MongoDB to the
      Rescue
•Flexible (and sane) Schema
•Easily searchable
•Easily accessible
MongoDB to the
      Rescue
•Flexible (and sane) Schema
•Easily searchable
•Easily accessible
•Fast
Flexible schema
{                                 {
    sku: "00e8da9c",                  sku: "00e8da9d",
    type: "Audio Album",              type: "Film",
    title: "Hoss",                    title: "The Matrix",
    description: "by Lagwagon",       description: "Set in the 22nd century, Th
    asin: "B0000007QG",               asin: "B000P0J0AQ",

    shipping: {                       shipping: {
       weight: 6,                        weight: 6,
       dimensions: {                     dimensions: {
          width: 10,                        width: 10,
          height: 10,                       height: 10,
          depth: 1                          depth: 1
       },                                },
    },                                },

    pricing: {                        pricing: {
       list: 1000,                       list: 1200,
       retail: 800,                      retail: 1100,
       savings: 200,                     savings: 100,
       pct_savings: 20                   pct_savings: 8.5
    },                                },

    details: {                        details: {
      title: "Hoss",                    title: "The Matrix",
pct_savings: 20                      pct_savings: 8.5
},                                   },

details: {                           details: {
  title: "Hoss",                        title: "The Matrix",
  artist: "Lagwagon",                   director: [ "Andy Wachowski", "Larry Wa
  genre: [ "Punk", "Hardcore", "Indie Rock" ], [ "Andy Wachowski", "Larry Wach
                                        writer:
  label: "Fat Wreck Chords",            actor: [ "Keanu Reeves" , "Lawrence Fis
  number_of_discs: 1,                   genre: [ "Science Fiction", "Action" ],
  issue_date: "November 21, 1995",      number_of_discs: 1,
  format: "CD",                         issue_date: "May 15 2007",
  alternate_formats: [ 'Vinyl', 'MP3' ],original_release_date: "1999",
  tracks: [                             disc_format: "DVD",
     "Kids Don't Like To Share",        rating: "R",
     "Violins",                         alternate_formats: [ 'VHS', 'Bluray' ],
     "Name Dropping",                   run_time: "136",
     "Bombs Away",                      studio: "Warner Bros",
     "Move The Car",                    language: "English",
     "Sleep",                           format: [ "AC-3", "Closed-captioned", "
     "Sick",                            aspect_ratio: "1.66:1"
     "Rifle",                        },
     "Weak",                       }
     "Black Eye",
     "Bro Dependent",
     "Razor Burn",
     "Shaving Your Head",
     "Ride The Snake",
  ],
Queries
db.products.find( { 'name': "The Matrix" } );
db.products.find( { 'name': "The Matrix" } );


 {
     "_id": ObjectId("4d8ad78b46b731a22943d3d3"),
     "sku": "00e8da9d",
     "type": "Film",
     "name": "The Matrix",
     "description": "Set in the 22nd century, The Matrix...",
     "asin": "B000P0J0AQ",
     "shipping": {
         "weight": 6,
         "dimensions": {
             "width": 10,
             "height": 10,
             "depth": 1
         }
     },
     "pricing": {
db.products.find( { 'details.actor': "Groucho Marx" } );
db.products.find( { 'details.actor': "Groucho Marx" } );


 },
 "pricing": {
     "list": 1000,
     "retail": 800,
     "savings": 200,
     "pct_savings": 20
 },
 "details": {
     "title": "A Night at the Opera",
     "director": "Sam Wood",
     "actor": ["Groucho Marx", "Chico Marx", "Harpo Marx"],
     "genre": "Comedy",
     "number_of_discs": 1,
     "issue_date": "May 4 2004",
     "original_release_date": "1935",
     "disc_format": "DVD",
db.products.find( {
     'details.genre': "Jazz", 'details.format': "CD"
} );
db.products.find( {
     'details.genre': "Jazz", 'details.format': "CD"
} );


     "list": 1200,
     "retail": 1100,
     "savings": 100,
     "pct_savings": 8
 },
 "details": {
     "title": "A Love Supreme [Original Recording Reissued]",
     "artist": "John Coltrane",
     "genre": ["Jazz", "General"],
     "format": "CD",
     "label": "Impulse Records",
     "number_of_discs": 1,
     "issue_date": "December 9, 1964",
     "alternate_formats": ["Vinyl", "MP3"],
     "tracks": [
     "A Love Supreme Part I: Acknowledgement",
db.products.find( { 'details.actor':
     { $all: ['James Stewart', 'Donna Reed'] }
} );
db.products.find( { 'details.actor':
     { $all: ['James Stewart', 'Donna Reed'] }
} );


 },
 "details": {
     "title": "It's a Wonderful Life",
     "director": "Frank Capra",
     "actor": ["James Stewart", "Donna Reed", "Lionel Barrymore"],
     "writer": [
     "Frank Capra",
     "Albert Hackett",
     "Frances Goodrich",
     "Jo Swerling",
     "Michael Wilson"
     ],
     "genre": "Drama",
     "number_of_discs": 1,
     "issue_date": "Oct 31 2006",
     "original_release_date": "1947",
Wanna Play?

• grab products.js from
  http://github.com/spf13/
  mongoProducts
• mongo   --shell products.js

• > use   mongoProducts
Embedded documents
 are great for orders
•Ordered items need to be fixed at the
  time of purchase
•Embed them right in the order
db.order.find( { 'items.sku': '00e8da9f' } );
db.order.find( {
    'items.details.actor': 'James Stewart'
} ).count();
What about
     transactions?


Using the right solution for each situation
Data (like people) are
really sensitive when
  it comes to money
Stricter data
requirements for $$
Stricter data
 requirements for $$

•For financial systems any data
  inconsistency is unacceptable
Stricter data
 requirements for $$

•For financial systems any data
  inconsistency is unacceptable
•Perhaps you’ve heard of ACID?
What about ACID?
What about ACID?


Q: Is MongoDB ACID?
What about ACID?


Q: Is MongoDB ACID?
A: Kinda
Atomicity
Atomicity

•MongoDB does atomic writes
Atomicity

•MongoDB does atomic writes
  ... for single document changesets
Atomicity

•MongoDB does atomic writes
  ... for single document changesets


• $set, $unset, $inc, $push,
  $pushAll, $pull, $pullAll, $bit
Consistency
Consistency


•MongoDB can enforce unique keys
Consistency


•MongoDB can enforce unique keys
•MongoDB can't enforce referential
  integrity
Isolation
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );

•   // Isolated updates
    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false ,
    true );
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );

•   // Isolated updates
    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false ,
    true );

•   But there are caveats...
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );

•   // Isolated updates
    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false ,
    true );

•   But there are caveats...

     •   Despite the $atomic keyword, this is not an atomic update,
         since atomicity implies “all or nothing”
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );

•   // Isolated updates
    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false ,
    true );

•   But there are caveats...

     •   Despite the $atomic keyword, this is not an atomic update,
         since atomicity implies “all or nothing”

     •   $atomic here means update is done without an interference
         from any other operation (isolated)
Isolation
•   // Pseudo-isolated updates
    db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );

•   // Isolated updates
    db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false ,
    true );

•   But there are caveats...

     •   Despite the $atomic keyword, this is not an atomic update,
         since atomicity implies “all or nothing”

     •   $atomic here means update is done without an interference
         from any other operation (isolated)

     •   An isolated update can only act on a single collection. Multi-
         collection updates are not transactional, thus not
         isolatable.
Durability
Durability


•Mongo has this one covered
What does
MongoDB Support?
• Atomic single document writes
 • If you need atomic writes across multi-document
     transactions don't use Mongo

  • Many if not most e-commerce transactions could be
     accomplished within a single document write
• Atomic single document writes
 • If you need atomic writes across multi-document
     transactions don't use Mongo

  • Many if not most e-commerce transactions could be
     accomplished within a single document write
• Unique indexes
 • This only works on keys used by the entire
     collection
• Atomic single document writes
 • If you need atomic writes across multi-document
     transactions don't use Mongo

  • Many if not most e-commerce transactions could be
     accomplished within a single document write
• Unique indexes
 • This only works on keys used by the entire
     collection

• Isolated (not atomic) single collection updates.
 • Mongo does not support locking
 • There are ways to work around this
• Atomic single document writes
 • If you need atomic writes across multi-document
     transactions don't use Mongo

  • Many if not most e-commerce transactions could be
     accomplished within a single document write
• Unique indexes
 • This only works on keys used by the entire
     collection

• Isolated (not atomic) single collection updates.
 • Mongo does not support locking
 • There are ways to work around this
• It’s durable
There are ways to
   guarantee ACID
properties in MongoDB


 Here are 2 good approaches useful for
       E-commerce transactions
Optimistic
Concurrency
Optimistic
       Concurrency
•Read the current state of a product
Optimistic
       Concurrency
•Read the current state of a product
•Make your changes with the assertion
  that your product has the same state as
  it did when you last read it
Optimistic concurrency
     in MongoDB
Optimistic concurrency
     in MongoDB
 We’ll use an update-if-current strategy.
Optimistic concurrency
     in MongoDB
 We’ll use an update-if-current strategy.
 This example is straight from the documentation:
Optimistic concurrency
     in MongoDB
    We’ll use an update-if-current strategy.
    This example is straight from the documentation:

>   t = db.inventory
>   p = t.findOne({sku:'abc'})
>   t.update({_id:p._id, qty:p.qty}, {'$inc': {qty: -1}});
>   db.$cmd.findOne({getlasterror:1});

{"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
// it worked
Optimistic concurrency
      in MongoDB
      We’ll use an update-if-current strategy.
      This example is straight from the documentation:

  >   t = db.inventory
  >   p = t.findOne({sku:'abc'})
  >   t.update({_id:p._id, qty:p.qty}, {'$inc': {qty: -1}});
  >   db.$cmd.findOne({getlasterror:1});

  {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
  // it worked



... If that didn't work, try again until it does.
Optimistic
       concurrency
•Read the current state of a product.
•Make your changes with the assertion
  that your product has the same state as
  it did when you last read it.
Optimistic
         concurrency
•Read the current state of a product.
•Make your changes with the assertion
    that your product has the same state as
    it did when you last read it.
•   It is also possible to use OCC to
    bootstrap pessimistic concurrency and
    fake row level locking
Optimistic concurrency
 control assumes an
environment with low
   data contention
OCC works great for
companies like Amazon

•Amazon has a long-tail catalog
•A long tail catalog lends itself well to
  optimistic concurrency, because it has
  low data contention
OCC fails miserably
        for
OCC fails miserably
        for
•eBay
OCC fails miserably
        for
•eBay
•Gilt
OCC fails miserably
         for
•eBay
•Gilt
•Groupon
OCC fails miserably
         for
•eBay
•Gilt
•Groupon
•OpenSky
OCC fails miserably
             for
•eBay
•Gilt
•Groupon
•OpenSky
•Living Social
OCC fails miserably
             for
•eBay
•Gilt
•Groupon
•OpenSky
•Living Social
•InsertFlashSaleSiteOfTheMinute
Flash sales and
auctions are defined by
 high data contention
Flash sales and
auctions are defined by
 high data contention

•The model doesn't work otherwise
Flash sales and
auctions are defined by
 high data contention

•The model doesn't work otherwise
•They can't afford to be optimistic
Flash sales and
auctions are defined by
 high data contention

•The model doesn't work otherwise
•They can't afford to be optimistic
•Order really matters
What about high
  contention
environments?
If we can avoid
concurrency we’ve
    got it made
Commerce is ACID
   In Real Life
1. I go to Barneys and see a pair of shoes I just have to
   buy.
2. I call “dibs” (by grabbing them off the shelf).
3. I take them up to the cash register and purchase
   them:

    • Store inventory has been manually decremented.
    • I pay for them with my trusty AmEx.
4. If all goes according to plan, I walk out of the store.
5. If my card was declined, the shoes are “rolled back”
   ... out onto the shelves and sold to the next customer
   who wants them.
All of this is
   accomplished
without concurrency
Each item can only be
 held by a consumer
We follow the same
model for e-commerce
1. Select a product.
1. Select a product.

2. Update the document to hold inventory.
1. Select a product.

2. Update the document to hold inventory.

 • Store inventory has been
    decremented.
1. Select a product.

2. Update the document to hold inventory.

 • Store inventory has been
    decremented.

3. Purchase the product(s)
1. Select a product.

2. Update the document to hold inventory.

 • Store inventory has been
    decremented.

3. Purchase the product(s)

 • Process payment
1. Select a product.

2. Update the document to hold inventory.

 • Store inventory has been
    decremented.

3. Purchase the product(s)

 • Process payment
4. Roll back if anything went wrong.
MongoDB e-commerce
    transactions
MongoDB e-commerce
    transactions
• Each Item (not SKU) has it’s own document
• Document consists of...
 • a reference to the SKU (product)
 • a state ( available / sold / ... )
 • potentially other data (timestamp, order
    ref)
Transactions
in MongoDB
Transactions
      in MongoDB
We’ll use a simple update statement
here.
Transactions
            in MongoDB
 We’ll use a simple update statement
 here.

> t = db.inventory
> sku = sku.findOne({sku:'abc'})
> t.update({ref_id:sku._id, state: 'available'}, {'$set':
{state: 'ordered'}});
> db.$cmd.findOne({getlasterror:1});

{"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
// it worked
Transactions
              in MongoDB
   We’ll use a simple update statement
   here.

  > t = db.inventory
  > sku = sku.findOne({sku:'abc'})
  > t.update({ref_id:sku._id, state: 'available'}, {'$set':
  {state: 'ordered'}});
  > db.$cmd.findOne({getlasterror:1});

  {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
  // it worked


... If that didn't work, no inventory available
Cart in Cart Action
Cart in Cart Action
An added benefit, it can easily provide
inventory hold in cart.
Cart in Cart Action
 An added benefit, it can easily provide
 inventory hold in cart.
> t = db.inventory
> sku = sku.findOne({sku:'abc'})
> t.update({ref_id:sku._id, state: 'available'}, {'$set':
{state: 'in cart'}});
> db.$cmd.findOne({getlasterror:1});

{"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
// it worked
Cart in Cart Action
 An added benefit, it can easily provide
 inventory hold in cart.
> t = db.inventory
> sku = sku.findOne({sku:'abc'})
> t.update({ref_id:sku._id, state: 'available'}, {'$set':
{state: 'in cart'}});
> db.$cmd.findOne({getlasterror:1});

{"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1}
// it worked


    just like reality, each item is either
     available, in a cart, or purchased
http://spf13.com
                                http://github.com/spf13
                                @spf13




           Questions?
        download at mongodb.org
PS: We’re hiring!! Contact us at jobs@10gen.com
MongoDB, E-commerce and Transactions

Más contenido relacionado

La actualidad más candente

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBRavi Teja
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Patrycja Wegrzynowicz
 
Azure SQL Database & Azure SQL Data Warehouse
Azure SQL Database & Azure SQL Data WarehouseAzure SQL Database & Azure SQL Data Warehouse
Azure SQL Database & Azure SQL Data WarehouseMohamed Tawfik
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architectureBishal Khanal
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Clean Architecture Applications in Python
Clean Architecture Applications in PythonClean Architecture Applications in Python
Clean Architecture Applications in PythonSubhash Bhushan
 
Or2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflowOr2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflow4Science
 
Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013larsgeorge
 
3D: DBT using Databricks and Delta
3D: DBT using Databricks and Delta3D: DBT using Databricks and Delta
3D: DBT using Databricks and DeltaDatabricks
 
Azure SQL Database Managed Instance - technical overview
Azure SQL Database Managed Instance - technical overviewAzure SQL Database Managed Instance - technical overview
Azure SQL Database Managed Instance - technical overviewGeorge Walters
 
Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBScaleGrid.io
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesVMware Tanzu
 
NoSQL databases - An introduction
NoSQL databases - An introductionNoSQL databases - An introduction
NoSQL databases - An introductionPooyan Mehrparvar
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentationHyphen Call
 
Relational databases vs Non-relational databases
Relational databases vs Non-relational databasesRelational databases vs Non-relational databases
Relational databases vs Non-relational databasesJames Serra
 
Sql server 2019 new features
Sql server 2019 new featuresSql server 2019 new features
Sql server 2019 new featuresGeorge Walters
 

La actualidad más candente (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
Spark SQL
Spark SQLSpark SQL
Spark SQL
 
Azure SQL Database & Azure SQL Data Warehouse
Azure SQL Database & Azure SQL Data WarehouseAzure SQL Database & Azure SQL Data Warehouse
Azure SQL Database & Azure SQL Data Warehouse
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
Postgresql
PostgresqlPostgresql
Postgresql
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Clean Architecture Applications in Python
Clean Architecture Applications in PythonClean Architecture Applications in Python
Clean Architecture Applications in Python
 
Or2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflowOr2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflow
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013
 
3D: DBT using Databricks and Delta
3D: DBT using Databricks and Delta3D: DBT using Databricks and Delta
3D: DBT using Databricks and Delta
 
Azure SQL Database Managed Instance - technical overview
Azure SQL Database Managed Instance - technical overviewAzure SQL Database Managed Instance - technical overview
Azure SQL Database Managed Instance - technical overview
 
Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDB
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
 
NoSQL databases - An introduction
NoSQL databases - An introductionNoSQL databases - An introduction
NoSQL databases - An introduction
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Relational databases vs Non-relational databases
Relational databases vs Non-relational databasesRelational databases vs Non-relational databases
Relational databases vs Non-relational databases
 
Sql server 2019 new features
Sql server 2019 new featuresSql server 2019 new features
Sql server 2019 new features
 

Similar a MongoDB, E-commerce and Transactions

Augmenting RDBMS with MongoDB for ecommerce
Augmenting RDBMS with MongoDB for ecommerceAugmenting RDBMS with MongoDB for ecommerce
Augmenting RDBMS with MongoDB for ecommerceSteven Francia
 
Blending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerceBlending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerceSteven Francia
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationSteven Francia
 
Optimize drupal using mongo db
Optimize drupal using mongo dbOptimize drupal using mongo db
Optimize drupal using mongo dbVladimir Ilic
 
Chris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for YouChris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for YouCarsonified Team
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FSMongoDB
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015Himanshu Desai
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on RailsAvi Kedar
 
Building an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stackBuilding an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stackdivyapisces
 
NoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionNoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionBrian Enochson
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Javasunnygleason
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 MinutesMongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 MinutesMongoDB
 
NoSQL databases and managing big data
NoSQL databases and managing big dataNoSQL databases and managing big data
NoSQL databases and managing big dataSteven Francia
 

Similar a MongoDB, E-commerce and Transactions (20)

Augmenting RDBMS with MongoDB for ecommerce
Augmenting RDBMS with MongoDB for ecommerceAugmenting RDBMS with MongoDB for ecommerce
Augmenting RDBMS with MongoDB for ecommerce
 
Blending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerceBlending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerce
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combination
 
Optimize drupal using mongo db
Optimize drupal using mongo dbOptimize drupal using mongo db
Optimize drupal using mongo db
 
Chris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for YouChris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for You
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
 
CouchDB introduction
CouchDB introductionCouchDB introduction
CouchDB introduction
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
Building an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stackBuilding an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stack
 
NoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionNoSQL and MongoDB Introdction
NoSQL and MongoDB Introdction
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Java
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 MinutesMongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
 
NoSQL databases and managing big data
NoSQL databases and managing big dataNoSQL databases and managing big data
NoSQL databases and managing big data
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
cadec-2017-golang
cadec-2017-golangcadec-2017-golang
cadec-2017-golang
 

Más de Steven Francia

State of the Gopher Nation - Golang - August 2017
State of the Gopher Nation - Golang - August 2017State of the Gopher Nation - Golang - August 2017
State of the Gopher Nation - Golang - August 2017Steven Francia
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in GoSteven Francia
 
The Future of the Operating System - Keynote LinuxCon 2015
The Future of the Operating System -  Keynote LinuxCon 2015The Future of the Operating System -  Keynote LinuxCon 2015
The Future of the Operating System - Keynote LinuxCon 2015Steven Francia
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)Steven Francia
 
What every successful open source project needs
What every successful open source project needsWhat every successful open source project needs
What every successful open source project needsSteven Francia
 
7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid themSteven Francia
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Steven Francia
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Steven Francia
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with GoSteven Francia
 
Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Steven Francia
 
Modern Database Systems (for Genealogy)
Modern Database Systems (for Genealogy)Modern Database Systems (for Genealogy)
Modern Database Systems (for Genealogy)Steven Francia
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopSteven Francia
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012Steven Francia
 
Big data for the rest of us
Big data for the rest of usBig data for the rest of us
Big data for the rest of usSteven Francia
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialOSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialSteven Francia
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoverySteven Francia
 
Multi Data Center Strategies
Multi Data Center StrategiesMulti Data Center Strategies
Multi Data Center StrategiesSteven Francia
 
MongoDB, Hadoop and Humongous Data
MongoDB, Hadoop and Humongous DataMongoDB, Hadoop and Humongous Data
MongoDB, Hadoop and Humongous DataSteven Francia
 

Más de Steven Francia (20)

State of the Gopher Nation - Golang - August 2017
State of the Gopher Nation - Golang - August 2017State of the Gopher Nation - Golang - August 2017
State of the Gopher Nation - Golang - August 2017
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in Go
 
The Future of the Operating System - Keynote LinuxCon 2015
The Future of the Operating System -  Keynote LinuxCon 2015The Future of the Operating System -  Keynote LinuxCon 2015
The Future of the Operating System - Keynote LinuxCon 2015
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
 
What every successful open source project needs
What every successful open source project needsWhat every successful open source project needs
What every successful open source project needs
 
7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013
 
Modern Database Systems (for Genealogy)
Modern Database Systems (for Genealogy)Modern Database Systems (for Genealogy)
Modern Database Systems (for Genealogy)
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and Hadoop
 
Future of data
Future of dataFuture of data
Future of data
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012
 
Big data for the rest of us
Big data for the rest of usBig data for the rest of us
Big data for the rest of us
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB TutorialOSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB Tutorial
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
 
Multi Data Center Strategies
Multi Data Center StrategiesMulti Data Center Strategies
Multi Data Center Strategies
 
MongoDB, Hadoop and Humongous Data
MongoDB, Hadoop and Humongous DataMongoDB, Hadoop and Humongous Data
MongoDB, Hadoop and Humongous Data
 
MongoDB and hadoop
MongoDB and hadoopMongoDB and hadoop
MongoDB and hadoop
 

Último

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
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
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
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
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 

Último (20)

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
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...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
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)
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 

MongoDB, E-commerce and Transactions

  • 1. MongoDB E-commerce and Transactions
  • 2. My name is Steve Francia @spf13
  • 3. • 15+ years building the internet • Father, husband, skateboarder • Chief Solutions Architect @ 10gen • Author of upcoming O’Reilly publication “MongoDB and PHP”
  • 4. Before 10gen I worked for http://opensky.com
  • 5. OpenSky was the first e-commerce site built on MongoDB ... also the first e-commerce site built on Symfony2
  • 6. Introduction to MongoDB
  • 8. MongoDB Goals • Open source • Designed for today • Today’s hardware / environments • Today’s challenges • Great developer experience • Reliable • Scalable
  • 9. • Company behind MongoDB • AGPL license, own copyrights, engineering team • support, consulting, commercial license revenue • Management • Google/DoubleClick, Oracle, Apple, NetApp • Funding: Sequoia, Union Square, Flybridge • Offices in NYC, Redwood Shores & London • 60+ employees
  • 10. A bit of history
  • 12.
  • 13.
  • 14. 1979
  • 15. 1979 1982-1996
  • 16. 1979 1982-1996 1995
  • 17. Computers in 1995 •Pentium 100 mhz •10base T •16 MB ram •200 MB HD
  • 18. Cloud in 1995 (Windows 95 cloud wallpaper)
  • 19. Cell Phones in 2011 •Dual core 1.5 Ghz •WiFi 802.11n (300+ Mbps) •1 GB ram •64GB Solid State
  • 20. How about a DB designed for today?
  • 21. MongoDB philosophy • Keep functionality when we can (key/ value stores are great, but we need more) • Non-relational (no joins) makes scaling horizontally practical • Document data models are good • Database technology should run anywhere VMs, cloud, metal, etc
  • 22. MongoDB is: Application Document Oriented { author: “steve”, High date: new Date(), text: “About MongoDB...”, Performance tags: [“tech”, “database”]} Fully Consistent Horizontally Scalable
  • 23. Under the hood •Written in C++ •Runs on nearly anything •Data serialized to BSON •Extensive use of memory-mapped files
  • 25. This has led some to say “ MongoDB has the best features of key/ values stores, document databases and relational databases in one. John Nunemaker
  • 27. CMS / Blog Needs: • Business needed modern data store for rapid development and scale Solution: • Use PHP & MongoDB Results: • Real time statistics • All data, images, etc stored together, easy access, easy deployment, easy high availability • No need for complex migrations • Enabled very rapid development and growth
  • 28. Photo Meta-Data Problem: • Business needed more flexibility than Oracle could deliver Solution: • Use MongoDB instead of Oracle Results: • Developed application in one sprint cycle • 500% cost reduction compared to Oracle • 900% performance improvement compared to Oracle
  • 29. Customer Analytics Problem: • Deal with massive data volume across all customer sites Solution: • Use MongoDB to replace Google Analytics / Omniture options Results: • Less than one week to build prototype and prove business case • Rapid deployment of new features
  • 30. Online Dictionary Problem: • MySQL could not scale to handle their 5B+ documents Solution: • Switched from MySQL to MongoDB Results: • Massive simplification of code base • Eliminated need for external caching system • 20x performance improvement over MySQL
  • 31. E-commerce Problem: • Multi-vertical E-commerce impossible to model (efficiently) in RDBMS Solution: • Switched from MySQL to MongoDB Results: • Massive simplification of code base • Rapidly build, halving time to market (and cost) • Eliminated need for external caching system • 50x+ improvement over MySQL
  • 32. Tons more Pretty much if you can use a RDMBS or Key/Value MongoDB is a great fit
  • 34. Why NoSQL for e-commerce? Using the right solution for each situation
  • 35. Data dilemma of e-commerce Pick One
  • 36. Data dilemma of e-commerce Pick One •Stick to one vertical (Sane schema) •Flexibility (Insane schema)
  • 38. Sane schema •Works ... for a while •Fine for a few types of products •Not possible when more product types introduced
  • 39. Let’s Use an Example
  • 40. Let’s Use an Example How about we start with books
  • 41. Book Product Schema Product { id: sku: General Product product dimensions: shipping weight: attributes MSRP: price: description: ... author: Orson Scott Card title: Enders Game binding: Hardcover publication date: July 15, 1994 Book Specific publisher name: Tor Science Fiction attributes number of pages: 352 ISBN: 0812550706 language: English ...
  • 42. Seems simple enough What happens when we add another vertical... say music albums
  • 43. Album Product Schema Product { id: sku: General Product product dimensions: attributes stay shipping weight: MSRP: the same price: description: ... artist: MxPx title: Panic Album Specific release date: June 7, 2005 label: Side One Dummy attributes are track listing: [ The Darkest ... different language: English format: CD ...
  • 44. Okay, it’s getting hairy but is still manageable, right? Now the business want to sell jeans
  • 45. Jeans Product Schema Product { id: General Product sku: attributes stay the product dimensions: same shipping weight: MSRP: price: description: ... brand: Lucky Jeans specific gender: Mens attributes are make: Vintage totally different ... style: Straight Cut length: 34 and not consistent width: 34 across brands & color: Hipster make material: Cotten Blend ...
  • 48. We need a flexible schema in RDBMS
  • 49. We need a flexible schema in RDBMS We got this ... right?
  • 50. Many approaches dealing with unknown unknowns in RDBMS
  • 51. Many approaches dealing with unknown unknowns in RDBMS None work well
  • 52. EAV as popularized by Magento “For purposes of flexibility, the Magento database heavily utilizes an Entity-Attribute-Value (EAV) data model. As is often the case, the cost of flexibility is complexity - Magento is no exception. The process of manipulating data in Magento is often more “involved” than that typically experienced using traditional relational tables.” - Varien
  • 53. EAV • Crazy SQL queries • Hundreds of joins in a query... or • Hundreds of queries joined in the application • No database enforced integrity
  • 54. Did I say crazy SQL (this is a single query)
  • 55. Did I say crazy SQL (this is a single query) You may have trouble reading this in the back
  • 57. Single Table Inheritance (insanely wide tables) • No data integrity enforcement • Only can use FK for common elements • Very wasteful (but disk is cheap!) • Can’t effectively index
  • 58. Generic Columns • No data integrity enforcement • No data type enforcement • Only can use FK for common elements • Wasteful (but disk is cheap!) • Can’t index
  • 59. Serialized in Blob • Not searchable • No integrity • All the disadvantages of a document store, but none of the advantages • Never should be used • One exception is Oracle XML which operates similar to a document store
  • 60. Concrete Table Inheritance (a table for each product attribute set) • Allows for data integrity • Querying across attribute sets quite hard to do (lots of joins, OR statements and full table scanning) • New table needs to be created for each new attribute set
  • 61. Class table inheritance (single product table, each attribute set in own table) • Likely best of SQL within the constraint solution • Supports data type enforcement • No data integrity enforcement • Easybrowse pages) since (for querying across categories common data in single table • Every set needs a new table • Requiresare very complicated changes a ton of forsight, as
  • 62. MongoDB to the Rescue
  • 63. MongoDB to the Rescue •Flexible (and sane) Schema
  • 64. MongoDB to the Rescue •Flexible (and sane) Schema •Easily searchable
  • 65. MongoDB to the Rescue •Flexible (and sane) Schema •Easily searchable •Easily accessible
  • 66. MongoDB to the Rescue •Flexible (and sane) Schema •Easily searchable •Easily accessible •Fast
  • 68. { { sku: "00e8da9c", sku: "00e8da9d", type: "Audio Album", type: "Film", title: "Hoss", title: "The Matrix", description: "by Lagwagon", description: "Set in the 22nd century, Th asin: "B0000007QG", asin: "B000P0J0AQ", shipping: { shipping: { weight: 6, weight: 6, dimensions: { dimensions: { width: 10, width: 10, height: 10, height: 10, depth: 1 depth: 1 }, }, }, }, pricing: { pricing: { list: 1000, list: 1200, retail: 800, retail: 1100, savings: 200, savings: 100, pct_savings: 20 pct_savings: 8.5 }, }, details: { details: { title: "Hoss", title: "The Matrix",
  • 69. pct_savings: 20 pct_savings: 8.5 }, }, details: { details: { title: "Hoss", title: "The Matrix", artist: "Lagwagon", director: [ "Andy Wachowski", "Larry Wa genre: [ "Punk", "Hardcore", "Indie Rock" ], [ "Andy Wachowski", "Larry Wach writer: label: "Fat Wreck Chords", actor: [ "Keanu Reeves" , "Lawrence Fis number_of_discs: 1, genre: [ "Science Fiction", "Action" ], issue_date: "November 21, 1995", number_of_discs: 1, format: "CD", issue_date: "May 15 2007", alternate_formats: [ 'Vinyl', 'MP3' ],original_release_date: "1999", tracks: [ disc_format: "DVD", "Kids Don't Like To Share", rating: "R", "Violins", alternate_formats: [ 'VHS', 'Bluray' ], "Name Dropping", run_time: "136", "Bombs Away", studio: "Warner Bros", "Move The Car", language: "English", "Sleep", format: [ "AC-3", "Closed-captioned", " "Sick", aspect_ratio: "1.66:1" "Rifle", }, "Weak", } "Black Eye", "Bro Dependent", "Razor Burn", "Shaving Your Head", "Ride The Snake", ],
  • 71. db.products.find( { 'name': "The Matrix" } );
  • 72. db.products.find( { 'name': "The Matrix" } ); { "_id": ObjectId("4d8ad78b46b731a22943d3d3"), "sku": "00e8da9d", "type": "Film", "name": "The Matrix", "description": "Set in the 22nd century, The Matrix...", "asin": "B000P0J0AQ", "shipping": { "weight": 6, "dimensions": { "width": 10, "height": 10, "depth": 1 } }, "pricing": {
  • 74. db.products.find( { 'details.actor': "Groucho Marx" } ); }, "pricing": { "list": 1000, "retail": 800, "savings": 200, "pct_savings": 20 }, "details": { "title": "A Night at the Opera", "director": "Sam Wood", "actor": ["Groucho Marx", "Chico Marx", "Harpo Marx"], "genre": "Comedy", "number_of_discs": 1, "issue_date": "May 4 2004", "original_release_date": "1935", "disc_format": "DVD",
  • 75. db.products.find( { 'details.genre': "Jazz", 'details.format': "CD" } );
  • 76. db.products.find( { 'details.genre': "Jazz", 'details.format': "CD" } ); "list": 1200, "retail": 1100, "savings": 100, "pct_savings": 8 }, "details": { "title": "A Love Supreme [Original Recording Reissued]", "artist": "John Coltrane", "genre": ["Jazz", "General"], "format": "CD", "label": "Impulse Records", "number_of_discs": 1, "issue_date": "December 9, 1964", "alternate_formats": ["Vinyl", "MP3"], "tracks": [ "A Love Supreme Part I: Acknowledgement",
  • 77. db.products.find( { 'details.actor': { $all: ['James Stewart', 'Donna Reed'] } } );
  • 78. db.products.find( { 'details.actor': { $all: ['James Stewart', 'Donna Reed'] } } ); }, "details": { "title": "It's a Wonderful Life", "director": "Frank Capra", "actor": ["James Stewart", "Donna Reed", "Lionel Barrymore"], "writer": [ "Frank Capra", "Albert Hackett", "Frances Goodrich", "Jo Swerling", "Michael Wilson" ], "genre": "Drama", "number_of_discs": 1, "issue_date": "Oct 31 2006", "original_release_date": "1947",
  • 79. Wanna Play? • grab products.js from http://github.com/spf13/ mongoProducts • mongo --shell products.js • > use mongoProducts
  • 80. Embedded documents are great for orders •Ordered items need to be fixed at the time of purchase •Embed them right in the order db.order.find( { 'items.sku': '00e8da9f' } ); db.order.find( { 'items.details.actor': 'James Stewart' } ).count();
  • 81. What about transactions? Using the right solution for each situation
  • 82. Data (like people) are really sensitive when it comes to money
  • 84. Stricter data requirements for $$ •For financial systems any data inconsistency is unacceptable
  • 85. Stricter data requirements for $$ •For financial systems any data inconsistency is unacceptable •Perhaps you’ve heard of ACID?
  • 87. What about ACID? Q: Is MongoDB ACID?
  • 88. What about ACID? Q: Is MongoDB ACID? A: Kinda
  • 91. Atomicity •MongoDB does atomic writes ... for single document changesets
  • 92. Atomicity •MongoDB does atomic writes ... for single document changesets • $set, $unset, $inc, $push, $pushAll, $pull, $pullAll, $bit
  • 95. Consistency •MongoDB can enforce unique keys •MongoDB can't enforce referential integrity
  • 97. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true );
  • 98. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true ); • // Isolated updates db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true );
  • 99. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true ); • // Isolated updates db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true ); • But there are caveats...
  • 100. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true ); • // Isolated updates db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true ); • But there are caveats... • Despite the $atomic keyword, this is not an atomic update, since atomicity implies “all or nothing”
  • 101. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true ); • // Isolated updates db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true ); • But there are caveats... • Despite the $atomic keyword, this is not an atomic update, since atomicity implies “all or nothing” • $atomic here means update is done without an interference from any other operation (isolated)
  • 102. Isolation • // Pseudo-isolated updates db.foo.update( { x : 1 } , { $inc : { y : 1 } } , false , true ); • // Isolated updates db.foo.update( { x : 1 , $atomic : 1 } , { $inc : { y : 1 } } , false , true ); • But there are caveats... • Despite the $atomic keyword, this is not an atomic update, since atomicity implies “all or nothing” • $atomic here means update is done without an interference from any other operation (isolated) • An isolated update can only act on a single collection. Multi- collection updates are not transactional, thus not isolatable.
  • 106.
  • 107. • Atomic single document writes • If you need atomic writes across multi-document transactions don't use Mongo • Many if not most e-commerce transactions could be accomplished within a single document write
  • 108. • Atomic single document writes • If you need atomic writes across multi-document transactions don't use Mongo • Many if not most e-commerce transactions could be accomplished within a single document write • Unique indexes • This only works on keys used by the entire collection
  • 109. • Atomic single document writes • If you need atomic writes across multi-document transactions don't use Mongo • Many if not most e-commerce transactions could be accomplished within a single document write • Unique indexes • This only works on keys used by the entire collection • Isolated (not atomic) single collection updates. • Mongo does not support locking • There are ways to work around this
  • 110. • Atomic single document writes • If you need atomic writes across multi-document transactions don't use Mongo • Many if not most e-commerce transactions could be accomplished within a single document write • Unique indexes • This only works on keys used by the entire collection • Isolated (not atomic) single collection updates. • Mongo does not support locking • There are ways to work around this • It’s durable
  • 111. There are ways to guarantee ACID properties in MongoDB Here are 2 good approaches useful for E-commerce transactions
  • 113. Optimistic Concurrency •Read the current state of a product
  • 114. Optimistic Concurrency •Read the current state of a product •Make your changes with the assertion that your product has the same state as it did when you last read it
  • 115. Optimistic concurrency in MongoDB
  • 116. Optimistic concurrency in MongoDB We’ll use an update-if-current strategy.
  • 117. Optimistic concurrency in MongoDB We’ll use an update-if-current strategy. This example is straight from the documentation:
  • 118. Optimistic concurrency in MongoDB We’ll use an update-if-current strategy. This example is straight from the documentation: > t = db.inventory > p = t.findOne({sku:'abc'}) > t.update({_id:p._id, qty:p.qty}, {'$inc': {qty: -1}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked
  • 119. Optimistic concurrency in MongoDB We’ll use an update-if-current strategy. This example is straight from the documentation: > t = db.inventory > p = t.findOne({sku:'abc'}) > t.update({_id:p._id, qty:p.qty}, {'$inc': {qty: -1}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked ... If that didn't work, try again until it does.
  • 120. Optimistic concurrency •Read the current state of a product. •Make your changes with the assertion that your product has the same state as it did when you last read it.
  • 121. Optimistic concurrency •Read the current state of a product. •Make your changes with the assertion that your product has the same state as it did when you last read it. • It is also possible to use OCC to bootstrap pessimistic concurrency and fake row level locking
  • 122. Optimistic concurrency control assumes an environment with low data contention
  • 123. OCC works great for companies like Amazon •Amazon has a long-tail catalog •A long tail catalog lends itself well to optimistic concurrency, because it has low data contention
  • 125. OCC fails miserably for •eBay
  • 126. OCC fails miserably for •eBay •Gilt
  • 127. OCC fails miserably for •eBay •Gilt •Groupon
  • 128. OCC fails miserably for •eBay •Gilt •Groupon •OpenSky
  • 129. OCC fails miserably for •eBay •Gilt •Groupon •OpenSky •Living Social
  • 130. OCC fails miserably for •eBay •Gilt •Groupon •OpenSky •Living Social •InsertFlashSaleSiteOfTheMinute
  • 131. Flash sales and auctions are defined by high data contention
  • 132. Flash sales and auctions are defined by high data contention •The model doesn't work otherwise
  • 133. Flash sales and auctions are defined by high data contention •The model doesn't work otherwise •They can't afford to be optimistic
  • 134. Flash sales and auctions are defined by high data contention •The model doesn't work otherwise •They can't afford to be optimistic •Order really matters
  • 135. What about high contention environments?
  • 136. If we can avoid concurrency we’ve got it made
  • 137. Commerce is ACID In Real Life
  • 138.
  • 139. 1. I go to Barneys and see a pair of shoes I just have to buy. 2. I call “dibs” (by grabbing them off the shelf). 3. I take them up to the cash register and purchase them: • Store inventory has been manually decremented. • I pay for them with my trusty AmEx. 4. If all goes according to plan, I walk out of the store. 5. If my card was declined, the shoes are “rolled back” ... out onto the shelves and sold to the next customer who wants them.
  • 140. All of this is accomplished without concurrency
  • 141. Each item can only be held by a consumer
  • 142. We follow the same model for e-commerce
  • 143.
  • 144. 1. Select a product.
  • 145. 1. Select a product. 2. Update the document to hold inventory.
  • 146. 1. Select a product. 2. Update the document to hold inventory. • Store inventory has been decremented.
  • 147. 1. Select a product. 2. Update the document to hold inventory. • Store inventory has been decremented. 3. Purchase the product(s)
  • 148. 1. Select a product. 2. Update the document to hold inventory. • Store inventory has been decremented. 3. Purchase the product(s) • Process payment
  • 149. 1. Select a product. 2. Update the document to hold inventory. • Store inventory has been decremented. 3. Purchase the product(s) • Process payment 4. Roll back if anything went wrong.
  • 150. MongoDB e-commerce transactions
  • 151. MongoDB e-commerce transactions • Each Item (not SKU) has it’s own document • Document consists of... • a reference to the SKU (product) • a state ( available / sold / ... ) • potentially other data (timestamp, order ref)
  • 153. Transactions in MongoDB We’ll use a simple update statement here.
  • 154. Transactions in MongoDB We’ll use a simple update statement here. > t = db.inventory > sku = sku.findOne({sku:'abc'}) > t.update({ref_id:sku._id, state: 'available'}, {'$set': {state: 'ordered'}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked
  • 155. Transactions in MongoDB We’ll use a simple update statement here. > t = db.inventory > sku = sku.findOne({sku:'abc'}) > t.update({ref_id:sku._id, state: 'available'}, {'$set': {state: 'ordered'}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked ... If that didn't work, no inventory available
  • 156. Cart in Cart Action
  • 157. Cart in Cart Action An added benefit, it can easily provide inventory hold in cart.
  • 158. Cart in Cart Action An added benefit, it can easily provide inventory hold in cart. > t = db.inventory > sku = sku.findOne({sku:'abc'}) > t.update({ref_id:sku._id, state: 'available'}, {'$set': {state: 'in cart'}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked
  • 159. Cart in Cart Action An added benefit, it can easily provide inventory hold in cart. > t = db.inventory > sku = sku.findOne({sku:'abc'}) > t.update({ref_id:sku._id, state: 'available'}, {'$set': {state: 'in cart'}}); > db.$cmd.findOne({getlasterror:1}); {"err" : , "updatedExisting" : true , "n" : 1 , "ok" : 1} // it worked just like reality, each item is either available, in a cart, or purchased
  • 160. http://spf13.com http://github.com/spf13 @spf13 Questions? download at mongodb.org PS: We’re hiring!! Contact us at jobs@10gen.com

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. Remember in 1995 there were around 10,000 websites. Mosiac, Lynx, Mozilla (pre netscape) and IE 2.0 were the only web browsers. \nApache (Dec ’95), Java (’96), PHP (June ’95), and .net didn’t exist yet. Linux just barely (1.0 in ’94)\n
  14. Remember in 1995 there were around 10,000 websites. Mosiac, Lynx, Mozilla (pre netscape) and IE 2.0 were the only web browsers. \nApache (Dec ’95), Java (’96), PHP (June ’95), and .net didn’t exist yet. Linux just barely (1.0 in ’94)\n
  15. Remember in 1995 there were around 10,000 websites. Mosiac, Lynx, Mozilla (pre netscape) and IE 2.0 were the only web browsers. \nApache (Dec ’95), Java (’96), PHP (June ’95), and .net didn’t exist yet. Linux just barely (1.0 in ’94)\n
  16. \n
  17. \n
  18. \n
  19. \n
  20. By reducing transactional semantics the db provides, one can still solve an interesting set of problems where performance is very important, and horizontal scaling then becomes easier.\n\n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. actually, just the first 1/3 of it. \n
  51. \n
  52. Ironically this is how magento solves the performance problems associated with EAV, by caching the data into insanely wide tables.\n
  53. \n
  54. \n
  55. \n
  56. Can’t create a FK as each set references a different table. “Key” really made of attribute table name id and attribute table name\n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. Whenever you use a inter system coordination you need to implement your own atomic checks in the application... But SOAP does have transactions.. so not quite accurate. \n\nkyle idea... but we are fairly atomic with authorize.net\n\natomicity, consistency, isolation, durability.\n\n
  78. Whenever you use a inter system coordination you need to implement your own atomic checks in the application... But SOAP does have transactions.. so not quite accurate. \n\nkyle idea... but we are fairly atomic with authorize.net\n\natomicity, consistency, isolation, durability.\n\n
  79. atomicity, consistency, isolation, durability.\n\n
  80. atomicity, consistency, isolation, durability.\n\n
  81. Mongo has a grip of atomic operations: set, unset, etc.\n
  82. Mongo has a grip of atomic operations: set, unset, etc.\n
  83. Mongo has a grip of atomic operations: set, unset, etc.\n
  84. \n
  85. \n
  86. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  87. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  88. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  89. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  90. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  91. update( { where }, { values }, upsert?, multiple? )\n\nIsolated is not atomic. Atomic implies that there is an all-or-nothing semantic to the update; this is not possible with more than one document. Isolated just means than you are the only one writing when the update is done; this means each update is done without any interference from any other.\n\nMongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n\n\n
  92. \n
  93. \n
  94. MongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n
  95. MongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n
  96. MongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n
  97. MongoDB supports atomic operations on single documents.  MongoDB does not support traditional locking and complex transactions for a number of reasons:\nFirst, in sharded environments, distributed locks could be expensive and slow.  Mongo DB's goal is to be lightweight and fast.\nWe dislike the concept of deadlocks.  We want the system to be simple and predictable without these sort of surprises.\nWe want Mongo DB to work well for realtime problems.  If an operation may execute which locks large amounts of data, it might stop some small light queries for an extended period of time.  (We don't claim Mongo DB is perfect yet in regards to being "real-time", but we certainly think locking would make it even harder.)\n\n
  98. \n
  99. lemme show you an example\n
  100. lemme show you an example\n
  101. or instead of qty, use an version_id.\n object id / md5 as a version. \n
  102. or instead of qty, use an version_id.\n object id / md5 as a version. \n
  103. or instead of qty, use an version_id.\n object id / md5 as a version. \n
  104. or instead of qty, use an version_id.\n object id / md5 as a version. \n
  105. \n
  106. Imagine what would happen if everyone tried to access the same record at the same time. Just think of all those spinning while loops :)\n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. Mind if I tell you a story?\n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  132. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  133. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  134. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  135. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  136. By using a single document we avoid any need for complicated transactions. \n Any number of concurrent read operations are allowed, but typically only one write operation (although some write operations yield and in the future more concurrency will be added). The write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled.\n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. Inventory can be provided by using count. Can be cached as value on the sku.\nAs the items themselves are atomic, the order need not be to reserve inventory.\n
  143. Inventory can be provided by using count. Can be cached as value on the sku.\nAs the items themselves are atomic, the order need not be to reserve inventory.\n
  144. Inventory can be provided by using count. Can be cached as value on the sku.\nAs the items themselves are atomic, the order need not be to reserve inventory.\n
  145. remember by default, update only updates 1 document and the operation is atomic on that document.\n\n
  146. remember by default, update only updates 1 document and the operation is atomic on that document.\n\n
  147. remember by default, update only updates 1 document and the operation is atomic on that document.\n\n
  148. \n
  149. \n