Random Photo Returns

The random photos are back. I wrote a quick hack to loop over every photo in every album and read its relevant info into a MySQL table. Now instead of taking a few seconds to get a random photo using the Gallery data stores, it uses a single query and takes a millisecond. Long-time visitors to the site remember that the random image in the corner has always been one of my favorite things about this site, but as the photolog grew to a thousand, two thousand, and then nine thousand images it slowed down more and more. I had to start caching it so it would change once every 15 seconds, then every minute, then every 5 minutes, and then I just manually rotated it for a while. Finally I put the random image out of its misery.

Now it’s fully dynamic, every page you view is completely unique, just like you.

(There goes my bandwidth.)

24 thoughts on “Random Photo Returns

  1. There goes my bandwidth.

    Indeed! Nine thousand photos is a whole lot, I can imagine those take up a lot of server space. (Poor me, I’ve only got 75 MB on my server, with a bandwidth limit of 5 GB…)

  2. Nine thousand photos? Wow. Maybe you should have your randomizer provide a unique photo when a visitor comes back, without serving a photo twice. Until all 9000 photos are delivered for that visitor. Then another shuffle, and the same cycle all over again…

    Just another stupid idea. 😉

  3. Thought bandwidth was a commodity which one doesn’t have to worry about anymore? 😉

    Anyhoo… good to see it back as I’m using Gallery’s native “Random Block” feature on a friend’s site since June-ish, and finally gave in and started using it on my own blog just a couple weeks ago.

    F5 F5 F5 F5 F5 😀

    /me feels dirty in misusing <code> when he should have used <kbd>…

  4. Reload to your heart’s content, that is what it’s there for. I use a lot of bandwidth, but it’s still a fraction of what’s available. Besides, what is the point of bandwidth if you don’t enjoy it?

  5. Groovy. Tunes. Thanks, Matt! I use Gallery to organize as well as to present, and I don’t think anyone wants to be bombarded with random clip art or blobs. 😀