Loading ...
Sorry, an error occurred while loading the content.
 

RE: $Session object

Expand Messages
  • Chris Marschall
    Hello all, I seem to remember reading in this group, that you shouldn t stuff too much data in $Session. Why is this the case? Is is simply performance, and
    Message 1 of 6 , Feb 4, 2004
      Hello all,

      I seem to remember reading in this group, that you shouldn't stuff too
      much data in $Session. Why is this the case? Is is simply performance,
      and if so how much data can I store in here reasonably.

      The reason that I ask is this:

      I tend to develop using OO, and was wondering if there are any
      ramifications of generating a reasonably complex object (hash structure
      with references to array references and other hash structures, probably
      about 30K of data) and simply storing the pointer to this in the $Session
      object.

      Now when the script actually finishes, does the $Session object in it's
      entirity get dumped to the state directory (I'm assuming that this is the
      case) or does my complex object get kept in memory until the $Session
      object expires; when the $Session object is destroyed, there will be no
      more references to my object and hence it should be garbage collected.

      Any shedding of light on this would be appreciated.

      Regards,

      Chris.

      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Helmut Zeilinger
      Hi Chris, the reason for the data size limit is, that the SDBM hash size limit is 1024 bytes for the key + the value. You can store more data if you use
      Message 2 of 6 , Feb 4, 2004
        Hi Chris,

        the reason for the data size limit is, that the SDBM hash size
        limit is 1024 bytes for the key + the value.

        You can store more data if you use DB_File or MLDBM::Sync::SDBM_File
        for storing the data.

        But see "man Apache::ASP", Section "State Management" (StateDB).

        Regards

        Helmut

        >
        > I seem to remember reading in this group, that you shouldn't stuff too
        > much data in $Session. Why is this the case? Is is simply performance,
        > and if so how much data can I store in here reasonably.
        >
        > The reason that I ask is this:
        >
        > I tend to develop using OO, and was wondering if there are any
        > ramifications of generating a reasonably complex object (hash structure
        > with references to array references and other hash structures, probably
        > about 30K of data) and simply storing the pointer to this in the $Session
        > object.
        >
        > Now when the script actually finishes, does the $Session object in it's
        > entirity get dumped to the state directory (I'm assuming that this is the
        > case) or does my complex object get kept in memory until the $Session
        > object expires; when the $Session object is destroyed, there will be no
        > more references to my object and hence it should be garbage collected.
        >
        > Any shedding of light on this would be appreciated.
        >
        > Regards,
        >
        > Chris.
        >
        > ---------------------------------------------------------------------
        > To unsubscribe, e-mail: asp-unsubscribe@...
        > For additional commands, e-mail: asp-help@...
        >

        ---------------------------------------------------------------------
        To unsubscribe, e-mail: asp-unsubscribe@...
        For additional commands, e-mail: asp-help@...
      • Josh Chamas
        ... Helmut is correct. I would like to add that since mod_perl & Apache are multi-process, they don t share memory, so all this session state is stored to
        Message 3 of 6 , Feb 4, 2004
          Helmut Zeilinger wrote:
          > Hi Chris,
          >
          > the reason for the data size limit is, that the SDBM hash size
          > limit is 1024 bytes for the key + the value.
          >
          > You can store more data if you use DB_File or MLDBM::Sync::SDBM_File
          > for storing the data.
          >
          > But see "man Apache::ASP", Section "State Management" (StateDB).
          >
          > Regards
          >
          > Helmut
          >

          Helmut is correct. I would like to add that since mod_perl & Apache
          are multi-process, they don't share memory, so all this session state
          is stored to disk to allow multi-process data sharing. So basically,
          you want to keep the data going to disk lighter, and only store enough
          to allow your objects to be recreated in memory each request via
          constructors, & not serialize the object to disk/$Session fully each
          request/read/write.

          Consider that each time one does:

          $Session->{object} = {};

          you just wrote to disk. Though DB_File holds more than SDBM_File,
          it is much slower to do basic read/write operations for smaller
          bits of data, and accessing large blocks of data is obviously slow.

          Definitely read the MLDBM::Sync man page for a further analysis of this
          which is the internal state manager used for Apache::ASP.

          Regards,

          Josh

          ________________________________________________________________
          Josh Chamas, Founder phone:925-552-0128
          Chamas Enterprises Inc. http://www.chamas.com
          NodeWorks Link Checker http://www.nodeworks.com


          ---------------------------------------------------------------------
          To unsubscribe, e-mail: asp-unsubscribe@...
          For additional commands, e-mail: asp-help@...
        • Chris Marschall
          Gentlemen, Thanks for the prompt feedback. Of course, the lack of shared memory (multi-threading) explains why it would have to commit all state information
          Message 4 of 6 , Feb 4, 2004
            Gentlemen,

            Thanks for the prompt feedback.

            Of course, the lack of shared memory (multi-threading) explains why it
            would have to commit all state information for each request.

            Thanks also for the DB_File information.

            Much appreciated.

            Regards,

            Chris.

            On Wed, 4 Feb 2004, Josh Chamas wrote:

            > Helmut Zeilinger wrote:
            > > Hi Chris,
            > >
            > > the reason for the data size limit is, that the SDBM hash size
            > > limit is 1024 bytes for the key + the value.
            > >
            > > You can store more data if you use DB_File or MLDBM::Sync::SDBM_File
            > > for storing the data.
            > >
            > > But see "man Apache::ASP", Section "State Management" (StateDB).
            > >
            > > Regards
            > >
            > > Helmut
            > >
            >
            > Helmut is correct. I would like to add that since mod_perl & Apache
            > are multi-process, they don't share memory, so all this session state
            > is stored to disk to allow multi-process data sharing. So basically,
            > you want to keep the data going to disk lighter, and only store enough
            > to allow your objects to be recreated in memory each request via
            > constructors, & not serialize the object to disk/$Session fully each
            > request/read/write.
            >
            > Consider that each time one does:
            >
            > $Session->{object} = {};
            >
            > you just wrote to disk. Though DB_File holds more than SDBM_File,
            > it is much slower to do basic read/write operations for smaller
            > bits of data, and accessing large blocks of data is obviously slow.
            >
            > Definitely read the MLDBM::Sync man page for a further analysis of this
            > which is the internal state manager used for Apache::ASP.
            >
            > Regards,
            >
            > Josh
            >
            > ________________________________________________________________
            > Josh Chamas, Founder phone:925-552-0128
            > Chamas Enterprises Inc. http://www.chamas.com
            > NodeWorks Link Checker http://www.nodeworks.com
            >

            ---------------------------------------------------------------------
            To unsubscribe, e-mail: asp-unsubscribe@...
            For additional commands, e-mail: asp-help@...
          Your message has been successfully submitted and would be delivered to recipients shortly.