You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Guernsey, Byron (GE Consumer & Industrial)" <BY...@GE.COM> on 2005/02/14 21:18:30 UTC
How to prevent multiple threads per session
I have a bit of a problem where deep in a servlet there is some
synchronized code that is synchronized on an object in session. On a
rare occasion, that code runs very slowly when a long report is running
or a database slows. This causes the users of the application to keep
clicking stop and refresh- thinking their request is going to run.
Recently when the server stopped responding, I did a kill -3 and found
almost all of the threads waiting for that synchronzied session object-
meaning 1 user had managed to consume a large number of threads be click
refresh.
I realize that I could modify the code to fail out if it couldn't grab
the monitor in a set period of time, but I'd prefer to cancel the thread
that has no web browser endpoint associated with it- the one that holds
the monitor and won't release it until its done with its query.
Basically, if someone refreshes, I'd like to abort any threads they
already have running- or simply allow tomcat to abort the processing
when the threads endpoint goes away.
Is there any way I can accomplish this?
I'm using Tomcat 4.1.31 and Mod_jk2 on apache 2.0.52
Thanks,
Byron
==============================
Byron Guernsey
Senior Software Architect
GE Consumer & Industrial Systems
(502) 452 - 5101
Re: How to prevent multiple threads per session
Posted by sven morales <ak...@yahoo.com>.
Hi,
Filters. There was a filter code developed by
Ivelin Ivanov and Kevin Chipalkowsky that maybe be
applicable to your needs. It is called
RequestControlFilter.
If a user makes two request, A and B then A will be
processed first while B waits. When A finishes, B
will be processed. If a user makes three or more
requests ( e.g. A, B, and C) then the first will be
processed (A), and then the after it finishes the last
will be processed (C), and any intermediate requests
will be skipped (B).
aka_sergio
--- "Guernsey, Byron (GE Consumer & Industrial)"
<BY...@GE.COM> wrote:
>
> I have a bit of a problem where deep in a servlet
> there is some
> synchronized code that is synchronized on an object
> in session. On a
> rare occasion, that code runs very slowly when a
> long report is running
> or a database slows. This causes the users of the
> application to keep
> clicking stop and refresh- thinking their request is
> going to run.
> Recently when the server stopped responding, I did a
> kill -3 and found
> almost all of the threads waiting for that
> synchronzied session object-
> meaning 1 user had managed to consume a large number
> of threads be click
> refresh.
>
> I realize that I could modify the code to fail out
> if it couldn't grab
> the monitor in a set period of time, but I'd prefer
> to cancel the thread
> that has no web browser endpoint associated with it-
> the one that holds
> the monitor and won't release it until its done with
> its query.
> Basically, if someone refreshes, I'd like to abort
> any threads they
> already have running- or simply allow tomcat to
> abort the processing
> when the threads endpoint goes away.
>
> Is there any way I can accomplish this?
>
> I'm using Tomcat 4.1.31 and Mod_jk2 on apache 2.0.52
>
> Thanks,
> Byron
>
>
> ==============================
> Byron Guernsey
> Senior Software Architect
> GE Consumer & Industrial Systems
> (502) 452 - 5101
>
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org