Crossposting this from the EhCache forums, since maybe this is the better place to post this:
---------------------------------------------------------------------------------------------------------------
We are looking at implementing a fully replicated Hibernate/Ehcache solution with a second level cache. Everything persistent on disk, synced via RMI, etc.
All seems to work fine, but we are astounded by the insane amount of disk that is consumed for the disk store.
In our initial test we created 400,000 objects (100,000 of one type and 300,000 of another). Set the cache so it mostly overflows right away to disk.
The size of the two .data files are: 1.2 GB and 445 MB. Each of these object types is a typical Hibernate JPA.
So taking the second example 445 MB (that is 467379000 bytes) is used to store 100,000 POJOs. That comes out to 4673 bytes per POJO, i.e. nearly 4.5 KB.
4.5 KB for a single POJO is insane...what type of data does Hibernate store that mushrooms a POJO that has 10 properties and 2 FKs on it to that size? This should be in bytes, not KBs.
We need to handle volumes of 10,000,000 at first (i.e. 40,000,000 approx. of both types) and potentially up to 100,000,000 in a few years. There is no way we can do this with Hibernate/Ehcache if it eats disk up at this rate.
Any suggestions or clarifications would be welcome.
This is how our Spring Hibernate is configured:
Code:
<bean id="sessionFactory" parent="sessionFactoryAbstract">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</prop>
<prop key="hibernate.jdbc.batch_size">3000</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.use_structured_entries">false</prop>
<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">META-INF/aps-ehcache.xml</prop>
</props>
</property>
</bean>
And this is how we configured EhCache during testing:
Code:
<defaultCache
maxElementsInMemory="1000"
eternal="true"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
diskPersistent="true"
diskAccessStripes="5"
diskExpiryThreadIntervalSeconds="43200"
memoryStoreEvictionPolicy="LRU"
/>
We're on Hibernate 3.3.2 and EhCache 2.0.0 (I tried with 1.7.2 and had pretty much the same issue with disk size)