Welcome! Log In Create A New Profile

Advanced

"nginx ошибочно(?) пропускает запросы к бэкэнду вместо отдачи из своего кэша.

Posted by Romny 
nginx стоит перед сайтом на IIS. Практически всё кэшируется. При тестировании на том же сервере, где стоит nginx кэширование дало отличные результаты. Сервер с nginx и сервер бэкэнд находятся на одной площадке.
Тест с альтернативной машины расстроил до кровавых слез. Часть запросов отваливается по таймауту, часть или они же уходит на бэкэнд и валит его соответственно.

Тест нгинкса со стороны сервера c nginx:

siege -c 90 -r 20 http://domain.com/address...

Transactions: 1800 hits
Availability: 100.00 %
Elapsed time: 213.46 secs
Data transferred: 147.81 MB
Response time: 9.81 secs
Transaction rate: 8.43 trans/sec
Throughput: 0.69 MB/sec
Concurrency: 82.69
Successful transactions: 1800
Failed transactions: 0
Longest transaction: 15.88
Shortest transaction: 0.72

Тест нгинкса со стороны альтернативной машины:

siege -c 90 -r 20 http://domain.com/address...

Transactions: 1666 hits
Availability: 92.56 %
Elapsed time: 175.41 secs
Data transferred: 136.72 MB
Response time: 5.62 secs
Transaction rate: 9.50 trans/sec
Throughput: 0.78 MB/sec
Concurrency: 53.35
Successful transactions: 1666
Failed transactions: 134
Longest transaction: 17.42
Shortest transaction: 0.41

Конфиг nginx:

worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
include black-list-ip.conf;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_min_length 255;

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:30m inactive=1d max_size=3G;

server {

listen IPнгинкса:80;
access_log logs/access.log;

location / {
proxy_cache_valid 15m;
proxy_pass http://IP;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache cache;
proxy_no_cache $cookie_logged;
proxy_cache_bypass $cookie_logged;
proxy_ignore_headers "Expires" "Cache-Control";
proxy_hide_header "Pragma";
expires 15m;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|swf|doc|xls|mp3|wma)$ {
expires -1;
proxy_pass http://IPбэкэнда;
proxy_ignore_headers "Expires" "Cache-Control";
proxy_set_header Cache-Control "no-store, no-cache";
proxy_hide_header "Pragma";
}

location ~ (auth|admin) {
proxy_pass http://IPбэкэнда;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready