SlideShare ist ein Scribd-Unternehmen logo
1 von 118
Downloaden Sie, um offline zu lesen
Terracotta Ehcache Consistency
Strong and Eventual
Abhishek Sanoujam
March 29, 2011
Ehcache-2.4 + Terracotta 3.5

   Search
     –   http://ehcache.org/documentation/search.html
   New Consistency modes
     –   http://ehcache.org/documentation/terracotta/
         consistency_options.html
   Nonstop feature
     –   http://ehcache.org/documentation/terracotta/non_stop_cache.html
   Rejoin
   Explicit locking api merged to Ehcache interface
   Various other perf improvements and bug fixes
     –   http://ehcache.org

                                Terracotta Ehcache Consistency             2
Terracotta Ehcache Consistency




                 Terracotta Ehcache Consistency   3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml




                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>




                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>
   Consistency can be “strong” or “eventual”




                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>
   Consistency can be “strong” or “eventual”
   Old “coherent” attribute deprecated




                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>
   Consistency can be “strong” or “eventual”
   Old “coherent” attribute deprecated
   With “strong” consistency, changes made by any node in
    the cluster are visible instantly




                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>
   Consistency can be “strong” or “eventual”
   Old “coherent” attribute deprecated
   With “strong” consistency, changes made by any node in
    the cluster are visible instantly
   With “eventual” consistency, changes made by any node
    are visible to other nodes eventually


                           Terracotta Ehcache Consistency        3
Terracotta Ehcache Consistency

   New attribute “consistency” in “terracotta” sub-element of
    “cache” in ehcache.xml
    <cache name=”sampleCache”>
       <terracotta consistency=”strong|eventual” />
    </cache>
   Consistency can be “strong” or “eventual”
   Old “coherent” attribute deprecated
   With “strong” consistency, changes made by any node in
    the cluster are visible instantly
   With “eventual” consistency, changes made by any node
    are visible to other nodes eventually
   http://ehcache.org/documentation/terracotta/consistency_options.html


                              Terracotta Ehcache Consistency               3
Strong Consistency




                 Terracotta Ehcache Consistency   4
Strong Consistency

   Changes are visible cluster-wide instantly




                             Terracotta Ehcache Consistency   4
Strong Consistency

 Changes are visible cluster-wide instantly
 Reads/Writes uses clustered locks
    – Clustered locks same as normal read-write locks, but valid
      through the cluster
    – Multiple reads possible
    – Writes are mutually exclusive to other writes and reads




                              Terracotta Ehcache Consistency       4
Strong Consistency

 Changes are visible cluster-wide instantly
 Reads/Writes uses clustered locks
     – Clustered locks same as normal read-write locks, but valid
       through the cluster
     – Multiple reads possible
     – Writes are mutually exclusive to other writes and reads

   Honors happens-before cluster wide (using clustered locks)




                               Terracotta Ehcache Consistency       4
Strong Consistency

 Changes are visible cluster-wide instantly
 Reads/Writes uses clustered locks
    – Clustered locks same as normal read-write locks, but valid
      through the cluster
    – Multiple reads possible
    – Writes are mutually exclusive to other writes and reads

 Honors happens-before cluster wide (using clustered locks)
 Supports other concurrent apis
    – putIfAbsent(Element element)
    – removeElement(Element element)
    – replace(Element element)
    – replace(Element old, Element element)




                               Terracotta Ehcache Consistency      4
Strong Consistency

 Changes are visible cluster-wide instantly
 Reads/Writes uses clustered locks
     – Clustered locks same as normal read-write locks, but valid
       through the cluster
     – Multiple reads possible
     – Writes are mutually exclusive to other writes and reads

 Honors happens-before cluster wide (using clustered locks)
 Supports other concurrent apis
     – putIfAbsent(Element element)
     – removeElement(Element element)
     – replace(Element element)
     – replace(Element old, Element element)
   Works with explicit locking apis

                                 Terracotta Ehcache Consistency     4
Eventual Consistency




                 Terracotta Ehcache Consistency   5
Eventual Consistency
   Changes are visible to other nodes eventually (in order of ms)




                                 Terracotta Ehcache Consistency      5
Eventual Consistency
 Changes are visible to other nodes eventually (in order of ms)
 L2 notifies clients about which keys were updated




                               Terracotta Ehcache Consistency      5
Eventual Consistency
 Changes are visible to other nodes eventually (in order of ms)
 L2 notifies clients about which keys were updated
 On receiving update from L2, those mappings are removed from
  clients local cache




                              Terracotta Ehcache Consistency       5
Eventual Consistency
 Changes are visible to other nodes eventually (in order of ms)
 L2 notifies clients about which keys were updated
 On receiving update from L2, those mappings are removed from
  clients local cache
 Can read stale data for some time (in order of msecs)




                              Terracotta Ehcache Consistency       5
Eventual Consistency
   Changes are visible to other nodes eventually (in order of ms)
   L2 notifies clients about which keys were updated
   On receiving update from L2, those mappings are removed from
    clients local cache
   Can read stale data for some time (in order of msecs)
   Suitable for apps that can tolerate reading stale data




                                Terracotta Ehcache Consistency       5
Eventual Consistency
   Changes are visible to other nodes eventually (in order of ms)
   L2 notifies clients about which keys were updated
   On receiving update from L2, those mappings are removed from
    clients local cache
   Can read stale data for some time (in order of msecs)
   Suitable for apps that can tolerate reading stale data
   No need of locks for reads/writes
     –   Better performance compared to strong consistency




                                   Terracotta Ehcache Consistency    5
Eventual Consistency
   Changes are visible to other nodes eventually (in order of ms)
   L2 notifies clients about which keys were updated
   On receiving update from L2, those mappings are removed from
    clients local cache
   Can read stale data for some time (in order of msecs)
   Suitable for apps that can tolerate reading stale data
   No need of locks for reads/writes
     –   Better performance compared to strong consistency
   Supports other concurrent apis
     –   putIfAbsent(Element element)
     –   removeElement(Element element)
     –   replace(Element element)
     –   replace(Element old, Element element)




                                           Terracotta Ehcache Consistency   5
Eventual Consistency
   Changes are visible to other nodes eventually (in order of ms)
   L2 notifies clients about which keys were updated
   On receiving update from L2, those mappings are removed from
    clients local cache
   Can read stale data for some time (in order of msecs)
   Suitable for apps that can tolerate reading stale data
   No need of locks for reads/writes
     –   Better performance compared to strong consistency
   Supports other concurrent apis
     –   putIfAbsent(Element element)
     –   removeElement(Element element)
     –   replace(Element element)
     –   replace(Element old, Element element)
   Works with explicit locking apis
     –   provides more control over locking

                                           Terracotta Ehcache Consistency   5
Old “coherent” attribute deprecated




                  Terracotta Ehcache Consistency   6
Old “coherent” attribute deprecated

   Old “coherent” attribute deprecated




                           Terracotta Ehcache Consistency   6
Old “coherent” attribute deprecated

   Old “coherent” attribute deprecated
   coherent=”true” translates to consistency=”strong”




                           Terracotta Ehcache Consistency   6
Old “coherent” attribute deprecated

   Old “coherent” attribute deprecated
   coherent=”true” translates to consistency=”strong”
   coherent=”false” translates to consistency=”eventual”




                           Terracotta Ehcache Consistency   6
Old “coherent” attribute deprecated

   Old “coherent” attribute deprecated
   coherent=”true” translates to consistency=”strong”
   coherent=”false” translates to consistency=”eventual”
   Old coherent=”false” meant bulk-load mode (incoherent
    mode)
     – Cannot be set in config (use “eventual” consistency instead)
     – possible through api only now
        • setNodeBulkLoadEnabled(true)
        • setNodeBulkLoadEnabled(false)




                               Terracotta Ehcache Consistency         6
Bulk-load mode




                 Terracotta Ehcache Consistency   7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode




                                  Terracotta Ehcache Consistency   7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes




                                   Terracotta Ehcache Consistency   7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
   Writes are batched heavily in the client (L1)




                                    Terracotta Ehcache Consistency   7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
 Writes are batched heavily in the client (L1)
 Warmup of large caches happens pretty fast




                                   Terracotta Ehcache Consistency   7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
 Writes are batched heavily in the client (L1)
 Warmup of large caches happens pretty fast
   Once values are fetched, changes/updates by other nodes visible after
    specific time (5 mins by default)




                                   Terracotta Ehcache Consistency           7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
 Writes are batched heavily in the client (L1)
 Warmup of large caches happens pretty fast
   Once values are fetched, changes/updates by other nodes visible after
    specific time (5 mins by default)
   Possible through api only




                                   Terracotta Ehcache Consistency           7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
 Writes are batched heavily in the client (L1)
 Warmup of large caches happens pretty fast
   Once values are fetched, changes/updates by other nodes visible after
    specific time (5 mins by default)
   Possible through api only
   Old api’s are deprecated
     –   setNodeCoherent(boolean coherent)
     –   isNodeCoherent()
     –   isClusterCoherent()
     –   waitUntilClusterCoherent()




                                       Terracotta Ehcache Consistency       7
Bulk-load mode
   coherent=”false” - bulk load mode or incoherent mode
   No locks are required for reads/writes
 Writes are batched heavily in the client (L1)
 Warmup of large caches happens pretty fast
   Once values are fetched, changes/updates by other nodes visible after
    specific time (5 mins by default)
   Possible through api only
   Old api’s are deprecated
     –   setNodeCoherent(boolean coherent)
     –   isNodeCoherent()
     –   isClusterCoherent()
     –   waitUntilClusterCoherent()
   New api’s added in Ehcache interface:
     –   setNodeBulkLoadEnabled(boolean enabledBulkLoad)
     –   isNodeBulkLoadEnabled()
     –   isClusterBulkLoadEnabled()
     –   waitUntilClusterBulkLoadComplete()
                                         Terracotta Ehcache Consistency     7
How it works - Strong Consistency




                 Terracotta Ehcache Consistency   8
How it works - Strong Consistency


             Terracotta Server Array (L2)




    Node A             Node B                           Node C
     (L1)               (L1)                             (L1)




                       Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                Terracotta Server Array (L2)




    Node A                Node B                           Node C
     (L1)                  (L1)                             (L1)


      put(k1, v1)


                          Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)




    acquireLock
    (WRITE)




    Node A                  Node B                           Node C
     (L1)                    (L1)                             (L1)


       put(k1, v1)


                            Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)




    acquireLock
                     grant lock
    (WRITE)




    Node A                    Node B                           Node C
     (L1)                      (L1)                             (L1)


       put(k1, v1)


                              Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)




    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)



    Node A                    Node B                           Node C
     (L1)                      (L1)                             (L1)


       put(k1, v1)


                              Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)
                           (k1, v1 )


    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)



    Node A                    Node B                           Node C
     (L1)                      (L1)                             (L1)


       put(k1, v1)


                              Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)
                           (k1, v1 )


    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)



     Node A                   Node B                           Node C
      (L1)                     (L1)                             (L1)
    (k1, v1)

       put(k1, v1)


                              Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)
                           (k1, v1 )


    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)



     Node A                   Node B                           Node C
      (L1)                     (L1)                             (L1)
    (k1, v1)

       put(k1, v1)      get(k1)


                              Terracotta Ehcache Consistency            8
How it works - Strong Consistency


                  Terracotta Server Array (L2)
                           (k1, v1 )


    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)



     Node A                   Node B                               Node C
      (L1)                     (L1)                                 (L1)
    (k1, v1)

       put(k1, v1)      get(k1)                                get(k1)


                              Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                  Terracotta Server Array (L2)
                           (k1, v1 )


    acquireLock
                     grant lock
    (WRITE)
   put(k1, v1)
                      acquireLock
                      (READ)                             acquireLock
                                                         (READ)

     Node A                   Node B                               Node C
      (L1)                     (L1)                                 (L1)
    (k1, v1)

       put(k1, v1)      get(k1)                                get(k1)


                              Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock
                      grant lock
    (WRITE) recall
   put(k1, v1)
                        acquireLock
                        (READ)                             acquireLock
                                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock
                      grant lock
    (WRITE) recall
   put(k1, v1)
                        acquireLock
                        (READ)                             acquireLock
                                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock                           grant read
                      grant lock
    (WRITE)                               lock
            recall
   put(k1, v1)
                        acquireLock
                        (READ)                             acquireLock
                                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock                           grant read               grant read
                      grant lock                                   lock
    (WRITE)                               lock
            recall
   put(k1, v1)
                        acquireLock
                        (READ)                             acquireLock
                                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                  8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock                    grant read      grant read
                      grant lock                   lock
    (WRITE)                        lock
            recall      get(k1)
   put(k1, v1)                            get(k1)
                       acquireLock
                       (READ)              acquireLock
                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock                    grant read      grant read
                      grant lock                   lock
    (WRITE)                        lock
            recall      get(k1)
   put(k1, v1)                      v1    get(k1)     v1
                       acquireLock
                       (READ)              acquireLock
                                           (READ)

     Node A                     Node B                               Node C
      (L1)                       (L1)                                 (L1)
    (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                     Terracotta Server Array (L2)
                             (k1, v1 )


    acquireLock                    grant read      grant read
                      grant lock                   lock
    (WRITE)                        lock
            recall      get(k1)
   put(k1, v1)                      v1    get(k1)     v1
                       acquireLock
                       (READ)              acquireLock
                                           (READ)

     Node A                     Node B                               Node C
      (L1)                        (L1)                                 (L1)
    (k1, v1)                    (k1, v1)                              (k1, v1)

        put(k1, v1)       get(k1)                                get(k1)


                                Terracotta Ehcache Consistency                   8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read      grant read
                          grant lock                   lock
        (WRITE)                        lock
                recall      get(k1)
       put(k1, v1)                      v1    get(k1)     v1
                           acquireLock
                           (READ)              acquireLock
                                               (READ)

         Node A                     Node B                               Node C
          (L1)                        (L1)                                 (L1)
        (k1, v1)                    (k1, v1)                              (k1, v1)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                   8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read      grant read
                          grant lock                   lock
        (WRITE)                        lock
                recall      get(k1)
       put(k1, v1)                      v1    get(k1)     v1
                           acquireLock
                           (READ)              acquireLock
                                               (READ)

         Node A                     Node B                               Node C
          (L1)                        (L1)                                 (L1)
        (k1, v1)                    (k1, v1)                              (k1, v1)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                   8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
       put(k1, v1)                      v1     get(k1)     v1
                           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

         Node A                     Node B                               Node C
          (L1)                        (L1)                                 (L1)
        (k1, v1)                    (k1, v1)                              (k1, v1)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                   8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
       put(k1, v1)                      v1     get(k1)     v1
                           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

         Node A                     Node B                               Node C
          (L1)                       (L1)                                 (L1)


put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
       put(k1, v1)                      v1     get(k1)     v1
                           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

         Node A                     Node B                               Node C
          (L1)                       (L1)                                 (L1)


put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v1 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

         Node A                     Node B                               Node C
          (L1)                       (L1)                                 (L1)


put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

         Node A                     Node B                               Node C
          (L1)                       (L1)                                 (L1)


put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                    grant read       grant read
                          grant lock                    lock
        (WRITE)                        lock
                recall      get(k1)
      put(k1, v1)                       v1     get(k1)     v1
     put(k1, v2)           acquireLock
                           (READ)               acquireLock recall
                                         recall
                                                (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                   grant read       grant read
                          grant lock                   lock
        (WRITE)                       lock
                recall      get(k1)
      put(k1, v1)                      v1                 v1
     put(k1, v2)           acquireLock v2 get(k1)
                           (READ)              acquireLock v2recall
                                        recall
                                               (READ)

        Node A                      Node B                               Node C
           (L1)                      (L1)                                 (L1)
      (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                   grant read       grant read
                          grant lock                   lock
        (WRITE)                       lock
                recall      get(k1)
      put(k1, v1)                      v1                 v1
     put(k1, v2)           acquireLock v2 get(k1)
                           (READ)              acquireLock v2recall
                                        recall
                                               (READ)

        Node A                     Node B                                Node C
           (L1)                      (L1)                                  (L1)
      (k1, v2)                   (k1, v2)                                (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                  8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                   grant read       grant read
                          grant lock                   lock
        (WRITE)                       lock
                recall      get(k1)
      put(k1, v1)                      v1                 v1
     put(k1, v2)           acquireLock v2 get(k1)
                           (READ)              acquireLock v2recall
                                        recall
                                               (READ)

        Node A                     Node B                                Node C
           (L1)                      (L1)                                  (L1)
      (k1, v2)                   (k1, v2)                                (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                  8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                   grant read       grant read
                          grant lock                   lock
        (WRITE)                       lock
                recall      get(k1)
      put(k1, v1)                      v1                 v1
     put(k1, v2)           acquireLock v2 get(k1)
                           (READ)              acquireLock v2recall
                                        recall
                                               (READ)

        Node A                     Node B                                Node C
           (L1)                      (L1)                                  (L1)
      (k1, v2)                   (k1, v2)                                (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)                                get(k1)


                                    Terracotta Ehcache Consistency                  8
How it works - Strong Consistency


                         Terracotta Server Array (L2)
                                 (k1, v2 )


        acquireLock                   grant read       grant read
                          grant lock                   lock
        (WRITE)                       lock
                recall      get(k1)
      put(k1, v1)                      v1                 v1
     put(k1, v2)           acquireLock v2 get(k1)
                           (READ)              acquireLock v2recall
                                        recall
                                               (READ)

        Node A                     Node B                                Node C
           (L1)                      (L1)                                  (L1)
      (k1, v2)                   (k1, v2)                                (k1, v2)

put(k1, v2) put(k1, v1)       get(k1)         v2                     get(k1)   v2


                                    Terracotta Ehcache Consistency                  8
How it works - Eventual Consistency




                 Terracotta Ehcache Consistency   9
How it works - Eventual Consistency


             Terracotta Server Array (L2)




    Node A             Node B                           Node C
     (L1)               (L1)                             (L1)




                       Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                Terracotta Server Array (L2)




    Node A                Node B                           Node C
     (L1)                  (L1)                             (L1)


      put(k1, v1)


                          Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)




   put(k1, v1)



     Node A                 Node B                           Node C
      (L1)                   (L1)                             (L1)


        put(k1, v1)


                            Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )




   put(k1, v1)



     Node A                  Node B                           Node C
      (L1)                    (L1)                             (L1)


        put(k1, v1)


                             Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )




   put(k1, v1)



     Node A                  Node B                           Node C
       (L1)                   (L1)                             (L1)
     (k1, v1)

        put(k1, v1)


                             Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )




   put(k1, v1)



     Node A                  Node B                           Node C
       (L1)                   (L1)                             (L1)
     (k1, v1)

        put(k1, v1)   get(k1)


                             Terracotta Ehcache Consistency            9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )




   put(k1, v1)



     Node A                  Node B                                Node C
       (L1)                   (L1)                                  (L1)
     (k1, v1)

        put(k1, v1)   get(k1)                                 get(k1)


                             Terracotta Ehcache Consistency                 9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )



                      get(k1)
   put(k1, v1)                                      get(k1)



     Node A                  Node B                                Node C
       (L1)                   (L1)                                  (L1)
     (k1, v1)

        put(k1, v1)   get(k1)                                 get(k1)


                             Terracotta Ehcache Consistency                 9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )



                      get(k1)
   put(k1, v1)                          v1          get(k1)        v1



     Node A                  Node B                                Node C
       (L1)                   (L1)                                  (L1)
     (k1, v1)

        put(k1, v1)   get(k1)                                 get(k1)


                             Terracotta Ehcache Consistency                 9
How it works - Eventual Consistency


                  Terracotta Server Array (L2)
                          (k1, v1 )



                      get(k1)
   put(k1, v1)                          v1          get(k1)        v1



     Node A                  Node B                                Node C
       (L1)                    (L1)                                  (L1)
     (k1, v1)                (k1, v1)                               (k1, v1)

        put(k1, v1)   get(k1)                                 get(k1)


                             Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v1 )



                          get(k1)
       put(k1, v1)                          v1          get(k1)        v1



         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v1 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)           v1                    get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

put(k1, v2) put(k1, v1)   get(k1)           v1                    get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1


         Node A                  Node B                                Node C
           (L1)                    (L1)                                  (L1)
       (k1, v2)
         (k1, v1)                (k1, v1)                               (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                    9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1


         Node A                  Node B                                Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1


         Node A                  Node B                                Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1


         Node A                  Node B                                Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                  Node B                                Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                 Node B                                 Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)             (k1, v2)                                (k1, v2)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)


                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                 Node B                                 Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)             (k1, v2)                                (k1, v2)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)    v2
                                            v2

                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                 Node B                                 Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)             (k1, v2)                                (k1, v2)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)    v2
                                            v2

                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                 Node B                                 Node C
           (L1)                   (L1)                                  (L1)
       (k1, v2)
         (k1, v1)             (k1, v2)                                (k1, v2)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)    v2
                                            v2

                                 Terracotta Ehcache Consistency                   9
How it works - Eventual Consistency


                      Terracotta Server Array (L2)
                              (k1, v2 )



                          get(k1)
      put(k1, v1)                           v1          get(k1)        v1
     put(k1, v2)                            k1                          k1
                                             v2                         v2

         Node A                 Node B                                 Node C
          (L1)                    (L1)                                  (L1)
       (k1, v2)               (k1, v2)                                (k1, v2)

                                            v1                               v1
put(k1, v2) put(k1, v1)   get(k1)                                 get(k1)    v2
                                            v2

                                 Terracotta Ehcache Consistency                   9
How it works - Bulk load mode




                 Terracotta Ehcache Consistency   10
How it works - Bulk load mode

   Similar to eventual consistency
     –   No locks required




                             Terracotta Ehcache Consistency   10
How it works - Bulk load mode

   Similar to eventual consistency
     –   No locks required
   Puts are batched heavily in the L1




                             Terracotta Ehcache Consistency   10
How it works - Bulk load mode

   Similar to eventual consistency
     –   No locks required
   Puts are batched heavily in the L1
   The L2 don’t send out invalidation notifications




                             Terracotta Ehcache Consistency   10
How it works - Bulk load mode

   Similar to eventual consistency
     –   No locks required
   Puts are batched heavily in the L1
   The L2 don’t send out invalidation notifications
   Invalidations in the local cache happen based on time (5
    mins by default)




                             Terracotta Ehcache Consistency    10
How it works - Bulk load mode

   Similar to eventual consistency
     –   No locks required
   Puts are batched heavily in the L1
   The L2 don’t send out invalidation notifications
   Invalidations in the local cache happen based on time (5
    mins by default)
   Apps read stale data for the specified time interval
      – configurable via tc property
        “ehcache.storageStrategy.dcv2.localcache.incoherentReadTimeout”




                               Terracotta Ehcache Consistency             10
Comparison

   Strong consistency
     – Reads/Writes happen under locks
     – Invalidations of local cache happens when a node acquires
       WRITE locks
   Eventual Consistency
     – Reads/Writes do not require locks
     – L2 notifies about changes to interested nodes
     – L1 invalidates local cache upon receiving notification from L2
     – Notifications are batched and sent to only interested nodes

   Bulk-load mode
     – No locks required
     – Invalidations happen based on time (5 mins by default)
     – Puts are batched heavily in the L1

                               Terracotta Ehcache Consistency           11
Summary

   Strong consistency
     –   Pros
          • Provides coherent data across the cluster
          • Changes visible to all nodes instantly
          • Honors happens-before cluster wide
     –   Cons
          • If coherent cache not desired, suffers from performance
          • Needs locks for both reads and writes
          • May result in lock hopping when data not partitioned leading to perf
            degradation




                                  Terracotta Ehcache Consistency                   12
Summary




          Terracotta Ehcache Consistency   13
Summary

   Eventual Consistency
     – Pros
        • No need of locks for reads/writes
        • Better performance
        • Changes are visible across cluster in order of ms
     – Cons
        • Application can read stale data for some time




                                Terracotta Ehcache Consistency   13
Summary

   Eventual Consistency
     – Pros
        • No need of locks for reads/writes
        • Better performance
        • Changes are visible across cluster in order of ms
     – Cons
        • Application can read stale data for some time

   Bulk Load mode
     – Pros
        • No need of locks for reads/writes
        • Better performance for puts, useful for cache warmup
     – Cons
        • Application can read stale data for longer amount of time
        • Values once fetched, will see changes after specific amount of time


                                Terracotta Ehcache Consistency                  13
Thank you!
Abhishek Sanoujam
asanoujam@terracottatech.com

http://terracotta.org
http://ehcache.org
http://ehcache.org/documentation/terracotta/consistency_options.html

Weitere ähnliche Inhalte

Ähnlich wie Eventual consistency

Building High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaBuilding High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaDavid Reines
 
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Paul Brebner
 
Ozone- Object store for Apache Hadoop
Ozone- Object store for Apache HadoopOzone- Object store for Apache Hadoop
Ozone- Object store for Apache HadoopHortonworks
 
All you didn't know about the CAP theorem
All you didn't know about the CAP theoremAll you didn't know about the CAP theorem
All you didn't know about the CAP theoremKanstantsin Hontarau
 
Hadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionHadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionDataWorks Summit/Hadoop Summit
 
Cassandra 2.1 boot camp, Read/Write path
Cassandra 2.1 boot camp, Read/Write pathCassandra 2.1 boot camp, Read/Write path
Cassandra 2.1 boot camp, Read/Write pathJoshua McKenzie
 
Hadoop & cloud storage object store integration in production (final)
Hadoop & cloud storage  object store integration in production (final)Hadoop & cloud storage  object store integration in production (final)
Hadoop & cloud storage object store integration in production (final)Chris Nauroth
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Baruch Sadogursky
 
SVN session from PiTechnologies
SVN session from PiTechnologies SVN session from PiTechnologies
SVN session from PiTechnologies PiTechnologies
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 
Future on Servlet #scala_ks
Future on Servlet #scala_ksFuture on Servlet #scala_ks
Future on Servlet #scala_ksKazuhiro Sera
 
Hadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionHadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionDataWorks Summit/Hadoop Summit
 
Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupAdam Hutson
 
Kafka syed academy_v1_introduction
Kafka syed academy_v1_introductionKafka syed academy_v1_introduction
Kafka syed academy_v1_introductionSyed Hadoop
 

Ähnlich wie Eventual consistency (20)

Building High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaBuilding High Scalability Apps With Terracotta
Building High Scalability Apps With Terracotta
 
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
 
Ozone- Object store for Apache Hadoop
Ozone- Object store for Apache HadoopOzone- Object store for Apache Hadoop
Ozone- Object store for Apache Hadoop
 
All you didn't know about the CAP theorem
All you didn't know about the CAP theoremAll you didn't know about the CAP theorem
All you didn't know about the CAP theorem
 
Freckle
FreckleFreckle
Freckle
 
Memory model
Memory modelMemory model
Memory model
 
Alfresco tuning part2
Alfresco tuning part2Alfresco tuning part2
Alfresco tuning part2
 
Hadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionHadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in Production
 
The Java Memory Model
The Java Memory ModelThe Java Memory Model
The Java Memory Model
 
Cassandra 2.1 boot camp, Read/Write path
Cassandra 2.1 boot camp, Read/Write pathCassandra 2.1 boot camp, Read/Write path
Cassandra 2.1 boot camp, Read/Write path
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Hadoop & cloud storage object store integration in production (final)
Hadoop & cloud storage  object store integration in production (final)Hadoop & cloud storage  object store integration in production (final)
Hadoop & cloud storage object store integration in production (final)
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
 
Elastic search
Elastic searchElastic search
Elastic search
 
SVN session from PiTechnologies
SVN session from PiTechnologies SVN session from PiTechnologies
SVN session from PiTechnologies
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Future on Servlet #scala_ks
Future on Servlet #scala_ksFuture on Servlet #scala_ks
Future on Servlet #scala_ks
 
Hadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in ProductionHadoop & Cloud Storage: Object Store Integration in Production
Hadoop & Cloud Storage: Object Store Integration in Production
 
Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User Group
 
Kafka syed academy_v1_introduction
Kafka syed academy_v1_introductionKafka syed academy_v1_introduction
Kafka syed academy_v1_introduction
 

Kürzlich hochgeladen

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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 Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Eventual consistency

  • 1. Terracotta Ehcache Consistency Strong and Eventual Abhishek Sanoujam March 29, 2011
  • 2. Ehcache-2.4 + Terracotta 3.5  Search – http://ehcache.org/documentation/search.html  New Consistency modes – http://ehcache.org/documentation/terracotta/ consistency_options.html  Nonstop feature – http://ehcache.org/documentation/terracotta/non_stop_cache.html  Rejoin  Explicit locking api merged to Ehcache interface  Various other perf improvements and bug fixes – http://ehcache.org Terracotta Ehcache Consistency 2
  • 3. Terracotta Ehcache Consistency Terracotta Ehcache Consistency 3
  • 4. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml Terracotta Ehcache Consistency 3
  • 5. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache> Terracotta Ehcache Consistency 3
  • 6. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache>  Consistency can be “strong” or “eventual” Terracotta Ehcache Consistency 3
  • 7. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache>  Consistency can be “strong” or “eventual”  Old “coherent” attribute deprecated Terracotta Ehcache Consistency 3
  • 8. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache>  Consistency can be “strong” or “eventual”  Old “coherent” attribute deprecated  With “strong” consistency, changes made by any node in the cluster are visible instantly Terracotta Ehcache Consistency 3
  • 9. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache>  Consistency can be “strong” or “eventual”  Old “coherent” attribute deprecated  With “strong” consistency, changes made by any node in the cluster are visible instantly  With “eventual” consistency, changes made by any node are visible to other nodes eventually Terracotta Ehcache Consistency 3
  • 10. Terracotta Ehcache Consistency  New attribute “consistency” in “terracotta” sub-element of “cache” in ehcache.xml <cache name=”sampleCache”> <terracotta consistency=”strong|eventual” /> </cache>  Consistency can be “strong” or “eventual”  Old “coherent” attribute deprecated  With “strong” consistency, changes made by any node in the cluster are visible instantly  With “eventual” consistency, changes made by any node are visible to other nodes eventually  http://ehcache.org/documentation/terracotta/consistency_options.html Terracotta Ehcache Consistency 3
  • 11. Strong Consistency Terracotta Ehcache Consistency 4
  • 12. Strong Consistency  Changes are visible cluster-wide instantly Terracotta Ehcache Consistency 4
  • 13. Strong Consistency  Changes are visible cluster-wide instantly  Reads/Writes uses clustered locks – Clustered locks same as normal read-write locks, but valid through the cluster – Multiple reads possible – Writes are mutually exclusive to other writes and reads Terracotta Ehcache Consistency 4
  • 14. Strong Consistency  Changes are visible cluster-wide instantly  Reads/Writes uses clustered locks – Clustered locks same as normal read-write locks, but valid through the cluster – Multiple reads possible – Writes are mutually exclusive to other writes and reads  Honors happens-before cluster wide (using clustered locks) Terracotta Ehcache Consistency 4
  • 15. Strong Consistency  Changes are visible cluster-wide instantly  Reads/Writes uses clustered locks – Clustered locks same as normal read-write locks, but valid through the cluster – Multiple reads possible – Writes are mutually exclusive to other writes and reads  Honors happens-before cluster wide (using clustered locks)  Supports other concurrent apis – putIfAbsent(Element element) – removeElement(Element element) – replace(Element element) – replace(Element old, Element element) Terracotta Ehcache Consistency 4
  • 16. Strong Consistency  Changes are visible cluster-wide instantly  Reads/Writes uses clustered locks – Clustered locks same as normal read-write locks, but valid through the cluster – Multiple reads possible – Writes are mutually exclusive to other writes and reads  Honors happens-before cluster wide (using clustered locks)  Supports other concurrent apis – putIfAbsent(Element element) – removeElement(Element element) – replace(Element element) – replace(Element old, Element element)  Works with explicit locking apis Terracotta Ehcache Consistency 4
  • 17. Eventual Consistency Terracotta Ehcache Consistency 5
  • 18. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms) Terracotta Ehcache Consistency 5
  • 19. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated Terracotta Ehcache Consistency 5
  • 20. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache Terracotta Ehcache Consistency 5
  • 21. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache  Can read stale data for some time (in order of msecs) Terracotta Ehcache Consistency 5
  • 22. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache  Can read stale data for some time (in order of msecs)  Suitable for apps that can tolerate reading stale data Terracotta Ehcache Consistency 5
  • 23. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache  Can read stale data for some time (in order of msecs)  Suitable for apps that can tolerate reading stale data  No need of locks for reads/writes – Better performance compared to strong consistency Terracotta Ehcache Consistency 5
  • 24. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache  Can read stale data for some time (in order of msecs)  Suitable for apps that can tolerate reading stale data  No need of locks for reads/writes – Better performance compared to strong consistency  Supports other concurrent apis – putIfAbsent(Element element) – removeElement(Element element) – replace(Element element) – replace(Element old, Element element) Terracotta Ehcache Consistency 5
  • 25. Eventual Consistency  Changes are visible to other nodes eventually (in order of ms)  L2 notifies clients about which keys were updated  On receiving update from L2, those mappings are removed from clients local cache  Can read stale data for some time (in order of msecs)  Suitable for apps that can tolerate reading stale data  No need of locks for reads/writes – Better performance compared to strong consistency  Supports other concurrent apis – putIfAbsent(Element element) – removeElement(Element element) – replace(Element element) – replace(Element old, Element element)  Works with explicit locking apis – provides more control over locking Terracotta Ehcache Consistency 5
  • 26. Old “coherent” attribute deprecated Terracotta Ehcache Consistency 6
  • 27. Old “coherent” attribute deprecated  Old “coherent” attribute deprecated Terracotta Ehcache Consistency 6
  • 28. Old “coherent” attribute deprecated  Old “coherent” attribute deprecated  coherent=”true” translates to consistency=”strong” Terracotta Ehcache Consistency 6
  • 29. Old “coherent” attribute deprecated  Old “coherent” attribute deprecated  coherent=”true” translates to consistency=”strong”  coherent=”false” translates to consistency=”eventual” Terracotta Ehcache Consistency 6
  • 30. Old “coherent” attribute deprecated  Old “coherent” attribute deprecated  coherent=”true” translates to consistency=”strong”  coherent=”false” translates to consistency=”eventual”  Old coherent=”false” meant bulk-load mode (incoherent mode) – Cannot be set in config (use “eventual” consistency instead) – possible through api only now • setNodeBulkLoadEnabled(true) • setNodeBulkLoadEnabled(false) Terracotta Ehcache Consistency 6
  • 31. Bulk-load mode Terracotta Ehcache Consistency 7
  • 32. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode Terracotta Ehcache Consistency 7
  • 33. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes Terracotta Ehcache Consistency 7
  • 34. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1) Terracotta Ehcache Consistency 7
  • 35. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1)  Warmup of large caches happens pretty fast Terracotta Ehcache Consistency 7
  • 36. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1)  Warmup of large caches happens pretty fast  Once values are fetched, changes/updates by other nodes visible after specific time (5 mins by default) Terracotta Ehcache Consistency 7
  • 37. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1)  Warmup of large caches happens pretty fast  Once values are fetched, changes/updates by other nodes visible after specific time (5 mins by default)  Possible through api only Terracotta Ehcache Consistency 7
  • 38. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1)  Warmup of large caches happens pretty fast  Once values are fetched, changes/updates by other nodes visible after specific time (5 mins by default)  Possible through api only  Old api’s are deprecated – setNodeCoherent(boolean coherent) – isNodeCoherent() – isClusterCoherent() – waitUntilClusterCoherent() Terracotta Ehcache Consistency 7
  • 39. Bulk-load mode  coherent=”false” - bulk load mode or incoherent mode  No locks are required for reads/writes  Writes are batched heavily in the client (L1)  Warmup of large caches happens pretty fast  Once values are fetched, changes/updates by other nodes visible after specific time (5 mins by default)  Possible through api only  Old api’s are deprecated – setNodeCoherent(boolean coherent) – isNodeCoherent() – isClusterCoherent() – waitUntilClusterCoherent()  New api’s added in Ehcache interface: – setNodeBulkLoadEnabled(boolean enabledBulkLoad) – isNodeBulkLoadEnabled() – isClusterBulkLoadEnabled() – waitUntilClusterBulkLoadComplete() Terracotta Ehcache Consistency 7
  • 40. How it works - Strong Consistency Terracotta Ehcache Consistency 8
  • 41. How it works - Strong Consistency Terracotta Server Array (L2) Node A Node B Node C (L1) (L1) (L1) Terracotta Ehcache Consistency 8
  • 42. How it works - Strong Consistency Terracotta Server Array (L2) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 43. How it works - Strong Consistency Terracotta Server Array (L2) acquireLock (WRITE) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 44. How it works - Strong Consistency Terracotta Server Array (L2) acquireLock grant lock (WRITE) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 45. How it works - Strong Consistency Terracotta Server Array (L2) acquireLock grant lock (WRITE) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 46. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 47. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) Terracotta Ehcache Consistency 8
  • 48. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) Terracotta Ehcache Consistency 8
  • 49. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 50. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) put(k1, v1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 51. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) recall put(k1, v1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 52. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant lock (WRITE) recall put(k1, v1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 53. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant lock (WRITE) lock recall put(k1, v1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 54. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall put(k1, v1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 55. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) get(k1) acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 56. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 57. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 58. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 59. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 60. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 61. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 62. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 63. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v1 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 64. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 65. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 66. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 67. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 68. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 69. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 70. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 71. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 72. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) acquireLock (READ) acquireLock recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 73. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 v1 put(k1, v2) acquireLock v2 get(k1) (READ) acquireLock v2recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 74. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 v1 put(k1, v2) acquireLock v2 get(k1) (READ) acquireLock v2recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v2) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 75. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 v1 put(k1, v2) acquireLock v2 get(k1) (READ) acquireLock v2recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v2) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 76. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 v1 put(k1, v2) acquireLock v2 get(k1) (READ) acquireLock v2recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v2) (k1, v2) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 8
  • 77. How it works - Strong Consistency Terracotta Server Array (L2) (k1, v2 ) acquireLock grant read grant read grant lock lock (WRITE) lock recall get(k1) put(k1, v1) v1 v1 put(k1, v2) acquireLock v2 get(k1) (READ) acquireLock v2recall recall (READ) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v2) (k1, v2) put(k1, v2) put(k1, v1) get(k1) v2 get(k1) v2 Terracotta Ehcache Consistency 8
  • 78. How it works - Eventual Consistency Terracotta Ehcache Consistency 9
  • 79. How it works - Eventual Consistency Terracotta Server Array (L2) Node A Node B Node C (L1) (L1) (L1) Terracotta Ehcache Consistency 9
  • 80. How it works - Eventual Consistency Terracotta Server Array (L2) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 9
  • 81. How it works - Eventual Consistency Terracotta Server Array (L2) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 9
  • 82. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) put(k1, v1) Terracotta Ehcache Consistency 9
  • 83. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) Terracotta Ehcache Consistency 9
  • 84. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) Terracotta Ehcache Consistency 9
  • 85. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) put(k1, v1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 86. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) get(k1) put(k1, v1) get(k1) Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 87. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) get(k1) put(k1, v1) v1 get(k1) v1 Node A Node B Node C (L1) (L1) (L1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 88. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) get(k1) put(k1, v1) v1 get(k1) v1 Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 89. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) get(k1) put(k1, v1) v1 get(k1) v1 Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 90. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v1 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 91. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 92. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 93. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 94. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) v1 get(k1) Terracotta Ehcache Consistency 9
  • 95. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) put(k1, v2) put(k1, v1) get(k1) v1 get(k1) Terracotta Ehcache Consistency 9
  • 96. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 97. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v1) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 98. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 99. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 100. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 101. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 102. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v2) (k1, v2) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) Terracotta Ehcache Consistency 9
  • 103. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v2) (k1, v2) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) v2 v2 Terracotta Ehcache Consistency 9
  • 104. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v2) (k1, v2) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) v2 v2 Terracotta Ehcache Consistency 9
  • 105. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v1) (k1, v2) (k1, v2) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) v2 v2 Terracotta Ehcache Consistency 9
  • 106. How it works - Eventual Consistency Terracotta Server Array (L2) (k1, v2 ) get(k1) put(k1, v1) v1 get(k1) v1 put(k1, v2) k1 k1 v2 v2 Node A Node B Node C (L1) (L1) (L1) (k1, v2) (k1, v2) (k1, v2) v1 v1 put(k1, v2) put(k1, v1) get(k1) get(k1) v2 v2 Terracotta Ehcache Consistency 9
  • 107. How it works - Bulk load mode Terracotta Ehcache Consistency 10
  • 108. How it works - Bulk load mode  Similar to eventual consistency – No locks required Terracotta Ehcache Consistency 10
  • 109. How it works - Bulk load mode  Similar to eventual consistency – No locks required  Puts are batched heavily in the L1 Terracotta Ehcache Consistency 10
  • 110. How it works - Bulk load mode  Similar to eventual consistency – No locks required  Puts are batched heavily in the L1  The L2 don’t send out invalidation notifications Terracotta Ehcache Consistency 10
  • 111. How it works - Bulk load mode  Similar to eventual consistency – No locks required  Puts are batched heavily in the L1  The L2 don’t send out invalidation notifications  Invalidations in the local cache happen based on time (5 mins by default) Terracotta Ehcache Consistency 10
  • 112. How it works - Bulk load mode  Similar to eventual consistency – No locks required  Puts are batched heavily in the L1  The L2 don’t send out invalidation notifications  Invalidations in the local cache happen based on time (5 mins by default)  Apps read stale data for the specified time interval – configurable via tc property “ehcache.storageStrategy.dcv2.localcache.incoherentReadTimeout” Terracotta Ehcache Consistency 10
  • 113. Comparison  Strong consistency – Reads/Writes happen under locks – Invalidations of local cache happens when a node acquires WRITE locks  Eventual Consistency – Reads/Writes do not require locks – L2 notifies about changes to interested nodes – L1 invalidates local cache upon receiving notification from L2 – Notifications are batched and sent to only interested nodes  Bulk-load mode – No locks required – Invalidations happen based on time (5 mins by default) – Puts are batched heavily in the L1 Terracotta Ehcache Consistency 11
  • 114. Summary  Strong consistency – Pros • Provides coherent data across the cluster • Changes visible to all nodes instantly • Honors happens-before cluster wide – Cons • If coherent cache not desired, suffers from performance • Needs locks for both reads and writes • May result in lock hopping when data not partitioned leading to perf degradation Terracotta Ehcache Consistency 12
  • 115. Summary Terracotta Ehcache Consistency 13
  • 116. Summary  Eventual Consistency – Pros • No need of locks for reads/writes • Better performance • Changes are visible across cluster in order of ms – Cons • Application can read stale data for some time Terracotta Ehcache Consistency 13
  • 117. Summary  Eventual Consistency – Pros • No need of locks for reads/writes • Better performance • Changes are visible across cluster in order of ms – Cons • Application can read stale data for some time  Bulk Load mode – Pros • No need of locks for reads/writes • Better performance for puts, useful for cache warmup – Cons • Application can read stale data for longer amount of time • Values once fetched, will see changes after specific amount of time Terracotta Ehcache Consistency 13