1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I had to disable Nginx to improve site speed

Discussion in 'Nginx' started by Jeffr2014, Mar 26, 2015.

  1. #1
    I am running a small commercial site on dedicated VPS ("dedicated" means there is only a single website on this VPS). Initially, I enabled Nginx in "Smart static files processing" mode, but after a few days of testing I disabled it as the average page loading speed was 15% lower without Nginx.
    I was very surprised by this and my only explanation here is that the site has relatively small traffic of 200-250 visitors per day and the overhead of Nginx running was too significant to balance its benefits with such low traffic.

    Any thoughts?
     
    Solved! View solution.
    Jeffr2014, Mar 26, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Uhm - you say nothing about how your site is coded, or what it's running on when you're not using nginx - I'm assuming Apache? There are lots of ways to increase Apache speeds, and if they're all present, while nothing is done with nginx, there's no reason nginx should be any faster than Apache.
     
    PoPSiCLe, Mar 26, 2015 IP
  3. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    405
    Best Answers:
    21
    Trophy Points:
    295
    #3
    Must of had something tuned funny. I went to nginx a few weeks ago on my VPS. Its faster by several orders of magnitude.

    N.
     
    Nigel Lew, Mar 26, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Yes, that is the norm (it's light and tight), but there's no automatic speed increase - there are lots of factors playing a role - especially if you're just transferring existing sites / files to nginx from Apache, for instance
     
    PoPSiCLe, Mar 27, 2015 IP
  5. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Well, the site is on Apache and Nginx was installed and configured to accelerate the site. We used default settings for Nginx: "Reverse Proxy Server (nginx)" was on and nginx settings were "Smart static files processing." As for Apache optimizations, there is not much we had to do there: AFAIK, Apache has relatively few tuning parameters. You want to be sure that there are sufficient child processes that you are not waiting for them to start. You want to be sure that KeepAlive is enabled but has a short enough timeout that idle browsers do not monopolize the Apache child processes. You want to enable compression. All of that was done. Anything we could be missing?
     
    Jeffr2014, Mar 27, 2015 IP
  6. billzo

    billzo Well-Known Member

    Messages:
    961
    Likes Received:
    278
    Best Answers:
    15
    Trophy Points:
    113
    #6
    Why don't you tell people what your load times are.

    Stuff like nginx is usually done for dealing with high load (and other things), not shaving 5/100ths of a second off a server's response time on a server with low traffic. I read up on "Smart static files processing" and there is nothing smart about it from what I can see. Any time you have a program sitting in the middle you should expect a small amount of latency as a result.

    Compression takes CPU cycles and for those on broadband any benefit may be negligible. Compression is very helpful for those on slow connections. I have not looked at my stats for a while, but 85% of my visitors were on broadband I think.
     
    billzo, Mar 27, 2015 IP
  7. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #7
    Average page loading time for US + Canada: 2.16 sec (Nginx disabled) vs. 2.44 sec (Nginx enabled). Sample size 600+ page views each.
     
    Jeffr2014, Mar 27, 2015 IP
  8. billzo

    billzo Well-Known Member

    Messages:
    961
    Likes Received:
    278
    Best Answers:
    15
    Trophy Points:
    113
    #8
    That is a considerable difference and a pretty big load time on a low load VPS to begin with. What is taking all the time? Do you have a large number of file requests? How many Apache processes have you started? Max and Min spare servers? KeepAlive Timeout? What is your RAM consumption versus total RAM? Run the free -m command.
     
    billzo, Mar 27, 2015 IP
  9. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #9
    Well, most of the requests are for WordPress blog and even with caching enabled we still pay some performance penalty for WP... We use VPS at OVH Canada and their network routing/switching with other ISPs is not very good - I see much higher Server Response Times and Page Download Times than we had before (especially for outside North America) I don't think we have large # of file requests. I checked RAM with "free -m" and it shows that we use 90% of 2Gb (strange: Plesk control panel was showing only 20% average and 50% use at peaks) and CPU usage is under 20%. KeepAlive Timeout = 1, other parameters are StartServers = 5, MinSpareServers = 5, MaxSpareServers = 10, MaxRequestWorkers = 150
     
    Jeffr2014, Mar 27, 2015 IP
  10. #10
    I will reply back again when I have time. Linux will gobble memory. That does not mean it is unavailable for programs as it will be released to programs/processes as needed. When running the free -m command to check memory, look at the second line:

    -/+ buffers/cache

    Under the free column. That should be how much memory is available for programs.

    As far as OVH, they have the cheapest VPS I have seen and you get what you pay for. I have read some complaints. I don't know what plugins you are using for your Wordpress, but 2 seconds is a long time. You could start a timer in your Wordpress index.php file and stop the timer in your footer.php file and output the difference in an HTML comment at the bottom of your footer. Then you can get an idea of what is taking the time. Is it page generation time or time for the data to get out of the data center (network)? At that point you can start narrowing things down.
     
    billzo, Mar 27, 2015 IP
  11. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #11
    @billzo, thanks a lot for your responses. When I run free -m command I see this:
    # free -m
    total used free shared buffers cached
    Mem: 1995 1817 178 49 214 897
    -/+ buffers/cache: 706 1289
    Swap: 1998 70 1928
    #
    If I add page cache (cached) to free and extract from total I get 46% RAM used up. When I look at monitoring stats at OVH control panel, the highest RAM usage for the past 7 days is 20%... so I'm a bit puzzled about what other stuff except cached is not counted in RAM used... Anyway, RAM doesn't seem to be a problem.

    @billzo, love you suggestion re timer, it is really good idea. I am going to try it. Thanks again and if you offer consulting services over Elance please PM me more info.
     
    Jeffr2014, Mar 28, 2015 IP
  12. MyBargainHost

    MyBargainHost Active Member

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #12
    @Jeffr2014, how are you configuring nginx (manually of via a control panel)? Also, were you serving static files directly through nginx or were those also being routed back to apache?
     
    MyBargainHost, Nov 6, 2015 IP
  13. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #13
    @MyBargainHost, I was using Plesk panel... anyway, it's been over 5 months since I posted it, so it's not really relevant anymore.
     
    Jeffr2014, Nov 7, 2015 IP
  14. MyBargainHost

    MyBargainHost Active Member

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #14
    Oops, didn't notice the date when I posted. Control panels do a notoriously bad job of configuring nginx, especially in a proxy situation. Though DirectAdmin does do a good job with nginx/php-fpm in stand-alone mode.
     
    MyBargainHost, Nov 7, 2015 IP
  15. Freddy63

    Freddy63 Well-Known Member

    Messages:
    85
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    163
    #15
    You should use Nginx as the standalone web server to get it's full benefits.
     
    Freddy63, Jan 16, 2016 IP
  16. wissam

    wissam Well-Known Member

    Messages:
    2,289
    Likes Received:
    78
    Best Answers:
    1
    Trophy Points:
    185
    #16
    Please consider using easyengine.io if you want to setup static, php, or wordpress sites as it makes life easier, and before installing it make sure to permanently delete apache from your life using "apt-get autoremove apache*".
    I am running my smallest wordpress with more than 50k visits/month average on a 256 ram vps for fun sake!
     
    wissam, Mar 4, 2016 IP