I home somebody can help me with tips of optimization, thank you :-)
I have the following vps server:
6 CPU Cores
320 GB Storage SSD
16 GB RAM
Apache version 2.4.6
MariaDB version 5.5.60
Most load is between time 17.00 to 19.00 and there the server is slow and sometimes goes down.
The server has around 200 websites with mysql queries.
my apache httpd.conf configuration:
KeepAlive Off
KeepAliveTimeout 5
MaxKeepAliveRequests 200
HostnameLookups Off
#KeepAlive Off
<IfModule prefork.c>
StartServers 50
MinSpareServers 50
MaxSpareServers 100
ThreadsPerChild 200
MaxClients 250
MaxRequestsPerChild 2000
</IfModule>
and in 01-cgi.conf
<IfModule mpm_worker_module>
LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 4000
ServerLimit 5000
</IfModule>
mariadb my.cnf
symbolic-links=0
innodb_file_per_table = 1
myisam_sort_buffer_size = 64M
read_rnd_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
sort_buffer_size = 512K
table_open_cache = 64
max_allowed_packet = 1M
key_buffer_size = 16M
max_connections = 500
connect_timeout=30
max_connect_errors=2000
log-slow-queries=/var/log/mariadb/mysql-slow.log
skip-name-resolve
query_cache_limit = 1M
query_cache_size = 256M
I tried load test with loader.io with following settings but it seems to reach about 180-185 clients and my server timeout
clients from 0-250 duration 1 min
Related
I have a VPS server that sometimes stop Apache2 because its settings are not well seized
Service specifications:
RAM 30
CPU 8
I tried to seize it myself, but I did not succeed
The current settings:
<IfModule mpm_prefork_module> StartServers 100 MinSpareServers 20 MaxSpareServers 50 ServerLimit 4000 MaxClients 1400 MaxRequestWorkers 8000 MaxConnectionsPerChild 10000 MaxRequestsPerChild 5000 KeepAlive 0 </IfModule>
Can you give me the best settings that suit the server specifications, knowing that it receives huge requests
mod_prefork is an old module.
I advise you to use mod_event or mod_worker these module are clearly better.
You can see more information here explanation.
About your configuration, it’s depend on you server software stack.
If you have only Apache with maybe a Php webapp or other.
I think you can use this profile, of course with monitoring you can configure it better that my estimation.
StartServers 8
MinSpareServers 10
MaxSpareServers 40
KeepAlive 0
ServerLimit 1500
MaxRequestWorkers 1500
MaxConnectionsPerChild 4000
MaxRequestWorkers and MaxClients is the same directive, MaxClients is the old version.
MaxRequestsPerChild and MaxConnectionsPerChild is the same too, MaxRequestsPerChild is the old version.
I would like to change the default max connection numbers in Apache as the number of processes is now
# ps -ef | grep apache2 | wc -l
152
I have read that I have to change ServerLimit, but I don't see that in apache config files.
# grep -r ServerLimit .
#
Where should I apply that?
UPDATE:
Regarding the MPM module, I see this in mods-available/mpm_prefork.conf:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
Should I increase MaxRequestWorkers only? Or I have to define ServerLimit?
MPM configuration setting located in conf.modules.d/00-mpm.conf file. You can configure ServerLimit after LoadModule entry. You can refer httpd process always 256
I'm using apache 2.2 on centos 6.8. Sometime some httpd process used 100% as image below:
Top monitoring
I already checked all website's source code and all of them is ok ( no loop, no error, ... ).
and httpd.conf:
Timeout 30
KeepAlive Off
<IfModule worker.c>
StartServers 8
MaxClients 1000
MinSpareThreads 8
MaxSpareThreads 100
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
RLimitCPU 60 80
but I can not find any reason about that issue, pls help, thank so much ^^.
I have a vps with Ubuntu 14.04.1 LTS and plesk 12.01
Where I have 8 active domains.
Many times I find myself off the http service logs the following error:
server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
I tried different configurations, but nothing.
Just start the apache service sites go quietly, after 2-3 minutes they all go off. But the cpu and ram are completely free.
In plesk I only active mpm_prefor
How can I fix this?
Can you please try to increase MaxRequestWorkers value on your server to 250 and monitor your Apache services logs, if you are getting same issues that meas your server is under DDOS attack and due to that you are getting this issues,
I need to tune my apache2 Config to handle 1500 Connections simultaneously. Each request user makes it never ends and he gets data all the time except if he press the stop from his browser.
My Current Config Is:
<IfModule mpm_prefork_module>
StartServers 15
MinSpareServers 5
MaxSpareServers 50
ServerLimit 5000
MaxClients 5000
MaxRequestsPerChild 4000
</IfModule>
<IfModule mpm_worker_module>
ServerLimit 40
StartServers 2
MaxClients 1000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Which i have no idea if this is tuned. Also do i need to tune something else other tan prefork_module and worker module?
Please note that the server is really strong with 12 Cores and 64GB Ram.
Thank you