Answer the question
In order to leave comments, you need to log in
Sometimes a long response from the subdomain. nginx spools up?
Good evening.
There is a subdomain static.mysite.com
from time to time a long response from it. On it are avatars and other pictures.
But no, sometimes there is a long wait on static.mysite.com on mysite.com (loading img)
At first I thought it was necessary to proxy as they did with apache. But even if you upload a 16x16px image weighing 5kb to static.mysite.com and go to static.mysite.com/image16.png in the browser and press f5 10 times in 7 cases it will be displayed immediately and in 3x it will be loaded for a long time (waiting) as if something blunts =(
nginx.conf:
user apache;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
timer_resolution 100ms;
worker_rlimit_nofile 131072;
worker_processes 8;
events {
worker_connections 65536;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
reset_timedout_connection on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain application/xml application/x-javascript text/javascript text/css text/json;
gzip_disable "msie6";
gzip_comp_level 3;
include /etc/nginx/conf.d/*.conf;
include /usr/local/ispmgr/etc/nginx.domain;
client_max_body_size 16M;
client_body_buffer_size 128k;
log_format isp '$bytes_sent $request_length';
}
server {
server_name static.mysite.com;
root /var/www/user/data/www/static.mysite.com;
listen xxx.xxx.xxx.xx;
charset WINDOWS-1251;
#disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/user/data/www/static.mysite.com;
error_page 403 400 404 = http://mysite.com/404.php;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|js|css|txt|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
#access_log off;
expires 7d;
}
}
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
$i = 0;
$table_r = mysql_query("SHOW TABLES FROM `".$bd_base."`");
while ($tb_r=mysql_fetch_row($table_r)){$i++;
$status = mysql_query("OPTIMIZE TABLE `".trim($tb_r[0])."`");
if($i == 5){sleep(5);$i=0;}
Answer the question
In order to leave comments, you need to log in
Forgot to unsubscribe. Ruined.
The situation was like this in short, there were a lot of js scripts executing at SetInterval every 10-11 seconds that killed chrome with most of the open tabs, all the static in chrome and the inscription waiting for an available socket began to blunt. The solution is to replace the setintvaral with a settimeout. Setinterval breaks client-side browsers with heaps of scripts. But it's better to go directly to web sockets
nginx on windows? It seems like there are pitfalls with this.
Try
or commenttimer_resolution 100ms;
1. If you measure the packet transit time using ping - bring the packet size closer to the real one of 1500 bytes and do not rely on 4 pings. Because in small packets of 32 or 64 bytes it is difficult to notice network problems.
2. I once chased our web workers with a mop for executing a crown with a web request to PHP. What prevents you from entering the execution of any command into the crontab without jerking the web server? The same PHP can be easily executed from the shell. In addition, sooner or later someone will find your url (the same Google or Yandex will collect data and go to check what is in the url) and then trouble will not be avoided.
3. Can you explain why do OPTIMIZE crown? And how often do you do it?
4. Your response time is long. Server on another continent? For example, you are in Europe and the server is in New York. In this case, there is nothing surprising in dulling.
5. VDS server? In this case, blunting is also quite possible if an HDD is used, or during oversailing at the hoster.
6. Are you using Chrome and your site is also open in adjacent tabs? Please note that Chrome only establishes a maximum of 6 connections to a single host.
It's a good idea to look at the Network tab in the Browser Inspector to see the timings when blunting.
7. Is the image request intercepted by another location? Perhaps the request misses and gets processed, for example, in a PHP script, which itself takes the file from the disk and gives it to nginx.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question