Kaylas
Kaylas

Reputation: 112

Nginx response time

I manage a website created using symfony2, i need to "stabilize" the response time of it.

The response time is floating from 100ms (lower limit) to 1200ms, and it improve randomicaly (i have already excluded the visit dependency).

The config as following:

pm = static pm.max_children = 100 pm.start_servers = 3

Any suggestion?

Thanks

UPDATE 13:11

RT Correct:

[01/Sep/2016:11:01:04 +0200] XX.XX.XX.XX - "GET / HTTP/1.1" "0.044"  200 15035 "-" "XXXXX" "XX.XX.XX.XX"

[01/Sep/2016:11:01:31 +0200] XX.XX.XX.XX - "GET / HTTP/1.1" "0.061"  200 15035 "-" "XXXXX" "-"

RT Not Correct:

[01/Sep/2016:11:19:23 +0200] XX.XX.XX.XX - "GET / HTTP/1.1" "1.114"  200 15035 "-" "XXXXX" "XX.XX.XX.XX"

[01/Sep/2016:11:25:33 +0200] XX.XX.XX.XX - "GET / HTTP/1.1" "1.131"  200 15035 "-" "XXXXX" "-"

**SAME USER (monitoring system) **

Upvotes: 5

Views: 33248

Answers (2)

ashok
ashok

Reputation: 11

     ##
     # Logging Settings
     ##


     log_format main '[$time_local] '
         '$remote_addr '
         '"$request" '
         '$status '
         '$body_bytes_sent'
         '"$http_user_agent" '
         '$upstream_response_time';

     access_log /var/log/nginx/access.log main;

Upvotes: 0

Engo
Engo

Reputation: 969

In order to optimize my nginx system I have used the following 3 tutorials/tips.

1. A few tips I used to boost my nginx system

Tip 1 – Accelerate and Secure Applications with a Reverse Proxy Server

Tip 2 – Add a Load Balancer

Tip 3 – Cache Static and Dynamic Content

Tip 4 – Compress Data

Tip 5 – Optimize SSL/TLS

Tip 6 – Implement HTTP/2 or SPDY

Tip 7 – Update Software Versions

Tip 8 – Tune Linux for Performance

Tip 9 – Tune Your Web Server for Performance

Tip 10 – Monitor Live Activity to Resolve Issues and Bottlenecks

More info: https://www.nginx.com/blog/10-tips-for-10x-application-performance/

2. Very good tutorial to optimize Nginx configuration

https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration

3. Tracking Application Response Time with Nginx

I added the following block to /etc/nginx/nginx.conf

log_format timed_combined '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" '
    '$request_time $upstream_response_time $pipe';

Next we modify our access_log directives to use the new format:

access_log /var/log/nginx/yourdomain.com.access.log timed_combined;

Here’s an example of the log output:

 66.249.71.173 - - [08/Nov/2010:14:16:18 -0600]  "GET /blog/2010/apr/30/installing-geodjango-dependencies-homebrew/ HTTP/1.1" 200 6569 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 0.640 0.640 .

The last part will show you the time it took to serve:

0.640 in this case

Some clever log filtering can now show you exactly where and when your stack is slowing down, giving you clues about where to start optimizing.

More info: https://lincolnloop.com/blog/tracking-application-response-time-nginx/

Upvotes: 19

Related Questions