SlideShare une entreprise Scribd logo
1  sur  73
Télécharger pour lire hors ligne
NoSQL & DataGrids from a Developer Perspective

         Cyrille Le Clerc - Michaël Figuière
Speaker

     @cyrilleleclerc
     blog.xebia.fr

          Cyrille Le Clerc
                                    Large Scale

                             DataGrids
    Apache CXF
Speaker

     @mfiguiere
     blog.xebia.fr

          Michaël Figuière           Distributed
                                     Systems

                             NoSQL
   Search Engines
About NoSQL




              No SQL
About NoSQL


         Not    Only




              No SQL
About NoSQL


         Not    Only




              No SQL
                   Relational
Once upon a time...
On the Web side

                                 - Created Dynamo
Similar needs for Web giants :
                                 - < 40 min of unavailability per year
• Huge amount of data


• High availability


• Fault tolerance
                                 - Created BigTable & MapReduce
• Scalability on commodity       - Stores every webpages of Internet
  hardware
Amazon : the birth of Dynamo



                                         Requires complex requests,
                                      temporal unavailability is acceptable


 Fill cart     Checkout     Payment    Process order   Prepare     Send




    Requires high availability,
    key-value store is enough
On the Financial side

                                 - Released Coherence in 2001
Needs within financial market :
                                 - Started as a distributed cache
• Very low latency


• Rich queries & transactions


• Scalability
                                 - Released Gigaspaces XAP in 2001
• Data consistency               - Routes the request inside the data
Data Partitioning and Replication
Use Case : Train Ticketing System




                                With trains, stations,
                                seats, booking and
                                passengers
Store everything in a Mainframe !




                               Up to 3 To of RAM !
                               More than $1,000,000




         IBM z11
Data Partitioning



                                     Partition gamma


                                                        Small
                                                        servers
                                       Partition beta



     MainFrame
                                      Partition alpha

                 Split data for scalability
Data Replication



                              Node 1




                                       synchro
   Partition alpha
                              Node 2


      Duplicate data for
      high availability and
                              Node 3
                scalability
Partitioned Data Modeling
Partitioned Data Modeling



                                   Seat
                                              Booking        Passenger
                             number
                                           reduction       name
                             price

                Train
         code
         type

                                            TrainStation
                               TrainStop
                                           code
                             date
                                           name




                        Typical relational data model
Partitionned Data Modeling

                                Partitioning ready
                                  entities tree




             e   ntity
        Root                        Seat
                                                        Booking               Passenger
                              number
                                                     reduction              name
                              price

                 Train
         code
                                                                     Du
         type                                                             pli Refe
                                                                             ca
                                                                                ted renc
                                                                                   in e d
                                                      TrainStation                    ea ata
                                TrainStop                                               ch
                                                     code                                  pa
                              date                                                            rtit
                                                                                                  ion
                                                     name




                     Find the root entity and denormalize
Partitionned Data Modeling

                       Remove unused data



                             Seat
                                        Booking        Passenger
                       number
                                     reduction       name
                       price
                       booked
               Train
        code
        type

                                      TrainStation
                         TrainStop
                                     code
                       date
                                     name
Partitionned Data Modeling


        Sharding ready data structure

                              Seat
                        number
                        price
                        booked
                Train
         code
         type

                                       TrainStation
                          TrainStop
                                      code
                        date
                                      name
Consistency, Availability and Partition Tolerance
Data Consistency with replicas

                                              Node 1
            {    "name": "Barbie Computer",
                 "price": 15.50,
                 "tags" : [
                   "doll",
                   "barbie"                   Node 2
                ]}




                write to all                  Node 3



                                              Node 1


                      read from one           Node 2


                                              Node 3
Data Consistency with replicas

              {    "name": "Barbie Computer",   Node 1
                   "price": 15.50,
                   "tags" : [
                     "doll",
                     "barbie"
                  ]}
                                                Node 2
              write to one
                                                Node 3



                                                Node 1


                                                Node 2


              read from all                     Node 3
Data Consistency with replicas

• You can adjust the balance between number of writes and number of
  reads




• See Eventual Consistency
Data Consistency with Multiple Data Centers


  {    "name": "Barbie Computer",
       "price": 15.50,
       "tags" : [
         "doll",
         "barbie"
      ]}
                                    {    "name": "Barbie Computer",
                                         "price": 15.50,
                                         "tags" : [

 West Coast                                "doll",
                                           "barbie"
                                        ]}




                                                East Coast
Data Consistency with Multiple Data Centers

 set price to $ 20.00




  {    "name": "Barbie Computer",
       "price": 20.00,
       "tags" : [
         "doll",
         "barbie"
      ]}
                                                          {    "name": "Barbie Computer",
                                                               "price": 15.50,
 West Coast                                                    "tags" : [
                                                                 "doll",
                                                                 "barbie"
                                                              ]}



                                                                East Coast
                                    propagation delay !
Data Consistency with Multiple Data Centers

 set price to $ 20.00




  {    "name": "Barbie Computer",
       "price": 20.00,
       "tags" : [
         "doll",
         "barbie"
      ]}                                               {    "name": "Barbie Computer",
                                                            "price": 15.50,

 West Coast                                                 "tags" : [
                                                              "doll",
                                                              "barbie",
                                                                “girl”
                                                           ]}


                                                            East Coast
                                                                                         add tag “girl”
                         reconciliation API needed !
Data Consistency with Multiple Data Centers

 set price to $ 20.00




  {    "name": "Barbie Computer",
       "price": 20.00,
       "tags" : [
         "doll",
         "barbie"
      ]}                                                   {    "name": "Barbie Computer",
                                                                "price": 15.50,

 West Coast                                                     "tags" : [
                                                                  "doll",
                                                                  "barbie",
                                                                    “girl”
                                                               ]}


                                                                East Coast
                                                                                             add tag “girl”
                                    Network partitioning
Data Consistency with Multiple Data Centers


                      London
       New York
                                              Tokyo




                  World wide replication
                   for financial market
CAP Theorem

                                        Only 2 of these 3
                                        properties can be
                                       achieved in storage
              Consistency
                                                   system



                        Availability
           Partition
          Tolerance
CAP Theorem


                                       Relational DB
NoSQL DB
              Consistency



                        Availability
            Partition                     Impossible
           Tolerance
Data models & APIs
Request Driven Data Modeling

• Relational data modeling is business driven

         Adaptation to requests comes with tuning



• With partitioning, data modeling had to be adapted for requests
         Because network latency matters



• NoSQL & DataGrids data modeling is request driven
         Two requests may require to store data twice
Key-Value Store


                  In memory


                  In memory
                  with async
                  persistence


                  Persistent
Example with a user profile




               johndoe   User profile as byte[]




  Similar to a Java
          HashMap
Write Example with Riak

   RiakClient riak = new RiakClient("http://server1:8098/riak");

   RiakObject userProfileObj =
      new RiakObject("bucket", "johndoe", serializer.serialize(userProfile);

   riak.store(userProfileObj);




                        Inserts a user profile
                              into Riak
Read Example with Riak


       FetchResponse response = riak.fetch("bucket", "johndoe");

       if (response.hasObject()) {

           userProfileObj = response.getObject();

       }




                  Fetch a user profile using
                        its key in Riak
Column Families Store
Column Families Store

    For each Row ID we have
      a list of key-value pairs
                                                     Key-value
                                                      pairs are
                                                   sorted by keys




    Relational DB             Column families DB
Example with a shopping cart



   johndoe     17:21   Iphone        17:32   DVD Player     17:44     MacBook


   willsmith   6:10    Camera        8:29      Ipad


   pitdavis    14:45   PlayStation     15:01     Asus EEE     15:03    Iphone
Write Example with Cassandra


Cluster cluster =
   HFactory.getOrCreateCluster("cluster", new CassandraHostConfigurator("server1:9160"));

Keyspace keyspace = HFactory.createKeyspace("EcommerceKeyspace", cluster);

Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);

mutator.insert("johndoe", "ShoppingCartColumnFamily",
               HFactory.createStringColumn("14:21", "Iphone"));




                         Inserts a column into the
                         ShoppingCartColumnFamily
Read Example with Cassandra


SliceQuery<String, String, String> query =
    HFactory.createSliceQuery(keyspace,
                              stringSerializer, stringSerializer, stringSerializer);

query.setColumnFamily("ShoppingCartColumnFamily")
     .setKey("johndoe")
     .setRange("", "", false, 10);

QueryResult<ColumnSlice<String, String>> result = query.execute();




                       Reads a slice of 10 columns
                     from ShoppingCartColumnFamily
Document Store
Example with an item of a catalog


                          {
                              "name": "Iphone",
                              "price": 559.0,
            item_1            "vendor": "Apple",
                              "rating": 4.6,
                              "tags": [ "phone", "touch" ]
                          }




   The database is aware of
     document’s fields and
        can offers complex
                    queries
Write Example with MongoDB

       Mongo mongo = new Mongo("mongos_1", 27017);
       DB db = mongo.getDB("Ecommerce");
       DBCollection catalog = db.getCollection("Catalog");

       BasicDBObject doc = new BasicDBObject();
       doc.put("name", "Iphone");
       doc.put("price", 559.0);

       catalog.insert(doc);




                     Inserts an item
                  document into MongoDB
Read Example with MongoDB


        BasicDBObject query = new BasicDBObject();
        query.put("price", new BasicDBObject("$lt", 600));
        DBCursor cursor = catalog.find(query);

        while(cursor.hasNext()) {
           System.out.println(cursor.next());
        }




               Queries for all items with
                a price lower than 600
In Memory Data Grids




                       eXtreme Scale
Example with train booking with IBM eXtremeScale
  @Entity(schemaRoot=true)
  public class Train {                                                 Seat
                                                                 number
                                                                 price
      @Id
                                                                 booked
      String code;                                       Train
                                                  code
      @Index                                      type
      @Basic
                                                                   TrainStop
      String name;
                                                                 date

      @OneToMany(cascade=CascadeType.ALL)
      List<Seat> seats = new ArrayList<Seat>();

      @Version
      int version;

      ...
  }                                    With Data Grids,
                                       sub entities can have
                                       cross relations
Write Example with IBM eXtreme Scale

                          eXtreme Scale provides
                          a JPA Style API

              void persist(Train train) {
                  entityManager.persist(train);
              }




                 Inserts a train into
                   eXtreme Scale
Read Example with IBM eXtreme Scale

/** Find by key */
Train findById(String id) {
   return (Train) entityManager.find(Train.class, id);
}


/** Query Language */
Train findByTrain(String code) {
   Query q = entityManager.createQuery("select t from Train t where t.code=:code");
   q.setParameter("code", code);

    return (Train) q.getSingleResult();
}



                        Simple and complex queries
                           with eXtreme Scale
More APIs

• Another Java EE versus Spring battle ? JSR 347 Data Grids vs. Spring Data


         Unified API ontop of relational, document, column, key-value ?


         Object to tuple projection API
Transactions
Transactions

• NoSQL usually means NO transactions

• Except when it means eXtreme Transactions !
Transactions Concurrency

Place order
                                                                       231

   canon-eos: 1
   ipod : 1
   headphone : 1
                                                                 311
   iphone: 1
   ...




    ipad : 1                                                    121
    iphone: 1
                                                                             264


                       concurrency on iphone           2
   barbie : 1
   iphone: 1                                                      637
   cabbage-doll: 1

                                                           12

                     cancel order if one product   warehouse stocks
                              is missing
SQL Transactions

 Place order
                                                                     231

     canon-eos: 1
     ipod : 1          begin
     headphone : 1
                                                               311
     iphone: 1
     ...
                       for each
                       shoppingCart.product
                         select for update ...
                                                              121
      ipad : 1
      iphone: 1
                         update ...
                                                                           264
                       commit
                                                     2
     barbie : 1
     iphone: 1
     cabbage-doll: 1                                                 637

                                                         12

                                                 warehouse stocks

lock duration = f(shoppingcart.length)
if too many locks on the rows, then lock table !
SQL Transactions

 Place order           select for update ...

                                                                   231

     canon-eos: 1
     ipod : 1
     headphone : 1
                                                             311
     iphone: 1
     ...




      ipad : 1                                              121
      iphone: 1
                                                                         264

                                                   2
     barbie : 1
     iphone: 1
     cabbage-doll: 1                                               637

                                                       12

                                               warehouse stocks

lock duration = f(shoppingcart.length)
if too many locks on the rows, then lock table !
SQL Transactions

 Place order           select for update ...

                                                               231

     canon-eos: 1
     ipod : 1
     headphone : 1
                                                         311
     iphone: 1
     ...




      ipad : 1                                          121
      iphone: 1
                                                                     264

                                                   2
     barbie : 1
     iphone: 1
     cabbage-doll: 1
                                                              637

                                                   12

                                               warehouse stocks
lock duration = f(shoppingcart.length)
if too many locks on the rows, then lock table !
Transactions with Manual Compensation

     Place order
                            DO
                                                   -1
                if(stock - quantity > 0) {
                  stock = stock - quantity;
                } else {
                  throw exception() !
                                                                                                          231
                           UNDO
                stock = stock + quantity;




                                                                                                    311
canon-eos: 1                                  -1
                            DO
ipod : 1        if(stock - quantity > 0) {

headphone : 1     stock = stock - quantity;
                } else {
                  throw exception() !
iphone: 1
...                        UNDO
                stock = stock + quantity;


                                              -1
                                                                                                   121
                            DO
                if(stock - quantity > 0) {

                                                                                                                264
                  stock = stock - quantity;
                } else {
                  throw exception() !


                           UNDO
                stock = stock + quantity;
                                                                                          2

                                              -1                     DO
                            DO
                if(stock - quantity > 0) {              if(stock - quantity > 0) {
                  stock = stock - quantity;
                } else {
                  throw exception() !
                                                          stock = stock - quantity;                       637
                                                        } else {
                           UNDO
                stock = stock + quantity;
                                                          throw exception() !                 12
                                                        }
                                                                                      warehouse stocks
                                                                    UNDO
                                                        stock = stock + quantity;


   code “do”, “undo” and the chain
Transactions with Manual Compensation

     Place order
                              DO
                                                     -1
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !
                                                                      231
                             UNDO
                  stock = stock + quantity;                  637

barbie : 1
iphone: 1                     DO
                  if(stock - quantity > 0) {
                                                -1                          311
cabbage-doll: 1     stock = stock - quantity;
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                  0

                              DO
                                                                        264
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                                                -1
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                      12

                                                                            121




                                                          warehouse stocks
Transactions with Manual Compensation

     Place order
                              DO
                                                     -1
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !
                                                                      231
                             UNDO
                  stock = stock + quantity;                  636

barbie : 1
iphone: 1                     DO
                  if(stock - quantity > 0) {
                                                -1                          311
cabbage-doll: 1     stock = stock - quantity;
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                  0

                              DO
                                                                        264
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                                                -1
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                      12

                                                                            121




                                                          warehouse stocks
Transactions with Manual Compensation

     Place order
                              DO
                                                     -1
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !
                                                                                         231
                             UNDO
                  stock = stock + quantity;                                     636

barbie : 1
iphone: 1                     DO
                  if(stock - quantity > 0) {
                                                -1                                             311
cabbage-doll: 1     stock = stock - quantity;
                  } else {




                                                          no more iphone !
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                                     0

                              DO
                                                                                           264
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                                                -1
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                                         12

                                                                                               121




                                                                             warehouse stocks
Transactions with Manual Compensation

     Place order
                              DO
                                                     -1
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !
                                                                                    231
                             UNDO
                  stock = stock + quantity;                                636

barbie : 1
iphone: 1                                       -1                                        311
                                                          interrupted
                              DO
                  if(stock - quantity > 0) {
cabbage-doll: 1     stock = stock - quantity;
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                                0

                              DO
                                                                                      264
                                                -1
                                                          cancelled
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                                    12

                                                                                          121




                                                                        warehouse stocks
Transactions with Manual Compensation

     Place order
                                DO
                                                       -1
                    if(stock - quantity > 0) {




                                                        undo
                      stock = stock - quantity;
                    } else {
                      throw exception() !
                                                                                                   231
                               UNDO
                    stock = stock + quantity;                                             636 +1

barbie : 1                    DO
iphone: 1                                         -1                                                     311
                                                            interrupted
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
cabbage-doll: 1   } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;
                                                                                         0

                               DO
                                                                                                     264
                                                  -1
                                                            cancelled
                  if(stock - quantity > 0) {
                    stock = stock - quantity;
                  } else {
                    throw exception() !


                             UNDO
                  stock = stock + quantity;                                                  12

                                                                     DO                                  121
                                                        if(stock - quantity > 0) {
                                                          stock = stock - quantity;
                                                        } else {

                                                        }
                                                          throw exception() !
                                                                                      warehouse stocks
                                                                    UNDO
                                                        stock = stock + quantity;
Transactions with Manual Compensation



• Code “do” & “undo” & chain execution


• What about interrupted chain execution ? Data corruption ?
Transactions with Manual Compensation



• Code “do” & “undo” & chain execution


• What about interrupted chain execution ? Data corruption ?


      data store managed transaction chain execution
Which solution to choose?
Key-Value Store

• Get and Set by key

         Simple but enough for a lot of use cases



• Riak and Voldemort provide a great scalability
         Great to persist continuously growing datasets



• Memcached and Redis offer low overhead and latency
         Great for cache and live data
Column Families Store

• Get and Set by key of a list of columns

         Makes it possible to fetch and update partial data



• Queries are simples, but columns slice fetching is possible
         Great for pagination



• Data model is too low level for many complex data modeling
         Should typically be used for the largest scalability needs
Document Store

• Schema less

         Great for continuously updated schemas



• Complex queries are available
         Necessary for filtering and search



• Scalability may be limited if not querying using partition key
         Can be handle using multiple storage and limited queries
In Memory Data Grid

• Very Low Latency & eXtreme Transaction Processing (XTP)

        Investment banking, booking & inventory systems



• In Memory - No Persistence
         Most of the time backed with a database



• High budget and Developer skills required
        Some Open Source alternatives are appearing
Polyglot storage for eCommerce

                  Products
                                                  Solr
                  search


                             Product catalog    MongoDB

    Application
                             User account and
                                                Cassandra
                              Shopping cart


             Warehouse
              inventory                         Coherence
Why NoSQL & DataGrids matter ?

• Polyglot Storage: databases that fit the needs of every type of data


• Linear Scalability: being able to handle any further business requirements


• High Availability: multi-servers and multi-datacenters


• Elasticity: natural integration with Cloud Computing philosophy


• Some new use cases now available
Questions / Answers




                      ?

Contenu connexe

Similaire à Optimize NoSQL data modeling for scalability

Large Scale Data Analysis Tools
Large Scale Data Analysis ToolsLarge Scale Data Analysis Tools
Large Scale Data Analysis Toolsboorad
 
Coderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersCoderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersJason Myers
 
High Performance Cloud Computing
High Performance Cloud ComputingHigh Performance Cloud Computing
High Performance Cloud ComputingAmazon Web Services
 
Balancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java DatabaseBalancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java DatabaseBen Stopford
 
Scalable Computing Labs (SCL).
Scalable Computing Labs (SCL).Scalable Computing Labs (SCL).
Scalable Computing Labs (SCL).Mindtree Ltd.
 
Introduction to Elastic MapReduce
Introduction to Elastic MapReduceIntroduction to Elastic MapReduce
Introduction to Elastic MapReduceAmazon Web Services
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...JAX London
 
Detecting and Recognising Highly Arbitrary Shaped Texts from Product Images
Detecting and Recognising Highly Arbitrary Shaped Texts from Product ImagesDetecting and Recognising Highly Arbitrary Shaped Texts from Product Images
Detecting and Recognising Highly Arbitrary Shaped Texts from Product ImagesDatabricks
 
How to Include GIS 3D Technology in Transport Network Representation
How to Include GIS 3D Technology in Transport Network RepresentationHow to Include GIS 3D Technology in Transport Network Representation
How to Include GIS 3D Technology in Transport Network RepresentationEsri
 
Take the spaghetti out of windows azure – an insight for it pro techies part 1
Take the spaghetti out of windows azure – an insight for it pro techies part 1Take the spaghetti out of windows azure – an insight for it pro techies part 1
Take the spaghetti out of windows azure – an insight for it pro techies part 1Microsoft TechNet - Belgium and Luxembourg
 
Data Driven Innovation with Amazon Web Services
Data Driven Innovation with Amazon Web ServicesData Driven Innovation with Amazon Web Services
Data Driven Innovation with Amazon Web ServicesAmazon Web Services
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure javaRoman Elizarov
 
What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5Robert MacLean
 

Similaire à Optimize NoSQL data modeling for scalability (20)

VO Course 06: VO Data-models
VO Course 06: VO Data-modelsVO Course 06: VO Data-models
VO Course 06: VO Data-models
 
Large Scale Data Analysis Tools
Large Scale Data Analysis ToolsLarge Scale Data Analysis Tools
Large Scale Data Analysis Tools
 
Coderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersCoderfaire Data Networking for Developers
Coderfaire Data Networking for Developers
 
Data Aggregation System
Data Aggregation SystemData Aggregation System
Data Aggregation System
 
High Performance Cloud Computing
High Performance Cloud ComputingHigh Performance Cloud Computing
High Performance Cloud Computing
 
6 Months Net
6 Months Net6 Months Net
6 Months Net
 
Balancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java DatabaseBalancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java Database
 
Scalable Computing Labs (SCL).
Scalable Computing Labs (SCL).Scalable Computing Labs (SCL).
Scalable Computing Labs (SCL).
 
Ieee metadata-conf-1999-keynote-amit sheth
Ieee metadata-conf-1999-keynote-amit shethIeee metadata-conf-1999-keynote-amit sheth
Ieee metadata-conf-1999-keynote-amit sheth
 
Introduction to Elastic MapReduce
Introduction to Elastic MapReduceIntroduction to Elastic MapReduce
Introduction to Elastic MapReduce
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
 
Detecting and Recognising Highly Arbitrary Shaped Texts from Product Images
Detecting and Recognising Highly Arbitrary Shaped Texts from Product ImagesDetecting and Recognising Highly Arbitrary Shaped Texts from Product Images
Detecting and Recognising Highly Arbitrary Shaped Texts from Product Images
 
How to Include GIS 3D Technology in Transport Network Representation
How to Include GIS 3D Technology in Transport Network RepresentationHow to Include GIS 3D Technology in Transport Network Representation
How to Include GIS 3D Technology in Transport Network Representation
 
Introduction to AWS tools
Introduction to AWS toolsIntroduction to AWS tools
Introduction to AWS tools
 
Take the spaghetti out of windows azure – an insight for it pro techies part 1
Take the spaghetti out of windows azure – an insight for it pro techies part 1Take the spaghetti out of windows azure – an insight for it pro techies part 1
Take the spaghetti out of windows azure – an insight for it pro techies part 1
 
Data Driven Innovation with Amazon Web Services
Data Driven Innovation with Amazon Web ServicesData Driven Innovation with Amazon Web Services
Data Driven Innovation with Amazon Web Services
 
Dancing with the Elephant
Dancing with the ElephantDancing with the Elephant
Dancing with the Elephant
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 
What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5
 
Drra brief
Drra briefDrra brief
Drra brief
 

Plus de Cyrille Le Clerc

Embracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetryEmbracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetryCyrille Le Clerc
 
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Cyrille Le Clerc
 
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...Cyrille Le Clerc
 
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...Cyrille Le Clerc
 
Java Application Monitoring with AppDynamics' Founder
Java Application Monitoring with AppDynamics' FounderJava Application Monitoring with AppDynamics' Founder
Java Application Monitoring with AppDynamics' FounderCyrille Le Clerc
 
Bonnes pratiques des applications java prêtes pour la production
Bonnes pratiques des applications java prêtes pour la productionBonnes pratiques des applications java prêtes pour la production
Bonnes pratiques des applications java prêtes pour la productionCyrille Le Clerc
 
Soirée OSGi au Paris Jug (14/10/2008)
Soirée OSGi au Paris Jug (14/10/2008)Soirée OSGi au Paris Jug (14/10/2008)
Soirée OSGi au Paris Jug (14/10/2008)Cyrille Le Clerc
 
Xebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top TenXebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top TenCyrille Le Clerc
 
Soirée Data Grid au Paris JUG (2009/05/12)
Soirée Data Grid au Paris JUG (2009/05/12)Soirée Data Grid au Paris JUG (2009/05/12)
Soirée Data Grid au Paris JUG (2009/05/12)Cyrille Le Clerc
 

Plus de Cyrille Le Clerc (9)

Embracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetryEmbracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetry
 
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
 
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...
Monitoring Open Source pour Java avec JmxTrans, Graphite et Nagios - DevoxxFR...
 
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...
Paris NoSQL User Group - In Memory Data Grids in Action (without transactions...
 
Java Application Monitoring with AppDynamics' Founder
Java Application Monitoring with AppDynamics' FounderJava Application Monitoring with AppDynamics' Founder
Java Application Monitoring with AppDynamics' Founder
 
Bonnes pratiques des applications java prêtes pour la production
Bonnes pratiques des applications java prêtes pour la productionBonnes pratiques des applications java prêtes pour la production
Bonnes pratiques des applications java prêtes pour la production
 
Soirée OSGi au Paris Jug (14/10/2008)
Soirée OSGi au Paris Jug (14/10/2008)Soirée OSGi au Paris Jug (14/10/2008)
Soirée OSGi au Paris Jug (14/10/2008)
 
Xebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top TenXebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top Ten
 
Soirée Data Grid au Paris JUG (2009/05/12)
Soirée Data Grid au Paris JUG (2009/05/12)Soirée Data Grid au Paris JUG (2009/05/12)
Soirée Data Grid au Paris JUG (2009/05/12)
 

Dernier

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Dernier (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Optimize NoSQL data modeling for scalability

  • 1. NoSQL & DataGrids from a Developer Perspective Cyrille Le Clerc - Michaël Figuière
  • 2. Speaker @cyrilleleclerc blog.xebia.fr Cyrille Le Clerc Large Scale DataGrids Apache CXF
  • 3. Speaker @mfiguiere blog.xebia.fr Michaël Figuière Distributed Systems NoSQL Search Engines
  • 4. About NoSQL No SQL
  • 5. About NoSQL Not Only No SQL
  • 6. About NoSQL Not Only No SQL Relational
  • 7. Once upon a time...
  • 8. On the Web side - Created Dynamo Similar needs for Web giants : - < 40 min of unavailability per year • Huge amount of data • High availability • Fault tolerance - Created BigTable & MapReduce • Scalability on commodity - Stores every webpages of Internet hardware
  • 9. Amazon : the birth of Dynamo Requires complex requests, temporal unavailability is acceptable Fill cart Checkout Payment Process order Prepare Send Requires high availability, key-value store is enough
  • 10. On the Financial side - Released Coherence in 2001 Needs within financial market : - Started as a distributed cache • Very low latency • Rich queries & transactions • Scalability - Released Gigaspaces XAP in 2001 • Data consistency - Routes the request inside the data
  • 11. Data Partitioning and Replication
  • 12. Use Case : Train Ticketing System With trains, stations, seats, booking and passengers
  • 13. Store everything in a Mainframe ! Up to 3 To of RAM ! More than $1,000,000 IBM z11
  • 14. Data Partitioning Partition gamma Small servers Partition beta MainFrame Partition alpha Split data for scalability
  • 15. Data Replication Node 1 synchro Partition alpha Node 2 Duplicate data for high availability and Node 3 scalability
  • 17. Partitioned Data Modeling Seat Booking Passenger number reduction name price Train code type TrainStation TrainStop code date name Typical relational data model
  • 18. Partitionned Data Modeling Partitioning ready entities tree e ntity Root Seat Booking Passenger number reduction name price Train code Du type pli Refe ca ted renc in e d TrainStation ea ata TrainStop ch code pa date rtit ion name Find the root entity and denormalize
  • 19. Partitionned Data Modeling Remove unused data Seat Booking Passenger number reduction name price booked Train code type TrainStation TrainStop code date name
  • 20. Partitionned Data Modeling Sharding ready data structure Seat number price booked Train code type TrainStation TrainStop code date name
  • 21. Consistency, Availability and Partition Tolerance
  • 22. Data Consistency with replicas Node 1 { "name": "Barbie Computer", "price": 15.50, "tags" : [ "doll", "barbie" Node 2 ]} write to all Node 3 Node 1 read from one Node 2 Node 3
  • 23. Data Consistency with replicas { "name": "Barbie Computer", Node 1 "price": 15.50, "tags" : [ "doll", "barbie" ]} Node 2 write to one Node 3 Node 1 Node 2 read from all Node 3
  • 24. Data Consistency with replicas • You can adjust the balance between number of writes and number of reads • See Eventual Consistency
  • 25. Data Consistency with Multiple Data Centers { "name": "Barbie Computer", "price": 15.50, "tags" : [ "doll", "barbie" ]} { "name": "Barbie Computer", "price": 15.50, "tags" : [ West Coast "doll", "barbie" ]} East Coast
  • 26. Data Consistency with Multiple Data Centers set price to $ 20.00 { "name": "Barbie Computer", "price": 20.00, "tags" : [ "doll", "barbie" ]} { "name": "Barbie Computer", "price": 15.50, West Coast "tags" : [ "doll", "barbie" ]} East Coast propagation delay !
  • 27. Data Consistency with Multiple Data Centers set price to $ 20.00 { "name": "Barbie Computer", "price": 20.00, "tags" : [ "doll", "barbie" ]} { "name": "Barbie Computer", "price": 15.50, West Coast "tags" : [ "doll", "barbie", “girl” ]} East Coast add tag “girl” reconciliation API needed !
  • 28. Data Consistency with Multiple Data Centers set price to $ 20.00 { "name": "Barbie Computer", "price": 20.00, "tags" : [ "doll", "barbie" ]} { "name": "Barbie Computer", "price": 15.50, West Coast "tags" : [ "doll", "barbie", “girl” ]} East Coast add tag “girl” Network partitioning
  • 29. Data Consistency with Multiple Data Centers London New York Tokyo World wide replication for financial market
  • 30. CAP Theorem Only 2 of these 3 properties can be achieved in storage Consistency system Availability Partition Tolerance
  • 31. CAP Theorem Relational DB NoSQL DB Consistency Availability Partition Impossible Tolerance
  • 33. Request Driven Data Modeling • Relational data modeling is business driven Adaptation to requests comes with tuning • With partitioning, data modeling had to be adapted for requests Because network latency matters • NoSQL & DataGrids data modeling is request driven Two requests may require to store data twice
  • 34. Key-Value Store In memory In memory with async persistence Persistent
  • 35. Example with a user profile johndoe User profile as byte[] Similar to a Java HashMap
  • 36. Write Example with Riak RiakClient riak = new RiakClient("http://server1:8098/riak"); RiakObject userProfileObj = new RiakObject("bucket", "johndoe", serializer.serialize(userProfile); riak.store(userProfileObj); Inserts a user profile into Riak
  • 37. Read Example with Riak FetchResponse response = riak.fetch("bucket", "johndoe"); if (response.hasObject()) { userProfileObj = response.getObject(); } Fetch a user profile using its key in Riak
  • 39. Column Families Store For each Row ID we have a list of key-value pairs Key-value pairs are sorted by keys Relational DB Column families DB
  • 40. Example with a shopping cart johndoe 17:21 Iphone 17:32 DVD Player 17:44 MacBook willsmith 6:10 Camera 8:29 Ipad pitdavis 14:45 PlayStation 15:01 Asus EEE 15:03 Iphone
  • 41. Write Example with Cassandra Cluster cluster = HFactory.getOrCreateCluster("cluster", new CassandraHostConfigurator("server1:9160")); Keyspace keyspace = HFactory.createKeyspace("EcommerceKeyspace", cluster); Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer); mutator.insert("johndoe", "ShoppingCartColumnFamily", HFactory.createStringColumn("14:21", "Iphone")); Inserts a column into the ShoppingCartColumnFamily
  • 42. Read Example with Cassandra SliceQuery<String, String, String> query = HFactory.createSliceQuery(keyspace, stringSerializer, stringSerializer, stringSerializer); query.setColumnFamily("ShoppingCartColumnFamily") .setKey("johndoe") .setRange("", "", false, 10); QueryResult<ColumnSlice<String, String>> result = query.execute(); Reads a slice of 10 columns from ShoppingCartColumnFamily
  • 44. Example with an item of a catalog { "name": "Iphone", "price": 559.0, item_1 "vendor": "Apple", "rating": 4.6, "tags": [ "phone", "touch" ] } The database is aware of document’s fields and can offers complex queries
  • 45. Write Example with MongoDB Mongo mongo = new Mongo("mongos_1", 27017); DB db = mongo.getDB("Ecommerce"); DBCollection catalog = db.getCollection("Catalog"); BasicDBObject doc = new BasicDBObject(); doc.put("name", "Iphone"); doc.put("price", 559.0); catalog.insert(doc); Inserts an item document into MongoDB
  • 46. Read Example with MongoDB BasicDBObject query = new BasicDBObject(); query.put("price", new BasicDBObject("$lt", 600)); DBCursor cursor = catalog.find(query); while(cursor.hasNext()) { System.out.println(cursor.next()); } Queries for all items with a price lower than 600
  • 47. In Memory Data Grids eXtreme Scale
  • 48. Example with train booking with IBM eXtremeScale @Entity(schemaRoot=true) public class Train { Seat number price @Id booked String code; Train code @Index type @Basic TrainStop String name; date @OneToMany(cascade=CascadeType.ALL) List<Seat> seats = new ArrayList<Seat>(); @Version int version; ... } With Data Grids, sub entities can have cross relations
  • 49. Write Example with IBM eXtreme Scale eXtreme Scale provides a JPA Style API void persist(Train train) { entityManager.persist(train); } Inserts a train into eXtreme Scale
  • 50. Read Example with IBM eXtreme Scale /** Find by key */ Train findById(String id) { return (Train) entityManager.find(Train.class, id); } /** Query Language */ Train findByTrain(String code) { Query q = entityManager.createQuery("select t from Train t where t.code=:code"); q.setParameter("code", code); return (Train) q.getSingleResult(); } Simple and complex queries with eXtreme Scale
  • 51. More APIs • Another Java EE versus Spring battle ? JSR 347 Data Grids vs. Spring Data Unified API ontop of relational, document, column, key-value ? Object to tuple projection API
  • 53. Transactions • NoSQL usually means NO transactions • Except when it means eXtreme Transactions !
  • 54. Transactions Concurrency Place order 231 canon-eos: 1 ipod : 1 headphone : 1 311 iphone: 1 ... ipad : 1 121 iphone: 1 264 concurrency on iphone 2 barbie : 1 iphone: 1 637 cabbage-doll: 1 12 cancel order if one product warehouse stocks is missing
  • 55. SQL Transactions Place order 231 canon-eos: 1 ipod : 1 begin headphone : 1 311 iphone: 1 ... for each shoppingCart.product select for update ... 121 ipad : 1 iphone: 1 update ... 264 commit 2 barbie : 1 iphone: 1 cabbage-doll: 1 637 12 warehouse stocks lock duration = f(shoppingcart.length) if too many locks on the rows, then lock table !
  • 56. SQL Transactions Place order select for update ... 231 canon-eos: 1 ipod : 1 headphone : 1 311 iphone: 1 ... ipad : 1 121 iphone: 1 264 2 barbie : 1 iphone: 1 cabbage-doll: 1 637 12 warehouse stocks lock duration = f(shoppingcart.length) if too many locks on the rows, then lock table !
  • 57. SQL Transactions Place order select for update ... 231 canon-eos: 1 ipod : 1 headphone : 1 311 iphone: 1 ... ipad : 1 121 iphone: 1 264 2 barbie : 1 iphone: 1 cabbage-doll: 1 637 12 warehouse stocks lock duration = f(shoppingcart.length) if too many locks on the rows, then lock table !
  • 58. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 311 canon-eos: 1 -1 DO ipod : 1 if(stock - quantity > 0) { headphone : 1 stock = stock - quantity; } else { throw exception() ! iphone: 1 ... UNDO stock = stock + quantity; -1 121 DO if(stock - quantity > 0) { 264 stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 2 -1 DO DO if(stock - quantity > 0) { if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! stock = stock - quantity; 637 } else { UNDO stock = stock + quantity; throw exception() ! 12 } warehouse stocks UNDO stock = stock + quantity; code “do”, “undo” and the chain
  • 59. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 637 barbie : 1 iphone: 1 DO if(stock - quantity > 0) { -1 311 cabbage-doll: 1 stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 0 DO 264 if(stock - quantity > 0) { stock = stock - quantity; -1 } else { throw exception() ! UNDO stock = stock + quantity; 12 121 warehouse stocks
  • 60. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 636 barbie : 1 iphone: 1 DO if(stock - quantity > 0) { -1 311 cabbage-doll: 1 stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 0 DO 264 if(stock - quantity > 0) { stock = stock - quantity; -1 } else { throw exception() ! UNDO stock = stock + quantity; 12 121 warehouse stocks
  • 61. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 636 barbie : 1 iphone: 1 DO if(stock - quantity > 0) { -1 311 cabbage-doll: 1 stock = stock - quantity; } else { no more iphone ! throw exception() ! UNDO stock = stock + quantity; 0 DO 264 if(stock - quantity > 0) { stock = stock - quantity; -1 } else { throw exception() ! UNDO stock = stock + quantity; 12 121 warehouse stocks
  • 62. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 636 barbie : 1 iphone: 1 -1 311 interrupted DO if(stock - quantity > 0) { cabbage-doll: 1 stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 0 DO 264 -1 cancelled if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 12 121 warehouse stocks
  • 63. Transactions with Manual Compensation Place order DO -1 if(stock - quantity > 0) { undo stock = stock - quantity; } else { throw exception() ! 231 UNDO stock = stock + quantity; 636 +1 barbie : 1 DO iphone: 1 -1 311 interrupted if(stock - quantity > 0) { stock = stock - quantity; cabbage-doll: 1 } else { throw exception() ! UNDO stock = stock + quantity; 0 DO 264 -1 cancelled if(stock - quantity > 0) { stock = stock - quantity; } else { throw exception() ! UNDO stock = stock + quantity; 12 DO 121 if(stock - quantity > 0) { stock = stock - quantity; } else { } throw exception() ! warehouse stocks UNDO stock = stock + quantity;
  • 64. Transactions with Manual Compensation • Code “do” & “undo” & chain execution • What about interrupted chain execution ? Data corruption ?
  • 65. Transactions with Manual Compensation • Code “do” & “undo” & chain execution • What about interrupted chain execution ? Data corruption ? data store managed transaction chain execution
  • 66. Which solution to choose?
  • 67. Key-Value Store • Get and Set by key Simple but enough for a lot of use cases • Riak and Voldemort provide a great scalability Great to persist continuously growing datasets • Memcached and Redis offer low overhead and latency Great for cache and live data
  • 68. Column Families Store • Get and Set by key of a list of columns Makes it possible to fetch and update partial data • Queries are simples, but columns slice fetching is possible Great for pagination • Data model is too low level for many complex data modeling Should typically be used for the largest scalability needs
  • 69. Document Store • Schema less Great for continuously updated schemas • Complex queries are available Necessary for filtering and search • Scalability may be limited if not querying using partition key Can be handle using multiple storage and limited queries
  • 70. In Memory Data Grid • Very Low Latency & eXtreme Transaction Processing (XTP) Investment banking, booking & inventory systems • In Memory - No Persistence Most of the time backed with a database • High budget and Developer skills required Some Open Source alternatives are appearing
  • 71. Polyglot storage for eCommerce Products Solr search Product catalog MongoDB Application User account and Cassandra Shopping cart Warehouse inventory Coherence
  • 72. Why NoSQL & DataGrids matter ? • Polyglot Storage: databases that fit the needs of every type of data • Linear Scalability: being able to handle any further business requirements • High Availability: multi-servers and multi-datacenters • Elasticity: natural integration with Cloud Computing philosophy • Some new use cases now available