I would recommend to not store the session in the DB. Use a cookie if you can store your data in 4kb otherwise look into memcached. (it will autorecycle old sessions)
Regarding: the controller searches for csv's older than a couple days and deletes them. > In theory it's not a bad idea but the only problem is that you are slowing down your request response. In the case of a session and/or shopping cart, I would advise not to do that. If you want to handle the cleaning up in your code, why not creating a clean up action protected by http auth and then call it via curl using a cron job? (this way you don't need to load rails just to potentially clean up some records) I hope that helps. - Matt On Wed, Nov 25, 2009 at 12:45 PM, Scott Olmsted <[email protected]> wrote: > > I have a new client for whom I'm adding a feature to their shopping cart. I > don't think their previous developer quite finished the site; there was an > obvious bug that generated an error when one tried to remove something from > the cart. > > But the surprise was that the database contains 644,000 sessions! That's > 150MB. Also 18,000 shopping carts, all generated in a little over a year, > that's maybe 1600 sessions and 50 carts a day, pretty low volume (they sell > expensive stuff). It would be advisable to set up a cron job to remove old > sessions and carts, yes? But I had another idea. > > On another low volume site I created, some pages displayed tables that > could also be downloaded as csv's. The csv's are generated at the same time > as the displayed table, it was just easier that way. After generation > they're saved to the database, available for download. Rather than add a > cron job to remove old csv's, when a table and new csv are generated, the > controller searches for csv's older than a couple days and deletes them. > > Any problem with doing the same thing on the site with the shopping cart? I > don't think I would add the check to every new session. Maybe when creating > a new cart it could remove old sessions and carts; if that caused a small > delay it would be tolerable, the user is more likely to be patient when > waiting for the cart to first come up. Comments? > > Thanks, > > Scott > > -- > SD Ruby mailing list > [email protected] > http://groups.google.com/group/sdruby -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
