Welcome! Log In Create A New Profile

Advanced

nginx latency/performance issues

Posted by Ameer Antar 
Ameer Antar
nginx latency/performance issues
January 04, 2018 03:10AM
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: nginx latency/performance issues
January 04, 2018 06:00PM
Hello!

On Wed, Jan 03, 2018 at 09:01:16PM -0500, Ameer Antar wrote:

> Hello All,
> First time subscriber here, as I am new to using nginx. My question is
> about latency/performance issue as compared to our previously
> configured Apache server. Our web application is running on Apache +
> PHP-FPM, and we are planning on publishing a new site which contains
> only static files "published" from within the web application on a set
> interval. Thinking of saving the overhead of apache and php, I've setup
> nginx-light package on ubuntu and configured the server with minimal
> changes from default. Just to see what kind of improvement we have, I
> compared avg response times for the same static javascript file and
> noticed a difference, but the opposite of what I expected: ~128ms from
> apache and ~142ms from nginx. I've also tested with php enabled on
> nginx and seen about the same results.
> There must be something not right. I've looked at a lot performance
> tips, but no huge difference. The only minor help was switching to
> buffered logging, but the difference is probably close to the margin of
> error. Can anyone help?

Depending on what and how you've measured, the difference between
~128ms and ~142ms might be either non-significant, or explainable by
different settings, or have some other explanation. You may want
to elaborate a bit more on what and how you are measuring. Also,
you may want to measure more details to better understand where
the time is spent.

In any case, both values are larger than 100ms, and this suggests
that you aren't measuring local latency. Likely, most of the
latency is network-related, and switching servers won't help much
here. In particular, if you are measuring latency on real users
within your web application, the difference might be due to no
established connection and/or no cached SSL session to a separate
static site.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
eFX News Development
Re: nginx latency/performance issues
January 05, 2018 12:20AM
Hello! Thanks for your response. I'm using apache bench for the tests, simply hitting the same static javascript file (no php). I was thinking since I'm using the same location and as long as the tests are repeatable, using remote testing would be ok and give more realistic results.

Both apache and nginx are on the same machine, just using different IP aliases so I can connect to both via port 443. After more detective work, I think I've narrowed the problem to the aliasing. The first alias which nginx is on is slower than the second where apache is. When I placed nginx on the same ip, but different port than apache, the speed is much better. There must be some ip address priority as the nginx server is new and has zero traffic on it. This is probably out of scope, but if you have any other thoughts or advice, let me know.

Thanks again for your help on this.

-Ameer

----- Original Message -----
From: Maxim Dounin <[email protected]>
To: nginx@nginx.org
Subject: Re: nginx latency/performance issues
Date: 1/4/18 11:52:44 AM

>Depending on what and how you've measured, the difference between
>~128ms and ~142ms might be either non-significant, or explainable by
>different settings, or have some other explanation. You may want
>to elaborate a bit more on what and how you are measuring. Also,
>you may want to measure more details to better understand where
>the time is spent.
>
>In any case, both values are larger than 100ms, and this suggests
>that you aren't measuring local latency. Likely, most of the
>latency is network-related, and switching servers won't help much
>here. In particular, if you are measuring latency on real users
>within your web application, the difference might be due to no
>established connection and/or no cached SSL session to a separate
>static site.
>
>--
>Maxim Dounin
>http://mdounin.ru/
>_______________________________________________
>nginx mailing list
>[email protected]
>http://mailman.nginx.org/mailman/listinfo/nginx_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: nginx latency/performance issues
January 05, 2018 03:10AM
Hello!

On Thu, Jan 04, 2018 at 06:12:38PM -0500, eFX News Development wrote:

> Hello! Thanks for your response. I'm using apache bench for the
> tests, simply hitting the same static javascript file (no php).
> I was thinking since I'm using the same location and as long as
> the tests are repeatable, using remote testing would be ok and
> give more realistic results.

With ApacheBench on an SSL host you are likely testing your SSL
configuration. Or, rather, performance of handshakes with most
secure ciphersuite available in your OpenSSL library. Try
looking into detailed timing information provided by ApacheBench,
it should show that most of the time is spend in the "Connect"
phase - which in fact means that the time is spent in SSL
hadshakes. Also try using keepalive connections with "ab -k" to
see a drammatic difference.

> Both apache and nginx are on the same machine, just using
> different IP aliases so I can connect to both via port 443.
> After more detective work, I think I've narrowed the problem to
> the aliasing. The first alias which nginx is on is slower than
> the second where apache is. When I placed nginx on the same ip,
> but different port than apache, the speed is much better. There
> must be some ip address priority as the nginx server is new and
> has zero traffic on it. This is probably out of scope, but if
> you have any other thoughts or advice, let me know.

First of all, check if your results are statistically significant.
That is, take a look at the "+/-sd" column in the ApacheBench
detailed output. Alternatively, run both tests at least three
times and compare resulting numbers using ministat(1).

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Peter Booth
Re: nginx latency/performance issues
January 05, 2018 03:30AM
Are you running apache bench on the sam for different host?
How big is the javascript file? What is your ab command line?
If your site is to be static published (which is a great idea)
why are you using SSL anyway?



> On 4 Jan 2018, at 6:12 PM, eFX News Development <[email protected]> wrote:
>
> Hello! Thanks for your response. I'm using apache bench for the tests, simply hitting the same static javascript file (no php). I was thinking since I'm using the same location and as long as the tests are repeatable, using remote testing would be ok and give more realistic results.
>
> Both apache and nginx are on the same machine, just using different IP aliases so I can connect to both via port 443. After more detective work, I think I've narrowed the problem to the aliasing. The first alias which nginx is on is slower than the second where apache is. When I placed nginx on the same ip, but different port than apache, the speed is much better. There must be some ip address priority as the nginx server is new and has zero traffic on it. This is probably out of scope, but if you have any other thoughts or advice, let me know.
>
> Thanks again for your help on this.
>
> -Ameer
>
> ----- Original Message -----
> From: Maxim Dounin <[email protected]>
> To: nginx@nginx.org
> Subject: Re: nginx latency/performance issues
> Date: 1/4/18 11:52:44 AM
>
>> Depending on what and how you've measured, the difference between
>> ~128ms and ~142ms might be either non-significant, or explainable by
>> different settings, or have some other explanation. You may want
>> to elaborate a bit more on what and how you are measuring. Also,
>> you may want to measure more details to better understand where
>> the time is spent.
>>
>> In any case, both values are larger than 100ms, and this suggests
>> that you aren't measuring local latency. Likely, most of the
>> latency is network-related, and switching servers won't help much
>> here. In particular, if you are measuring latency on real users
>> within your web application, the difference might be due to no
>> established connection and/or no cached SSL session to a separate
>> static site.
>>
>> --
>> Maxim Dounin
>> http://mdounin.ru/
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Ameer Antar
Re: nginx latency/performance issues
January 05, 2018 07:30AM
I'm using multiple runs with these commands:

ab -n100 <url>
ab -c20 -n100 <url>

Testing now on the same host eliminates the issue with the ip alias, so I can now see nginx running much faster for the 95kB file, (gzip is on, so it's probably less). Unfortunately, we have a embedded login form so if you don't use https, there is a warning in most browsers about this being insecure, even though it posts to a different sub-domain on https.

----- Original Message -----
From: Peter Booth <[email protected]>
To: Mik J via nginx <[email protected]>
Cc: Maxim Dounin <[email protected]>
Subject: Re: nginx latency/performance issues
Date: 1/4/18 9:19:29 PM


>Are you running apache bench on the sam for different host?
>How big is the javascript file? What is your ab command line?
>If your site is to be static published (which is a great idea)
>why are you using SSL anyway?
>

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Ameer Antar
Re: nginx latency/performance issues
January 05, 2018 07:40AM
Hello,

----- Original Message -----
From: Maxim Dounin <[email protected]>
To: nginx@nginx.org
Subject: Re: nginx latency/performance issues
Date: 1/4/18 8:58:45 PM


>With ApacheBench on an SSL host you are likely testing your SSL
>configuration. Or, rather, performance of handshakes with most
>secure ciphersuite available in your OpenSSL library. Try
>looking into detailed timing information provided by ApacheBench,
>it should show that most of the time is spend in the
>"Connect"
>phase - which in fact means that the time is spent in SSL
>hadshakes. Also try using keepalive connections with "ab -k"
>to
>see a drammatic difference.
>

Yes, using http is much faster, but I was thinking of getting stats in a real-world scenario. That's probably the wrong course in this case to compare two different servers.. eliminating the extra common bottlenecks really focuses on the difference between the two servers. I guess the more "real-world" stats might be good just to have an idea of what users may experience, but not at comparing performance.

>First of all, check if your results are statistically significant.
>That is, take a look at the "+/-sd" column in the ApacheBench
>detailed output. Alternatively, run both tests at least three
>times and compare resulting numbers using ministat(1).

The data looks good now, with minimal deviation. Now I'm getting 36k req/s vs. ~25k req/s for apache for 20 concurrent requests. I'm pleased, but the only issue remains why remote performance is not as good except for one ip alias. If my assumption is correct, this will get better over time. For now, I'll just have to wait to find out...

Thanks again.

-Ameer
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login