Decrease RAM usage

bravely

Joined: 2005-12-09
Posts: 11
Posted: Fri, 2005-12-09 03:17

Hello,

I am desperatly trying to decrease the RAM usage on gallery, as my host has just disabled my account for overloading the server. I was using over 1 gig of RAM when the normal limit for my host is 48 MB.

What I have done:
Decreased the MySQL key buffer from 16 MB to 8 MB .
Reduced the php_value memory_limit from 24 MB to 16M in my
.htaccess file (Gallery refuses to work under 16 MB)

Are there any other steps I can take to decrease RAM usage? If I decrease the Max clients in httpd.conf, users start getting errors.


Gallery version 2.01
PHP version 5.05
Webserver Apache/1.3.27 (Unix) (Red-Hat/Linux)
Database 4.1.9
Activated toolkits NetPbm, GD, ImageMagick

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-09 11:30
Quote:
Reduced the php_value memory_limit from 24 MB to 16M in my

this won't help. PHP/apache processes just need a certain amount of memory to start and run. that's the basic memory usage which is above 10 MB per process.
from there, G2 needs a certain amount of memory to work. it varies from installation to installation, but ~ 12 MB per request is maybe the minimum.
but the memory usage of G2 is not what you define with the memory_limit. if G2 needs just 12 MB and you have a memory_limit of 64 MB, it won't allocate 64 MB ( + 10 MB ) per process. it will just use up to 64 MB if it needs that much. and if it needs more than 64 MB, it will create an error and die.

so if you set the memory_limit to 16 MB, it just means that G2 processes are more likely to die. but the normal G2 requests don't use more than 16 MB anyway. it won't help you (much) to bring the memory usage down. but administrative tasks in G2 (adding images, running maintenance tasks) are more likely to just die which is bad, because we can't guarantee data integrity if the platform just dies.

Quote:
Decreased the MySQL key buffer from 16 MB to 8 MB .

yeah, that could help, but it will also have an impact on performance.

so you were using more than 1 GB memory? maybe limit the nr of apache workers. nr of apache processes * memory usage per php/apache process = total used memory.

 
mdev

Joined: 2005-12-08
Posts: 17
Posted: Fri, 2005-12-09 14:07
bravely wrote:
I am desperatly trying to decrease the RAM usage on gallery, as my host has just disabled my account for overloading the server. I was using over 1 gig of RAM when the normal limit for my host is 48 MB.

...

If I decrease the Max clients in httpd.conf, users start getting errors.

You have outgrown your host. 48MB is for personal homepages, if that. I mean, that's 3 16MB processes + the root process, meaning you can service 3 simultanious requests, which in practice is 0.75 users as a normal browser uses 4 threads per server to load a page.
Chances are you violate the SLA daily even if you'd only allow yourself on the site.

What you can do while you search for a new host (or upgrade your SLA), is set MaxRequestPerChild to a low value. It'll lower the ammount of memory used as childs are killed off sooner and initialized with default values.

Seriously though, 48MB max memory usage for all processes is way too low. There are a few more tricks you can use, to tackle the MaxClients problem, but that only makes sense if your site has a lot of static images and 48MB would be a reasonable target to make.

 
bravely

Joined: 2005-12-09
Posts: 11
Posted: Fri, 2005-12-09 14:51

What would be the lowest reasonable MaxRequestPerChild setting I can use for a g2 site? What negative affects will this have on users? Will logged in users be booted? Will people get error pages?

 
mdev

Joined: 2005-12-08
Posts: 17
Posted: Fri, 2005-12-09 23:04

MaxRequestPerChild doesn't create errors. It kills off a child after it has handled it's number of requests. A request is done, when the user is done with it.

I can't tell you a reasonable value though. It depends largely on how much memory of a child increases when it services a few gallery requests. The main factor here is that you have too many visitors for your webhost. Not by a bit, but by a huge number. MaxRequestsPerChild probably won't help you much, just decrease the average over time. On peak times, when it's close to it's MaxClients, it won't make a single difference.