I have always learned, don't put stuff in the session unless you have to, so when I started my project, I made all of my backing beans request scoped, but started wondering lately if there are benefits to keeping them in the session.

Is there a valid argument for making them session beans? You could argue that you're using less database resources by not having to hit the database over and over for the same information that you've already gotten. Less network traffic because you're not passing as many request params around all the time. Less code in your jsp's because you don't have to write out hidden fields all over the place.

Are these points enough to offset the server overhead of keeping this info all the time in the session? I guess it depends on how many concurrent users you have to worry about. Is there a rule of thumb for how many users you have before you start to kill your server with too much in the session? The project this is for is a pay site that you have to log in for, so it's not going to have the thousands of public users surfing the site at one time, it's more like a thousand users total and *maybe* a few hundred logged in at a time. Is that enough to worry about session sizes?

Any other arguments for or against sessions over requests? Am I crazy for even considering making most of my beans session scoped?

Jesse

Reply via email to