我已经在我的VPS上安装了ubuntu 14.04,nginx,mariadb和hhvm,以便运行Laravel应用程序。但是,当活动连接数超过100时,用户无法访问我们的服务器(或者他们需要等待很长时间)。我可以知道造成这种情况的可能原因是什么?这是我的VPS的日志和配置。
cpu infor:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
stepping : 7
cpu MHz : 1500.138
cache size : 15360 KB
physical id : 0
siblings : 12
core id : 0
cpu cores : 6
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
RAM:
3GB
顶部:
iotop:
nginx状态:
Active connections: 112
server accepts handled requests
269927 269927 368061
Reading: 0 Writing: 2 Waiting: 110
nginx config:
user www-data;
worker_processes 6;
pid /run/nginx.pid;
events {
worker_connections 4096;
use epoll;
multi_accept on;
}
worker_rlimit_nofile 10000;
http {
##
# Basic Settings
##
client_max_body_size 110m;
client_body_buffer_size 10K;
client_header_timeout 12;
client_body_timeout 12;
send_timeout 12;
sendfile on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 12;
types_hash_max_size 2048;
server_tokens off;
reset_timedout_connection on;
limit_conn_zone $binary_remote_addr zone=addr:5m;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_proxied expired no-cache no-store private auth;
gzip_min_length 10240;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Cache Configs
##
open_file_cache max=100000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 5;
open_file_cache_errors on;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
服务器配置:
server {
server_name www.xxx.com;
return 301 $scheme://xxx.com$request_uri;
}
server {
listen 80;
##
# Static File Caching
##
location ~* .(jpg|jpeg|png|gif|ico)$ {
expires 365d;
}
root /xxx/xxx.com/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name xxx.com;
access_log off;
error_log /var/log/nginx/xxx-error.log error;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
include hhvm-with-fallback.conf;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location @fallback {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
mysql config:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
bind-address = 127.0.0.1
#
# * Fine Tuning
#
max_connections = 500
connect_timeout = 5
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover = BACKUP
key_buffer_size = 128M
#open-files-limit = 2000
table_open_cache = 400
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 1M
#
# * Query Cache Configuration
#
# Cache only tiny result sets, so we can fit more in the query cache.
query_cache_limit = 128K
query_cache_size = 64M
# for more write intensive setups, set to DEMAND or OFF
#query_cache_type = DEMAND
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
log_warnings = 2
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log[={0|1}]
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
#sync_binlog = 1
expire_logs_days = 10
max_binlog_size = 100M
default_storage_engine = InnoDB
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
hhvm php.ini
; php options
session.save_handler = files
session.save_path = /var/lib/php5
session.gc_maxlifetime = 1440
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
hhvm server.ini
; php options
pid = /var/run/hhvm/pid
; hhvm specific
hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
"显示完整的流程清单;"结果
+--------+------+-----------+---------------+---------+------+-------+-----------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+--------+------+-----------+---------------+---------+------+-------+-----------------------+----------+
| 126338 | root | localhost | NULL | Query | 0 | init | show full processlist | 0.000 |
| 127981 | root | localhost | pa_db | Sleep | 5 | | NULL | 0.000 |
+--------+------+-----------+---------------+---------+------+-------+-----------------------+----------+