我有一个使用 nginx、fastcgi 部署的 opencart 应用程序。我使用 RDS 作为 Mysql 服务器。
最近,我的日志中出现了这个错误,我用 siege 对 400 个并发用户进行了负载测试。我得到了这个错误
FastCGI sent in stderr: "PHP message: PHP Warning: mysqli::mysqli
使用 apache 作为服务器运行与 siege 相同的负载测试。测试结果积极
这些是使用 nginx 进行围攻的结果
Transactions: 3246 hits
Availability: 77.80 %
Elapsed time: 146.43 secs
Data transferred: 35.27 MB
Response time: 6.86 secs
Transaction rate: 22.17 trans/sec
Throughput: 0.24 MB/sec
Concurrency: 152.01
Successful transactions: 1049
Failed transactions: 926
Longest transaction: 36.83
Shortest transaction: 0.65
和 apache
Transactions: 7921 hits
Availability: 99.01 %
Elapsed time: 462.60 secs
Data transferred: 218.75 MB
Response time: 9.94 secs
Transaction rate: 17.12 trans/sec
Throughput: 0.47 MB/sec
Concurrency: 170.12
Successful transactions: 4925
Failed transactions: 79
Longest transaction: 114.25
Shortest transaction: 0.59
这些是 nginx 和 fpm conf:
user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
# Compression
# Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
#gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 4;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/x-javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component
text/xml
text/javascript
text/x-javascript
# text/html is always compressed by HttpGzipModule
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}