Koozali.org: home of the SME Server

httpd children are swamping my server

Holger

httpd children are swamping my server
« on: September 11, 2002, 07:42:21 PM »
I didn't get any feed back in the "General Discussion" forum so I'll try here...

The question:
Is there a way that I can prevent httpd or PHP to not start more than 3 simultaneous 'convert' (ImageMagick) requests?
Or should I make a cron job that kills extra processes (seems a primitive way to do it)?

The issue:
One of the best uses of my e-smith server, is my online photo albums containing pictures of event thats I have participated in with family, friends and colleagues.
I am using Yappa (see the howto section) and it is a brilliant PHP app.

Yappa scales the pictures the first time they get a hit and saves the scaled pictures for subsequent requests.

But my server gets swamped every time I announce that a new photo section is up. It just takes 4 or 5 simultaneous requests to pictures that are not yet scaled and all of my 128MB are used. The swapd will go bananas and nothing gets through after that - I can't even make an ssh connection anymore.


Thanks!

Rich Lafferty

Re: httpd children are swamping my server
« Reply #1 on: September 11, 2002, 08:19:28 PM »
You'd have to modify Yappa to behave nicely, since it's the one running
convert. Personally, I'd take another approach -- since converting on first
view is suboptimal for your setup, where first views all happen at once,
why not convert first? Put up your album, and either manually or with
a little script go through and request each picture so they're already
converted, and *then* announce it.

(I like marginalhacks album as a gallery program, because it does just that --
you run it once on a directory of pictures, and it produces a static HTML
gallery, so there's nothing to run when people come to see the pictures.)

Cheers,
--Rich

Charlie Brady

Re: httpd children are swamping my server
« Reply #2 on: September 11, 2002, 08:38:20 PM »
Rich Lafferty wrote:

> You'd have to modify Yappa to behave nicely, since it's the
> one running convert.

No,  you could simply limit the number of Apache processes in httpd.conf.

Charlie

Rich Lafferty

Re: httpd children are swamping my server
« Reply #3 on: September 11, 2002, 08:55:59 PM »
Well, if it was acceptable for the httpd to refuse connections while images
were being resized, that would work, but that sort of beats the point of
putting the gallery up on the web in the first place, I think :-)

Holger

Re: httpd children are swamping my server
« Reply #4 on: September 12, 2002, 12:26:29 AM »
Thanks for the input!

I really like the concept of yappa - I just drop pictures in folders and everything else is done as needed.
Also that it only scales the pictures in the resolutions that are requested. No more, no less.

I would be willing to do the limiting of http threads hack (it is a hack right?) if it doesn't mean broken connections.

New question:
Does Apache reject connections when the limit is hit or does it just defer them?

Filippo Carletti

Re: httpd children are swamping my server
« Reply #5 on: September 12, 2002, 06:54:36 PM »
> New question:
> Does Apache reject connections when the limit is hit or does
> it just defer them?

Defer, until the client timeout is reached.