

Running Apache On A Memory-Constrained VPS - dmytton
http://www.kalzumeus.com/2010/06/19/running-apache-on-a-memory-constrained-vps/

======
irrelative
A lot of the math in this is a little... strange. For instance:

"20 * 60 * 5 = 60k satisfied clients a minute"

Hmm, that's a lot closer to 6k in my mind :-)

Also:

"The throughput of the server went from about 60k requests per second to about
380 requests per second"

The original (incorrect) calculation supposedly took place at 60k per minute,
not per second.

Not trying to be a stickler for accuracy, but I feel like it matters when
dealing with benchmarks.

------
ck2
I swear we covered this recently. Oh here it is.

<http://news.ycombinator.com/item?id=1413446>

Different source but same concepts, I'll repeat what I said then.

Takes more than 5 minutes but worth the effort: replace Apache.

Nginx, Lighttpd, Cherokee, Zeus, LiteSpeed, etc. All use far fewer resources.

~~~
ay
To give some factual support to the parent's argument: I run lighttpd+fcgi-
lua+redis comfortably on a 128M VPS, which according to my benchmarks is
capable of serving between 200 and 400 requests per second on the dynamic
page. With about half of the RAM free, still.

------
sillicongal
You can also install nginx with apache running on reverse proxy.

<http://aruljohn.com/info/nginx/>

~~~
patio11
A couple of years ago, I would have said "That's wonderful advice because
Nginx excels at serving static files and Apache is needed for the dynamic
requests", but today only one of these is still true. The technique will
certainly still work, though.

If I ever get a few hours to install Nginx and write config files for a few
dozen PHP sites (blarg), I'm going to get rid of Apache altogether.

~~~
jeb
Why is it so hard to break nginx vs apache? What's the core difference?

~~~
bradleyland
Core difference: the request processing model. Nginx uses the "hot new" event-
loop model. It's a good model, but I find that most people overstate the
performance difference and resource usage.

The bigger problem is that Apache comes configured "out of the box" on most
distros with a whole slew of options that you probably don't need. Even having
said that, most people _think_ that Apache is using more resources than it is.
They see all these processes floating around in `top` and they freak out. See
my post in the other thread (linked in parent) for more info on that.

Most of the concern is driven by ignorance rather than deep understanding. I
can feel the searing burn of Nginx fans' glare, so let me qualify that. YES,
Nginx is a fantastic web server. YES, pound-for-pound, it is more resource
efficient than Apache. The catch is, if you trim Apache down to do only what
you need, the margin between it and Nginx becomes much smaller. If you really
know Apache well, then you don't necessarily need to switch to Nginx, just
because it's hot and new.

If you don't know Apache well enough to scale it, or if you're really, really
tight on resources (you can't afford a 10% bump in VPS RAM), then you should
probably learn Nginx straight away, because it's a fantastic web server. Hell,
every Apache admin ought to learn Nginx, because you will no doubt learn
something in the process.

~~~
sirn
> _The catch is, if you trim Apache down to do only what you need, the margin
> between it and Nginx becomes much smaller. If you really know Apache well,
> then you don't necessarily need to switch to Nginx, just because it's hot
> and new._

Care to elaborate? I used to do that few years ago for static serving, from
tuning Min/MaxSpareServers, measuring resource usage and speed of
worker/prefork MPMs to strip out all modules to bare minimum and I still can't
get the margin between Nginx and Apache to be any close.

~~~
Daniel_Newby
How are you measuring resource consumption? Memory consumption often includes
_a lot_ of shared virtual memory, where multiple Apache threads/processes
simultaneously use the same physical memory.

~~~
sirn
Resident size. Normally ps -o rss,ucomm

