Archive for January, 2009

Rails sessions round two - Turn off by request type

Thursday, January 22nd, 2009

This is a follow up to my previous post about clearing out sessions. It turns out I was pulling a lot of crap sessions from rss feeds and xml requests which I didn’t need. I had over 14k new sessions in less than one day. To help combat this, I came up with a solution to turn sessions off based on a request type. I added this to application.rb file:

session :off, :if => Proc.new { |req| ['xml', 'rss'].include?(req.params[:format]) }

You could ideally just add this to an individual controller, and add :only or :except to it as well, but I wanted to eliminate all of the controllers and actions.

OMFG Sessions!! Clear them out!!

Wednesday, January 14th, 2009

So since my site, jamzee.com has been in production for over a year now, I have gotten ambitious and decided to do some database maintenance. The first thing I did was log into the server and run a:

mysqlcheck -o database -u username -p

This runs a bunch of mysql tasks; repair, optimize, etc. I notice this was taking a long time on one of the tables which happened to be the sessions table. I got suspicious and logged into the database for a peak.

What did I find, LOTS AND LOTS of rows, 150k+. This seemed relatively unnecessary so after some research found out that I can run the following:

rake db:sessions:clear

After some time of running that, we have a nice clear, and smaller database now! Next task is to throw that on a cron, probably run on a weekly interval.

Moral of the story, CLEAR THOSE SESSIONS!

Number of Jamzee Updates!

Thursday, January 8th, 2009

I have made a bunch of new updates to jamzee. They are as follows:

  • Added ability to search for YouTube videos by the URL from youtube.
  • Updated searching functionality to be more friendly and intuitive. You can preview videos and search for more videos on the fly.
  • Added ability to sort playlists videos.
  • Freshened up the main page some.

I have also been playing with working on an official myspace application, although receiving some resistance from myspace regarding the fact that the jamzee site searching through youtube. Hopefully we can work this out with them.