Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My web host only provides 64-bit OS, but the 64-bit Apache webservers take too much memory and occasionally lead to thrashing, under not too much external load.

Is there any way to configure Apache to use less memory, or do you suggest any other configuration?

My server has 256MB RAM and runs one wordpress and two other subdomains with static pages.

Current Apache process configs as shown by Webmin are:-

Min processes: 10

Max processes: 15

Initial startup processes count: 8

Max simultaneous connections per process: 4000

Update:- Right now I see 11 Apache processes running each taking about 360MB of RAM on my 256MB system!

share|improve this question
1  
Why are you running a 64-bit OS on 256 MB of RAM? –  Ignacio Vazquez-Abrams Jul 4 '11 at 22:27
1  
I'd go further, Ignacio -- why do you even have a server with 256MB of RAM? –  womble Jul 4 '11 at 22:33
    
Probably a VPS..? –  Kyle Smith Jul 4 '11 at 23:07
    
Yes, but why would you get a 256MB VPS, especially when your capacity planning should have determined that you'd need X apache processes at Y MB each, and X*Y > 256? –  womble Jul 5 '11 at 0:15
    
Well.. This is the one I could afford, and my service provider only provides 64-bit. Now why I chose this service provider is another story. –  AppleGrew Jul 5 '11 at 4:10

2 Answers 2

up vote 5 down vote accepted

If you really think it'll make a difference, just install a 32-bit Apache binary and modules and run that instead. That's the only way to "make 64-bit Apache behave as 32-bit". It's not simple, and a maintenance nightmare, though -- I wouldn't recommend it.

There are a pile of ways to make Apache use less memory, but you're making incremental gains there, and if you've got only 256MB of RAM to play with, you're going to need a big change -- and nginx is the one I'd recommend. It doesn't spawn dozens of workers, and each of the 2-4 it does use only take a few MB each (the one in front of me at the moment, running about a dozen vhosts, is taking up 2448kB resident).

share|improve this answer
    
This brings me to one fundamental question. On an average how my requests can a single process handle? Or the more fundamental question would why do we need multiple processes running? –  AppleGrew Jul 5 '11 at 5:00
1  
There is a good article on optimizing Apache/MySQL for low memory here: emergent.urbanpug.com/?p=60 I would second the idea to use Nginx though - the difference will be substantial. –  cyberx86 Jul 5 '11 at 5:03
    
@cyberx86 I am trying to understand what difference the multiple number of processes make in Apache. Is running one process of Apache is equivalent to running (say) 3 processes of Nginx? I mean what are the use cases for Apache v/s Nginx? –  AppleGrew Jul 5 '11 at 11:47
1  
Apache requires one process per connection, while Nginx does not - Nginx usually scales better. Additionally, each Apache process tends to use more memory - each module takes some memory and all are loaded with each process (one of the benefits php-fpm has over than mod_php). Nginx uses an evented model and will use a single worker process for many connections. Apache offers more features, but for most circumstances, Nginx offers better performance and uses less memory. If you require the features of Apache, consider at least using Nginx as a reverse proxy and serving static files with it. –  cyberx86 Jul 5 '11 at 13:49

This has nothing to 32bit vs. 64bit.

Why do you think 15 Processes at 60MB each (just a guess) will use less than 900MB of memory when running on a 32bit architecture?

I'd rather run some numbers.

  • How much memory does each process take
  • How many processes do you want/need to run
  • Is running fcgi with nginx an option (not that apache is bad, it's just easier to calculate)?
share|improve this answer
1  
64 bit processes do take up more memory than 32 bit ones... every pointer is twice the size, for a start. –  womble Jul 5 '11 at 0:16
    
I know that, I can't prove it but my feeling is the problem isn't with 64bit but rather with 256MB of RAM vs. the Apache Config. I have yet to see a situation where it actually helps to run on 32bit vs. 64bit -- that is for a general purpose thing like apache –  Server Horror Jul 5 '11 at 18:47
    
I have seen the difference, and it can be considerable. However, I agree that a 256MB VM isn't going to cut the mustard running Apache with any sort of reasonable load, and that's the primary source of the OP's pain. –  womble Jul 5 '11 at 22:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.