in reply to Re: Session management
in thread Session management

I have implemented the whole session details using database. But i believe there is a better way than storing in database or say may be in a file. If details such as this i.e. session details which has to be accessed regularly on all the web page, it is awfull to make so many database transaction. So if we can somehow maintain the session details in Shared variable of apache. Then the task would have been more easier. can you suggest me whether wat i ve thought is correct or wrong? if it is wright, Do you have any solution.

Replies are listed 'Best First'.
Re^3: Session management
by Herkum (Parson) on Apr 17, 2006 at 13:09 UTC

    There are only two places you can store data, disk(hard drive) and memory(RAM). If you use to much memory, then the system will put the information on disk in the pagefile and you are not getting anywhere. All you are doing is pushing the problem around, you are not necessarily improving performance.

    If you want to improve performance, do benchmark tests FIRST do see what and where your performance issues are before implementing a solution without understanding the problem.

    Refer to the discussion on the XY Problem which is what you are really doing

Re^3: Session management
by davido (Cardinal) on Apr 17, 2006 at 07:23 UTC
Re^3: Session management
by perrin (Chancellor) on Apr 17, 2006 at 15:56 UTC
    You are making guesses about what will be faster. Have you done any benchmarks? In my benchmarks, simple database access with MySQL based on a primary key is faster than the shared memory options available for Perl. This is because the perl data has to be serialized before writing to shared memory and de-serialized on the other end, and because the memory chunks tend to be quite large and require reading or writing much more data than the small piece needed for a single session.

    If you are really having problems with the performance of database storage (and have already followed the performance suggestions in the DBI documentation) you should look at BerkeleyDB, which uses shared memory for caching. That's the fastest option. Cache::FastMmap is also fast, but is a cache and can drop data if it gets full, so think about how you plan to use it.

Re^3: Session management
by fmerges (Chaplain) on Apr 17, 2006 at 09:44 UTC

    Hi,

    I wouldn't do that

    You don't need to do transactions on the DB, you just need to lookup, if something get modified (added a new product to the basket, f.e., then you do an update)... Accessing to a local database to do a lookup of data, sometimes is faster than looking up on the fs (for example if you have to schedule files or so)... The FS one is the simpliest and it works in any case...

    If you use shared mem, you could use the key of the session itself to identify it, but things are thought for having an "amount" of users visiting the web, where it is not "the best way" to having a endless growing shared mem, only because you don't like the "normal" way of doing it. And don't forget that the amount of memory freed of a process will return to the interpreter, not the system...

    Regards,

    fmerges at irc.freenode.net