Reverse proxy vs. stand-alone

Hi everyone,

I am setting up a small VPS. My plan is to have nginx as a reverse proxy
to apache2 (running with mod-php). All other static files will be served
by nginx.

Does anyone know if there would be a significant difference in
performance and/or stability if I removed apache, and have nginx use
fcgi for php?

Thx.

Posted at Nginx Forum:

On Thu, 2009-05-14 at 20:24 -0400, jemari wrote:

Hi everyone,

I am setting up a small VPS. My plan is to have nginx as a reverse
proxy to apache2 (running with mod-php). All other static files will
be served by nginx.

Does anyone know if there would be a significant difference in
performance and/or stability if I removed apache, and have nginx use
fcgi for php?

Yes, you’d save hundreds of megabytes of RAM by not using Apache, which
will undoubtedly affect performance in a positive fashion.

Cliff

On Thu, May 14, 2009 at 05:36:15PM -0700, Cliff W. wrote:

Yes, you’d save hundreds of megabytes of RAM by not using Apache, which
will undoubtedly affect performance in a positive fashion.

Would not these megabytes go to php/FastCGI ?

On Fri, 2009-05-15 at 09:19 +0400, Igor S. wrote:

performance and/or stability if I removed apache, and have nginx use
fcgi for php?

Yes, you’d save hundreds of megabytes of RAM by not using Apache, which
will undoubtedly affect performance in a positive fashion.

Would not these megabytes go to php/FastCGI ?

Not really. PHP under FastCGI seems to use a lot less resources than
mod_php. I assume this is because the number of threads is a constant
with PHP under FCGI.

I converted a Joomla site from Apache/mod_php to Nginx/FastCGI and went
from constantly consuming the full 256MB (and crashing the VPS) to using
only around 20MB of RAM.

Regards,
Cliff

On Fri, 2009-05-15 at 18:55 +0400, Igor S. wrote:

be served by nginx.
Not really. PHP under FastCGI seems to use a lot less resources than
MinSpareServers 20
MaxSpareServers 20
MaxClients 20

StartServers 3
MinSpareServers 3
MaxSpareServers 10
ServerLimit 10
MaxClients 10
MaxRequestsPerChild 2000

I tried both prefork and worker MPM.

Apache and PHP would still exhaust the 256MB RAM in the VPS once a week
or so and force a restart of the entire VPS. Someone suggested that
using FastCGI with Apache might help, but I never got around to trying
it before switching the site over to Nginx.

Cliff

On Fri, May 15, 2009 at 12:48:28AM -0700, Cliff W. wrote:

Does anyone know if there would be a significant difference in
with PHP under FCGI.

I converted a Joomla site from Apache/mod_php to Nginx/FastCGI and went
from constantly consuming the full 256MB (and crashing the VPS) to using
only around 20MB of RAM.

Have you tried to set

StartServers 20
MinSpareServers 20
MaxSpareServers 20
MaxClients 20

?

Cliff, what did your Core SEF for Joomla! from .htaccess look like after
converting to nginx?

On Fri, 2009-05-15 at 13:09 -0500, AMP Admin wrote:

Cliff, what did your Core SEF for Joomla! from .htaccess look like after
converting to nginx?

This is all I used:

http://wiki.nginx.org/NginxJoomla

It’s someone else’s site (my VPS), so I’m not 100% certain of any Joomla
settings (from the admin interface) might come into play.

Cliff

Apache using PHP FastCGI uses a ton less memory than mod_php. Granted
I
have 1GB of RAM serving 6 drupal sites, but with one site, it would
definitely take less than 256 MB

On Fri, May 15, 2009 at 8:38 PM, Cliff W. [email protected] wrote:

settings (from the admin interface) might come into play.

Cliff

Bill Cosby http://www.brainyquote.com/quotes/authors/b/bill_cosby.html

“Fatherhood is pretending the present you love most is soap-on-a-rope.”

On Fri, May 15, 2009 at 11:38:34AM -0700, Cliff W. wrote:

On Fri, 2009-05-15 at 13:09 -0500, AMP Admin wrote:

Cliff, what did your Core SEF for Joomla! from .htaccess look like after
converting to nginx?

This is all I used:

http://wiki.nginx.org/NginxJoomla

This

location / {
expires 30d;
error_page 404 = @joomla;
log_not_found off;
}

location @joomla {
rewrite ^(.*)$ /index.php?q=$1 last;
}

should be

location / {
expires 30d;
error_page 404 = /index.php?q=$uri;
log_not_found off;
}

or

location / {
expires 30d;
try_files $uri /index.php?q=$uri;
}

On Fri, 2009-05-15 at 14:09 -0500, AMP Admin wrote:

I looked at that. I’m not sure how that would take care of the pretty urls
(Core SEF) part. Oh wait… was it an older version or 1.5.x of Joomla?

It’s a fairly recent install. The SEF urls did work at one point, but
a Joomla upgrade broke that.

Cliff

I looked at that. I’m not sure how that would take care of the pretty
urls
(Core SEF) part. Oh wait… was it an older version or 1.5.x of Joomla?

Btw, thanks for your reply.

Thanks to everyone for taking your time in replying.

My question was asked my Igor: how about the FastCGI php processes?
Would the difference be really that significant if nginx is serving all
non-php requests? In which case, apache doesn’t need many modules?

Cliff W. Wrote:

I converted a Joomla site from Apache/mod_php to
Nginx/FastCGI and went
from constantly consuming the full 256MB (and
crashing the VPS) to using
only around 20MB of RAM.

@Cliff
was your joomla site using nginx proxy before you converted to
Nginx/FastCGI?

–Jemari

Posted at Nginx Forum:

On Sat, 2009-05-16 at 18:59 -0400, jemari wrote:

Thanks to everyone for taking your time in replying.

My question was asked my Igor: how about the FastCGI php processes?
Would the difference be really that significant if nginx is serving
all non-php requests? In which case, apache doesn’t need many modules?

It’s not the modules that make Apache bloat, it’s the threads. On the
site I mentioned, I removed almost every module I could. It didn’t
help.

Cliff