Всем доброго дня!
Имеется 3 контейнера:
nginx (192.168.0.1; 1 GB)
apache (192.168.0.2; 1 GB) PHP + APC, memcached (сессии)
mysql (192.168.0.3; 4 GB)
MySQL ~15-20к запросов/сек на запись/чтение/изменение
При легком тестировании нагрузки слишком высокое время отклика, порядка 0.4-0.7 сек
Подскажите, пожалуйста, в какую сторону смотреть? Спасибо!
/etc/nginx/nginx.conf
user www-data;
worker_processes 8;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
worker_priority -5;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
sendfile on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log /var/log/nginx/error.log;
gzip on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 3;
gzip_http_version 1.1;
gzip_proxied any;
gzip_types text/plain application/xml application/x-javascript text/css;
include /etc/nginx/users/*;
}
/etc/nginx/users/u00001.conf
server {
root /mnt/home/u00001/example.ru/public_html;
server_name example.ru;
index index.htm index.html index.php;
location ~ /\.ht {
deny all;
}
location ~* ^.+\.(js|JPG|jpg|png|jpeg|gif|zip|tgz|gz|rar|doc|xls|exe|pdf|ppt|txt|wav|bmp|rtf)$ {
expires 30d;
root /mnt/home/u00001/example.ru/public_html;
}
location / {
proxy_pass http://192.168.0.2:80;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 61;
proxy_send_timeout 61;
proxy_read_timeout 61;
}
}
Apache Server MPM: ITK
/etc/apache2/apache2.conf
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 75
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
/etc/apache2/users/u00001.conf
<VirtualHost *:80>
ServerName example.ru
DocumentRoot /mnt/home/u00001/example.ru/public_html
AssignUserID u00001 u00001
php_admin_value open_basedir /mnt/home/u00001/example.ru/public_html
php_admin_value doc_root /mnt/home/u00001/example.ru/public_html
php_admin_value upload_tmp_dir /mnt/home/u00001/example.ru/tmp
php_admin_value apc.enabled 1
php_admin_value apc.shm_size 128M
php_admin_value apc.mmap_file_mask /mnt/home/u00001/example.ru/tmp/apc.XXXXX
php_admin_value apc.num_files_hint 20000
php_admin_value apc.user_entries_hint 20000
php_admin_value apc.ttl 86400
php_admin_value apc.user_ttl 7200
php_admin_value apc.gc_ttl 3600
php_admin_value apc.max_file_size 4M
ErrorLog /mnt/home/u00001/example.ru/logs/error.log
TransferLog /mnt/home/u00001/example.ru/logs/access.log
<Directory /mnt/home/u00001/example.ru/public_html>
Options FollowSymLinks
Order Allow,Deny
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
/etc/mysql/my.cnf
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
skip-external-locking
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_buffer_pool_size = 2GB
innodb_doublewrite = 0
innodb_support_xa = 0
innodb_thread_concurrency = 16
transaction-isolation = READ-COMMITTED
table_open_cache=800
bind-address = 0.0.0.0
key_buffer = 32M
max_allowed_packet = 32M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 64M
query_cache_size = 32M
expire_logs_days = 10
max_binlog_size = 100M
/proc/user_beancounters
[nginx]
kmemsize 3872872 7360512 1073741824 1073741824
lockedpages 3194 16384 16384
privvmpages 13588 16444 1073741824 1073741824
shmpages 7 7 1152 1152
numproc 23 42 128 128
numtcpsock 1 141 1024 1024
numflock 1 6 50 60
numpty 4 32 32
numsiginfo 21 256 256
tcpsndbuf 17440 2476480 1073741824 1073741824
tcprcvbuf 16384 577400 4194304 4194304
othersockbuf 18496 30136 135168 237568
dgramrcvbuf 135168 196608
numothersock 43 49 100 100
dcachesize 400092 405466 405504 405504
numfile 153 330 1024 1024
numiptent 20 20 64 64
[apache]
kmemsize 4760406 84217856 1073741824 1073741824
lockedpages 3194 16384 16384
privvmpages 50508 822778 1073741824 1073741824
shmpages 26 26 16384 16384
numproc 21 186 1024 1024
numtcpsock 4 294 1024 1024
numflock 2 6 50 60
numpty 4 32 32
numsiginfo 57 256 256
tcpsndbuf 69760 5127360 1073741824 1073741824
tcprcvbuf 65536 762968 4194304 4194304
othersockbuf 4624 32304 135168 237568
dgramrcvbuf 4624 135168 196608
numothersock 40 46 100 100
dcachesize 396396 405503 405504 405504
numfile 225 640 1024 1024
numiptent 20 20 64 64
[mysql]
kmemsize 2431247 4243456 4294967296 4294967296
lockedpages 3194 16384 16384
privvmpages 639503 641670 1073741824 1073741824
shmpages 6 6 1152 1152
numproc 34 117 128 128
numtcpsock 1 68 1024 1024
numflock 4 9 50 60
numpty 4 32 32
numsiginfo 24 256 256
tcpsndbuf 165680 524288 524288
tcprcvbuf 16384 541728 4194304 4194304
othersockbuf 2312 8456 135168 237568
dgramrcvbuf 2312 135168 196608
numothersock 29 35 100 100
dcachesize 401016 405492 405504 405504
numfile 133 280 1024 1024
numiptent 20 20 64 64