Storing Objects in a Session - how much is too much?

I’m using a web service and to avoid duplicate calls to the service I
am caching objects in the session. The object count is probably around
500 max. Is this ok? Is this silly??? Should I be looking at
alternative methods. I’m using ActiveRecord/Database sessions. The
reason I am asking is that I am having memory issues and wondering if
this maybe the cause of it.

On Tue, 26 Sep 2006 18:02:46 -000066
[email protected] wrote:

I’m using a web service and to avoid duplicate calls to the service I
am caching objects in the session. The object count is probably around
500 max. Is this ok? Is this silly??? Should I be looking at
alternative methods. I’m using ActiveRecord/Database sessions. The
reason I am asking is that I am having memory issues and wondering if
this maybe the cause of it.

Well, first off you probably didn’t measure to see if storing in the
session (that goes into the same database) is actually faster than just
using the database anyway. Second, you’re taking the 500 objects and
multiplying them by however many users you have, rather than sharing
then a more space efficient way.

I’d say rethink this completely, but first just don’t worry about it,
use the AR cleanly without any caching tricks, then profile your app and
tune the parts that are slow.


Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu


http://mongrel.rubyforge.org/
http://www.lingr.com/room/3yXhqKbfPy8 – Come get help.

Just to clarify, I’m not pulling the data from a database connected to
my rails app, I’m pulling the data from an external web service (i.e.
I don’t own the data). So yes, definitely pulling the data from the
session is faster than executing another query from the web service.

but you can always store data localy once retrieved…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs