Peter1 Alvin wrote:
Using mod_perl, how do you keep Perl objects in RAM from page to page? I don't want to re-instantiate my objects on every page request, and I don't want the overhead of serializing my objects to a persistent store from page to page (I use A LOT of objects).

I think you should reconsider this design. Needing to keep lots of objects in RAM is likely to become a scalability problem on any platform.

You can keep objects alive easilly by putting them in globals or closures. If you use a prefork MPM, they will not be shared between processes. This could lead to a lot of memory use, and a user may hit different processes on every request, making this useless for "session" information. It does keep the objects in RAM though.

If you use a threaded MPM, you will be able to share data between threads, assuming you are trying to share pure Perl objects and not XS pointers or open sockets or the like. See the threads documentation that comes with Perl for more. However, as soon as you need multiple servers for scaling or redundancy, this solution has the same problem with session data.

The usual solution to this sort of thing is to keep most of your data in a database, and just serialize the session data between servers.

I can't believe Perl doesn't support keeping objects in RAM. This would de-qualify Perl for half of the projects I need to develop.

There are languages with better threading support, particularly Java. If you're determined to pursue this design, I think you'd be bettter off with one of them.

- Perrin

Reply via email to