Don't Forget to Clear Out Your Rails Session Data 4

Posted by Kurt Schrader Tue, 01 Jul 2008 07:01:00 GMT

For the last year or so, this blog has been running slow, slow, slow.

From time to time, I tried to figure out what was going on, but I figured that Typo upgrades were just causing things to slow down and use more and more memory.

Until tonight.

Tonight I did a database dump and it came to 44 MB.

There is no way I have 44 MB of content in this blog.

So I had a look at the dump and realized that I had close to 100000 sessions in the sessions table, and that there was a table for Sitealizer plugin that's no longer part of typo.

So after a drop of the Sitealizer table and a

rake db:sessions:clear

Typo is now using 20% of the memory it was using before, running much, much faster, and the database dump comes to a slim 476 KB in size.

So this is my reminder to myself (and everyone else) to be sure to clear out your sessions table from time to time.

Comments

Leave a comment

  1. Avatar
    netzdamon@gmail.com about 15 hours later:

    why not just create a crontab that does this every week or month, or whatever is best for your site.

    22 4 * * 0 ~/bin/somescript.sh

  2. Avatar
    Kurt Schrader about 18 hours later:

    @netzdamon: Yep, already did that. Probably should have put it in the article.

  3. Avatar
    leethal about 24 hours later:

    Psst! Cookie based session store!

  4. Avatar
    Hodinky 14 days later:

    I made a crontab, and it makes the hardwork :)

Comments