没有stream量的网站需要10秒才能加载Nginx + FastCGI

昨天我有一个工作优化的Nginx安装服务的网站,它非常快。 今天,我只是做了一些testing,在configuration上做了一些额外的改变(只是增加了一个redirect),现在突然间,服务器需要7或10秒来提供页面。 一旦请求被加载,页面加载速度非常快,但是在进入站点和浏览时也有10秒钟的挂起。 这是我第一个使用fastcgi的nginxconfiguration,我不知道发生了什么,因为我处于debugging模式,而且我看到的唯一信息是错误日志中的信息消息,没有任何错误或警报。 所有你可以在代码中看到的重写都在昨天,所以我想这不是问题。 你认为我的代码是错误的格式?

我会在这里发布configuration,并希望有人可以给我一个暗示…谢谢。

user www-data; worker_processes 2; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; worker_rlimit_nofile 30000; events { worker_connections 4096; } http { perl_modules perl; perl_require JavaScript/Minifier.pm; perl_require CSS/Minifier.pm; perl_require JSMinify.pm; perl_require CSSMinify.pm; include 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 logs/access.log main; gzip_static on; gzip_http_version 1.1; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; gzip_vary on; sendfile on; tcp_nopush off; tcp_nodelay on; #keepalive_timeout 0; keepalive_timeout 10; gzip on; log_request_speed_filter on; log_request_speed_filter_timeout 3; server { listen 80; server_name mysite.com; #charset koi8-r; access_log logs/mysite.access.log; error_log logs/mysite.error.log debug; location /nginx_status { stub_status on; access_log off; } location ~ \.js$ { perl JSMinify::handler; } location ~ \.css$ { perl CSSMinify::handler; } location / { root /usr/local/nginx/html; index index.php; rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last; rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last; rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last; rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last; rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; try_files $uri $uri/ /index.php?$args; index index.html index.htm index.php; strip on; } if ($http_user_agent ~* aesop_com_spiderman|alexibot|backweb|bandit|batchftp|bigfoot|black.hole|blackwidow|blowfish|botalot|buddy|builtbottough|bullseye|cheesebot|cherryicker|chinaclaw|collector| copier|copyrightcheck|cosmos|crescent|curl|custo|da|diibot|disco|dittospyder|dragonfly|drip|easydl|ebingbong|ecatch|eirgrabber) { rewrite ^/ http://mysite.com/robots.txt; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 10; fastcgi_send_timeout 10; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # server { # listen 80; # server_name www.mysite.com; # rewrite ^ http://www.mysite.com$uri permanent; # } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } 

你不应该对微型实例进行任何forms的性能testing,除非你正在计划在生产中运行微型(我不推荐)。

微型实例有一个节制CPU,低I / O性能。 这些都足以避免在生产中使用它们,或担心解决性能问题。

我的build议是在生产级实例types上运行一些性能testing(对于小stream量来说,小的开始是一个好的开始)。 这将是排除微型实例作为间歇性性能问题根源的最快最明智的方法。

http://aws.amazon.com/ec2/instance-types/

微型实例(t1.micro)提供less量一致的CPU资源,并允许您在有额外的周期可用时以短脉冲来增加CPU容量。 它们非常适合低吞吐量的应用程序和定期需要额外计算周期的网站

微型实例

  • 613兆内存
  • 最多2个EC2计算单位(短周期性突发)
  • 只有EBS存储
  • 32位或64位平台
  • I / O性能:低
  • EBS优化可用:否
  • API名称:t1.micro