SlideShare a Scribd company logo
Transactions chapter will be presented
                                 during another session




       In Memory Data Grid in Action
       with Oracle Coherence
       for Paris NoSQL User Group

                                       Cyrille Le Clerc




Wednesday, May 25, 2011
Speaker



                          @cyrilleleclerc
                          blog.xebia.fr


                               Cyrille Le Clerc
                                                                 Large Scale


                                                       In Memory Data Grid
      Open Source
      (Apache CXF, ...)

                                            “you build it, you run it”

                                                                               2
Wednesday, May 25, 2011
Once upon a time...




                            3
Wednesday, May 25, 2011
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               - Started as a data grid




                                                                           4
Wednesday, May 25, 2011
Let’s define an In Memory Data Grid ...




                                               5
Wednesday, May 25, 2011
Let’s define an In Memory Data Grid




                          eXtreme Scale




                            This is an In Memory Data Grid


                                                             6
Wednesday, May 25, 2011
Let’s define an In Memory Data Grid




                          This is Network Attached Memory


                                                            7
Wednesday, May 25, 2011
Let’s define an In Memory Data Grid

 Similarities with NoSQL document oriented
   Partitioned, distributed Hastable, schema-less, value is not opaque,
   scale-out scalability


 Very fast
   In memory (persistence coming), business logic inside the data



 Consistent and Available
   Transactional, redundant



 Written in Java, data are POJOs
   Not necessary



 Clients in Java, Microsoft, etc
                                                                          8
Wednesday, May 25, 2011
Use cases for this presentation




                                        9
Wednesday, May 25, 2011
Train Booking System




                          trains, stations,
                          seats, booking and
                          passengers




                                           10
Wednesday, May 25, 2011
eCommerce Web Site

      warehouse &
      customers shopping carts
                                                                                          231

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




                                                                                   121
               ipad : 1
               iphone: 1
                                                                                                264

                                                                          2

              barbie : 1
                                {
              iphone: 1
                                        "name": "Barbie Computer",
              cabbage-doll: 1           "stock": 637,                                    637
                                        "weigth" : 200
                                    }                                         12

                                                                     warehouse stocks



                                                                                                      11
Wednesday, May 25, 2011
In Memory Data Grids Key Principles




                                            12
Wednesday, May 25, 2011
Store Everything in a Mainframe !




                                                3 To of RAM
                                                80 x 5.2 GHtz cores
                                                Much more than $1,000,000




                          http://ibm.com/



                                      IBM z11




                                                                            13
Wednesday, May 25, 2011
Spread on Inexpensive Servers




             http://ibm.com/

                               http://1userverrack.net/

             Mainframe                                    Cheap Servers !




                                                                            14
Wednesday, May 25, 2011
Partition Data




                                                      Partition gamma


                                                                        Small
                                                                        servers
                                                       Partition beta



                    MainFrame
                                                      Partition alpha

                          Partition for scalability

                                                                              15
Wednesday, May 25, 2011
Duplicate Data




                                                                                 sync synchronization
                                                                   Master


                 Partition alpha


                                                                Standby Backup



                                   Duplicate data for high availability


                                                                                                        16
Wednesday, May 25, 2011
Data Access Patterns




                             17
Wednesday, May 25, 2011
Data Access Patterns


 This is not traditional Java EE coding style !


 Can apply very complex business logic inside the
    data
                 Stored Procedures Style




                          Change management challenge !

                                                          18
Wednesday, May 25, 2011
Pattern : Targeted Operation




                                     19
Wednesday, May 25, 2011
Pattern: Targeted Operation


                     {
                             "train-id": "tgv-3071-20110512",
                             "time" : 2011/05/12 12:15,          Search Trains
                             "departure" : "Paris",
                             "arrival" : "Marseille",
                             "seats" : 3,                                   Partition gamma
                         }




                                                                 Search Trains
                                                                                 Partition beta
            “train-id” is indexed


                                                                 Search Trains

                                                                             Partition alpha

                                                         Book Train Tickets
                                                                                                  20
Wednesday, May 25, 2011
Pattern : Map Reduce Style Operation




                                             21
Wednesday, May 25, 2011
Pattern: Map Reduce


                    {
                          "departure": "Paris",
                          "arrival": "Marseille",
                          "time" : 2011/05/12 12:00,
                                                        Search Trains
                          "seats" : 3,
                     }
                                                                   Partition gamma




                                                         Search Trains
                                                                        Partition beta




                                                        Search Trains

                                                                    Partition alpha

                                         Distributed “Search Train Ticket”
                                                                                         22
Wednesday, May 25, 2011
Pattern: Map Reduce


                              {
                                  "Paris -> Marseille : 12:15",
                                  "Paris -> Marseille : 13:15"       Search Trains
                              }

                                                                                Partition gamma



                                                    {   #NONE# }




                                                                     Search Trains
                                                                                     Partition beta

                          {
                              "Paris -> Lyon -> Marseille : 12:40"
                          }



                                                                     Search Trains

                                                                                 Partition alpha

                                        Distributed “Search Train Ticket”
                                                                                                      23
Wednesday, May 25, 2011
Pattern: Map Reduce



                                                   Search Trains
                                                              Partition gamma




                                                    Search Trains
    {                                                              Partition beta
        "Paris -> Marseille : 12:15",
        "Paris -> Lyon -> Marseille : 12:40",
        "Paris -> Marseille : 13:15"
    }




                                                   Search Trains

                                                               Partition alpha

                                    Distributed “Search Train Ticket”
                                                                                    24
Wednesday, May 25, 2011
Data Access Patterns

 This is not traditional Java EE coding style
                    Change management



 Don’t forget “Map Reduce” = “Distributed Table
    Scan”

                      Use Indexes




                                                   25
Wednesday, May 25, 2011
CAP Theorem & In Memory Data Grids




                                           26
Wednesday, May 25, 2011
CAP Theorem and In Memory Data Grid


                                                                    Only 2 of these 3
                                                                    properties can be
                           Consistency                            achieved at any given
                                                                      moment in time
                                                                                                  Brewer’s Conjecture




                                       Availability
                           Partition
                          Tolerance



                                                      http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf
                                                                                                                        27
Wednesday, May 25, 2011
CAP Theorem and In Memory Data Grid



                                            Data Grids              Only 2 of these 3
                                                                    properties can be
                           Consistency                            achieved at any given
                                                                      moment in time
                                                                                                  Brewer’s Conjecture




                                       Availability
                           Partition
                          Tolerance



                                                      http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf
                                                                                                                        28
Wednesday, May 25, 2011
Cross Data Center Data Consistency



                                        London
                          New York
                                                              Tokyo




                                     World wide replication
                                      for financial market
                                                                      29
Wednesday, May 25, 2011
Cross Data Center Data Consistency




          {
                  "name": "Barbie Computer",
                  "stock": 147,
                  "weigth" : 200
              }
                                                           {
                                                                   "name": "Barbie Computer",

              West Coast                                           "stock": 147,
                                                                   "weigth" : 200
                                                               }




                                                           East Coast




                                               Warehouse stocks

                                                                                                30
Wednesday, May 25, 2011
Cross Data Center Data Consistency


                  set stock to 146




          {
                  "name": "Barbie Computer",
                  "stock": 147,
                  "weigth" : 200
              }
                                                                     {
                                                                             "name": "Barbie Computer",

              West Coast                                                     "stock": 147,
                                                                             "weigth" : 200
                                                                         }




                                                                     East Coast
                                               propagation delay !




                                                                                                          31
Wednesday, May 25, 2011
Cross Data Center Data Consistency


                  set stock to 146




          {
                  "name": "Barbie Computer",
                  "stock": 147,
                  "weigth" : 200
              }
                                                                    {
                                                                            "name": "Barbie Computer",

              West Coast                                                    "stock": 147,
                                                                            "weigth" : 200
                                                                        }




                                                                    East Coast
                                                                                                   set weight 175
                                      reconciliation API needed !




                                                                                                                    32
Wednesday, May 25, 2011
Cross Data Center Data Consistency


                  set stock to 146




          {
                  "name": "Barbie Computer",
                  "stock": 147,
                  "weigth" : 200
              }
                                                                      {
                                                                              "name": "Barbie Computer",

              West Coast                                                      "stock": 147,
                                                                              "weigth" : 200
                                                                          }




                                                                      East Coast
                                                                                                     set weight 175
                                               Network partitioning




                                                                                                                      33
Wednesday, May 25, 2011
Data Modeling




                          34
Wednesday, May 25, 2011
Data Modeling

 Dominant Question Driven Design
                   Opposite to Relational which is Domain Driven Design


 Constrained Tree Schema
                    Because RPC matters


 Denormalized
                    Due to dominant questions and CTS




                                                                          35
Wednesday, May 25, 2011
Data Modeling




                                                    Seat
                                                               Booking        Passenger
                                              number
                                                            reduction       name
                                              price

                                 Train
                          code
                          type

                                                             TrainStation
                                                TrainStop
                                                            code
                                              date
                                                            name




                                         Typical relational data model



                                                                                          36
Wednesday, May 25, 2011
Data Modeling


                                                   Partitioning ready
                                                     entities tree




                               e   ntity
                          Root                         Seat
                                                                           Booking               Passenger
                                                 number
                                                                        reduction              name
                                                 price

                                   Train
                           code
                           type                                                         Du            R
                                                                                             pli
                                                                                                   ca efer
                                                                                                     ted en
                                                                         TrainStation                   in ce d
                                                                                                           ea
                                                   TrainStop                                                  ch ata
                                                                        code                                    gri
                                                 date                                                               dn
                                                                        name                                             od
                                                                                                                              e




                                           Find the root entity and denormalize



                                                                                                                                  37
Wednesday, May 25, 2011
Data Modeling


                                          Remove unused data



                                                Seat
                                                           Booking        Passenger
                                          number
                                                        reduction       name
                                          price
                                          booked
                                  Train
                           code
                           type

                                                         TrainStation
                                            TrainStop
                                                        code
                                          date
                                                        name



                   Partitioned

                   Replicated



                                                                                      38
Wednesday, May 25, 2011
Data Modeling




                                                             Seat
                                                       number
                                                       price
                                                       booked
                                               Train
                                        code
                                        type

                                                                      TrainStation
                                                         TrainStop
                                                                     code
                                                       date
                                                                     name




                          Partitioned

                          Replicated


                                 Data Grid Ready data structure

                                                                                     39
Wednesday, May 25, 2011
Data Modeling is Hard !




                                40
Wednesday, May 25, 2011
Data Modeling is Hard !




                            Account                                      Account
                          number                                       number




                                          from                    to


                          CashWitdrawal           MoneyTransfer        CashWitdrawal
                          date                   id                    date
                          amount                 date                  amount
                                                 amount




                            Two root entities for the
                             same MoneyTransfer !

                                                                                       41
Wednesday, May 25, 2011
Data Modeling is Hard !




                                     Account                             Account
                                   number                              number




                          CashWitdrawal    MoneyTransferIn   MoneyTransferOut   CashWitdrawal
                          date            id                 id                 date
                          amount          date               date               amount
                                          amount             amount




                                               Split MoneyTransfer

                                                                                                42
Wednesday, May 25, 2011
Data Modeling is Hard !




                                    Account                            Account
                                  number                             number




                          CashWitdrawal    MoneyTransferIn   MoneyTransferOut    CashWitdrawal
                          date            id                 id                  date
                          amount          date               date                amount
                                          amount             amount




                                              Split MoneyTransfer

                                                                                                 43
Wednesday, May 25, 2011
Data Modeling is Hard !




                                                Account
                                              number




                             CashWitdrawal   MoneyTransferOut    MoneyTransferIn
                             date            id                 id
                             amount          date               date
                                             amount             amount




                          Data Grid Ready data structure

                                                                                   44
Wednesday, May 25, 2011
Grid Internals




                          45
Wednesday, May 25, 2011
Data Serialization

 Used for data transfer and byte oriented storage
                   Must support evolvable data structure



 Hot topic like Apache Thrift, Apache Avro, Google
    Protocol Buffer




                                                           46
Wednesday, May 25, 2011
Data Storage

 Store Java Beans in the grid
                   No need to unmarshall for inprocess operations

                   Beware of garbage collector !

 Store byte arrays in the grid
                   Pay unmarshalling at each read and write

                   Low-level / byte-oriented APIs to read data
                   Slightly more garbage collector friendly




                                                                    47
Wednesday, May 25, 2011
Communication Protocols


 UDP Multi Cast (Coherence, Gigaspaces)

 TCP/IP (Websphere eXtreme Scale)




                                           48
Wednesday, May 25, 2011
Topology


 Partitions made of shards : 1 primary + 0..*
    backups)

 Dynamic shards location (changes at runtime and
    at restart)

 Can use dedicated “directory servers” or embed it
    in the “data nodes”




                                                  49
Wednesday, May 25, 2011
JVM and Memory

 Many editors recommend tiny 1.4 Go JVM !
         Garbage collector hell


 More than ten JVM per server
         Management hell




             More and more IMDG support large heaps


                                                      50
Wednesday, May 25, 2011
APIs




                          51
Wednesday, May 25, 2011
Raw Java Mapping with Oracle Coherence
      public class Train extends AbstractEvolvable implements PortableObject {
        enum Type {
          HIGH_SPEED, NORMAL
        }

          /** Key of the Cache */
          String code;

          /** Indexed */                                                                                  Seat
          String name;
                                                                                                    number
          Type type;
                                                                                                    price
                                                                                                    booked
          List<Seat> seats = new ArrayList<Seat>();                                         Train
                                                                                     code
          int version;                                                               type
          List<TrainStop> trainStops = new ArrayList<TrainStop>();
                                                                                                      TrainStop
          @Override                                                                                 date
          public int getImplVersion() {
            return 1;
          }

          @Override
          public void readExternal(PofReader pofReader) throws IOException {
            this.code = pofReader.readString(0);
            this.name = pofReader.readString(1);
            this.type = (Type) pofReader.readObject(2);
            pofReader.readCollection(3, this.seats);
            pofReader.readCollection(4, this.trainStops);
            this.version = pofReader.readInt(5);

                                                                                 hand-coded serialization
          }

          @Override

                                                                                 JUnit is your friend !
          public void writeExternal(PofWriter pofWriter) throws IOException {
            pofWriter.writeString(0, this.code);
            pofWriter.writeString(1, this.name);
            pofWriter.writeObject(2, this.type);
            pofWriter.writeCollection(3, this.seats, Seat.class);
            pofWriter.writeCollection(4, this.trainStops, TrainStop.class);
            pofWriter.writeInt(5, this.version);
          }
      }
                                                                                                                  52
Wednesday, May 25, 2011
JPA Style Mapping with Websphere eXtreme
Scale

               @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;

                   ...
               }

                                                    sub entities can have
                                                    cross relations

                                                                                            53
Wednesday, May 25, 2011
Map API with Oracle Coherence

        NamedCache trainCache = CacheFactory.getCache("train-cache");

        /** Save */
        void persist(Train train) {
            trainCache.put(train.getCode(), train);
        }

        /** Find by key */
        Train findByCode(String code) {
          return (Train) trainCache.get(code);
        }

        /** Find by Query Language */
        Train findByTrainName(String name) {
          Filter filter = QueryHelper.createFilter("name = :name" ,
            Collections.singletonMap("name", name));
          Set<Map.Entry<String, Train>> trainEntrySet = trainCache.entrySet(filter);
          if (trainEntrySet.isEmpty()) {
              return null;
          } else {
              return trainEntrySet.iterator().next().getValue();
          }
        }


                                         Map API
                                                                                       54
Wednesday, May 25, 2011
JPA Style with Websphere eXtreme Scale

       /** Save */
       void persist(Train train) {
           entityManager.persist(train);
       }


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


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

            return (Train) q.getSingleResult();
       }



                                 JPA Style Entity Manager


                                                                                             55
Wednesday, May 25, 2011
Creating Indexes




               Map reduce (without index) = Distributed Table Scan !




                                                                       56
Wednesday, May 25, 2011
Indexes with Oracle Coherence



class Train {

    String name;

    Collection<String> getTrainStationsCodes() {
      return Collections2.transform(trainStops, ...);
    }

    ...
}

{
       NamedCache trainCache = CacheFactory.getCache("train-cache");

       trainCache.addIndex(new ReflectionExtractor("getName"), false, null);
       trainCache.addIndex(new ReflectionExtractor("getTrainStationsCodes"), false, null);
}




                                                                                             57
Wednesday, May 25, 2011
Indexes with Websphere eXtreme Scale

    @Entity(schemaRoot=true)
    class Train {

        @Index
        @Basic                                                                  eXtreme Scale
        String name;

        @Index
        Collection<String> getTrainStationsCodes() {
          return Collections2.transform(trainStops, ...);
        }

        ...
    }

    Query query = em.createQuery("select t from Train t where t.name=:name");
    query.getPlan();




                                This is an execution plan

                          for q2 in Train ObjectMap using INDEX on name = ( ?name)
                           filter ( q2.c[0] = ?name )
                          returning new Tuple( q2 )


                                                                                                58
Wednesday, May 25, 2011
More APIs

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

                Serialization / Object to Tuple Mapping API ?

                Unified API ontop of NoSQL stores ?




                                                                   59
Wednesday, May 25, 2011
Data Grid <-> Relational Database Interactions




                                                       60
Wednesday, May 25, 2011
Data Grid <-> Relational Database




   Data Grids are “In Memory” -> we need to persist data on disk !




                                                                61
Wednesday, May 25, 2011
Data Grid <-> Relational Database




                            update / insert / delete




                          “select directly modified in DB”




                                                             62
Wednesday, May 25, 2011
Data Grid <-> Relational Database
                            Data Grid -> Relational Database




                                                          backend DB




                          Highly available write behind queues
                              + SQL batched statements
                                                                       63
Wednesday, May 25, 2011
Data Grid <-> Relational Database

                     Data Grid -> Relational Database


                                 Seat
                           number
                           price
                           booked
             Train
      code
      type

                                          TrainStation
                             TrainStop
                                         code
                           date
                                         name




                          Constrained Tree Schema <-> Relational
                                   Impedance Mismatch

                                                                   64
Wednesday, May 25, 2011
Data Grid <-> Relational Database


   DB writes MUST succeed !

            Prefer raw SQL rather than reused business logic
            Denormalize the database
            Remove the foreign keys, use same PKs in DB and data grid
            Support unordered SQL statements




        Align the database on the Data Grid model !

                                                                   65
Wednesday, May 25, 2011
Data Grid <-> Relational Database
                              Relational Database -> Data Grid




                                             select * from train
                                            where last_modif > ?

                                                                      backend DB




                          Data Grid Originated Scheduled Refresh
                                 (Oracle System Change Number, etc)

                                                                                   66
Wednesday, May 25, 2011
Data Grid <-> Relational Database
                          Relational Database -> Data Grid




                                                                        backend DB




                            Database Originated Push
                           JMS = durable subscription
                           (Oracle Database Change Notification, etc)
                                                                                     67
Wednesday, May 25, 2011
Data Grid <-> Relational Database


 In Memory -> prepare for reloading after
    maintenance operations !
                 Need for “graceful shutdown with disk persistence”



 Prepare consistency checkers




                                                                      68
Wednesday, May 25, 2011
Transactions




                          69
Wednesday, May 25, 2011
We didn’t have the time to talk about
                            transaction.


    Another session is planned at Paris No SQL
              User Group for this.




                                                       70
Wednesday, May 25, 2011
Let’s go live !




                          71
Wednesday, May 25, 2011
Data Grids and Operations

 Standard packaging?
           Do It Yourself (layout, scripts, etc)


 Limited Management
        Do It Yourself (stop/start, detecting data loss, etc)


 Limited debugging tools
          Do It Yourself (debugging consoles, troubleshooting agents)


 JVM pandemia
        Dozens of JVM to manage !


                                                                    72
Wednesday, May 25, 2011
Data Grids and Operations

 Dev / Ops collaboration is required

 Experts only !




                                        73
Wednesday, May 25, 2011
The right tool for the right job




                                         74
Wednesday, May 25, 2011
The right tool for the right job

 Incredibly fast ! Even with transactions !

 Scalable
              If you solve the data loading issue

 Good at data replication (when it implements it)
              Reconciliation api, etc

 Very geeky on both dev and ops side
              Not an enterprise grade data store
              Requires very skilled people + change management

 “Quite” expensive


                                                                 75
Wednesday, May 25, 2011
Questions / Answers




                          ?

                              76
Wednesday, May 25, 2011

More Related Content

PDF
Membase Meetup - San Diego
PPT
Creating an RAD Authoratative Data Environment
PDF
Advanced mysql replication techniques
PDF
State of the art of MySQL replication and clustering
PDF
Engineered Systems: Oracle’s Vision for the Future
PDF
Solaris Barcelona
PPTX
Evaluation Question 1 - How did you use, develop or challenge codes and conve...
PPT
חבר מביא חבר - לעובדי גב מערכות
Membase Meetup - San Diego
Creating an RAD Authoratative Data Environment
Advanced mysql replication techniques
State of the art of MySQL replication and clustering
Engineered Systems: Oracle’s Vision for the Future
Solaris Barcelona
Evaluation Question 1 - How did you use, develop or challenge codes and conve...
חבר מביא חבר - לעובדי גב מערכות

Viewers also liked (17)

PPTX
Presentación_1
PPTX
BIG DATA MANAGEMENT - forget the hype, let's talk about the facts!
PDF
URL Hacking 101: An Easy Way to Streamline Processes in Salesforce
PPTX
Meaningful Analytics: Finding Data That Matters to You
DOC
A call for unity 2. english
PPTX
Apple Presentaion
PPTX
St Martin's Campus, Brighton
PPTX
Understanding the basics of web design
PPTX
¡¡¡¡NIVELACION!!!
PPTX
Sexto grado Productivo
PDF
Performance Arts Awards Graded Examinations in Musical Theatre | RSL
PPT
Guerilla marketing
PDF
Calendário 2015 2016
PPTX
Oral Health Care for All Ages
PDF
Actividad 6
PDF
Daily Newsletter: 13th April, 2011
Presentación_1
BIG DATA MANAGEMENT - forget the hype, let's talk about the facts!
URL Hacking 101: An Easy Way to Streamline Processes in Salesforce
Meaningful Analytics: Finding Data That Matters to You
A call for unity 2. english
Apple Presentaion
St Martin's Campus, Brighton
Understanding the basics of web design
¡¡¡¡NIVELACION!!!
Sexto grado Productivo
Performance Arts Awards Graded Examinations in Musical Theatre | RSL
Guerilla marketing
Calendário 2015 2016
Oral Health Care for All Ages
Actividad 6
Daily Newsletter: 13th April, 2011
Ad

Similar to Paris NoSQL User Group - In Memory Data Grids in Action (without transactions chapter) (20)

PDF
AFCEA C4I Symposium: The 4th C in C4I Stands for Cloud:Factors Driving Adopti...
PPTX
From distributed caches to in-memory data grids
PDF
Cassandra on Castle
PDF
Enterprise Applications in 2011
PPTX
Galaxy of bits
PDF
Cloud is such stuff as dreams are made on
PDF
Infinispan for Dummies
PDF
From concept to cloud (cf opentour india)
PPT
Getting Started with MongoDB at Oracle Open World 2012
KEY
Castle enhanced Cassandra
PDF
Supercharging Cassandra - GOTO Amsterdam
PDF
soft-shake.ch - Data grids and Data Grids
PDF
Overview and current topics in solid state storage
PDF
Scale-out Storage on Intel® Architecture Based Platforms: Characterizing and ...
PDF
Cosbench apac
PDF
Balancing Replication and Partitioning in a Distributed Java Database
PPTX
Introduction to NoSQL
PDF
Introduction to Big Data and Science Clouds (Chapter 1, SC 11 Tutorial)
PDF
Finding the Right Data Solution for Your Application in the Data Storage Hays...
PDF
Key-Value-Stores -- The Key to Scaling?
AFCEA C4I Symposium: The 4th C in C4I Stands for Cloud:Factors Driving Adopti...
From distributed caches to in-memory data grids
Cassandra on Castle
Enterprise Applications in 2011
Galaxy of bits
Cloud is such stuff as dreams are made on
Infinispan for Dummies
From concept to cloud (cf opentour india)
Getting Started with MongoDB at Oracle Open World 2012
Castle enhanced Cassandra
Supercharging Cassandra - GOTO Amsterdam
soft-shake.ch - Data grids and Data Grids
Overview and current topics in solid state storage
Scale-out Storage on Intel® Architecture Based Platforms: Characterizing and ...
Cosbench apac
Balancing Replication and Partitioning in a Distributed Java Database
Introduction to NoSQL
Introduction to Big Data and Science Clouds (Chapter 1, SC 11 Tutorial)
Finding the Right Data Solution for Your Application in the Data Storage Hays...
Key-Value-Stores -- The Key to Scaling?
Ad

More from Publicis Sapient Engineering (20)

PDF
XebiCon'18 - L'algorithme de reconnaissance de formes par le cerveau humain
PDF
Xebicon'18 - IoT: From Edge to Cloud
PDF
Xebicon'18 - Spark in jail : conteneurisez vos traitements data sans serveur
PDF
XebiCon'18 - Modern Infrastructure
PDF
XebiCon'18 - La Web App d'aujourd'hui et de demain : état de l'art et bleedin...
PDF
XebiCon'18 - Des notebook pour le monitoring avec Zeppelin
PDF
XebiCon'18 - Event Sourcing et RGPD, incompatibles ?
PDF
XebiCon'18 - Deno, le nouveau NodeJS qui inverse la tendance ?
PDF
XebiCon'18 - Boostez vos modèles avec du Deep Learning distribué
PDF
XebiCon'18 - Comment j'ai développé un jeu vidéo avec des outils de développe...
PDF
XebiCon'18 - Les utilisateurs finaux, les oubliés de nos produits !
PDF
XebiCon'18 - Comment fausser l'interprétation de vos résultats avec des dataviz
PDF
XebiCon'18 - Le développeur dans la Pop Culture
PDF
XebiCon'18 - Architecturer son application mobile pour la durabilité
PDF
XebiCon'18 - Sécuriser son API avec OpenID Connect
PDF
XebiCon'18 - Structuration du Temps et Dynamique de Groupes, Théorie organisa...
PDF
XebiCon'18 - Spark NLP, un an après
PDF
XebiCon'18 - La sécurité, douce illusion même en 2018
PDF
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
PDF
XebiCon'18 - Ce que l'histoire du métro Parisien m'a enseigné sur la création...
XebiCon'18 - L'algorithme de reconnaissance de formes par le cerveau humain
Xebicon'18 - IoT: From Edge to Cloud
Xebicon'18 - Spark in jail : conteneurisez vos traitements data sans serveur
XebiCon'18 - Modern Infrastructure
XebiCon'18 - La Web App d'aujourd'hui et de demain : état de l'art et bleedin...
XebiCon'18 - Des notebook pour le monitoring avec Zeppelin
XebiCon'18 - Event Sourcing et RGPD, incompatibles ?
XebiCon'18 - Deno, le nouveau NodeJS qui inverse la tendance ?
XebiCon'18 - Boostez vos modèles avec du Deep Learning distribué
XebiCon'18 - Comment j'ai développé un jeu vidéo avec des outils de développe...
XebiCon'18 - Les utilisateurs finaux, les oubliés de nos produits !
XebiCon'18 - Comment fausser l'interprétation de vos résultats avec des dataviz
XebiCon'18 - Le développeur dans la Pop Culture
XebiCon'18 - Architecturer son application mobile pour la durabilité
XebiCon'18 - Sécuriser son API avec OpenID Connect
XebiCon'18 - Structuration du Temps et Dynamique de Groupes, Théorie organisa...
XebiCon'18 - Spark NLP, un an après
XebiCon'18 - La sécurité, douce illusion même en 2018
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
XebiCon'18 - Ce que l'histoire du métro Parisien m'a enseigné sur la création...

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Spectroscopy.pptx food analysis technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A comparative analysis of optical character recognition models for extracting...
Review of recent advances in non-invasive hemoglobin estimation

Paris NoSQL User Group - In Memory Data Grids in Action (without transactions chapter)

  • 1. Transactions chapter will be presented during another session In Memory Data Grid in Action with Oracle Coherence for Paris NoSQL User Group Cyrille Le Clerc Wednesday, May 25, 2011
  • 2. Speaker @cyrilleleclerc blog.xebia.fr Cyrille Le Clerc Large Scale In Memory Data Grid Open Source (Apache CXF, ...) “you build it, you run it” 2 Wednesday, May 25, 2011
  • 3. Once upon a time... 3 Wednesday, May 25, 2011
  • 4. 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 - Started as a data grid 4 Wednesday, May 25, 2011
  • 5. Let’s define an In Memory Data Grid ... 5 Wednesday, May 25, 2011
  • 6. Let’s define an In Memory Data Grid eXtreme Scale This is an In Memory Data Grid 6 Wednesday, May 25, 2011
  • 7. Let’s define an In Memory Data Grid This is Network Attached Memory 7 Wednesday, May 25, 2011
  • 8. Let’s define an In Memory Data Grid  Similarities with NoSQL document oriented Partitioned, distributed Hastable, schema-less, value is not opaque, scale-out scalability  Very fast In memory (persistence coming), business logic inside the data  Consistent and Available Transactional, redundant  Written in Java, data are POJOs Not necessary  Clients in Java, Microsoft, etc 8 Wednesday, May 25, 2011
  • 9. Use cases for this presentation 9 Wednesday, May 25, 2011
  • 10. Train Booking System trains, stations, seats, booking and passengers 10 Wednesday, May 25, 2011
  • 11. eCommerce Web Site warehouse & customers shopping carts 231 canon-eos: 1 ipod : 1 headphone : 1 311 iphone: 1 ... 121 ipad : 1 iphone: 1 264 2 barbie : 1 { iphone: 1 "name": "Barbie Computer", cabbage-doll: 1 "stock": 637, 637 "weigth" : 200 } 12 warehouse stocks 11 Wednesday, May 25, 2011
  • 12. In Memory Data Grids Key Principles 12 Wednesday, May 25, 2011
  • 13. Store Everything in a Mainframe ! 3 To of RAM 80 x 5.2 GHtz cores Much more than $1,000,000 http://ibm.com/ IBM z11 13 Wednesday, May 25, 2011
  • 14. Spread on Inexpensive Servers http://ibm.com/ http://1userverrack.net/ Mainframe Cheap Servers ! 14 Wednesday, May 25, 2011
  • 15. Partition Data Partition gamma Small servers Partition beta MainFrame Partition alpha Partition for scalability 15 Wednesday, May 25, 2011
  • 16. Duplicate Data sync synchronization Master Partition alpha Standby Backup Duplicate data for high availability 16 Wednesday, May 25, 2011
  • 17. Data Access Patterns 17 Wednesday, May 25, 2011
  • 18. Data Access Patterns  This is not traditional Java EE coding style !  Can apply very complex business logic inside the data Stored Procedures Style Change management challenge ! 18 Wednesday, May 25, 2011
  • 19. Pattern : Targeted Operation 19 Wednesday, May 25, 2011
  • 20. Pattern: Targeted Operation { "train-id": "tgv-3071-20110512", "time" : 2011/05/12 12:15, Search Trains "departure" : "Paris", "arrival" : "Marseille", "seats" : 3, Partition gamma } Search Trains Partition beta “train-id” is indexed Search Trains Partition alpha Book Train Tickets 20 Wednesday, May 25, 2011
  • 21. Pattern : Map Reduce Style Operation 21 Wednesday, May 25, 2011
  • 22. Pattern: Map Reduce { "departure": "Paris", "arrival": "Marseille", "time" : 2011/05/12 12:00, Search Trains "seats" : 3, } Partition gamma Search Trains Partition beta Search Trains Partition alpha Distributed “Search Train Ticket” 22 Wednesday, May 25, 2011
  • 23. Pattern: Map Reduce { "Paris -> Marseille : 12:15", "Paris -> Marseille : 13:15" Search Trains } Partition gamma { #NONE# } Search Trains Partition beta { "Paris -> Lyon -> Marseille : 12:40" } Search Trains Partition alpha Distributed “Search Train Ticket” 23 Wednesday, May 25, 2011
  • 24. Pattern: Map Reduce Search Trains Partition gamma Search Trains { Partition beta "Paris -> Marseille : 12:15", "Paris -> Lyon -> Marseille : 12:40", "Paris -> Marseille : 13:15" } Search Trains Partition alpha Distributed “Search Train Ticket” 24 Wednesday, May 25, 2011
  • 25. Data Access Patterns  This is not traditional Java EE coding style Change management  Don’t forget “Map Reduce” = “Distributed Table Scan” Use Indexes 25 Wednesday, May 25, 2011
  • 26. CAP Theorem & In Memory Data Grids 26 Wednesday, May 25, 2011
  • 27. CAP Theorem and In Memory Data Grid Only 2 of these 3 properties can be Consistency achieved at any given moment in time Brewer’s Conjecture Availability Partition Tolerance http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf 27 Wednesday, May 25, 2011
  • 28. CAP Theorem and In Memory Data Grid Data Grids Only 2 of these 3 properties can be Consistency achieved at any given moment in time Brewer’s Conjecture Availability Partition Tolerance http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf 28 Wednesday, May 25, 2011
  • 29. Cross Data Center Data Consistency London New York Tokyo World wide replication for financial market 29 Wednesday, May 25, 2011
  • 30. Cross Data Center Data Consistency { "name": "Barbie Computer", "stock": 147, "weigth" : 200 } { "name": "Barbie Computer", West Coast "stock": 147, "weigth" : 200 } East Coast Warehouse stocks 30 Wednesday, May 25, 2011
  • 31. Cross Data Center Data Consistency set stock to 146 { "name": "Barbie Computer", "stock": 147, "weigth" : 200 } { "name": "Barbie Computer", West Coast "stock": 147, "weigth" : 200 } East Coast propagation delay ! 31 Wednesday, May 25, 2011
  • 32. Cross Data Center Data Consistency set stock to 146 { "name": "Barbie Computer", "stock": 147, "weigth" : 200 } { "name": "Barbie Computer", West Coast "stock": 147, "weigth" : 200 } East Coast set weight 175 reconciliation API needed ! 32 Wednesday, May 25, 2011
  • 33. Cross Data Center Data Consistency set stock to 146 { "name": "Barbie Computer", "stock": 147, "weigth" : 200 } { "name": "Barbie Computer", West Coast "stock": 147, "weigth" : 200 } East Coast set weight 175 Network partitioning 33 Wednesday, May 25, 2011
  • 34. Data Modeling 34 Wednesday, May 25, 2011
  • 35. Data Modeling  Dominant Question Driven Design Opposite to Relational which is Domain Driven Design  Constrained Tree Schema Because RPC matters  Denormalized Due to dominant questions and CTS 35 Wednesday, May 25, 2011
  • 36. Data Modeling Seat Booking Passenger number reduction name price Train code type TrainStation TrainStop code date name Typical relational data model 36 Wednesday, May 25, 2011
  • 37. Data Modeling Partitioning ready entities tree e ntity Root Seat Booking Passenger number reduction name price Train code type Du R pli ca efer ted en TrainStation in ce d ea TrainStop ch ata code gri date dn name od e Find the root entity and denormalize 37 Wednesday, May 25, 2011
  • 38. Data Modeling Remove unused data Seat Booking Passenger number reduction name price booked Train code type TrainStation TrainStop code date name Partitioned Replicated 38 Wednesday, May 25, 2011
  • 39. Data Modeling Seat number price booked Train code type TrainStation TrainStop code date name Partitioned Replicated Data Grid Ready data structure 39 Wednesday, May 25, 2011
  • 40. Data Modeling is Hard ! 40 Wednesday, May 25, 2011
  • 41. Data Modeling is Hard ! Account Account number number from to CashWitdrawal MoneyTransfer CashWitdrawal date id date amount date amount amount Two root entities for the same MoneyTransfer ! 41 Wednesday, May 25, 2011
  • 42. Data Modeling is Hard ! Account Account number number CashWitdrawal MoneyTransferIn MoneyTransferOut CashWitdrawal date id id date amount date date amount amount amount Split MoneyTransfer 42 Wednesday, May 25, 2011
  • 43. Data Modeling is Hard ! Account Account number number CashWitdrawal MoneyTransferIn MoneyTransferOut CashWitdrawal date id id date amount date date amount amount amount Split MoneyTransfer 43 Wednesday, May 25, 2011
  • 44. Data Modeling is Hard ! Account number CashWitdrawal MoneyTransferOut MoneyTransferIn date id id amount date date amount amount Data Grid Ready data structure 44 Wednesday, May 25, 2011
  • 45. Grid Internals 45 Wednesday, May 25, 2011
  • 46. Data Serialization  Used for data transfer and byte oriented storage Must support evolvable data structure  Hot topic like Apache Thrift, Apache Avro, Google Protocol Buffer 46 Wednesday, May 25, 2011
  • 47. Data Storage  Store Java Beans in the grid No need to unmarshall for inprocess operations Beware of garbage collector !  Store byte arrays in the grid Pay unmarshalling at each read and write Low-level / byte-oriented APIs to read data Slightly more garbage collector friendly 47 Wednesday, May 25, 2011
  • 48. Communication Protocols  UDP Multi Cast (Coherence, Gigaspaces)  TCP/IP (Websphere eXtreme Scale) 48 Wednesday, May 25, 2011
  • 49. Topology  Partitions made of shards : 1 primary + 0..* backups)  Dynamic shards location (changes at runtime and at restart)  Can use dedicated “directory servers” or embed it in the “data nodes” 49 Wednesday, May 25, 2011
  • 50. JVM and Memory  Many editors recommend tiny 1.4 Go JVM ! Garbage collector hell  More than ten JVM per server Management hell More and more IMDG support large heaps 50 Wednesday, May 25, 2011
  • 51. APIs 51 Wednesday, May 25, 2011
  • 52. Raw Java Mapping with Oracle Coherence public class Train extends AbstractEvolvable implements PortableObject { enum Type { HIGH_SPEED, NORMAL } /** Key of the Cache */ String code; /** Indexed */ Seat String name; number Type type; price booked List<Seat> seats = new ArrayList<Seat>(); Train code int version; type List<TrainStop> trainStops = new ArrayList<TrainStop>(); TrainStop @Override date public int getImplVersion() { return 1; } @Override public void readExternal(PofReader pofReader) throws IOException { this.code = pofReader.readString(0); this.name = pofReader.readString(1); this.type = (Type) pofReader.readObject(2); pofReader.readCollection(3, this.seats); pofReader.readCollection(4, this.trainStops); this.version = pofReader.readInt(5); hand-coded serialization } @Override JUnit is your friend ! public void writeExternal(PofWriter pofWriter) throws IOException { pofWriter.writeString(0, this.code); pofWriter.writeString(1, this.name); pofWriter.writeObject(2, this.type); pofWriter.writeCollection(3, this.seats, Seat.class); pofWriter.writeCollection(4, this.trainStops, TrainStop.class); pofWriter.writeInt(5, this.version); } } 52 Wednesday, May 25, 2011
  • 53. JPA Style Mapping with Websphere eXtreme Scale @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; ... } sub entities can have cross relations 53 Wednesday, May 25, 2011
  • 54. Map API with Oracle Coherence NamedCache trainCache = CacheFactory.getCache("train-cache"); /** Save */ void persist(Train train) { trainCache.put(train.getCode(), train); } /** Find by key */ Train findByCode(String code) { return (Train) trainCache.get(code); } /** Find by Query Language */ Train findByTrainName(String name) { Filter filter = QueryHelper.createFilter("name = :name" , Collections.singletonMap("name", name)); Set<Map.Entry<String, Train>> trainEntrySet = trainCache.entrySet(filter); if (trainEntrySet.isEmpty()) { return null; } else { return trainEntrySet.iterator().next().getValue(); } } Map API 54 Wednesday, May 25, 2011
  • 55. JPA Style with Websphere eXtreme Scale /** Save */ void persist(Train train) { entityManager.persist(train); } /** Find by key */ Train findByCode(String code) { return (Train) entityManager.find(Train.class, code); } /** Query Language */ Train findByTrainName(String name) { Query q = entityManager.createQuery("select t from Train t where t.name=:name"); q.setParameter("name", name); return (Train) q.getSingleResult(); } JPA Style Entity Manager 55 Wednesday, May 25, 2011
  • 56. Creating Indexes Map reduce (without index) = Distributed Table Scan ! 56 Wednesday, May 25, 2011
  • 57. Indexes with Oracle Coherence class Train { String name; Collection<String> getTrainStationsCodes() { return Collections2.transform(trainStops, ...); } ... } { NamedCache trainCache = CacheFactory.getCache("train-cache"); trainCache.addIndex(new ReflectionExtractor("getName"), false, null); trainCache.addIndex(new ReflectionExtractor("getTrainStationsCodes"), false, null); } 57 Wednesday, May 25, 2011
  • 58. Indexes with Websphere eXtreme Scale @Entity(schemaRoot=true) class Train { @Index @Basic eXtreme Scale String name; @Index Collection<String> getTrainStationsCodes() { return Collections2.transform(trainStops, ...); } ... } Query query = em.createQuery("select t from Train t where t.name=:name"); query.getPlan(); This is an execution plan for q2 in Train ObjectMap using INDEX on name = ( ?name) filter ( q2.c[0] = ?name ) returning new Tuple( q2 ) 58 Wednesday, May 25, 2011
  • 59. More APIs Another Java EE versus Spring battle ? JSR 347 Data Grids vs. Spring Data Serialization / Object to Tuple Mapping API ? Unified API ontop of NoSQL stores ? 59 Wednesday, May 25, 2011
  • 60. Data Grid <-> Relational Database Interactions 60 Wednesday, May 25, 2011
  • 61. Data Grid <-> Relational Database Data Grids are “In Memory” -> we need to persist data on disk ! 61 Wednesday, May 25, 2011
  • 62. Data Grid <-> Relational Database update / insert / delete “select directly modified in DB” 62 Wednesday, May 25, 2011
  • 63. Data Grid <-> Relational Database Data Grid -> Relational Database backend DB Highly available write behind queues + SQL batched statements 63 Wednesday, May 25, 2011
  • 64. Data Grid <-> Relational Database Data Grid -> Relational Database Seat number price booked Train code type TrainStation TrainStop code date name Constrained Tree Schema <-> Relational Impedance Mismatch 64 Wednesday, May 25, 2011
  • 65. Data Grid <-> Relational Database DB writes MUST succeed ! Prefer raw SQL rather than reused business logic Denormalize the database Remove the foreign keys, use same PKs in DB and data grid Support unordered SQL statements Align the database on the Data Grid model ! 65 Wednesday, May 25, 2011
  • 66. Data Grid <-> Relational Database Relational Database -> Data Grid select * from train where last_modif > ? backend DB Data Grid Originated Scheduled Refresh (Oracle System Change Number, etc) 66 Wednesday, May 25, 2011
  • 67. Data Grid <-> Relational Database Relational Database -> Data Grid backend DB Database Originated Push JMS = durable subscription (Oracle Database Change Notification, etc) 67 Wednesday, May 25, 2011
  • 68. Data Grid <-> Relational Database  In Memory -> prepare for reloading after maintenance operations ! Need for “graceful shutdown with disk persistence”  Prepare consistency checkers 68 Wednesday, May 25, 2011
  • 69. Transactions 69 Wednesday, May 25, 2011
  • 70. We didn’t have the time to talk about transaction. Another session is planned at Paris No SQL User Group for this. 70 Wednesday, May 25, 2011
  • 71. Let’s go live ! 71 Wednesday, May 25, 2011
  • 72. Data Grids and Operations  Standard packaging? Do It Yourself (layout, scripts, etc)  Limited Management Do It Yourself (stop/start, detecting data loss, etc)  Limited debugging tools Do It Yourself (debugging consoles, troubleshooting agents)  JVM pandemia Dozens of JVM to manage ! 72 Wednesday, May 25, 2011
  • 73. Data Grids and Operations  Dev / Ops collaboration is required  Experts only ! 73 Wednesday, May 25, 2011
  • 74. The right tool for the right job 74 Wednesday, May 25, 2011
  • 75. The right tool for the right job  Incredibly fast ! Even with transactions !  Scalable If you solve the data loading issue  Good at data replication (when it implements it) Reconciliation api, etc  Very geeky on both dev and ops side Not an enterprise grade data store Requires very skilled people + change management  “Quite” expensive 75 Wednesday, May 25, 2011
  • 76. Questions / Answers ? 76 Wednesday, May 25, 2011