Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a Terracotta server do when it is used as a backend for EHCache with Hibernate?


My DAL is implemented with Hibernate and I want to use EHCache as its second level cache with its distributed capabilities (for scalability and HA).
Seeing as EHCache provides distributed caching only with Terracotta my question is what is the role of the Terracotta server instance? Does it also hold data? Does it only coordinate the distribution between the partitioned cache parts?
My confusion derives mainly from this explanation regarding TSA which says the server holds the data but I think that maybe in my scenario the cache and the Terracotta server are sort of merged. Am I correct?
If the server does hold data then why shouldn't the bottleneck just move from the db to the Terracotta server?

Update: Affe's answer answered the second part of my question which was the important part but just in case someone comes by looking for the first part I'll say that the TC server has to hold all the data that the EHCache in memory holds and so if you want a distributed cache (not replicated) then the L2 (TC server) must hold all the objects itself as well.

Thanks in advance,
Ittai

like image 558
Ittai Avatar asked Jan 31 '11 18:01

Ittai


People also ask

How Ehcache works in hibernate?

Hibernate EHCache Configuration File diskStore: EHCache stores data into memory but when it starts overflowing, it start writing data into file system. We use this property to define the location where EHCache will write the overflown data.

What is a Terracotta server?

A Terracotta Server Array enables you to create distributed caches. A distributed cache can be shared by multiple Integration Servers. Clustered Integration Servers, for example, use a distributed cache to hold data that all the Integration Servers in the cluster need to share.

How does Ehcache work?

Ehcache can assist you with reducing the likelihood that stale data is used by your application by expiring cache entries after some amount of configured time. Once expired, the entry is automatically removed from the cache.

Where does Ehcache store data?

All the data is kept in the authority tier, which is slower but more abundant. Data stores supported by Ehcache include: On-Heap Store - Utilizes Java's on-heap RAM memory to store cache entries. This tier utilizes the same heap memory as your Java application, all of which must be scanned by the JVM garbage collector.


1 Answers

The idea is it's still significantly faster to contact the terracotta cluster via the terracotta driver and do what's basically a Map lookup, than to acquire a database connection and execute an SQL statement. Even if that does become the application's choke point, overall throughput would be expected to still be significantly higher than a JDBC Connection + SQL choke point. Open connections and open cursors are big resource hogs in the database, an open socket to the terracotta cluster is not!

like image 179
Affe Avatar answered Sep 22 '22 02:09

Affe