Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2 thread safety and performance

 
Jasvir Rupana
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic