You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Remy Maucherat <re...@apache.org> on 2002/12/16 18:46:38 UTC
Thread priority
Hi,
I was wondering about how expensive the Thread.setPriority method is,
and to which extent it does what it advetises.
The point would be to assign the minimum priority to background
reloading threads, as well as set the priority of the thread accepting
on the server socket to the maximum while is it accepting, and then
switch back to normal priority once the accept is done.
That would prevent the only thread accepting on the server socket from
being starved by the OS scheduler.
Here's a patch for the PoolTcpEndpoint:
diff -r1.8 PoolTcpEndpoint.java
496a497
> Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
500c501,503
< }
---
> } finally {
> Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
> }
I have no idea if this produces useful results. This adds no additional
overhead on Windows according to OptimizeIt (which might hint that it
doesn't do anything on that platform). Maybe it would be a good ideato
test this on different platforms (and hammer the server to see how it
compares to an unpatched server).
According to Doug Lea's book, this may heuristically do something
intelligent depending on the VM implementation. (great :) )
Comments ?
Remy
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Michael <fr...@adsl-209-204-165-151.sonic.net>.
Michael Smith wrote:
> Remy Maucherat wrote:
>
>> I was wondering about how expensive the Thread.setPriority method is,
>> and to which extent it does what it advetises.
>
> The extent to which it has an effect is very much platform (and
> probably JVM) dependent. It's also dependent on the permissions a user
> has - on many (all?) unix systems, only root may set a process or
> thread to higher than normal priority [...]
>
> I suspect that this will mean that your suggested use of these calls
> will [...] have no effect [...] on most common JVM implementations.
>
> [...] it's pretty unlikely to make any noticable difference in
> performance.
That may be true for Linux--which only has setpriority(2) available to
the common user--but Solaris and Windows JVMs can conceivably support
raising the Java Thread priority.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: mod_jk and load balancer - bug?
Posted by Filip Hanik <ma...@filip.net>.
Punky wrote:
>What if:
>1. load balancer receives a request for http://server/
>2. does httpd return http://server:81/ in Location? (I don't think so)
1. In this case the request never gets forwarded to tomcat, hence Apache
sends the redirect or forward, not Tomcat.
So that case does not apply to tomcat at all.
>And also what if
>1. load balancer receives a request for
>http://server/somecontext/index.jsp?
this works, because there is no redirect sent at all from Tomcat, because
you listed a file/page that exists.
the problem only occurs when tomcat redirects a request to a page in the
welcome file list, and sends it through apache back.
Filip
~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
www.filip.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: mod_jk and load balancer - bug?
Posted by Punky Tse <pu...@punknix.com>.
What if:
1. load balancer receives a request for http://server/
2. does httpd return http://server:81/ in Location? (I don't think so)
And also what if
1. load balancer receives a request for http://server/somecontext/index.jsp?
Punky
Filip Hanik wrote:
> I should also note that this scenario works fine if you remove Apache from
> the stack.
> so when the load balancer forwards to port 8080, the location uses port 80
> to return with.
>
> so maybe this is mod_jk that should list the port as 80?
>
> Filip
>
>>here is a scenario
>>
>>hardware stack
>>
>>LoadBalancer(port80) - Apache/mod_jk 2.0.43(port81) - Tomcat
>>4.1.12(port8080/8009)
>>
>>1. The load balancer receives a request for http://server/somecontext/
>>2. The load balancer forwards this to apache. Apache detects /somecontext/
>>and makes a request to Tomcat
>>3. Tomcat gets the request GET /somecontext/ and looks up welcome files
>>4. Tomcat finds index.jsp as a welcome file
>>5. Tomcat constructs a redirect using the absolute URL it got from Apache
>>
>>and here is the problem, in step 5 tomcat constructs an absolute URL, and
>>uses the port number from Apache which was 81.
>>hence the redirect will go to port 81.
>>
>>the response back to the server is
>>Location:http://server:81/somecontext/index.jsp --which is wrong, the
>>request came in on port 80
>>
>>when it would have been better if the response was the relative URL.
>>
>>Is this a bug, or could we add a feature to be able to configure the Coyote
>>connector to generate absolute or relative urls on sendRedirect
>>
>>Filip
>>
>>~
>>Namaste - I bow to the divine in you
>>~
>>Filip Hanik
>>Software Architect
>>www.filip.net
>>
>>
>>--
>>To unsubscribe, e-mail:
>
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: mod_jk and load balancer - bug?
Posted by Filip Hanik <ma...@filip.net>.
I should also note that this scenario works fine if you remove Apache from
the stack.
so when the load balancer forwards to port 8080, the location uses port 80
to return with.
so maybe this is mod_jk that should list the port as 80?
Filip
>
>here is a scenario
>
>hardware stack
>
>LoadBalancer(port80) - Apache/mod_jk 2.0.43(port81) - Tomcat
>4.1.12(port8080/8009)
>
>1. The load balancer receives a request for http://server/somecontext/
>2. The load balancer forwards this to apache. Apache detects /somecontext/
>and makes a request to Tomcat
>3. Tomcat gets the request GET /somecontext/ and looks up welcome files
>4. Tomcat finds index.jsp as a welcome file
>5. Tomcat constructs a redirect using the absolute URL it got from Apache
>
>and here is the problem, in step 5 tomcat constructs an absolute URL, and
>uses the port number from Apache which was 81.
>hence the redirect will go to port 81.
>
>the response back to the server is
>Location:http://server:81/somecontext/index.jsp --which is wrong, the
>request came in on port 80
>
>when it would have been better if the response was the relative URL.
>
>Is this a bug, or could we add a feature to be able to configure the Coyote
>connector to generate absolute or relative urls on sendRedirect
>
>Filip
>
>~
>Namaste - I bow to the divine in you
>~
>Filip Hanik
>Software Architect
>www.filip.net
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
mod_jk and load balancer - bug?
Posted by Filip Hanik <ma...@filip.net>.
here is a scenario
hardware stack
LoadBalancer(port80) - Apache/mod_jk 2.0.43(port81) - Tomcat
4.1.12(port8080/8009)
1. The load balancer receives a request for http://server/somecontext/
2. The load balancer forwards this to apache. Apache detects /somecontext/
and makes a request to Tomcat
3. Tomcat gets the request GET /somecontext/ and looks up welcome files
4. Tomcat finds index.jsp as a welcome file
5. Tomcat constructs a redirect using the absolute URL it got from Apache
and here is the problem, in step 5 tomcat constructs an absolute URL, and
uses the port number from Apache which was 81.
hence the redirect will go to port 81.
the response back to the server is
Location:http://server:81/somecontext/index.jsp --which is wrong, the
request came in on port 80
when it would have been better if the response was the relative URL.
Is this a bug, or could we add a feature to be able to configure the Coyote
connector to generate absolute or relative urls on sendRedirect
Filip
~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
www.filip.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Michael Smith <ms...@xn.com.au>.
Remy Maucherat wrote:
> Hi,
>
> I was wondering about how expensive the Thread.setPriority method is,
> and to which extent it does what it advetises.
Remy,
Thread.setPriority will (in a native threading implementation, rather
than something like the old green-threads JVM) be a system call, so it's
not free - but it's not a particularly expensive syscall. Expense is
probably similar to the various socket calls like setTimeout(), etc. So
it's cheap enough to do once or twice per connection.
The extent to which it has an effect is very much platform (and probably
JVM) dependent. It's also dependent on the permissions a user has - on
many (all?) unix systems, only root may set a process or thread to
higher than normal priority (unless the JVM itself is doing some
scheduling, which I doubt is the case with modern native-threading JVMs).
I suspect that this will mean that your suggested use of these calls
will either fail, or have no effect (the latter being more likely) on
most common JVM implementations. It's still worth setting the background
reloader thread(s) to low priority, though.
In short - this shouldn't hurt in any noticable way, but it's pretty
unlikely to make any noticable difference in performance.
Mike Smith
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Glenn Nielsen <gl...@mail.more.net>.
Yes, that sums up my thoughts exactly.
Peter Lin wrote:
> My 2 cents. I rather a server deny connections and keep on running than accept connections until it dies :)
>
> peter lin
>
> Remy Maucherat <re...@apache.org> wrote:Glenn Nielsen wrote:
>
>>Is there a reported bug you are trying to address?
>
>
> Not really. The test here reported a lot of connection failures:
> http://webperformanceinc.com/library/ServletReport/
>
> Tomcat 4.1.17 should improve the results over 4.1.12 (it's faster and
> would probably lower slightly GC), but I think the number of errors was
> higher than it should have been.
> This could be caused by GC, or possibly because the accepting thread
> couldn't get the job done, or some other unknown factor.
>
>
>>I have not noticed any problems related to thread scheduling with the
>>medium
>>volume site I administer.
>>
>>It is possible that this change could cause threads other than the socket
>>accept thread to be starved. I would be -1 for making this change unless
>>there is a significant reported bug that these changes would address.
>>
>>If it ain't broke, don't fix it. ;-)
>
>
> Remy
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Glenn Nielsen <gl...@mail.more.net>.
Thanks for the link Filip. It is specific to JVM 1.4.1, but has
alot of good information. The problem is that there is no one good set
of jvm args to tune memory and GC, it really depends on so many things.
Hardware, OS, memory, applications, etc. But there are some general rules
that can be distilled from this.
Regards,
Glenn
Filip Hanik wrote:
> here is a good link about the different VM settings for the GC.
> should be worth trying out the different ones to see which one is best for
> Tomcat
>
> http://wireless.java.sun.com/midp/articles/garbagecollection2/
>
> Filip
>
> ~
> Namaste - I bow to the divine in you
> ~
> Filip Hanik
> Software Architect
> www.filip.net
>
>
>>-----Original Message-----
>>From: Peter Lin [mailto:tcw00lfel@yahoo.com]
>>Sent: Tuesday, December 17, 2002 6:55 AM
>>To: Tomcat Developers List
>>Subject: Re: Thread priority
>>
>>
>>
>>My 2 cents. I rather a server deny connections and keep on running
>>than accept connections until it dies :)
>>
>>peter lin
>>
>>Remy Maucherat <re...@apache.org> wrote:Glenn Nielsen wrote:
>>
>>>Is there a reported bug you are trying to address?
>>
>>Not really. The test here reported a lot of connection failures:
>>http://webperformanceinc.com/library/ServletReport/
>>
>>Tomcat 4.1.17 should improve the results over 4.1.12 (it's faster and
>>would probably lower slightly GC), but I think the number of errors was
>>higher than it should have been.
>>This could be caused by GC, or possibly because the accepting thread
>>couldn't get the job done, or some other unknown factor.
>>
>>
>>>I have not noticed any problems related to thread scheduling with the
>>>medium
>>>volume site I administer.
>>>
>>>It is possible that this change could cause threads other than the socket
>>>accept thread to be starved. I would be -1 for making this change unless
>>>there is a significant reported bug that these changes would address.
>>>
>>>If it ain't broke, don't fix it. ;-)
>>
>>Remy
>>
>>
>>--
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
>>
>>
>>
>>---------------------------------
>>Do you Yahoo!?
>>Yahoo! Mail Plus - Powerful. Affordable. Sign up now
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Thread priority
Posted by Filip Hanik <ma...@filip.net>.
here is a good link about the different VM settings for the GC.
should be worth trying out the different ones to see which one is best for
Tomcat
http://wireless.java.sun.com/midp/articles/garbagecollection2/
Filip
~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
www.filip.net
>-----Original Message-----
>From: Peter Lin [mailto:tcw00lfel@yahoo.com]
>Sent: Tuesday, December 17, 2002 6:55 AM
>To: Tomcat Developers List
>Subject: Re: Thread priority
>
>
>
>My 2 cents. I rather a server deny connections and keep on running
>than accept connections until it dies :)
>
>peter lin
>
> Remy Maucherat <re...@apache.org> wrote:Glenn Nielsen wrote:
>> Is there a reported bug you are trying to address?
>
>Not really. The test here reported a lot of connection failures:
>http://webperformanceinc.com/library/ServletReport/
>
>Tomcat 4.1.17 should improve the results over 4.1.12 (it's faster and
>would probably lower slightly GC), but I think the number of errors was
>higher than it should have been.
>This could be caused by GC, or possibly because the accepting thread
>couldn't get the job done, or some other unknown factor.
>
>> I have not noticed any problems related to thread scheduling with the
>> medium
>> volume site I administer.
>>
>> It is possible that this change could cause threads other than the socket
>> accept thread to be starved. I would be -1 for making this change unless
>> there is a significant reported bug that these changes would address.
>>
>> If it ain't broke, don't fix it. ;-)
>
>Remy
>
>
>--
>To unsubscribe, e-mail:
>For additional commands, e-mail:
>
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Peter Lin <tc...@yahoo.com>.
My 2 cents. I rather a server deny connections and keep on running than accept connections until it dies :)
peter lin
Remy Maucherat <re...@apache.org> wrote:Glenn Nielsen wrote:
> Is there a reported bug you are trying to address?
Not really. The test here reported a lot of connection failures:
http://webperformanceinc.com/library/ServletReport/
Tomcat 4.1.17 should improve the results over 4.1.12 (it's faster and
would probably lower slightly GC), but I think the number of errors was
higher than it should have been.
This could be caused by GC, or possibly because the accepting thread
couldn't get the job done, or some other unknown factor.
> I have not noticed any problems related to thread scheduling with the
> medium
> volume site I administer.
>
> It is possible that this change could cause threads other than the socket
> accept thread to be starved. I would be -1 for making this change unless
> there is a significant reported bug that these changes would address.
>
> If it ain't broke, don't fix it. ;-)
Remy
--
To unsubscribe, e-mail:
For additional commands, e-mail:
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
Re: Thread priority
Posted by Remy Maucherat <re...@apache.org>.
Glenn Nielsen wrote:
> Is there a reported bug you are trying to address?
Not really. The test here reported a lot of connection failures:
http://webperformanceinc.com/library/ServletReport/
Tomcat 4.1.17 should improve the results over 4.1.12 (it's faster and
would probably lower slightly GC), but I think the number of errors was
higher than it should have been.
This could be caused by GC, or possibly because the accepting thread
couldn't get the job done, or some other unknown factor.
> I have not noticed any problems related to thread scheduling with the
> medium
> volume site I administer.
>
> It is possible that this change could cause threads other than the socket
> accept thread to be starved. I would be -1 for making this change unless
> there is a significant reported bug that these changes would address.
>
> If it ain't broke, don't fix it. ;-)
Remy
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Glenn Nielsen <gl...@mail.more.net>.
Is there a reported bug you are trying to address?
I have not noticed any problems related to thread scheduling with the medium
volume site I administer.
It is possible that this change could cause threads other than the socket
accept thread to be starved. I would be -1 for making this change unless
there is a significant reported bug that these changes would address.
If it ain't broke, don't fix it. ;-)
Regards,
Glenn
Remy Maucherat wrote:
> Hi,
>
> I was wondering about how expensive the Thread.setPriority method is,
> and to which extent it does what it advetises.
>
> The point would be to assign the minimum priority to background
> reloading threads, as well as set the priority of the thread accepting
> on the server socket to the maximum while is it accepting, and then
> switch back to normal priority once the accept is done.
>
> That would prevent the only thread accepting on the server socket from
> being starved by the OS scheduler.
>
> Here's a patch for the PoolTcpEndpoint:
>
> diff -r1.8 PoolTcpEndpoint.java
> 496a497
> > Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
> 500c501,503
> < }
> ---
> > } finally {
> >
> Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
> > }
>
> I have no idea if this produces useful results. This adds no additional
> overhead on Windows according to OptimizeIt (which might hint that it
> doesn't do anything on that platform). Maybe it would be a good ideato
> test this on different platforms (and hammer the server to see how it
> compares to an unpatched server).
> According to Doug Lea's book, this may heuristically do something
> intelligent depending on the VM implementation. (great :) )
>
> Comments ?
>
> Remy
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Thread priority
Posted by Michael <fr...@adsl-209-204-165-151.sonic.net>.
Remy Maucherat wrote:
> I was wondering about how expensive the Thread.setPriority method is,
> and to which extent it does what it advetises.
I don't think it's expensive at all. And it certainly has an effect.
> The point would be to assign the minimum priority to background
> reloading threads, as well as set the priority of the thread accepting
> on the server socket to the maximum while is it accepting, and then
> switch back to normal priority once the accept is done.
You should save the priority and switch back to it. You can't assume
that your initial priority is NORM_PRIORITY.
I assume--since you're asking this and you know TC--that TC doesn't have
it's own internal thread scheduler. Else you'd have to consider the
interaction with that algorithm, too.
> That would prevent the only thread accepting on the server socket from
> being starved by the OS scheduler.
One of the unequivocally good uses for setting priority.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>