Discussion:
Lighttpd or Nginx
r***@webworxshop.com
2011-09-15 23:28:46 UTC
Permalink
Hi All,

I'm looking into swapping out Apache on my server in favour of
something a bit lighter. My requirements are modest, I run mostly PHP
applications (Workpress, Piwik, Roundcube, PhpMyAdmin and ownCloud), but
in future I want to be able to run some Python based stuff. I also need
to be able to use multiple virtual hosts and have an equivalent of
mod_rewrite.

Based on my initial research it looks like I have a choice between
Lighttpd and Nginx. Does anyone out there have any experience with
either of these (or both)? Anyone know which may be most suitable for my
situation or are they both about equal?

Thanks in advance,

Cheers,

Rob Connolly

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Jim Cheetham
2011-09-15 23:48:38 UTC
Permalink
nginx is probably the most current & currently
supported/developed/documented (v1.0 has just been released). My
general non-substantiated feel is that both nginx and lighty will be
about the same in resource consumption terms when lightly loaded, but
I'd trust nginx to handle significant load better.

All your apps will have to run as FCGI, which may take you a little
time to get comfortable with, or proxied to an application server like
Apache (and your efficiency gains there are in making a more complex
nginx config so that it handles static content &c, and doesn't send
invalid requests down to the app server)

While you're swapping out apache, consider swapping out mysql for
sqlite at the same time, if you don't really have a lot of write
traffic it significantly reduces your overheads.

Your phpmyadmin should not be accessible from your public IP address
in the first place, so leave that on apache and bind it to localhost
only, much safer.

I note that nginx is also an IMAP proxy, although I've never used it
for that. Seeing as you have roundcube you probably have an imap
server, so it might be interesting to look at that too.

-jim

On Fri, Sep 16, 2011 at 11:28 AM, <***@webworxshop.com> wrote:
> Hi All,
>
> I'm looking into swapping out Apache on my server in favour of something a
> bit lighter. My requirements are modest, I run mostly PHP applications
> (Workpress, Piwik, Roundcube, PhpMyAdmin and ownCloud), but in future I want
> to be able to run some Python based stuff. I also need to be able to use
> multiple virtual hosts and have an equivalent of mod_rewrite.
>
> Based on my initial research it looks like I have a choice between Lighttpd
> and Nginx. Does anyone out there have any experience with either of these
> (or both)? Anyone know which may be most suitable for my situation or are
> they both about equal?
>
> Thanks in advance,
>
> Cheers,
>
> Rob Connolly
>
> _______________________________________________
> NZLUG mailing list ***@linux.net.nz
> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
>

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
r***@webworxshop.com
2011-09-16 02:11:21 UTC
Permalink
On Fri, 16 Sep 2011 11:48:38 +1200, Jim Cheetham wrote:
> nginx is probably the most current & currently
> supported/developed/documented (v1.0 has just been released). My
> general non-substantiated feel is that both nginx and lighty will be
> about the same in resource consumption terms when lightly loaded, but
> I'd trust nginx to handle significant load better.
>
> All your apps will have to run as FCGI, which may take you a little
> time to get comfortable with, or proxied to an application server
> like
> Apache (and your efficiency gains there are in making a more complex
> nginx config so that it handles static content &c, and doesn't send
> invalid requests down to the app server)
>

Yes, I suspected I would have to use FCGI, that's fine. Given I want to
lose Apache completely I don't think it will be sticking around to serve
applications.

> While you're swapping out apache, consider swapping out mysql for
> sqlite at the same time, if you don't really have a lot of write
> traffic it significantly reduces your overheads.

That's definitely something to think about, though I will need proper
migration tools for all the applications I use as well as a phpMyAdmin
equivalent for sqlite.

>
> Your phpmyadmin should not be accessible from your public IP address
> in the first place, so leave that on apache and bind it to localhost
> only, much safer.
>

Currently, phpMyAdmin is running over HTTPS only. I tried having it
accessible only from localhost, but I couldn't get it access to it over
ssh.

> I note that nginx is also an IMAP proxy, although I've never used it
> for that. Seeing as you have roundcube you probably have an imap
> server, so it might be interesting to look at that too.
>

You guess correctly, sounds interesting.

Cheers,

Rob

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Cliff Pratt
2011-09-16 05:36:07 UTC
Permalink
On 16/09/11 14:11, ***@webworxshop.com wrote:
>
>> All your apps will have to run as FCGI, which may take you a
>> little time to get comfortable with, or proxied to an application
>> server like Apache (and your efficiency gains there are in making a
>> more complex nginx config so that it handles static content &c, and
>> doesn't send invalid requests down to the app server)
>>
>
> Yes, I suspected I would have to use FCGI, that's fine. Given I want
> to lose Apache completely I don't think it will be sticking around to
> serve applications.
>
You are swapping a purpose built module in a fully functional web server
for a problematic external program that is generalised for all uses that
interfaces with a webserver that does nothing but pass off requests to
the external program. I'm not sure where you expect to win here.

Cheers,

Cliff

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Steve Holdoway
2011-09-16 06:14:45 UTC
Permalink
On Fri, 2011-09-16 at 17:36 +1200, Cliff Pratt wrote:
> On 16/09/11 14:11, ***@webworxshop.com wrote:
> >
> >> All your apps will have to run as FCGI, which may take you a
> >> little time to get comfortable with, or proxied to an application
> >> server like Apache (and your efficiency gains there are in making a
> >> more complex nginx config so that it handles static content &c, and
> >> doesn't send invalid requests down to the app server)
> >>
> >
> > Yes, I suspected I would have to use FCGI, that's fine. Given I want
> > to lose Apache completely I don't think it will be sticking around to
> > serve applications.
> >
> You are swapping a purpose built module in a fully functional web server
> for a problematic external program that is generalised for all uses that
> interfaces with a webserver that does nothing but pass off requests to
> the external program. I'm not sure where you expect to win here.
>
> Cheers,
>
> Cliff
>
Try it Cliff... performance and footprint are the two major gains.
Having an external program waiting for input provides a far lower
latency than apache having to crank up a module. And in a multi-owner
environment, you have to run (f)cgi even with apache. Yes, you'll need
to learn a few new tuning skills, but that all adds to the fun doesn't
it?

I have migrated a few dozen PHP - based sites ( mainly Magento and
WordPress ) from Apache/mod_php to nginx + php-fpm. The difference is
stunning, especially when you include some basic MySQL tuning in there
as well.

Here's one example which I did yesterday. EC2 medium instance using
Magento and Wordpress. Went to nginx 1.0.6 ( latest - unfortunately
built from source ) and php-fpm 5.3.x. The load on the server dropped by
40%, and page draw is now below a second - enough of an improvement for
the owner to comment on the difference.

I also maintain a lighty - based site. It's on a small EC2 instance, so
you're not really going to get any decent performance out of it anyway.
I have a few queries about edge cases in their rulesets, although that's
probably down to me not reading up enough ( another major point to
make... quality of docs will come as a shock after apache! ).

My current preference is to use nginx, php-fpm and APC to serve sites
like these. It's the best way to maximise your performance, especially
on a server of limited means - a low end VPS for example.

Also debian squeeze does win here bigtime - nginx 1.0.5 included, and
php 5.3.8 available from dotdeb.

My $0.02,

Steve

--
Steve Holdoway BSc(Hons) MNZCS <***@greengecko.co.nz>
http://www.greengecko.co.nz
MSN: ***@greengecko.co.nz
Skype: sholdowa
Cliff Pratt
2011-09-16 07:51:01 UTC
Permalink
On 16/09/11 18:14, Steve Holdoway wrote:
> On Fri, 2011-09-16 at 17:36 +1200, Cliff Pratt wrote:
>> On 16/09/11 14:11, ***@webworxshop.com wrote:
>>>
>>>> All your apps will have to run as FCGI, which may take you a
>>>> little time to get comfortable with, or proxied to an application
>>>> server like Apache (and your efficiency gains there are in making a
>>>> more complex nginx config so that it handles static content&c, and
>>>> doesn't send invalid requests down to the app server)
>>>>
>>>
>>> Yes, I suspected I would have to use FCGI, that's fine. Given I want
>>> to lose Apache completely I don't think it will be sticking around to
>>> serve applications.
>>>
>> You are swapping a purpose built module in a fully functional web server
>> for a problematic external program that is generalised for all uses that
>> interfaces with a webserver that does nothing but pass off requests to
>> the external program. I'm not sure where you expect to win here.
>
> Try it Cliff... performance and footprint are the two major gains.
> Having an external program waiting for input provides a far lower
> latency than apache having to crank up a module.
>
But it doesn't have to repeatedly crank up a module every time. The only
time anything gets 'cranked up' is when a new fork is required, which
admittedly would have a cost.

I don't know how FastCGI/FCGI works but in my experience CGI means slow,
slow, slow. Each call from the web server to the CGI program requires a
new 'connection' (SHM, socket or network connection) to be set up and
then torn down.
>
> And in a multi-owner
> environment, you have to run (f)cgi even with apache. Yes, you'll need
> to learn a few new tuning skills, but that all adds to the fun doesn't
> it?
>
> I have migrated a few dozen PHP - based sites ( mainly Magento and
> WordPress ) from Apache/mod_php to nginx + php-fpm. The difference is
> stunning, especially when you include some basic MySQL tuning in there
> as well.
>
I find that surprising. Did you compile the module into Apache?

Cheers,

Cliff

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Hadley Rich
2011-09-16 08:06:13 UTC
Permalink
On Fri, 2011-09-16 at 19:51 +1200, Cliff Pratt wrote:
> I don't know how FastCGI/FCGI works

That's probably the issue.

FCGI is a long running process, very little overhead to serve a request.
With it, you also don't have to load the entire PHP/Python/whatever
interpreter into all your web server's thread/processes. This means
those serving static files don't need to consume 20~50MB each.

hads
--
http://nicegear.co.nz


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
r***@webworxshop.com
2011-09-16 06:36:40 UTC
Permalink
On Fri, 16 Sep 2011 17:36:07 +1200, Cliff Pratt wrote:
> On 16/09/11 14:11, ***@webworxshop.com wrote:
>>
>>> All your apps will have to run as FCGI, which may take you a
>>> little time to get comfortable with, or proxied to an application
>>> server like Apache (and your efficiency gains there are in making a
>>> more complex nginx config so that it handles static content &c, and
>>> doesn't send invalid requests down to the app server)
>>>
>>
>> Yes, I suspected I would have to use FCGI, that's fine. Given I want
>> to lose Apache completely I don't think it will be sticking around
>> to
>> serve applications.
>>
> You are swapping a purpose built module in a fully functional web
> server for a problematic external program that is generalised for all
> uses that interfaces with a webserver that does nothing but pass off
> requests to the external program. I'm not sure where you expect to
> win
> here.
>

I question your base assumptions, for the following reasons:

1. At no point did I say all my content is served by PHP. What website
doesn't have at least some static content?
2. In what way is FCGI/php-cgi generalised for all uses? Surely it is
specifically designed to interface with a webserver.

I should win in that nginx doesn't have to include PHP in *every*
process, it just calls it when required and doesn't touch it for static
content [0].

Also, do you have any particular experience that informs your view of
FCGI as problematic?

Cheers,

Rob

[0]
http://blog.martinfjordvald.com/2011/02/nginx-primer-2-from-apache-to-nginx/




_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Hadley Rich
2011-09-15 23:50:08 UTC
Permalink
On Fri, 2011-09-16 at 11:28 +1200, ***@webworxshop.com wrote:
> I'm looking into swapping out Apache on my server in favour of
> something a bit lighter. My requirements are modest, I run mostly PHP
> applications (Workpress, Piwik, Roundcube, PhpMyAdmin and ownCloud),
> but in future I want to be able to run some Python based stuff. I also
> need to be able to use multiple virtual hosts and have an equivalent
> of mod_rewrite.
>
> Based on my initial research it looks like I have a choice between
> Lighttpd and Nginx. Does anyone out there have any experience with
> either of these (or both)? Anyone know which may be most suitable for
> my situation or are they both about equal?

In the last while I've used Lighttpd, Nginx and Cherokee, and of course
Apache2. Mostly serving Python WSGI applications, some PHP applications
such as Piwik.

Cherokee is cool, pretty GUI to configure it, has all the features we
needed. We were using it for a few months, unfortunately we ran across
an odd bug which exposed itself as random occasional empty responses to
requests over SSL.

Switched back to Apache in the mean time while investigating and testing
alternatives, the memory usage difference was substantial.

Now using Nginx (only since last night in production), configuration was
straight forward and makes sense, everything seems to work well so far
in testing and limited production.

Lighttpd is good too, I use it on a couple an a few embedded systems we
have around the place. Configuration can be a little bit of a pain (in
my experience with FCGI for Python). With my recent experience of nginx
I would consider switching out lightty installs to nginx.

For rewriting with nginx check out try_files

Hope this helps.

hads
--
http://nicegear.co.nz



_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
r***@webworxshop.com
2011-09-16 02:12:48 UTC
Permalink
On Fri, 16 Sep 2011 11:50:08 +1200, Hadley Rich wrote:
> On Fri, 2011-09-16 at 11:28 +1200, ***@webworxshop.com wrote:
>> I'm looking into swapping out Apache on my server in favour of
>> something a bit lighter. My requirements are modest, I run mostly
>> PHP
>> applications (Workpress, Piwik, Roundcube, PhpMyAdmin and ownCloud),
>> but in future I want to be able to run some Python based stuff. I
>> also
>> need to be able to use multiple virtual hosts and have an equivalent
>> of mod_rewrite.
>>
>> Based on my initial research it looks like I have a choice between
>> Lighttpd and Nginx. Does anyone out there have any experience with
>> either of these (or both)? Anyone know which may be most suitable
>> for
>> my situation or are they both about equal?
>
> In the last while I've used Lighttpd, Nginx and Cherokee, and of
> course
> Apache2. Mostly serving Python WSGI applications, some PHP
> applications
> such as Piwik.
>
> Cherokee is cool, pretty GUI to configure it, has all the features we
> needed. We were using it for a few months, unfortunately we ran
> across
> an odd bug which exposed itself as random occasional empty responses
> to
> requests over SSL.
>
> Switched back to Apache in the mean time while investigating and
> testing
> alternatives, the memory usage difference was substantial.
>
> Now using Nginx (only since last night in production), configuration
> was
> straight forward and makes sense, everything seems to work well so
> far
> in testing and limited production.
>
> Lighttpd is good too, I use it on a couple an a few embedded systems
> we
> have around the place. Configuration can be a little bit of a pain
> (in
> my experience with FCGI for Python). With my recent experience of
> nginx
> I would consider switching out lightty installs to nginx.
>
> For rewriting with nginx check out try_files
>
> Hope this helps.

Yes, that does help, thanks. I'll seriously be looking at nginx.

Cheers,

Rob


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Continue reading on narkive:
Loading...