java - Cache replication -
i'm using ehcache 2.10.2. synchronous replication (replicateasynchronously=false) between 2 servers (s1 , s2).
i have next situation:
- first http request going s1
- s1 can't find object in cache , loads db state "a" , puts cache
- s1 changes object's state "b", saves db , puts cache
- s1 sends success response
- next request going s2
- s2 finds obect in cache state "a"
- s2 sends error response, because object must have state "b" on second request.
when server puts object cache, thread blocked on put operation send serialized object server, , don't wait while server deserialize , put element cache. @ point 6 can state "a" or "b", if lucky.
is possible configure ehcache block operations until changes replicated on nodes?
may need replace ehcache other cache implementation, or change everything?
what experience weakness of cache replication. scenario seems require strong consistency.
note in addition of lacking strong consistency, cache replication not guarantee ordering of events on per key basis nor perform kind of conflict resolution. last update wins.
the feature of ehcache give proper guarantees terracotta clustering. in order deploy solution, need @ least 1 additional server/jvm act terracotta cluster.
Comments
Post a Comment