SlideShare uma empresa Scribd logo
1 de 118
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Último

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Último (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

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