in reply to Re: Compressing data structures for cookies
in thread Compressing data structures for cookies

I'm already using a local variant of CGI::Session to store data server-side. The problem is that there are two machines which run the program, and a user could be directed to either of the two (the sys admin says that each user is usually sent to the machine they were previously on, but it can't be guaranteed every time). The other thing is that the volume of users is such that it is not feasible to keep the session data for every person, and it would be better for users to be able to have their settings persist between sessions.

I just re-checked the maximum size of the data structure as the original estimate had extra unneeded info in it; it's 402 bytes (as a file), and most user settings would probably be half that.

  • Comment on Re^2: Compressing data structures for cookies

Replies are listed 'Best First'.
Re^3: Compressing data structures for cookies
by Herkum (Parson) on May 09, 2007 at 11:31 UTC

    If you are using CGI::Session with a database, having multiple machines would not be a problem. The reason for this is that the user would just a Session ID cookie. The session ID would correspond with a primary key on a 'sessions' table in the database. The database would contain all user settings and can store whatever information that they need for the duration of the session.

    All you would have to do is point both web services to the same database where the session data is stored. Now it would not matter which server you go to and you can add a third or a fourth server, etc... and you would not have to change anything.

    This would also apply to data as well. You can expand the number of user settings from your 402 bytes to 3 or 4 KB and you not have to change anything.

    The other thing is that the volume of users is such that it is not feasible to keep the session data for every person

    You have to keep the data somewhere. You stated that currently that the settings take up 402 bytes. Than means 1 MB can store settings for 2600 users. That is not much storage space at all.

    , and it would be better for users to be able to have their settings persist between sessions.

    If the data is persistent and is not needed for a particular session then store it in a table. You need someway of identifying the user, create a 'user' table and put everything in there.

    Databases are not a limitation, they can manage thousands and even millions of records and gigs of data.

    Cookies are what are limiting, move away from using them so much.

Re^3: Compressing data structures for cookies
by Anonymous Monk on May 13, 2007 at 21:20 UTC
                            /- prog 1  -\
    client - load balancer -            - database
                            \- prog 2  -/