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.

I have a Xen virtual private server (VPS) running Ubuntu 8.10, with 128M RAM.

I've found several "how to optimize Apache and MySQL for low-memory VPS" pages via Google, but they provide contradictory information. So I'm asking Server Fault: how does one optimize Apache and MySQL for a low-memory VPS configuration?


A couple of people have suggested using nginx instead of Apache. I'll look into that, but I'd prefer to stick with Apache if possible, just to avoid having to learn all about configuring application stacks on top of an unfamiliar (to me) web server.

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Nginx is great, but if you want to stick with Apache, it's possible to slim it down quite a bit from the default settings:

  • Use the worker MPM rather than prefork (with worker MPM Apache no longer has a "process per connection" model).
  • Look at all the shared modules you're loading, get rid of any that you don't need.
  • Avoid embedding application servers inside Apache (i.e. mod_python, mod_php, etc) if you can avoid it. Instead, run application servers in a separate process and have Apache proxy to them (i.e. for Python code use mod_wsgi in daemon mode). This way your Apache threads that are simply serving static content won't be unnecessarily bloated.
  • In your Apache config, reduce the StartServers, MaxClients, MinSpareThreads, and MaxSpareThreads settings. Depending on your expected load you can sometimes reduce them by a factor of five or more from the default settings.
share|improve this answer

If you have memory constraints, I would recommend using nginx as an alternative if at all possible. It consumes much less memory than Apache and depending on your needs could be all that you need.

As a bonus, nginx tends to be significantly faster than Apache. =)

share|improve this answer

Ditch apache, it's process per connection model will not play will with your low memory VPS.

I suggest nginx as a replacement.

share|improve this answer
4  
This is only an issue for 1.3. apache 2.x allows plugable process modules including MPM which runs many threads in a small number of processes. All tunable to taste –  Vagnerr Apr 30 '09 at 14:09
    
Yes, but nginx will still be a smaller process –  Dave Cheney May 10 '09 at 8:35
2  
Yes, but that's not what you said –  Domster Jun 11 '09 at 1:28

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.