Apache настройка mpm_prefork

T
На сайте с 06.10.2007
Offline
81
6261

Стоит Apache+Nginx, через ИСПменеджер все поставилось с коробки.

Оперативки хватает, 64GB

Где то 2 месяца все работало нормально, потом начали вылазить ошибки типа

[Tue Jul 05 02:10:03.646880 2016] [mpm_prefork:info] [pid 16185] AH00162: server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 18 idle, and 21 total children

При том что работало на дефолтных настройках о_О

# prefork MPM

# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of requests a server process serves

#<IfModule mpm_prefork_module>
# StartServers 5
# MinSpareServers 5
# MaxSpareServers 10
# MaxRequestWorkers 250
# MaxConnectionsPerChild 0
#</IfModule>
<IfModule mpm_prefork_module>
StartServers 20
MinSpareServers 20
MaxSpareServers 40
ServerLimit 750
MaxRequestWorkers 750
MaxRequestsPerChild 1000
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Server version: Apache/2.4.10 (Debian)

Server built: Nov 28 2015 14:05:48
Server's Module Magic Number: 20120211:37
Server loaded: APR 1.5.1, APR-UTIL 1.5.4
Compiled using: APR 1.5.1, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"

apache2.conf

Mutex file:${APACHE_LOCK_DIR} default


PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive Off

MaxKeepAliveRequests 150

KeepAliveTimeout 5


User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel info

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf


<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>





AccessFileName .htaccess

<FilesMatch "^\.ht">
Require all denied
</FilesMatch>


LogFormat "%v:%p %a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%a %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.conf

Include conf.d/
Include vhosts-default/
Include vhosts/
Listen 127.0.0.1:8080

#user 'site' virtual host 'site.ru' configuration file

<VirtualHost 127.0.0.1:8080>
ServerName site.ru
AddDefaultCharset UTF-8
DirectoryIndex index.html index.php
DocumentRoot /var/www/site/data/www/site.ru
ServerAdmin admin@site.ru
SuexecUserGroup site site
ServerAlias www.site.ru
ServerAlias 138.201.xxx.xxx
CustomLog /var/www/httpd-logs/site.ru.access.log combined
ErrorLog /var/www/httpd-logs/site.ru.error.log
<FilesMatch "\.ph(p[3-5]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f admin@site.ru"
php_admin_value upload_tmp_dir "/var/www/site/data/mod-tmp"
php_admin_value session.save_path "/var/www/site/data/mod-tmp"
php_admin_value open_basedir "/var/www/site/data:."
</VirtualHost>
<Directory /var/www/site/data/www/site.ru>
Options -ExecCGI
php_admin_flag engine on
</Directory>
<Directory /var/www/site/data/www/site.ru/webstat>
AddDefaultCharset UTF-8
DirectoryIndex index.html
Allow from all
AuthName "Access limited by ISPmanager"
AuthType Basic
AuthUserFile /var/www/site/data/etc/access.site.ru.VihQs/3k.passwd
Order allow,deny
Require valid-user
</Directory>

Apache server status

Гуглиг, клацал, менял... вроде стало лучше, но ошибки все равно проскакивают

Можете подсказать куда смотреть\что менять?

L
На сайте с 13.01.2011
Offline
125
#1

мало ему воркеров

может у вас апач в mysql упирается ? munin помогает оценить ситуацию и mysqltuner.pl

Контакты-icq 535609 ()
Andreyka
На сайте с 19.02.2005
Offline
822
#2

Возможно, что флудят - автореги, спамкаменты, грабберы

Не стоит плодить сущности без необходимости
T
На сайте с 09.12.2011
Offline
55
tls
#3

Новые процессы форкаются очень медленно. Например, из-за большого LA. Можно попробовать увеличить StartServers/MinSpareServers=40 (но лучше ориентироваться на значение reqs/s в течение дня) и смотреть дальше.

T
На сайте с 06.10.2007
Offline
81
#4
Logger:
мало ему воркеров
может у вас апач в mysql упирается ? munin помогает оценить ситуацию и mysqltuner.pl

Когда создавал топик поигрался с настройками, выделил дофига ресурсов)

perl mysqltuner.pl

 >>  MySQLTuner 1.6.10 - Major Hayden <major@mhtx.net>

>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[OK] Logged in using credentials from debian maintenance account.

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.47-0+deb8u1-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 2G (Tables: 401)
[--] Data in InnoDB tables: 1M (Tables: 62)
[!!] Total fragmented tables: 87

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'user1@%' hasn't specific host restriction.
[!!] User 'user2@%' hasn't specific host restriction.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 1d 20h 55m 46s (2 q [0.000 qps], 1M conn, TX: 181B, RX: 149B)
[--] Reads / Writes: 100% / 0%
[--] Binary logging is disabled
[--] Physical Memory : 62.9G
[--] Max MySQL memory : 8.7G
[--] Other process memory: 2.2G
[--] Total buffers: 400.0M global + 8.5M per thread (1000 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 748.5M (1.16% of installed RAM)
[OK] Maximum possible memory usage: 8.7G (13.82% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/2)
[OK] Highest usage of available connections: 4% (41/1000)
[OK] Aborted connections: 0.00% (38/1360997)
[!!] Query cache should be disabled by default due to mutex contention.
[OK] No Sort requiring temporary tables
[OK] No joins without indexes
[OK] No tmp tables created on disk
[OK] Thread cache hit rate: 99% (41 created / 1M connections)
[OK] Table cache hit rate: 100% (925 open / 0 opened)
[OK] Open file limit used: 25% (1K/5K)
[OK] Table locks acquired immediately: 99% (2M immediate / 2M locks)

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 99.0% (33M used / 33M cache)
[OK] Key buffer size / total MyISAM indexes: 32.0M/139.5M
[OK] Read Key buffer hit rate: 98.9% (50M cached / 576K reads)
[!!] Write Key buffer hit rate: 42.6% (1M cached / 939K writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 128.0M/1.5M
[OK] InnoDB buffer pool instances: 1
[!!] InnoDB Used buffer: 3.81% (312 used/ 8192 total)
[OK] InnoDB Read buffer efficiency: 98.14% (16483 hits/ 16796 total)
[!!] InnoDB Write Log efficiency: 0% (1 hits/ 0 total)
[OK] InnoDB log waits: 0.00% (0 waits / 1 writes)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Restrict Host for user@% to user@SpecificDNSorIp
Variables to adjust:
query_cache_type (=0)

Как то криво стал munin.... но мониторинг настроил

[Wed Jul 06 16:28:33.486710 2016] [mpm_prefork:info] [pid 30084] AH00162: server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 18 idle, and 20 total children

Я так понимаю что в это время на графиках где то что то должно быть выше нормы?

На что именно смотреть?

Стаса Munin

Но вроде все в пределах нормы... Или надо дождаться чтоб апач перезапустился и тогда смотреть?

Andreyka:
Возможно, что флудят - автореги, спамкаменты, грабберы

Я так понимаю что это дело смотреть в логах доступа апача? Или еще где то?

tls:
Новые процессы форкаются очень медленно. Например, из-за большого LA. Можно попробовать увеличить StartServers/MinSpareServers=40 (но лучше ориентироваться на значение reqs/s в течение дня) и смотреть дальше.

Просто когда я все перенес на новый сервер, примерно 2 месяца все работало нормально, потом возможно ISPmanager что то обновил и начались глюки...

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий