Quantcast
Channel: VMware Communities : All Content - vFabric GemFire [ARCHIVED]
Viewing all articles
Browse latest Browse all 990

The proper way to achieve consistency between cache and backend database

$
0
0

Dear guru,

 

I need to be sure that my cache and backend database are always in consistent state, i.e. all cache updates are guaranteed propagated to the database in transactional-like way. Going through documentation I found out two ways to achieve this, please let me know which one should be considered as the preferred one (from performance and reliability point of view).

 

1. To use JTA (with Gemfire itself playing the role of transaction coordinator - as soon as I am not in J2EE container).

Pros:

  • standard way to achieve consistent update for several resources;
  • rather easy to implement for several regions - it looks like CacheWriter (that is supposed to be invoked withing transaction) should be enough;

Cons:

  • overheads related to global transactions (that, potentially degrade performance);

 

2. User Gemfire CacheTransactionManager with TransactionWriter (all database updates are performed in TransactionWriter)

Pros:

  • seems to be a more lightweight and efficient solution (from performance point of view);
  • probably, allows to achieve the same level of consistency as with JTA (assuming that I have two sources only).

Cons:

  • as soon as TransactionWriter is defined per cache it should contain all the database update specific logic related to all the regions - so it could be rather hard to maintain the code (also something more sophisticated than just switch-case per region name should probably be invented);
  • it seems to be clear that it's quite possible to roll back cache transaction if database one failed but it's not obvious whether it is guaranteed that cache transaction will succeed when TransactionWriter finishes successfully. What if database transaction completes but cache transaction fails after TransactionWriter executes successfully?

 

I'll greatly appreciate any advices concerning that topic.

Thanks in advance.


Viewing all articles
Browse latest Browse all 990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>