aspose file tools*
The moose likes Struts and the fly likes struts2 thread safety and performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 thread safety and performance" Watch "struts2 thread safety and performance" New topic
Author

struts2 thread safety and performance

Jasvir Rupana
Ranch Hand

Joined: Oct 13, 2010
Posts: 52
Hi guys ,
Since struts2 is thread safe and creates new instance per request , how it handle if thousands of requests come at same time i.e thousands of instances.does not it put extra load on the server ??
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Saying " Struts is thread-safe" makes no sense - it's perfectly possible to write thread-unsafe applications in Struts, just like it is using every other web framework out there. Struts makes it marginally easier to write thread-safe code compared to servlets through the use of single-request actions, but that's far from the only factor in thread-safety.

Please work through one of the books I pointed you to in the other topic to get an understanding of what the issues in Java concurrency are before you work on systems having large-scale concurrency.
Jasvir Rupana
Ranch Hand

Joined: Oct 13, 2010
Posts: 52
Burnham ,so you mean to say we should not reply on struts 2 default behaviour which creates new instance per request , instead we should customize our implementation to prevent new instance per request ?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
You can't change that - it's how Struts works. What I'm saying is that by itself single-request instances do not make a web app thread-safe if you have shared mutable state (and I have yet to see a non-trivial web app that did not have that).
Jasvir Rupana
Ranch Hand

Joined: Oct 13, 2010
Posts: 52
I am sorry but my question is still same , if by default struts creates new instance per request , is it good to go with default struts 2 behaviour ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2 thread safety and performance