Everything about Web and Network Monitoring

Home > Monitis API > NGINX vs LightTPD

NGINX vs LightTPD

Intorduction

 

There is a big amount of web servers each has its own benefits, advantages and purposes…

However, only few of them are using in the lion share of domains. The leader is Apache without any doubts. But there are ,at least, 2 servers after Apache, that are good enough to be mentioned: Nginx & Lighttpd .


Scope

 

Today one of the hottest questions in discussions about web servers is “Which one is better lighttpd or NGINX ?”. In this article we will try to help network administrators to decide whether to use Lighttpd or NGINX.


Purpose

 

This article is not an attempt to prove some server’s advantage but just an example of real comparison tests. The goal is to compare 2 web servers without making any performance tuning in configurations. All must work from the box. For tests we have two Amazon m1.medium instances with 64 bit Ubuntu 12.04 with standard apt-get ed  nginx/lighttpd, php5-fpm with mysql support and default configured joomla (2.5.6) with sample data which comes with joomla’s  install package.


This article is about comparison of NGINX and Lighttpd: two light and versatile web servers, both of which are designed to be very fast, light and easy configurable. We will leave Apache alone in this article, but will come up and talk about king later on one of another’s.


Lighthttpd, is small, single threaded, so its memory and cpu consumptions are smaller,it is easy to configure, it is fast for static html pages. It was designed to be massively scalable and solve the C10k problem.

Nginx is an event-based web server. As it is asynchronous server,it provides scalability. In a process-based server, each simultaneous connection requires a thread which incurs significant overhead. An asynchronous server,like nginx, is event-driven and handles requests in a single (or at least, very few) threads which allows nginx to be very fast.


Tools


For web server benchmarking we will use probably the best tool for that purposes:

Siege:  http://www.joedog.org/siege-home/.

For Nginx and Lighttpd health monitoring we will use monitis-m3 , another  tool, that  makes your life easy:

Load time monitoring – https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/LoadTime

Web server monitoring -

https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/Lighttpd-monitor

https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/Nginx-monitor


And custom  bash monitor for process monitoring:

https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/Process-monitor


We also used Dstat for fixing memory, CPU usage and and Load Average.

http://dag.wieers.com/home-made/dstat/

 

 

Preparations


Nothing was changed to increase performance of neither web servers nor php+mysql stack.

The only change was made is increased ulimit to 10.000 on both servers

Added appropriate records for Amazon instances   in host files

Assume AMI1  is an instance with nginx installed and AMI2  is an instance with lighttpd installed accordingly


Tests

First of all we need to clarify, how we did our tests (Server, Benchmark tool, method etc .. ) So the servers are EC2 Medium instances

We run siege benchmarking tool with adding concurrent sessions each 2 minutes. starting with 5 and ending up with 60 concurrent connections. As I told  before we have standard apt-get ed nginx and lighty with MySQL-5.1 and php-fpm installed. Below are logs from siege run and dstat outputs  during peak load .

Siege logs:

NGINX:

Conn.

Trans

Elap Time

Data Trans

Resp Time

Trans Rate

Throughput

Concurrent

Failed

5

503

119.90

6

1.19

4.20

0.05

4.99

0

10

482

119.98

6

2.46

4.02

0.05

9.88

0

20

484

119.99

6

4.86

4.03

0.05

19.59

0

30

467

119.99

6

7.32

3.89

0.05

28.49

8

35

390

119.99

5

8.58

3.25

0.04

27.87

71

40

50

119.99

0

9.54

0.42

0.00

3.98

401

45

2

120.00

0

9.61

0.02

0.00

0.16

495

50

0

119.99

0

inf

0.00

0.00

0.00

550

55

0

119.99

0

inf

0.00

0.00

0.00

605

60

0

119.99

0

inf

0.00

0.00

0.38

660

 

Lighttpd:

Conn.

Trans

Elap Time

Data Trans

Resp Time

Trans Rate

Throughput

Concurrent

Failed

5

454

119.11

5

1.30

3.81

0.04

4.96

0

10

432

119.99

5

2.74

3.60

0.04

9.87

0

20

440

119.99

5

5.32

3.67

0.04

19.52

0

30

419

119.99

5

7.93

3.49

0.04

27.70

16

35

115

119.99

1

9.50

0.96

0.01

9.10

287

40

2

119.97

0

10.07

0.02

0.00

0.17

438

45

0

119.99

0

inf

0.00

0.00

0.00

495

50

0

119.99

0

inf

0.00

0.00

0.00

550

55

0

60.17

0

inf

0.00

0.00

0.88

1078

60

0

10.07

0

inf

0.00

0.00

1.38

1083

 

 

Ok. So what we can see here by looking on logs. As for me NGINX is definitive winner. After 45 concurrent connection Lighttpd was fully dead while NGINX was still somehow defending. 50 and more were critical for both so nothing to comment here. But even before that we can see that almost at every load NGINX behaves itself better that Lighttpd. You can see that all transfer rates throughput are better in NGINX rather than Lighttpd.


So I will leave you alone with this numbers and place more and much nicer Graphs below, which I grab from Monitis Dashboard. First graph shows http Load time and second: amount of resources used respectively by NGINX and Lighttpd.


So lets see what we have here with NGINX:

Http Load time:


Up to 0.4 seconds transfer time, quite impressive  results. Isn’t it ?

Amount of system resources used by NGINX (dstat output):

 

Nice, NGINX uses same amount of resources while it is loaded or idle.

So for me both graph and dtstat output shows quite impressive results.  I’m happy what I have seen with NGINX so far. Let’s now see how Lighttpd graph and dstat output looks like .

Http Load time:

Quite similar to NGINX even faster mx 0.3 seconds transfer time. Great !
And what’s up with resources ?

Amount of system resources used by Lighttpd  (dstat output):

OK what  can I say here : Lighttpd seems not so light in comparison with NGINX especially when it is loaded !

Now let’s summarize what we have got during test and what we know about these two servers.


In the table below we have  collected some data about both servers ,which will give us more clear picture of what these servers are and  which one is more preferable to use. We are not going to discuss special cases, when the Lighttpd or Nginx have some specific or even critically important features for specified project. These are just general descriptors which are interesting for most of users.

Load performance data:

Load Testing Metrics

Nginx

Weight

Lighttpd

Weight
Average response time 6.22 9 6.14 10
Peak response time 9.61 10 10.07 9
Error rates 398 (math average) 10 563 (math average) 7
Throughput 0.05 (max) 10 0.04 (max) 9
Concurrent Users 45 (max) 10 40 (max) 8
Summary 49 43

 

 

Criteria

NGINX

Weight(0-10)

Architecture

asynchronous server

5

Programming language

C

5

Performance

49

7

Load Balancer

Yes

10

Memcached

direct support

10

HTTP Health Check

HTTP Healthcheck(3rd party Module)

5

Protocols

HTTP(S), IMAP(S), POP3(S), SMTP(S)

10

Configuration

Single ascii file

5

Modules

Modular architecture, has also 3rd party modules repository

http://wiki.nginx.org/Modules

http://wiki.nginx.org/3rdPartyModules

6

Proxy AJP

non official https://github.com/yaoweibin/nginx_ajp_module

3

Proxy WSGI

native uWSGI

3rd party WSGI

9

Resources usage at idle time

Light

10

Resources sage under load

Light

10

Security

Bandwidth, connection and request policing

Request filtering

8

SSL support

TLSv1.1/TLSv1.2/SSL/SNI

9

Stability

Stable

10

License

BSD

10

Community

Mailing list, IRC, Forum, Planet

10

Popularity

9.63%

Commercial support

Available

5

Official repository

Debian, Ubuntu, RedHat, CentOS,OpenSuse,AIX,FreeBSD

10

History

2004 – Current

10

Development

Extremely Active

10

Production Ready

YES

10

Last Stable Release

1.2.2 (July 3,2012)

10

SUMMARY

197

 

LightHTTPD

Lighttpd

Weight(0-10)

asynchronous server

5

C

5

43

7

yes

10

via mod_cml

5

no

0

HTTP(S)

3

Single ascii file

          5

Modular architecture

http://redmine.lighttpd.net/projects/lighttpd/wiki/docs:configurationoptions

5

Strange unknown

0

as FastCGI

3

Light

10

Medium

7

chroot, set UID, set GID

protecting docroot

strict HTTP-header parsing

7

TLS/SSL/SNI

7

Users report about memory leaks

6

BSD

10

Forum, Bug tracking, IRC

5

0.6%

Not available

0

Debian, Ubuntu, RedHat, CentOS,OpenSuse,Gentoo,FreeBSD

9

2003 – Current

10

Active

8

YES

10

1.4.31 (May 31,2012 )

9

141

Conclusion

 

As your both servers have quite similar behavior, but seems that NGINX behaves itself better and has better community support. So if someone asks me which one to chose I will say “NGINX” as it is more popular and you will always have more info about NGINX with just Googleing your request. If you are corporate user and need commercial support NGINX will provide it at www.nginx.com, Lighthttpd will not (however we could not find any reference to commercial support of Lighthttpd). And in fact we see that NGINX is more actively developed and goes ahead much faster that Lighthttpd.  However the fact the giants Wikipedia and YouTube uses Lighthttpd make us believe that this server is well enough to be used for wide amount of website owners .


However, this test and others ones on various resources on the web are not a sentence. You can always make your own choice.

About zhirayr