Forum: NGINX reverse proxy vs. stand-alone

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jemari (Guest)
on 2009-05-15 04:34
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,2049,2049#msg-2049
Cliff W. (Guest)
on 2009-05-15 04:43
(Received via mailing list)
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
Igor S. (Guest)
on 2009-05-15 09:30
(Received via mailing list)
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 ?
Cliff W. (Guest)
on 2009-05-15 11:57
(Received via mailing list)
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
Igor S. (Guest)
on 2009-05-15 19:08
(Received via mailing list)
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 W. (Guest)
on 2009-05-15 20:24
(Received via mailing list)
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
AMP Admin (Guest)
on 2009-05-15 22:19
(Received via mailing list)
Cliff, what did your Core SEF for Joomla! from .htaccess look like after
converting to nginx?
Cliff W. (Guest)
on 2009-05-15 22:47
(Received via mailing list)
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
Claude B. (Guest)
on 2009-05-15 22:53
(Received via mailing list)
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. <removed_email_address@domain.invalid> 
wrote:

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


--

Bill Cosby <http://www.brainyquote.com/quotes/authors/b/bill_c...
-
"Fatherhood is pretending the present you love most is soap-on-a-rope."
Igor S. (Guest)
on 2009-05-15 22:55
(Received via mailing list)
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;
  }
AMP Admin (Guest)
on 2009-05-15 23:20
(Received via mailing list)
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.
Cliff W. (Guest)
on 2009-05-17 07:54
(Received via mailing list)
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
jemari (Guest)
on 2009-05-17 20:13
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,2049,2115#msg-2115
Cliff W. (Guest)
on 2009-05-18 00:56
(Received via mailing list)
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
This topic is locked and can not be replied to.