0

My website generate when I tried to hit 1000 requests per second on it. I am seeing the following errors in my apache logs

Apr 06 00:00:33 ns503772******100.net httpd[9585]: AH00515: WARNING: MaxRequestWorkers of 2000 would require 80 servers and
Apr 06 00:00:33 ns503772******100.net httpd[9585]: would exceed ServerLimit of 16, decreasing to 400.
Apr 06 00:00:33 ns503772******100.net httpd[9585]: To increase, please see the ServerLimit directive.

My current setting was following

<IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
MaxRequestWorkers 2000
</IfModule>

I'm am using Plesk Onyx and server specification are following.

Processor: Intel Xeon E5-1620v2 - 4c/8t - 3.7 GHz/3.9 GH

Sever Ram: 64GB DDR3

Then I have tried the following settings

<IfModule mpm_event_module>
StartServers                80
MinSpareThreads             50
MaxSpareThreads             300

ThreadLimit                 25
ThreadsPerChild             25

ServerLimit                 500
MaxRequestWorkers           2000
MaxConnectionsPerChild      0
</IfModule>

but issue remain un solved, infarct its generating more errors & log-writer started eating CPU

output of httpd -V | grep -i 'version\|mpm' is following

Server version: Apache/2.4.6 (CentOS)
Server MPM:     event
Hassaan
  • 387
  • 2
  • 7
  • 18
  • If you want `MaxRequestWorkers` of 2000, the `ServerLimit` only needs to be 25. Setting it to 500 may be overpowering your system. See the [ServerLimit directive documentation](http://httpd.apache.org/docs/2.4/mod/mpm_common.html#serverlimit) – Colt Apr 06 '17 at 11:15
  • You also don't need to start all 80 servers right off – Colt Apr 06 '17 at 11:21
  • @Colt could you suggest / optimize my values for high traffic site? – Hassaan Apr 06 '17 at 11:54
  • See [performance tuning documentation](http://httpd.apache.org/docs/2.4/misc/perf-tuning.html#hardware) for `MaxRequestWorkers` formula, and the MPM core and event documentation for other settings – Colt Apr 06 '17 at 12:20
  • @Colt I have tried it but results are not good. I have write the conf I have tried in my question. I think performance tuning need experience so I am asking to help me out please – Hassaan Apr 06 '17 at 12:31

1 Answers1

2

ServerLimit is not defined/not read, but still that value you want to try makes no sense since threads per child is already forcing the serverlimit to 80.

And why do you use so small number of threads? You are generating too many child processes without need, probably making Apache less performant in the process (spawn processes more expensive than threads)

Note: MPM settings require a FULL STOP/START (not restart).

Set this.

StartServers 1
ServerLimit 4
MinSpareThreads 500
MaxSpareThreads 1500
MaxRequestWorkers 2000
ThreadsPerChild 500
ThreadLimit 500
MaxConnectionsPerChild 0
MaxKeepAliveRequests 1500
KeepAlive On
KeepAliveTimeout 10

And do make sure you do a full stop then start for the changes to be applied for real.

ezra-s
  • 2,215
  • 1
  • 7
  • 13
  • Thank you so much for response. Yeah actually I don't much knowledge and experience in performance tuning of `apache 2.4`. I have applied your suggested setting and things seem OK but When I hit `ab -n 100000 -c 500 http://www.4songs.pk/` command to test server, my site works to slow. I have good processor and ram. What do you suggest is these setting are OK? – Hassaan Apr 06 '17 at 20:35
  • Do I need other setting like `EnableSendfile` or `KeepAlive connections` to increase performance ? – Hassaan Apr 07 '17 at 05:13
  • If your static content is not on a networked filesystem you can use EnableSendFile, KeepAlive, yes I usually allow around 80% of maxrequestworkers, but that's just me probably. Try ab from a different machin (not locally) otherwise you are adding the overhead of the calls to the overhead of the responses and also, try requesting static content first (index.html or hello.gif, etc), not dynamic content such as cgi scripts/php since then performance will depend on the scripts performance not apache itself. – ezra-s Apr 07 '17 at 12:30
  • I would also encourage to upgrade from 2.4.6 , it's quite an old version. – ezra-s Apr 07 '17 at 12:32
  • Does these improve performance, if yes then can you update your answer accordingly `KeepAlive On` `KeepAliveTimeout 5` `MaxKeepAliveRequests 128` – Hassaan Apr 07 '17 at 12:34
  • yes I want to upgrade this one but I affair it does not support working because `yum update` does not show new version of apache. – Hassaan Apr 07 '17 at 12:36
  • too small number of maxkeepalive if you want to allow a max of 2000 workers imo, try the 80% rule. – ezra-s Apr 07 '17 at 12:37
  • Can you update you answer and include ` KeepAlive` `KeepAliveTimeout` `MaxKeepAliveRequests` – Hassaan Apr 07 '17 at 12:42
  • there you have it. – ezra-s Apr 07 '17 at 12:52
  • Thank you. I read somewhere `KeepAlive` `KeepAliveTimeout ` `MaxKeepAliveRequests` are not used on `MPM Events` is this true? – Hassaan Apr 08 '17 at 05:05
  • no, that's false – ezra-s Apr 08 '17 at 23:46
  • Thank you, Can you help me out with this one http://serverfault.com/questions/843460/php-fpm-sock-failed-11-resource-temporarily-unavailable-while-connecting-to-u – Hassaan Apr 08 '17 at 23:55
  • You can you please update your answer according to 5000 `MaxRequestWorkers` setting – Hassaan Apr 10 '17 at 11:18
  • Actually I receive 503 errors. It would be great if you can help me out – Hassaan Apr 10 '17 at 13:00
  • You are expert in apache and I think you can help me out better – Hassaan Apr 11 '17 at 07:21