in reply to 2 Questions on Images and Mod_perl mem usage

Hi,

Erm, you should use thumbnails, for every photo uploaded you make a small thumbnail on the way. I recommend you not doing resizing on the fly when a person is viewing the page, because it's slow once you have a lot of pages/users. On the other side if you have a photo of 2mb, and you show this image on a <img> defining smaller width and height, the server send the 2mb size image to the client, and the browser will do the "scaling"... Take a look at projects around treating the same situation.

Imager and Image::Magick are great modules for doing all this kind of stuff (changing images and so).

I have seen other approaches instead of creating and managing the thumbnails, was using Mason caching the thumbnails, so the first time it takes a few ms. more but once you have a cached thumbnail, it's like having the file normally around on your filesystem. See here.

I can't tell you if this is normal, since I don't see your code, but normally you can do some optimisations... ;-)

I think that you should write clean code, since memory is cheap, and today there is no problem to have 512mb or 1024mb on your webserver. Using mod_perl: than more memory than better.

Regards,

|fire| at irc
  • Comment on Re: 2 Questions on Images and Mod_perl mem usage

Replies are listed 'Best First'.
Re^2: 2 Questions on Images and Mod_perl mem usage
by Anonymous Monk on Jul 02, 2005 at 00:30 UTC
    Thanks, I am looking at the image magick stuff, lil confused but ill play with it :)

    My webserver has 6gigs of memory, and is setup for 700 max clients. With all the sites combined I have a traffic load of about 1000 people at any given time. It still runs fast even though it is queing people but looking at my server stats, I have a nice steady increase of traffic every week for past year, so being able to have more max clients would defiantly help.

    An Example

    print &first;
    print &second;

    sub first() {
    my $key = "1";
    return $key;
    }

    sub second() {
    my $key = "2";
    return $key;
    }

    If I made $key a global would it be more efficent memory wise?

      Before taking time reading Image::Magick take a look at Imager first... ;-)

      Wow, our corporate webserver has 512 Mb running mod_perl + Mason.

      The example you put, you don't need to create this vars... but anyway, I understand what you mean, but you must see your code, and think about what optimisation you can do. I like to use global variables only where is necessary or is a really benefit.

      There are modules where you can see where is consuming more time, etc., take a look for Devel::.

        Well I am just not sure if my webserver is holding variable space for variables in subs that aren't being used.

        The script is 10k+ lines so posting it isn't going to work, but 90% of the time the script is hit it never touchs 75% of the script. But I have subs that read a lot of redudant information from data files, different subs will read the same data file, so they will create local variables to hold that information. If I created these redudant variables as globals, I wouldn't be reserving space for the same set of variables in different subs?

        I am not sure how it works, why I am asking. Does apache only use variable space when variables are in use or does it reserve space for every possible variable in my script?
Re^2: 2 Questions on Images and Mod_perl mem usage
by jimX11 (Friar) on Jul 02, 2005 at 15:09 UTC
    Mogrify, which comes with ImageMagick, resizes images.