Apache MaxRequestWorkers issue not resolving

6,642

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.

Share:
6,642

Related videos on Youtube

Hassaan
Author by

Hassaan

Updated on September 18, 2022

Comments

  • Hassaan
    Hassaan over 1 year

    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
    
    • Admin
      Admin about 7 years
      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
    • Admin
      Admin about 7 years
      You also don't need to start all 80 servers right off
    • Admin
      Admin about 7 years
      @Colt could you suggest / optimize my values for high traffic site?
    • Admin
      Admin about 7 years
      See performance tuning documentation for MaxRequestWorkers formula, and the MPM core and event documentation for other settings
    • Admin
      Admin about 7 years
      @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
    Hassaan about 7 years
    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
    Hassaan about 7 years
    Do I need other setting like EnableSendfile or KeepAlive connections to increase performance ?
  • ezra-s
    ezra-s about 7 years
    I would also encourage to upgrade from 2.4.6 , it's quite an old version.
  • Hassaan
    Hassaan about 7 years
    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.
  • ezra-s
    ezra-s about 7 years
    too small number of maxkeepalive if you want to allow a max of 2000 workers imo, try the 80% rule.
  • ezra-s
    ezra-s about 7 years
    there you have it.
  • Hassaan
    Hassaan about 7 years
    Thank you. I read somewhere KeepAlive KeepAliveTimeout MaxKeepAliveRequests are not used on MPM Events is this true?
  • ezra-s
    ezra-s about 7 years
    no, that's false
  • Hassaan
    Hassaan about 7 years
    Thank you, Can you help me out with this one serverfault.com/questions/843460/…
  • Hassaan
    Hassaan about 7 years
    You can you please update your answer according to 5000 MaxRequestWorkers setting
  • Hassaan
    Hassaan about 7 years
    You are expert in apache and I think you can help me out better