You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sasc sasc <sa...@gmail.com> on 2011/10/10 11:30:59 UTC
Re: parallel webapp initialization
+1 for this enhancement. With configurable number of threads (default:
Runtime.getRuntime().availableProcessors())
I would also like to expand/add to this request: Making contexts available
for request processing continuously as they are started. This in combination
with parallel startup, would significantly improve startup time and
perceived availability in many situations.
If you have 9 applications which each takes 1 sec to start, and 1 app that
takes 5 minutes to start, even with parallel start up, you would still have
to wait at least 5 minutes before any of the applications are available for
request processing. If they could be made available continuously, then the 9
fast apps could start processing requests, even if the 5 min app is still
initializing.
If such a feature is already available in tomcat, then I must have missed
it. In that case, can someone direct me to where in the docs I can find more
info about it? :)
Re: parallel webapp initialization
Posted by Felix Schumacher <fe...@internetallee.de>.
Christopher Schultz <ch...@christopherschultz.net> schrieb:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Pid,
>
>On 10/10/2011 2:28 PM, Pid wrote:
>> On 10/10/2011 10:30, sasc sasc wrote:
>>> +1 for this enhancement. With configurable number of threads
>>> (default: Runtime.getRuntime().availableProcessors())
>>
>> Such a change might prove unwelcome for people who've got (however
>> fragile) configurations which rely on apps starting in a specific
>> order.
>>
>> For Tomcat 7.0 I'd suggest that the default remain 1.
>
>I would say that the default should probably that the main thread
>directly initializes everything, instead of launching a new thread
>pool of size=1 and then sitting there waiting for it to finish.
>
>Practically speaking, it may be easier to just do the above (use a
>1-sized pool) in order to avoid terrible-looking and hard-to-follow
>code. An idle thread isn't really that much strain on a system.
I think that can be easily done with a self implemented executor which would just run the given runnables.
>
>It might be nice to have Tomcat auto-detect the number of processors
>and then subtract from them, say, with a negative number. So, "-2"
>means "number of processors minus two" with the obvious caveat that
>you always need to have at least one :)
>
>So, maybe "0" could mean "use all processors", positive integers mean
>"limit to X number", and negative integers mean "all available
>processors minus X".
Since all values are strings at first we could even reserve special words like "runtime" or "%f", "#+-x" to mark special vakues. Where x is an int and means add/subtract number from current processors and y is a float meaning percent off current processors.
Regards
Felix
>
>- -chris
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.10 (MingW32)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
>iEYEARECAAYFAk6TVzEACgkQ9CaO5/Lv0PCHcgCeM7ZCq7IMo0pOEXvMpeVXpsG6
>UVYAnRn2GyEufIcPtjhRkcxPuN5QL3Zi
>=/kM+
>-----END PGP SIGNATURE-----
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Pid,
On 10/11/2011 12:58 AM, Pid * wrote:
> On 10 Oct 2011, at 23:36, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> "limit to X number", and negative integers mean "all available
>> processors minus X".
>
> My first instinct was to say "that's crazy, fool!" but I'm starting
> to like it.
:)
Having written a multi-threaded job processor (runs hundreds of
JasperReports in parallel and emails them to people) in the past, I've
had time to think about it. Sometimes you want as much as you can get,
and sometimes you want to make sure that the system has some CPUs free
to do other things (like run the database, for instance) :)
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk6UY8kACgkQ9CaO5/Lv0PCGeQCfby2b0j57r3nHoodrvqnYMKpw
xP4AniWr+X7Fmbqbpf/CofXR0HcydkiV
=fty+
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Pid * <pi...@pidster.com>.
On 10 Oct 2011, at 23:36, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Pid,
>
> On 10/10/2011 2:28 PM, Pid wrote:
>> On 10/10/2011 10:30, sasc sasc wrote:
>>> +1 for this enhancement. With configurable number of threads
>>> (default: Runtime.getRuntime().availableProcessors())
>>
>> Such a change might prove unwelcome for people who've got (however
>> fragile) configurations which rely on apps starting in a specific
>> order.
>>
>> For Tomcat 7.0 I'd suggest that the default remain 1.
>
> I would say that the default should probably that the main thread
> directly initializes everything, instead of launching a new thread
> pool of size=1 and then sitting there waiting for it to finish.
>
> Practically speaking, it may be easier to just do the above (use a
> 1-sized pool) in order to avoid terrible-looking and hard-to-follow
> code. An idle thread isn't really that much strain on a system.
>
> It might be nice to have Tomcat auto-detect the number of processors
> and then subtract from them, say, with a negative number. So, "-2"
> means "number of processors minus two" with the obvious caveat that
> you always need to have at least one :)
>
> So, maybe "0" could mean "use all processors", positive integers mean
If we're talking about a thread pool, 0 should mean 'no extra threads'
ie runs in the main thread, so I agree with your first point above:
default 0.
> "limit to X number", and negative integers mean "all available
> processors minus X".
My first instinct was to say "that's crazy, fool!" but I'm starting to like it.
p
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk6TVzEACgkQ9CaO5/Lv0PCHcgCeM7ZCq7IMo0pOEXvMpeVXpsG6
> UVYAnRn2GyEufIcPtjhRkcxPuN5QL3Zi
> =/kM+
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Pid,
On 10/10/2011 2:28 PM, Pid wrote:
> On 10/10/2011 10:30, sasc sasc wrote:
>> +1 for this enhancement. With configurable number of threads
>> (default: Runtime.getRuntime().availableProcessors())
>
> Such a change might prove unwelcome for people who've got (however
> fragile) configurations which rely on apps starting in a specific
> order.
>
> For Tomcat 7.0 I'd suggest that the default remain 1.
I would say that the default should probably that the main thread
directly initializes everything, instead of launching a new thread
pool of size=1 and then sitting there waiting for it to finish.
Practically speaking, it may be easier to just do the above (use a
1-sized pool) in order to avoid terrible-looking and hard-to-follow
code. An idle thread isn't really that much strain on a system.
It might be nice to have Tomcat auto-detect the number of processors
and then subtract from them, say, with a negative number. So, "-2"
means "number of processors minus two" with the obvious caveat that
you always need to have at least one :)
So, maybe "0" could mean "use all processors", positive integers mean
"limit to X number", and negative integers mean "all available
processors minus X".
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk6TVzEACgkQ9CaO5/Lv0PCHcgCeM7ZCq7IMo0pOEXvMpeVXpsG6
UVYAnRn2GyEufIcPtjhRkcxPuN5QL3Zi
=/kM+
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Pid <pi...@pidster.com>.
On 10/10/2011 10:30, sasc sasc wrote:
> +1 for this enhancement. With configurable number of threads (default:
> Runtime.getRuntime().availableProcessors())
Such a change might prove unwelcome for people who've got (however
fragile) configurations which rely on apps starting in a specific order.
For Tomcat 7.0 I'd suggest that the default remain 1.
p
> I would also like to expand/add to this request: Making contexts available
> for request processing continuously as they are started. This in combination
> with parallel startup, would significantly improve startup time and
> perceived availability in many situations.
>
> If you have 9 applications which each takes 1 sec to start, and 1 app that
> takes 5 minutes to start, even with parallel start up, you would still have
> to wait at least 5 minutes before any of the applications are available for
> request processing. If they could be made available continuously, then the 9
> fast apps could start processing requests, even if the 5 min app is still
> initializing.
>
> If such a feature is already available in tomcat, then I must have missed
> it. In that case, can someone direct me to where in the docs I can find more
> info about it? :)
Re: parallel webapp initialization
Posted by Mark Thomas <ma...@apache.org>.
On 10/10/2011 19:16, Rainer Jung wrote:
> On 10.10.2011 19:35, Felix Schumacher wrote:
>> Am Montag, den 10.10.2011, 11:30 +0200 schrieb sasc sasc:
>>> +1 for this enhancement. With configurable number of threads (default:
>>> Runtime.getRuntime().availableProcessors())
>>>
>>> I would also like to expand/add to this request: Making contexts available
>>> for request processing continuously as they are started. This in combination
>>> with parallel startup, would significantly improve startup time and
>>> perceived availability in many situations.
>>>
>>> If you have 9 applications which each takes 1 sec to start, and 1 app that
>>> takes 5 minutes to start, even with parallel start up, you would still have
>>> to wait at least 5 minutes before any of the applications are available for
>>> request processing. If they could be made available continuously, then the 9
>>> fast apps could start processing requests, even if the 5 min app is still
>>> initializing.
>> I believe you will get more problems, than you solve by serving requests
>> too early. You might happen to serve a request to a context, which is
>> not initialized, or to a context, which would not be responsible.
>
> I think the goal is interesting, but not with a trivial implementation.
> So e.g. it would not be OK to serve the root context instead of /myapp
> only because the root context is already deployed and deploymentof
> /myapp hasn't started yet.
We don't handle that case now, so I'm not sure it should be a
pre-requisite for any implementation that starts Contexts in parallel.
> It would be more of a preprocessing (build the list of contexts to
> deploy), then concurrent startup ann making individual contexts
> immediately available for the request that really belong to them.
>
> Care would be needed for the parallel deployment in order to not
> temporarily serve old versions because the latest version isn't yet
> fully started.
Again, we don't handle this case currently.
> Also it would be nice to be able to express dependencies. This might be
> even a good feature for the simple case of first starting everything and
> then making it available. Because if we use an executor then a simple
> strategy like "start in alphabetical order" might no longer work.
That would make the configuration a lot messier than it is right now as
well as going against the intention of the Servlet specification.
>> I think the proper solution to your problem would be to do
>> initialization of your webapp in a background thread and put a flag into
>> your application scope, when initialization is done. Combine that with a
>> filter, which redirects every incoming request to a waiting page, if the
>> flag is missing from your application scope.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Pid <pi...@pidster.com>.
On 10/10/2011 19:16, Rainer Jung wrote:
> On 10.10.2011 19:35, Felix Schumacher wrote:
>> Am Montag, den 10.10.2011, 11:30 +0200 schrieb sasc sasc:
>>> +1 for this enhancement. With configurable number of threads (default:
>>> Runtime.getRuntime().availableProcessors())
>>>
>>> I would also like to expand/add to this request: Making contexts available
>>> for request processing continuously as they are started. This in combination
>>> with parallel startup, would significantly improve startup time and
>>> perceived availability in many situations.
>>>
>>> If you have 9 applications which each takes 1 sec to start, and 1 app that
>>> takes 5 minutes to start, even with parallel start up, you would still have
>>> to wait at least 5 minutes before any of the applications are available for
>>> request processing. If they could be made available continuously, then the 9
>>> fast apps could start processing requests, even if the 5 min app is still
>>> initializing.
>> I believe you will get more problems, than you solve by serving requests
>> too early. You might happen to serve a request to a context, which is
>> not initialized, or to a context, which would not be responsible.
>
> I think the goal is interesting, but not with a trivial implementation.
> So e.g. it would not be OK to serve the root context instead of /myapp
> only because the root context is already deployed and deploymentof
> /myapp hasn't started yet.
>
> It would be more of a preprocessing (build the list of contexts to
> deploy), then concurrent startup ann making individual contexts
> immediately available for the request that really belong to them.
>
> Care would be needed for the parallel deployment in order to not
> temporarily serve old versions because the latest version isn't yet
> fully started.
>
> Also it would be nice to be able to express dependencies. This might be
> even a good feature for the simple case of first starting everything and
> then making it available. Because if we use an executor then a simple
> strategy like "start in alphabetical order" might no longer work.
Logically, starting to accept requests after ROOT is deployed is similar
to auto-deploying apps any time after the server has started.
Would it be hard to start ROOT first (as a special case) and then start
the rest of the applications? This would also permit the previously
suggested idea[1] of loading a simple default ROOT application, if none
is supplied[2].
acceptRequestsAfterRootBoot="true"
sounds nifty ;)
p
1. but I can't remember why who.
2. I remember thinking that Servlet 3.0 would make it easy to supply a
simple webapp, but can't remember the details
Re: parallel webapp initialization
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rainer,
On 10/10/2011 2:16 PM, Rainer Jung wrote:
> I think the goal is interesting, but not with a trivial
> implementation. So e.g. it would not be OK to serve the root
> context instead of /myapp only because the root context is already
> deployed and deploymentof /myapp hasn't started yet.
Or, conversely, fail to serve something from ROOT context that hasn't
been deployed, yet (i.e. it looks like there is no ROOT context until,
later, surprise!).
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk6TVYsACgkQ9CaO5/Lv0PA25gCffVLZgO6+P9c/WGSnpJEi7krx
vFwAoKt9eIYia6l2M6xfi9KpvPrCwZU1
=SYxH
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Rainer Jung <ra...@kippdata.de>.
On 10.10.2011 19:35, Felix Schumacher wrote:
> Am Montag, den 10.10.2011, 11:30 +0200 schrieb sasc sasc:
>> +1 for this enhancement. With configurable number of threads (default:
>> Runtime.getRuntime().availableProcessors())
>>
>> I would also like to expand/add to this request: Making contexts available
>> for request processing continuously as they are started. This in combination
>> with parallel startup, would significantly improve startup time and
>> perceived availability in many situations.
>>
>> If you have 9 applications which each takes 1 sec to start, and 1 app that
>> takes 5 minutes to start, even with parallel start up, you would still have
>> to wait at least 5 minutes before any of the applications are available for
>> request processing. If they could be made available continuously, then the 9
>> fast apps could start processing requests, even if the 5 min app is still
>> initializing.
> I believe you will get more problems, than you solve by serving requests
> too early. You might happen to serve a request to a context, which is
> not initialized, or to a context, which would not be responsible.
I think the goal is interesting, but not with a trivial implementation.
So e.g. it would not be OK to serve the root context instead of /myapp
only because the root context is already deployed and deploymentof
/myapp hasn't started yet.
It would be more of a preprocessing (build the list of contexts to
deploy), then concurrent startup ann making individual contexts
immediately available for the request that really belong to them.
Care would be needed for the parallel deployment in order to not
temporarily serve old versions because the latest version isn't yet
fully started.
Also it would be nice to be able to express dependencies. This might be
even a good feature for the simple case of first starting everything and
then making it available. Because if we use an executor then a simple
strategy like "start in alphabetical order" might no longer work.
> I think the proper solution to your problem would be to do
> initialization of your webapp in a background thread and put a flag into
> your application scope, when initialization is done. Combine that with a
> filter, which redirects every incoming request to a waiting page, if the
> flag is missing from your application scope.
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: parallel webapp initialization
Posted by Felix Schumacher <fe...@internetallee.de>.
Am Montag, den 10.10.2011, 11:30 +0200 schrieb sasc sasc:
> +1 for this enhancement. With configurable number of threads (default:
> Runtime.getRuntime().availableProcessors())
>
> I would also like to expand/add to this request: Making contexts available
> for request processing continuously as they are started. This in combination
> with parallel startup, would significantly improve startup time and
> perceived availability in many situations.
>
> If you have 9 applications which each takes 1 sec to start, and 1 app that
> takes 5 minutes to start, even with parallel start up, you would still have
> to wait at least 5 minutes before any of the applications are available for
> request processing. If they could be made available continuously, then the 9
> fast apps could start processing requests, even if the 5 min app is still
> initializing.
I believe you will get more problems, than you solve by serving requests
too early. You might happen to serve a request to a context, which is
not initialized, or to a context, which would not be responsible.
I think the proper solution to your problem would be to do
initialization of your webapp in a background thread and put a flag into
your application scope, when initialization is done. Combine that with a
filter, which redirects every incoming request to a waiting page, if the
flag is missing from your application scope.
Regards
Felix
>
> If such a feature is already available in tomcat, then I must have missed
> it. In that case, can someone direct me to where in the docs I can find more
> info about it? :)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org