views:

76

answers:

1

Right now I'm running a PHP script on my LAMP (CentOS/Apache/MySQL/PHP) stack that generates dynamic images using GD. I'm caching them on the hard drive for 5 minutes. If a cached version exists, I pull that instead of generating a new one. This saves CPU time, but since Apache is still running the PHP file it generates a new Apache process for each image.

Apache typically ran at about 30MB, I rewrote a good portion of the config and got it down to about 10MB per process. However, with ~30 concurrent processes this adds up quickly. This server also has to serve normal website content. I was wondering if there was a good way to set up another lightweight server, or optimize Apache/PHP further? Here is my prefork setup on 500MB RAM:

StartServers         10
MinSpareServers      20
MaxSpareServers      30
ServerLimit         128
MaxClients          128
MaxRequestsPerChild 256
A: 

but since Apache is still running the PHP file it generates a new Apache process for each image.

...and of course your PHP script checks if there is a cached version before it loads all the PHP code necessary to render a new image?

...and you send caching headers to the client saying how long the cache file is valid for?

...and you are using an opcode cache?

...and you are compressing all non-image content?

How do you get your figure for per-process memory usage? Even 10Mb seems very high - are you sure you are not counting TXT segments each time?

You've shown us part of your config - but are you using SSL? Have you got keepAlives configured? If so, to what?

What does your load profile look like?

What is the problem you are trying to solve here? (make web serving faster? free up resource for something else?)

C.

symcbean