You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Torgeir Veimo <to...@netenviron.com> on 2009/10/22 13:57:43 UTC

jcr session creation takes 2 seconds

I've started seeing lately that session creation takes up to two
seconds. Am creating a new session on each http request at the moment,
but from what I've been reading in the past, such creation should not
be too demanding on the repository.

21:41:47,549 DEBUG SessionManager  - creating new admin credentials
jcr session took: 1977ms

Session created as

session = repository.login(new SimpleCredentials("admin", new
char[]{'a','d','m','i','n'}));

Repository.xml as following. Any idea where I can look? Or do I need
to implement some sort of read-only session pooling?

<?xml version="1.0"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD
Jackrabbit 1.5//EN"

"http://jackrabbit.apache.org/dtd/repository-1.5.dtd">
<Repository>
    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
        <param name="path" value="${rep.home}/repository"/>
    </FileSystem>

    <Security appName="Jackrabbit">
        <SecurityManager
class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager"
workspaceName="security">
        </SecurityManager>

        <AccessManager
class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
        </AccessManager>

        <LoginModule
class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
           <param name="anonymousId" value="anonymous"/>
           <param name="adminId" value="admin"/>
        </LoginModule>
    </Security>

    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
    <Workspace name="${wsp.name}">
        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            <param name="path" value="${wsp.home}"/>
        </FileSystem>

        <PersistenceManager
class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
        </PersistenceManager>
        <SearchIndex
class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
            <param name="path" value="${wsp.home}/index"/>
            <param name="textFilterClasses"
value="org.apache.jackrabbit.extractor.PlainTextExtractor,org.apache.jackrabbit.extractor.HTMLTextExtractor,org.apache.jackrabbit.extractor.XMLTextExtractor"/>
            <param name="extractorPoolSize" value="2"/>
            <param name="supportHighlighting" value="true"/>
        </SearchIndex>
    </Workspace>

    <Versioning rootPath="${rep.home}/version">
        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            <param name="path" value="${rep.home}/version" />
        </FileSystem>

        <PersistenceManager
class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
          <param name="url"
value="jdbc:derby:${rep.home}/version/db;create=true"/>
          <param name="schemaObjectPrefix" value="version_"/>
        </PersistenceManager>
    </Versioning>

    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
        <param name="path" value="${rep.home}/repository/index"/>
        <param name="textFilterClasses"
value="org.apache.jackrabbit.extractor.PlainTextExtractor,org.apache.jackrabbit.extractor.HTMLTextExtractor,org.apache.jackrabbit.extractor.XMLTextExtractor"/>
        <param name="extractorPoolSize" value="2"/>
        <param name="supportHighlighting" value="true"/>
    </SearchIndex>
</Repository>


-- 
-Tor

Re: jcr session creation takes 2 seconds

Posted by Fabián Mandelbaum <fm...@gmail.com>.
Hello,

for all it's worth: I am using R/O and R/W session pooling, with
Apache Common's pool classes.

Indeed opening/closing a session for each request is costy.

The downside, with the TransientRepo, the repo is locked while the app
is running, so there's no way you can access the repo with other tools
while the app is running (which is not a problem for me, just an
annoyance to debug the repo).

I'm using JackRabbit 1.4.8.

On Thu, Oct 22, 2009 at 8:57 AM, Torgeir Veimo <to...@netenviron.com> wrote:
> I've started seeing lately that session creation takes up to two
> seconds. Am creating a new session on each http request at the moment,
> but from what I've been reading in the past, such creation should not
> be too demanding on the repository.
>
> 21:41:47,549 DEBUG SessionManager  - creating new admin credentials
> jcr session took: 1977ms
>
> Session created as
>
> session = repository.login(new SimpleCredentials("admin", new
> char[]{'a','d','m','i','n'}));
>
> Repository.xml as following. Any idea where I can look? Or do I need
> to implement some sort of read-only session pooling?
>
> <?xml version="1.0"?>
> <!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD
> Jackrabbit 1.5//EN"
>
> "http://jackrabbit.apache.org/dtd/repository-1.5.dtd">
> <Repository>
>    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
>        <param name="path" value="${rep.home}/repository"/>
>    </FileSystem>
>
>    <Security appName="Jackrabbit">
>        <SecurityManager
> class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager"
> workspaceName="security">
>        </SecurityManager>
>
>        <AccessManager
> class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
>        </AccessManager>
>
>        <LoginModule
> class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
>           <param name="anonymousId" value="anonymous"/>
>           <param name="adminId" value="admin"/>
>        </LoginModule>
>    </Security>
>
>    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
>    <Workspace name="${wsp.name}">
>        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
>            <param name="path" value="${wsp.home}"/>
>        </FileSystem>
>
>        <PersistenceManager
> class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
>          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
>          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
>        </PersistenceManager>
>        <SearchIndex
> class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
>            <param name="path" value="${wsp.home}/index"/>
>            <param name="textFilterClasses"
> value="org.apache.jackrabbit.extractor.PlainTextExtractor,org.apache.jackrabbit.extractor.HTMLTextExtractor,org.apache.jackrabbit.extractor.XMLTextExtractor"/>
>            <param name="extractorPoolSize" value="2"/>
>            <param name="supportHighlighting" value="true"/>
>        </SearchIndex>
>    </Workspace>
>
>    <Versioning rootPath="${rep.home}/version">
>        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
>            <param name="path" value="${rep.home}/version" />
>        </FileSystem>
>
>        <PersistenceManager
> class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
>          <param name="url"
> value="jdbc:derby:${rep.home}/version/db;create=true"/>
>          <param name="schemaObjectPrefix" value="version_"/>
>        </PersistenceManager>
>    </Versioning>
>
>    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
>        <param name="path" value="${rep.home}/repository/index"/>
>        <param name="textFilterClasses"
> value="org.apache.jackrabbit.extractor.PlainTextExtractor,org.apache.jackrabbit.extractor.HTMLTextExtractor,org.apache.jackrabbit.extractor.XMLTextExtractor"/>
>        <param name="extractorPoolSize" value="2"/>
>        <param name="supportHighlighting" value="true"/>
>    </SearchIndex>
> </Repository>
>
>
> --
> -Tor
>



-- 
Fabián Mandelbaum
IS Engineer

Re: jcr session creation takes 2 seconds

Posted by Torgeir Veimo <to...@netenviron.com>.
2009/10/22 Torgeir Veimo <to...@netenviron.com>:
> I've started seeing lately that session creation takes up to two
> seconds. Am creating a new session on each http request at the moment,
> but from what I've been reading in the past, such creation should not
> be too demanding on the repository.
>
> 21:41:47,549 DEBUG SessionManager  - creating new admin credentials
> jcr session took: 1977ms

Hmm, looks like I was no longer keeping any system session open or
using any listeners, so my repository closed down on each
session.close().

-- 
-Tor

Re: jcr session creation takes 2 seconds

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Oct 22, 2009 at 2:47 PM, Torgeir Veimo <to...@netenviron.com> wrote:
> 2009/10/22 Jukka Zitting <ju...@gmail.com>:
>> Are you using the TransientRepository class? Then it could be that the
>> entire repository gets started up when you run login(). You can avoid
>> that by either keeping one long-lived session open, [...]
>
> Wouldn't the finalizer in Session call the close() method internally
> at some point, if the session is not referenced elsewhere?

Sure, but what's preventing you from keeping the session reference?

BR,

Jukka Zitting

Re: jcr session creation takes 2 seconds

Posted by Torgeir Veimo <to...@netenviron.com>.
2009/10/22 Jukka Zitting <ju...@gmail.com>:

> Are you using the TransientRepository class? Then it could be that the
> entire repository gets started up when you run login(). You can avoid
> that by either keeping one long-lived session open, [...]

Wouldn't the finalizer in Session call the close() method internally
at some point, if the session is not referenced elsewhere?

-- 
-Tor

Re: jcr session creation takes 2 seconds

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Oct 22, 2009 at 1:57 PM, Torgeir Veimo <to...@netenviron.com> wrote:
> I've started seeing lately that session creation takes up to two
> seconds. Am creating a new session on each http request at the moment,
> but from what I've been reading in the past, such creation should not
> be too demanding on the repository.

Correct, two seconds is definitely too much. A simple performance test
case I have can run thousands of login().logout() operations in a
second.

Are you using the TransientRepository class? Then it could be that the
entire repository gets started up when you run login(). You can avoid
that by either keeping one long-lived session open, or by switching to
using the RepositoryImpl class directly so you are in direct control
of when to shutdown() the repository.

BR,

Jukka Zitting