So I've just started a new job and we've got a traditional web app setup(Tomcat, Struts1, Sybase DB) and I have a question about design and synchronization. I've worked on a previous web app and all of our beans were never synchronized. We just created a new set of object's for every user and then served that information up. Now on this application the have decided to synchronize some of their operations on information. Is there really a need to do that in a web app? If you give every user a new set of object's there should be no problems with one user modifying another's information? They should all write to the DB and if one user is modifying the same information as another, the DB will just over-write the older information?
If we didn't share any of the objects between requests(meaning we create a distinct set of objects for each request) there should be no need for synchronization correct?
Thanks for the information Bear, that is very helpful. One followup question if we do add things to the user session would be it be best to synchronize mutators on those objects? Or should I just do some more investigation about how sessions are shared in tomcat?
The contention for session objects occurs due to frames, frames, additional windows, or Ajax from the same user, as the session cookie is shared amongst them. You won't need to worry about contention from other users on other systems.
I try to minimize, or completely eliminate, storing any read/write data in the session.
Excellent, thank you for all the good information. Unfortunately my system uses a lot of ajax and has been deployed in production for a while. I've been tasked with improving the performance, so I will take what you've told me and try to refactor the code I have to use the session less and less where I can. Thank you!
I will. I think my general approach for now, will be trying to get the synchronization out of the system slowly. We have lots of instance's of Vector's and Hashtable's floating around that I think can slowly be converted to List's and Map's of various kinds. I need to do more investigation into my system to determine what really needs to be in the session and what doesn't and also what really needs to be synchronized, because it is my feeling right now that alot of the stuff that is synchronized has been done so for no good reason.
@TS Yeah those are two types of design approaches and that is one of the major difference between struts 1 & struts 2. In struts 2.0 developer need not to worry about synchronization because new instance will be created for each and every request.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.