I’m trying to use Ehcache write-behind caching to write batches of transactions to my database. What I need is for the write-behind cache to dump transactions at 5 second intervals (or more often).
I must be missing something, because try as I might, it just won’t work. I set up the write-behind caching, and then put load onto the server. Thousands, and then hundreds of thousands of transactions later, and after waiting several minutes, there is still nothing in the database. It isn’t until I shut down the load on the server that the cache begins writing to the database.
Is this a problem with thread-priority? Is there a way to modify the Ehcache to perform the DB writes even when the server is under load?
Here is my configuration:
<cache name="server.db.model.Request"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="5"
timeToLiveSeconds="5"
overflowToDisk="false"
memoryStoreEvictionPolicy="FIFO">
<cacheWriter writeMode="write_behind" maxWriteDelay="5" rateLimitPerSecond="5"
writeCoalescing="true" writeBatching="true" writeBatchSize="5000"
retryAttempts="2" retryAttemptDelaySeconds="10">
<cacheWriterFactory class="server.db.util.RequestCacheWriterFactory"/>
</cacheWriter>
</cache>
Thanks.
In the end, changing my configuration to this is what worked – though I’m still not sure which parameter change made the difference.