Performance of Creating New Sessions
adam.mccormick Dec 6, 2016 12:41 AMWe are using ModeShape 4.6.1-Final...
Our application is high read, low write. We actually only write to the repository at most once per day (we use the JCR export/import to move content from a staging environment to production). Client's need not be authenticated so all sessions are anonymous.
I recently discovered that our application was not logging out the session after the http request had been completed. I changed this to create a new session for each request and log it out after rendering has completed (I took the same approach as in the modeshape-web-jcr-rest project of using a thread local to create and remove the request bound session).
After doing this we noticed a marked degradation in our performance tests. I think the problem lies in the workspace cache having to read from the persistence for each new session where as before each request may have been reusing a session which already has a lot of the content in the workspace cache.
Is there a way to help with this? Is some ModeShape or Infinispan configuration that can help with high read scenarios? The only thing I can think of upping the minimum binary size to try and avoid going to the binary store so often (i will give this a go tomorrow). In the mean time...
Any idea's would be great!
For reference here's my current infinispan.xml:
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:7.2 http://www.infinispan.org/schemas/infinispan-config-7.2.xsd"
xmlns="urn:infinispan:config:7.2">
<cache-container default-cache="unused" statistics="false" >
<jmx duplicate-domains="true"/>
<!-- avoids duplicate persistent directories because of cache configuration inheritance -->
<local-cache name="unused" statistics="false" />
<local-cache name="repository" statistics="false">
<locking acquire-timeout="2000" />
<transaction mode="NON_XA" locking="OPTIMISTIC"/>
<persistence passivation="false">
<file-store fetch-state="false" shared="false" preload="true" purge="false" path="${home}/jcr/data"/>
</persistence>
</local-cache>
<!-- Local in-memory caches with no persistence. Used instead of the default one in modeshape to avoid the LIRS bug in infinispan -->
<local-cache name="repository/system" statistics="false">
<!-- No more that 10K entries per cache, with LRU eviction. -->
<eviction max-entries="10000" strategy="LRU"/>
<!-- Expire entries after 120 seconds or after 60 seconds of not being used (whichever comes first). -->
<expiration lifespan="120000" max-idle="6000"/>
</local-cache>
<!-- Local in-memory caches with no persistence. Used instead of the default one in modeshape to avoid the LIRS bug in infinispan -->
<local-cache name="repository/default" statistics="false">
<!-- No more that 10K entries per cache, with LRU eviction. -->
<eviction max-entries="10000" strategy="LRU"/>
<!-- Expire entries after 120 seconds or after 60 seconds of not being used (whichever comes first). -->
<expiration lifespan="120000" max-idle="6000"/>
</local-cache>
<!-- persistent cache used by a connector -->
<local-cache name="connector" statistics="false">
<locking acquire-timeout="2000" />
<transaction mode="NON_XA" locking="OPTIMISTIC"/>
<persistence passivation="false">
<file-store fetch-state="false" shared="false" preload="false" purge="false" path="${home}/jcr/data"/>
</persistence>
</local-cache>
</cache-container>
</infinispan>
And repository configuration:
{
"name" : "repository",
"transactionMode":"none",
"workspaces":
{
"default":"default",
"cacheConfiguration":"infinispan.xml"
},
"storage" :
{
"cacheConfiguration" : "infinispan.xml",
"cacheName" : "repository",
"binaryStorage" :
{
"directory":"${home}/jcr/binary",
"minimumBinarySizeInBytes" : 100,
"minimumStringSize" : 999999999999, // avoids a problem we had in the connector with strings coming back as binary types
"type" : "file"
}
},
"garbageCollection":
{
"initialTime":"12:18",
"intervalInHours":1
},
"security":
{
"anonymous":
{
"roles" : ["readonly","readwrite","admin"],
"username" : "<anonymous>",
"useOnFailedLogin" : false
}
},
"journaling":{
"enabled":false
}
}