Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx now most popular HTTPD amongst top 1000 websites - Page 2
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx now most popular HTTPD amongst top 1000 websites

2»

Comments

  • @marcm: exactly! Completely agree with you!

  • @udk said:
    No love for lighty? :D

    Me.

  • joepie91joepie91 Member, Patron Provider

    @mpkossen said:
    OK. But my point was: was it Apache or something else? I mean, like PHP or something else embedded into the apache process. For example: top lists it as apache even when it's a PHP request.

    Seeing as I only changed the HTTPd and not the underlying software, and CPU usage magically went down, I can only conclude that it was Apache and not PHP causing the CPU spikes.

    @marcm said:
    The problem with Apache is that allot of people either don't know how to configure it, are lazy or leave it to its defaults. If you configure Apache right it is going to work pretty damn well.

    I always find this a bit of an odd argument. If you need to spend a significant amount of time and have a significant knowledge of a HTTPd to be able to configure it in a way that it actually works properly, then why would you use it if another HTTPd offers this out of the box with no configuration required?

  • Well I know that at Mashable (where I work as a reporter, not admin, but I'm one of the few that can get excited and need out with our CTO), when we moved from Apache to Nginx, it cut down our overhead and page load like a mofo. And that was back when we were on WordPress on the frontend (now we're on Ruby, Mongo and lots of JavaScript) and needed some ridiculous number of servers and instances just for database.

    It doesn't shock me that the bigger sites are switching because if you're serving millions of visitors a day - and often 10,000+ concurrent visitors -- and that's for a dynamic news site, not a web app -- Apache just doesn't work as well.

  • @joepie91 said:
    I always find this a bit of an odd argument. If you need to spend a significant amount of time and have a significant knowledge of a HTTPd to be able to configure it in a way that it actually works properly, then why would you use it if another HTTPd offers this out of the box with no configuration required?

    I'm not sure how nginx's defaults are configured, but the Apache ones aren't set for LowEnd by default. So it's only natural you have to tweak it a bit to get better performance. So while I don't disagree with you that Apache doesn't server LowEnd well out of the box, I also don't agree what you need to spend a significant amount of time and have significant knowledge to tweak a number of Apache parameters.

    Besides, most people (and most guides) still use the old Apache Prefork server, which is considerably slower than the MPM Worker or the 2.4 Event-driven worker (which matches/is faster as nginx), especially when used with PHP.

    Anyway, here's an interesting read about Apache 2.4 and some of the discussion about it's performance: http://apache.slashdot.org/story/12/02/21/1632230/apache-24-takes-direct-aim-at-nginx

  • marcmmarcm Member

    @mpkossen in all fairness I have to say that Nginx is easier to learn than Apache. I find it weird that some people think the opposite.

  • @marcm said:
    mpkossen in all fairness I have to say that Nginx is easier to learn than Apache. I find it weird that some people think the opposite.

    The configuration for Nginx is definately easier to learn and use. I would also say performance is better, but I've seen cases where Apache wins.

  • @marcm said:
    mpkossen in all fairness I have to say that Nginx is easier to learn than Apache. I find it weird that some people think the opposite.

    I'm all lost in nginx configuration. We have two load balancers here at the office running nginx. Always takes me longer to fix things than with Apache (with which I just know what to do). My point being: it boils down to experience configuration-wise.

  • vanarpvanarp Member

    @mpkossen said:
    Besides, most people (and most guides) still use the old Apache Prefork server, which is considerably slower than the MPM Worker or the 2.4 Event-driven worker (which matches/is faster as nginx), especially when used with PHP.

    Could you please share any tutorial or tutorial links to best optimize Apache 2.4 for low end boxes?

  • mpkossenmpkossen Member
    edited July 2013

    @vanarp said:
    Could you please share any tutorial or tutorial links to best optimize Apache 2.4 for low end boxes?

    Haven't got any links for you, sorry. It is on my list for a LEB tutorial, though. I haven't yet had to optimize Apache yet (as in: most of my servers are big enough to handle the load they get just fine). All my servers also still use Apache 2.2, as that's the one that shipped with Ubuntu 12.04 LTS, so I haven't got much hands-on experience with 2.4 yet except some tests.

    By the way (edit): the default Apache 2.2 config with the MPM Worker (on Ubuntu) results in a memory usage of at most 6MB reserved per apache process (in my case 4 in total). PHP-FPM, however, is the real memory hog with 3 processes needing 17MB each.

  • mpkossenmpkossen Member
    edited July 2013

    I'd like to get back on this. I've now got two boxes up and running, one with Apache and one with NGINX. Both have:

    php5-fpm (tweaked configuration, identical)
    postgresql (default configuration, identical)

    I've tweaked the default Apache config just a bit (because the default config is not fit for low-end boxes):

    <IfModule mpm_worker_module>
    StartServers          1
    MinSpareThreads      10
    MaxSpareThreads      25 
    ThreadLimit          25
    ThreadsPerChild      10
    MaxClients           50
    MaxRequestsPerChild   0
    </IfModule>
    

    I've compared the memory usage of Apache and NGINX in an idle state:

    • Apache: 4 processes, total 9072Kb of residential memory
    • NGINX: 5 processes, total 8936Kb of residential memory

    This is just a very basic and preliminary result. I've still got to do ab runs against both servers. But I wanted to share this anyhow.

  • Results from an Apache Bench to a phpinfo() file.

    NGINX machine to Apache machine:

    mpkossen@postexus2:~$ ab -n 1000 -c 10 http://postexus.example.net/info.php
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    
    Benchmarking postexus.example.net (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests
    
    
    Server Software:        Apache/2.2.22
    Server Hostname:        postexus.example.net
    Server Port:            80
    
    Document Path:          /info.php
    Document Length:        49595 bytes
    
    Concurrency Level:      10
    Time taken for tests:   61.208 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      49787000 bytes
    HTML transferred:       49595000 bytes
    Requests per second:    16.34 [#/sec] (mean)
    Time per request:       612.075 [ms] (mean)
    Time per request:       61.208 [ms] (mean, across all concurrent requests)
    Transfer rate:          794.35 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:      138  150   6.6    150     165
    Processing:   417  459  30.7    455     906
    Waiting:      140  157  24.2    155     591
    Total:        556  609  35.3    605    1063
    
    Percentage of the requests served within a certain time (ms)
      50%    605
      66%    625
      75%    631
      80%    635
      90%    642
      95%    645
      98%    651
      99%    668
     100%   1063 (longest request)
    mpkossen@postexus2:~$
    

    Apache machine to NGINX machine:

    mpkossen@postexus:~$ ab -n 1000 -c 10 http://postexus2.example.net/info.php
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    
    Benchmarking postexus2.example.net (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests
    
    
    Server Software:        nginx/1.1.19
    Server Hostname:        postexus2.example.net
    Server Port:            80
    
    Document Path:          /info.php
    Document Length:        45063 bytes
    
    Concurrency Level:      10
    Time taken for tests:   60.874 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      45222000 bytes
    HTML transferred:       45063000 bytes
    Requests per second:    16.43 [#/sec] (mean)
    Time per request:       608.744 [ms] (mean)
    Time per request:       60.874 [ms] (mean, across all concurrent requests)
    Transfer rate:          725.46 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:      138  150   6.6    150     172
    Processing:   418  454  19.7    454     534
    Waiting:      139  151   6.9    151     219
    Total:        556  605  26.1    604     692
    
    Percentage of the requests served within a certain time (ms)
      50%    604
      66%    623
      75%    629
      80%    631
      90%    639
      95%    643
      98%    646
      99%    647
     100%    692 (longest request)
    mpkossen@postexus:~$
    
  • @mpkossen So you ignore the main strength of nginx?

    Try -c 50 or -c 100 if you want to see the real strength of each web server.

  • You can seat Varnish in front Ngnix to drive the performance through the roof. Varnish is great at caching dynamic content. It would serve PHP files as though they were static output.

  • BluBoyBluBoy Member

    Would love to see a decent tuning guide for apache and nginx, comparing their strengths and weaknesses as well as a few benchmarks... Aimed at 128/256 Mb RAM nodes would be awesome.

    ... Anybody in the know with this?

  • @Rallias said:
    mpkossen So you ignore the main strength of nginx?

    Try -c 50 or -c 100 if you want to see the real strength of each web server.

    I'm an NGINX noob (basically, I have worked with it, but don't know much about it) so I honestly don't know where it's strengths are. I'm going to run the ABs again with higher concurrency, see what that does :-)

    @BluBoy: it is on my list for LEB, but these things generally take up a lot of time, so I can't promise it's be finished next week or something like that. More like a month.

  • mpkossenmpkossen Member
    edited July 2013

    Apache:

    mpkossen@postexus2:~$ ab -n 1000 -c 50 http://postexus.example.net/info.php
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    
    Benchmarking postexus.example.net (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests
    
    
    Server Software:        Apache/2.2.22
    Server Hostname:        postexus.example.net
    Server Port:            80
    
    Document Path:          /info.php
    Document Length:        49595 bytes
    
    Concurrency Level:      50
    Time taken for tests:   52.008 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      49787000 bytes
    HTML transferred:       49595000 bytes
    Requests per second:    19.23 [#/sec] (mean)
    Time per request:       2600.418 [ms] (mean)
    Time per request:       52.008 [ms] (mean, across all concurrent requests)
    Transfer rate:          934.85 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:      138  151   7.1    150     209
    Processing:   872 2386 186.7   2398    3485
    Waiting:      594 2083 183.3   2097    3168
    Total:       1011 2536 188.7   2549    3643
    
    Percentage of the requests served within a certain time (ms)
      50%   2549
      66%   2571
      75%   2585
      80%   2592
      90%   2614
      95%   2635
      98%   2712
      99%   3090
     100%   3643 (longest request)
    mpkossen@postexus2:~$
    

    NGINX

    mpkossen@postexus:~$ ab -n 1000 -c 50 http://postexus2.example.net/info.php
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking postexus2.example.net (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests
    
    
    Server Software:        nginx/1.1.19
    Server Hostname:        postexus2.example.net
    Server Port:            80
    
    Document Path:          /info.php
    Document Length:        45063 bytes
    
    Concurrency Level:      50
    Time taken for tests:   12.919 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      45222000 bytes
    HTML transferred:       45063000 bytes
    Requests per second:    77.41 [#/sec] (mean)
    Time per request:       645.928 [ms] (mean)
    Time per request:       12.919 [ms] (mean, across all concurrent requests)
    Transfer rate:          3418.50 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:      138  150   6.6    150     166
    Processing:   418  485 109.4    457     989
    Waiting:      139  181 107.5    153     660
    Total:        557  635 110.7    607    1149
    
    Percentage of the requests served within a certain time (ms)
      50%    607
      66%    629
      75%    635
      80%    641
      90%    653
      95%   1012
      98%   1108
      99%   1131
     100%   1149 (longest request)
    mpkossen@postexus:~$
    

    I can just say: wow! I'm impressed! Never knew it made that much difference.

    I'm curious how this will work with Apache's event worker. I'm trying to set that up now but apt is a bit grumpy this morning.

    EDIT: nope, event-worker on 2.2 did nothing. Still the same.

  • @Zen said:
    You have seen the light? :)

    Yes! But I still want to know the difference between NGINX's event model versus Apache's worker model. NGINX doesn't do the keepalive and I want to know what effect that has.

  • @mpkossen said:
    Yes! But I still want to know the difference between NGINX's event model versus Apache's worker model. NGINX doesn't do the keepalive and I want to know what effect that has.

    Nginx sacrifices a little speed with creating a new connection, Apache sacrifices a lot of speed by being all bloated in the core.

Sign In or Register to comment.