You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "KARR, DAVID (ATTCINW)" <dk...@att.com> on 2009/12/28 19:57:06 UTC
Best way to "prime" OpenJPA before first request?
I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
works fine, but I've noticed that the first request to the app after
startup takes quite a while, and most of the time is spent on the first
JPA request. Following requests, even for different objects and
classes, goes much faster. What are my possible options for "priming"
JPA at startup so that the first request doesn't take so long?
RE: Best way to "prime" OpenJPA before first request?
Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Kevin Sutter [mailto:kwsutter@gmail.com]
> Sent: Thursday, January 21, 2010 12:41 PM
> To: users@openjpa.apache.org
> Cc: Rick Curtis
> Subject: Re: Best way to "prime" OpenJPA before first request?
>
> Rick is the expert here, but the 1.2.2 release contains an improvement
> to do
> the metadata repository initialization up front. This has shown to
> greatly
> improve both performance and scalability. I believe you kickstart this
> activity by using the following property...
>
> <property name="openjpa.MetaDataRepository"
> value="Preload=true,NoLock=true"/>
Sounds very promising. When I added this property to the persistence-unit, I got this:
-----------------
org.apache.openjpa.lib.util.ParseException: There was an error while setting up the configuration plugin option "MetaDataRepository". The plugin was of type "org.apache.openjpa.meta.MetaDataRepository". Setter methods for the following plugin properties were not available in that type: [NoLock]. Possible plugin properties are: [MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY, MetaDataFactory, Preload, Resolve, SourceMode, VALIDATE_MAPPING, VALIDATE_META, VALIDATE_NONE, VALIDATE_RUNTIME, VALIDATE_UNENHANCED, Validate].
Ensure that your plugin configuration string uses key values that correspond to setter methods in the plugin class.
-----------------
I looked in the source, and I didn't see any reference to a "NoLock" property. I tried removing that property, and I appeared to get further (I have some other issues appearing with the new release that I'm looking at).
> On Thu, Jan 21, 2010 at 2:24 PM, KARR, DAVID (ATTCINW)
> <dk...@att.com>wrote:
>
> > > -----Original Message-----
> > > From: Miłosz Tylenda [mailto:mtylenda@o2.pl]
> > > Sent: Wednesday, December 30, 2009 7:03 AM
> > > To: users@openjpa.apache.org
> > > Subject: Re: Best way to "prime" OpenJPA before first request?
> > >
> > > > I'm building a REST-based app using CXF and OpenJPA 1.2.1. The
> app
> > > > works fine, but I've noticed that the first request to the app
> after
> > > > startup takes quite a while, and most of the time is spent on the
> > > first
> > > > JPA request. Following requests, even for different objects and
> > > > classes, goes much faster. What are my possible options for
> > > "priming"
> > > > JPA at startup so that the first request doesn't take so long?
> > >
> > > 1. If you are using servlets, confgure web.xml to load your servlet
> at
> > > start-up or add some *Listener.
> > > 2. Your application server might provide some scheduler API - try
> to
> > > configure it so that it issues a request to your app after the app
> gets
> > > loaded.
> >
> > > 3. openjpa.InitializeEagerly property but I am afraid it requires a
> > > newer OpenJPA than 1.2.1
> >
> > I see that this property isn't in 1.2.2. Will it be in the next
> point
> > release?
> >
> >
Re: Best way to "prime" OpenJPA before first request?
Posted by Michael Dick <mi...@gmail.com>.
Another strategy that I've seen used is to create the EntityManagerFactory
and an EntityManager at app start up. Much of the metadata resolution occurs
when you create the first EM (helps if you list your classes in
persistence.xml).
AIUI it isn't as complete as preloading the MetaDataRepository (among other
things the MDR still has a lot of synchronization points). But if you're
looking for a quick and dirty fix it might work for you.
-mike
On Thu, Jan 21, 2010 at 3:17 PM, Rick Curtis <cu...@gmail.com> wrote:
> Kevin - Close, but no cigar. "NoLock=true" isn't valid.
>
> I'll get the docs fully updated today or tomorrow.
>
> --
> Thanks,
> Rick
>
> On Thu, Jan 21, 2010 at 2:41 PM, Kevin Sutter <kw...@gmail.com> wrote:
>
> > Rick is the expert here, but the 1.2.2 release contains an improvement to
> > do the metadata repository initialization up front. This has shown to
> > greatly improve both performance and scalability. I believe you
> kickstart
> > this activity by using the following property...
> >
> > <property name="openjpa.MetaDataRepository"
> value="Preload=true,NoLock=true"/>
> >
> > Kevin
> >
> >
> > On Thu, Jan 21, 2010 at 2:24 PM, KARR, DAVID (ATTCINW) <dk068x@att.com
> >wrote:
> >
> >> > -----Original Message-----
> >> > From: Miłosz Tylenda [mailto:mtylenda@o2.pl]
> >> > Sent: Wednesday, December 30, 2009 7:03 AM
> >> > To: users@openjpa.apache.org
> >> > Subject: Re: Best way to "prime" OpenJPA before first request?
> >> >
> >> > > I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
> >> > > works fine, but I've noticed that the first request to the app after
> >> > > startup takes quite a while, and most of the time is spent on the
> >> > first
> >> > > JPA request. Following requests, even for different objects and
> >> > > classes, goes much faster. What are my possible options for
> >> > "priming"
> >> > > JPA at startup so that the first request doesn't take so long?
> >> >
> >> > 1. If you are using servlets, confgure web.xml to load your servlet at
> >> > start-up or add some *Listener.
> >> > 2. Your application server might provide some scheduler API - try to
> >> > configure it so that it issues a request to your app after the app
> gets
> >> > loaded.
> >>
> >> > 3. openjpa.InitializeEagerly property but I am afraid it requires a
> >> > newer OpenJPA than 1.2.1
> >>
> >> I see that this property isn't in 1.2.2. Will it be in the next point
> >> release?
> >>
> >>
> >
>
Re: Best way to "prime" OpenJPA before first request?
Posted by Rick Curtis <cu...@gmail.com>.
Kevin - Close, but no cigar. "NoLock=true" isn't valid.
I'll get the docs fully updated today or tomorrow.
--
Thanks,
Rick
On Thu, Jan 21, 2010 at 2:41 PM, Kevin Sutter <kw...@gmail.com> wrote:
> Rick is the expert here, but the 1.2.2 release contains an improvement to
> do the metadata repository initialization up front. This has shown to
> greatly improve both performance and scalability. I believe you kickstart
> this activity by using the following property...
>
> <property name="openjpa.MetaDataRepository" value="Preload=true,NoLock=true"/>
>
> Kevin
>
>
> On Thu, Jan 21, 2010 at 2:24 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:
>
>> > -----Original Message-----
>> > From: Miłosz Tylenda [mailto:mtylenda@o2.pl]
>> > Sent: Wednesday, December 30, 2009 7:03 AM
>> > To: users@openjpa.apache.org
>> > Subject: Re: Best way to "prime" OpenJPA before first request?
>> >
>> > > I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
>> > > works fine, but I've noticed that the first request to the app after
>> > > startup takes quite a while, and most of the time is spent on the
>> > first
>> > > JPA request. Following requests, even for different objects and
>> > > classes, goes much faster. What are my possible options for
>> > "priming"
>> > > JPA at startup so that the first request doesn't take so long?
>> >
>> > 1. If you are using servlets, confgure web.xml to load your servlet at
>> > start-up or add some *Listener.
>> > 2. Your application server might provide some scheduler API - try to
>> > configure it so that it issues a request to your app after the app gets
>> > loaded.
>>
>> > 3. openjpa.InitializeEagerly property but I am afraid it requires a
>> > newer OpenJPA than 1.2.1
>>
>> I see that this property isn't in 1.2.2. Will it be in the next point
>> release?
>>
>>
>
Re: Best way to "prime" OpenJPA before first request?
Posted by Kevin Sutter <kw...@gmail.com>.
Rick is the expert here, but the 1.2.2 release contains an improvement to do
the metadata repository initialization up front. This has shown to greatly
improve both performance and scalability. I believe you kickstart this
activity by using the following property...
<property name="openjpa.MetaDataRepository" value="Preload=true,NoLock=true"/>
Kevin
On Thu, Jan 21, 2010 at 2:24 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:
> > -----Original Message-----
> > From: Miłosz Tylenda [mailto:mtylenda@o2.pl]
> > Sent: Wednesday, December 30, 2009 7:03 AM
> > To: users@openjpa.apache.org
> > Subject: Re: Best way to "prime" OpenJPA before first request?
> >
> > > I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
> > > works fine, but I've noticed that the first request to the app after
> > > startup takes quite a while, and most of the time is spent on the
> > first
> > > JPA request. Following requests, even for different objects and
> > > classes, goes much faster. What are my possible options for
> > "priming"
> > > JPA at startup so that the first request doesn't take so long?
> >
> > 1. If you are using servlets, confgure web.xml to load your servlet at
> > start-up or add some *Listener.
> > 2. Your application server might provide some scheduler API - try to
> > configure it so that it issues a request to your app after the app gets
> > loaded.
>
> > 3. openjpa.InitializeEagerly property but I am afraid it requires a
> > newer OpenJPA than 1.2.1
>
> I see that this property isn't in 1.2.2. Will it be in the next point
> release?
>
>
RE: Best way to "prime" OpenJPA before first request?
Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Miłosz Tylenda [mailto:mtylenda@o2.pl]
> Sent: Wednesday, December 30, 2009 7:03 AM
> To: users@openjpa.apache.org
> Subject: Re: Best way to "prime" OpenJPA before first request?
>
> > I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
> > works fine, but I've noticed that the first request to the app after
> > startup takes quite a while, and most of the time is spent on the
> first
> > JPA request. Following requests, even for different objects and
> > classes, goes much faster. What are my possible options for
> "priming"
> > JPA at startup so that the first request doesn't take so long?
>
> 1. If you are using servlets, confgure web.xml to load your servlet at
> start-up or add some *Listener.
> 2. Your application server might provide some scheduler API - try to
> configure it so that it issues a request to your app after the app gets
> loaded.
> 3. openjpa.InitializeEagerly property but I am afraid it requires a
> newer OpenJPA than 1.2.1
I see that this property isn't in 1.2.2. Will it be in the next point release?
Re: Best way to "prime" OpenJPA before first request?
Posted by Miłosz Tylenda <mt...@o2.pl>.
> I'm building a REST-based app using CXF and OpenJPA 1.2.1. The app
> works fine, but I've noticed that the first request to the app after
> startup takes quite a while, and most of the time is spent on the first
> JPA request. Following requests, even for different objects and
> classes, goes much faster. What are my possible options for "priming"
> JPA at startup so that the first request doesn't take so long?
1. If you are using servlets, confgure web.xml to load your servlet at start-up or add some *Listener.
2. Your application server might provide some scheduler API - try to configure it so that it issues a request to your app after the app gets loaded.
3. openjpa.InitializeEagerly property but I am afraid it requires a newer OpenJPA than 1.2.1
See also this post
http://n2.nabble.com/EntityManager-used-in-multiple-threads-td3662432.html#a3687617
Greetings,
Milosz