Closed zhong1002 closed 4 years ago
请确认请求是否走了LaravelS(Swoole Http Server)?输出php_sapi_name()看看? 可以将JMeter请求地址与Nginx配置贴出来看看。
走的,因为api路由与web路由也在同一个项目.
nginx配置是
upstream swoole_test {
server workspace:5200 weight=5 max_fails=3 fail_timeout=30s;
# 通过 UnixSocket Stream 连接,小诀窍:将socket文件放在/dev/shm目录下,可获得更好的性能
#server unix:/xxxpath/laravel-s-test/storage/laravels.sock weight=5 max_fails=3 fail_timeout=30s;
#server 192.168.1.1:5200 weight=3 max_fails=3 fail_timeout=30s;
#server 192.168.1.2:5200 backup;
keepalive 16;
} server { listen 8083; listen [::]:8083;
# For https
#ssl on;
#listen 443 ssl;
#listen [::]:443 ssl;
#ssl_certificate /var/www/ssl_cert/default.crt;
#ssl_certificate_key /var/www/ssl_cert/default.key;
server_name 172.17.0.12;
root /var/www/abtest/laravel5-swoole/public;
index index.php index.html index.htm;
location / {
try_files $uri @laravels;
}
location ~* \.php$ {
return 404;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
error_log /var/log/nginx/laravel_error.log;
access_log /var/log/nginx/laravel_access.log;
location @laravels {
# proxy_connect_timeout 60s;
# proxy_send_timeout 60s;
# proxy_read_timeout 120s;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header Server-Protocol $server_protocol;
proxy_set_header Server-Name $server_name;
proxy_set_header Server-Addr $server_addr;
proxy_set_header Server-Port $server_port;
proxy_pass http://swoole_test;
}
}
1、session和cache换成redis驱动 2、关闭session(包括Csrf中间件)
高并发下会因为这两点疯狂写文件,即使session换用redis也会因为疯狂读写redis导致cpu飙升
压测注意事项:
+---------------------------+---------------------------------------+ | Component | Version | +---------------------------+---------------------------------------+ | PHP | 7.3.16-1+ubuntu16.04.1+deb.sury.org+1 | | Swoole | 4.4.17 | | LaravelS | 3.7.3 | | Laravel Framework [local] | 5.5.49 | +---------------------------+---------------------------------------+
api路由是 /api/test web路由是 /
Some
reproducible
code blocks andsteps
测试代码已上传到 https://github.com/slarkes/abtest