开门见山,网站请求反应速度慢首先考虑服务器问题。
我在开发中遇到的就是服务器实例限制cpu占用10%以内访问正常,超出则限制访问速度,也就是网站请求速度慢
具体和阿里工程师聊天截图如下:


按照对方说的,升级了相关配置,然后重启服务器,重启web端的nginx和php,速度溜溜上来了;
另外也最好把下面几条给做了
1增加nginx的upstream,其中upstream中为php-cgi的地址;
2利用nginx作为反向代理,分支法解决并发量;
3增加php-cgi的进程数,(这里会受到机器资源的限制,因此,也并不能无限增加)
我这里使用了反向代理这各办法解决了相关问题
下面把具体解决办法放在下面,顺便把nginx下配置项目的配置贴出来,供大家使用
1 server {2 listen 80;3 server_name 你的域名;4 index index.html index.htm index.php;5 root /yjdata/www/www/tp5_houtai/public;6 error_page 404 /404.html;7 8 location / {9 index index.php index.html index.htm;
10 if (!-e $request_filename) {
11 rewrite ^(.*)$ /index.php?s=$1 last;
12 break;
13 }
14 #nginx反向代理 此处是解决缓冲慢的重点部分
15 proxy_read_timeout 300;
16 proxy_connect_timeout 300;
17 proxy_set_header X-Real-IP $remote_addr;
18 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19 proxy_set_header Host $http_host;
20 proxy_redirect off;
21 #autoindex on;
22 }
23 #location ~ \.php$ {
24 # fastcgi_pass 127.0.0.1:10000;
25 # include fastcgi.conf;
26 #}
27 location ~ \.php(.*)$ {
#配置404
28 try_files $uri =404;
#此处是9000或者10000根据自己服务器实际情况改 我这里是10000
29 # fastcgi_pass 127.0.0.1:9000;
30 fastcgi_pass 127.0.0.1:10000;
31 fastcgi_index index.php;
32 fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
33 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
34 fastcgi_param PATH_INFO $fastcgi_path_info;
35 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
36 include fastcgi_params;
37 include fastcgi.conf;
38 }
39 } 配置https 1 # HTTPS server
2 #3 server {4 listen 443 ssl;5 server_name 你的域名;6 root /usr/share/nginx/html/wxssgsrz;7 8 index index.html index.htm;9 #相关证书
10 ssl_certificate cert/214757705190741.pem;
11 #相关证书
12 ssl_certificate_key cert/214757705190741.key;
13
14 ssl_session_timeout 5m;
15 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
16 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
17 ssl_prefer_server_ciphers on;
18 location / {
19 root /usr/share/nginx/html/项目名称;
20 index index.html index.htm index.php;
21 if (!-e $request_filename) {
22 rewrite ^(.*)$ /index.php?s=$1 last;
23 break;
24 } proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
25 }
26
27 location ~ .*\.(php|php5)?$ {
28 root /usr/share/nginx/html/项目名称;
#此处是9000或者10000根据自己服务器实际情况改 我这里是10000 29 fastcgi_pass 127.0.0.1:10000;
30 fastcgi_index index.php;
31 fastcgi_param HTTPS on;
32 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
33 include fastcgi_params;
34 #new line
35 include fastcgi.conf;
36 }
37 }
38
39 #此处是把http强制转成https的配置 及访问http会自动跳转到https对应地址上
40 server {
41 listen 80;
42 server_name wx.ssgsrz.com;
43 rewrite ^/(.*) https://$server_name$request_uri? permanent;
44 }
好了 多余的不说了 ,大家复制拿去用就是了
谢谢大家浏览到这里~~~
