You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Prasad, Kamakshya" <kp...@capitalservicing.co.jp> on 2004/04/14 08:04:27 UTC

Better peformance: Using static variables or application context object

Hi All,
 
Performance wise which will be the better way of caching for a web
application, using static variables or embedding the object to be cached
in the application context object.
 
KP
 
 

Re: Better peformance: Using static variables or application context object

Posted by Craig McClanahan <cr...@apache.org>.
Prasad, Kamakshya wrote:

>Hi All,
> 
>Performance wise which will be the better way of caching for a web
>application, using static variables or embedding the object to be cached
>in the application context object.
> 
>  
>
Unless your server is totally CPU bound, it's unlikely to make any 
difference at all from a performance point fo view.  If it is, then any 
difference is solely in the tradeoffs of how you get to the cached data 
-- the ServletContext.getAttributes() call is typically a lookup in a 
HashMap (with synchronization to avoid multithread issues), versus 
whatever lookup mechanism you use in your static variables.

But, I would suggest focusing on clean architecture and design as the 
first priority, and optimize stuff like this only if it shows up in your 
performance measurements.  Paying attention to the indexes on your 
database is likely to give you substantially more benefit for a given 
amount of time spent on performance tuning than something like this.

>KP
> 
>  
>
Craig


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