You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Ing. Andrea Vettori" <ma...@andreavettori.com> on 2007/07/17 16:04:18 UTC

slowing down action execution time

Hi

what's the best method to slow an action execution time ? Something  
like Thread.sleep(...).

Thanks !

--
Ing. Andrea Vettori
Consulente per l'Information Technology



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by Leon Rosenberg <ro...@googlemail.com>.
I think you misunderstand things a bit here (or maybe the spec wasnt
clear, as often)

servlet spec 2.5 (the current one, and the one tomcat 6 is
implementing) states in
SRV.14.2.2 Web Application Environment (9.11 now merily point to this chapter):

"Java EE defines a naming environment that allows applications to easily access
resources and external information without explicit knowledge of how
the external
information is named or organized."
...

"This type of servlet container must support lookups of such objects and
calls made to those objects when performed on a thread managed by the servlet
container. This type of servlet container should support this behavior when
performed on threads created by the developer, but are not currently
required to do
so. Such a requirement will be added in the next version of this specification.
Developers are cautioned that depending on this capability for
application-created
threads is not recommended, as it is non-portable."

So the distinction between application-created and container-created
thread is that application created thread may not have the ability to
access container managed resources (ejb related stuff, something 90%
of us will never need (*thankfully*)) but the servlet containers will
have to support it in next version (which I assume is 3.0 and is
scheduled to the end of 2008, so effectively 2009). The ability to
access such resources from custom threads is not portable. The threads
themself are absolutely portable.
I also doubt that its possible to prevent an application from thread
creation, maybe by some obscure security manager settings, but i doubt
it, since it will probably break 90% of existing 3 tier webapps.

Without the ability to create threads you won't be able to communicate
via corba or rmi or do anything useful in your webapp ;-)

regards
Leon




On 7/17/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/7/17, Leon Rosenberg <ro...@googlemail.com>:
> >
> > you can create threads in tomcat. It's not recommended unless you know
> > what you are doing, but you can.
> >
>
>
> It seems that you are right... and not :-)
> You can create threads in a servlet container, but it is not portable.
> As stated in Servlet 2.4 specification, section SRV.9.11:
>
> <snip>
> This type ofservlet container should support this behavior when performed on
> threads created by the
> developer, but are not currently required to do so. Such a requirement will
> be
> added in the next version of this specification.  Developers are cautioned
> that
> depending on this capability for application-created threads is not
> recommended,
> as it is non-portable.
> </snip>
>
> Antonio
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/17, Leon Rosenberg <ro...@googlemail.com>:
>
> you can create threads in tomcat. It's not recommended unless you know
> what you are doing, but you can.
>


It seems that you are right... and not :-)
You can create threads in a servlet container, but it is not portable.
As stated in Servlet 2.4 specification, section SRV.9.11:

<snip>
This type ofservlet container should support this behavior when performed on
threads created by the
developer, but are not currently required to do so. Such a requirement will
be
added in the next version of this specification.  Developers are cautioned
that
depending on this capability for application-created threads is not
recommended,
as it is non-portable.
</snip>

Antonio

Re: slowing down action execution time

Posted by Leon Rosenberg <ro...@googlemail.com>.
On 7/17/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/7/17, Ing. Andrea Vettori <ma...@andreavettori.com>:
> > I don't remember where but I think I read somewhere that's not
> > possibile to call Thread methods inside a servlet container.
> >
> > Anyone can confirm this ?
>
>
> AFAIK you cannot create any thread in a Java EE environment (though
> products like Quartz do this very elegantly), but I think that you can
> do anything with your *current* thread.

you can create threads in tomcat. It's not recommended unless you know
what you are doing, but you can.
regards
Leon
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by Leon Rosenberg <ro...@googlemail.com>.
We actually didnt provide you any solution, but its pretty hard, since
you haven't provided any details :-)

There are many possibilities, IP-Throttle, session-based throttle or a
mechanism which manages the overall load on the server. Without
knowing what you are doing, providing even a hint is pretty hard.

regards
Leon

On 7/17/07, Ing. Andrea Vettori <ma...@andreavettori.com> wrote:
> thanks to all
>
> I'll try...
>
>
> Il giorno 17/lug/07, alle ore 16:38, Antonio Petrelli ha scritto:
>
> > 2007/7/17, Ing. Andrea Vettori <ma...@andreavettori.com>:
> >> I don't remember where but I think I read somewhere that's not
> >> possibile to call Thread methods inside a servlet container.
> >>
> >> Anyone can confirm this ?
> >
> >
> > AFAIK you cannot create any thread in a Java EE environment (though
> > products like Quartz do this very elegantly), but I think that you can
> > do anything with your *current* thread.
> >
> > Antonio
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> --
> Ing. Andrea Vettori
> Consulente per l'Information Technology
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by "Ing. Andrea Vettori" <ma...@andreavettori.com>.
thanks to all

I'll try...


Il giorno 17/lug/07, alle ore 16:38, Antonio Petrelli ha scritto:

> 2007/7/17, Ing. Andrea Vettori <ma...@andreavettori.com>:
>> I don't remember where but I think I read somewhere that's not
>> possibile to call Thread methods inside a servlet container.
>>
>> Anyone can confirm this ?
>
>
> AFAIK you cannot create any thread in a Java EE environment (though
> products like Quartz do this very elegantly), but I think that you can
> do anything with your *current* thread.
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

--
Ing. Andrea Vettori
Consulente per l'Information Technology



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/17, Ing. Andrea Vettori <ma...@andreavettori.com>:
> I don't remember where but I think I read somewhere that's not
> possibile to call Thread methods inside a servlet container.
>
> Anyone can confirm this ?


AFAIK you cannot create any thread in a Java EE environment (though
products like Quartz do this very elegantly), but I think that you can
do anything with your *current* thread.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: slowing down action execution time

Posted by Al Sutton <al...@alsutton.com>.
You could always use a holder page and a meta refresh.

For example;

Page 1 - Has the form on which the details are entered
| 
[submits to]
|
Action A which stores the details of the query
|
[forwards to]
|
Page 2 which has a meta refresh
(http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm)
|
[refresh redirects to]
|
Action B which gets the results of the query
|
[forwards to]
|
Page 3 which displays the results.


You can then do two things;

1) Increase the meta refresh time in Page 2 to slow down requests.
2) Store the delay in the users session in Action A and if Action B is
called before the delay has completed you redirect the user to Page 2
instead of Page 3.


Hope this is useful,

Al.
-----Original Message-----
From: Ing. Andrea Vettori [mailto:mail@andreavettori.com] 
Sent: 17 July 2007 15:28
To: Struts Users Mailing List
Subject: Re: slowing down action execution time


I need to initially slow down and after a few minutes completely  
block access to aa site to logged-users and/or remote ip addresses  
that reads too many pages too fast.

It's something like controlling that the site is not mirrored.

I don't remember where but I think I read somewhere that's not  
possibile to call Thread methods inside a servlet container.

Anyone can confirm this ?

Thanks

Il giorno 17/lug/07, alle ore 16:25, Leon Rosenberg ha scritto:

> actually you named it.
> Thread.sleep().
>
> only for debugging purposes of course :-)
> regards
> leon
>
> On 7/17/07, Ing. Andrea Vettori <ma...@andreavettori.com> wrote:
>> Hi
>>
>> what's the best method to slow an action execution time ? Something 
>> like Thread.sleep(...).
>>
>> Thanks !
>>
>> --
>> Ing. Andrea Vettori
>> Consulente per l'Information Technology
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

--
Ing. Andrea Vettori
Consulente per l'Information Technology



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by "Ing. Andrea Vettori" <ma...@andreavettori.com>.
I need to initially slow down and after a few minutes completely  
block access to aa site to logged-users and/or remote ip addresses  
that reads too many pages too fast.

It's something like controlling that the site is not mirrored.

I don't remember where but I think I read somewhere that's not  
possibile to call Thread methods inside a servlet container.

Anyone can confirm this ?

Thanks

Il giorno 17/lug/07, alle ore 16:25, Leon Rosenberg ha scritto:

> actually you named it.
> Thread.sleep().
>
> only for debugging purposes of course :-)
> regards
> leon
>
> On 7/17/07, Ing. Andrea Vettori <ma...@andreavettori.com> wrote:
>> Hi
>>
>> what's the best method to slow an action execution time ? Something
>> like Thread.sleep(...).
>>
>> Thanks !
>>
>> --
>> Ing. Andrea Vettori
>> Consulente per l'Information Technology
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

--
Ing. Andrea Vettori
Consulente per l'Information Technology



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: slowing down action execution time

Posted by Leon Rosenberg <ro...@googlemail.com>.
actually you named it.
Thread.sleep().

only for debugging purposes of course :-)
regards
leon

On 7/17/07, Ing. Andrea Vettori <ma...@andreavettori.com> wrote:
> Hi
>
> what's the best method to slow an action execution time ? Something
> like Thread.sleep(...).
>
> Thanks !
>
> --
> Ing. Andrea Vettori
> Consulente per l'Information Technology
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org