'Apache performance tuning for high traffic with MPM Event

I currently manage the following set of servers that serve about 700 web pages:

SERVER 1 (WEB)

  • Web server: Apache 2.4.29 with MPM Event
  • PHP 7.2.22
  • CPU: Intel Xeon CPU E5-2673 v4 @2.30GHz (4 cores) 16GB memory
  • S.O: Ubuntu Server 18.04.2 LTS

SERVER 2 (DataBase)

  • DB: mysql 10.2.26
  • CPU: Intel Xeon CPU E5-2673 v4 @2.30GHz (8 cores) 32 GB memory
  • S.O: Ubuntu Server 18.04.2 LTS

Both servers are connected on the same local network.

Recurrently I have performance problems and I think it's because I don't have Apache optimized correctly.

The web server receives many web requests that it does not manage well and produces high CPU consumption and consequently slowness in the whole server.

Currently this is the MPM configuration I work with and I think it doesn't manage connections correctly:

<IfModule mpm_event_module>
        StartServers            2
        MinSpareThreads         25
        MaxSpareThreads         75
        ThreadLimit             64
        ThreadsPerChild         25
        MaxRequestWorkers       550
        ServerLimit             32
        MaxConnectionsPerChild  0
</IfModule>

Can anyone tell me an optimal configuration of the MPM according to the requirements and characteristics of the server?



Solution 1:[1]

Try these settings:

<IfModule mpm_event_module>
        StartServers            4
        MinSpareThreads         25
        MaxSpareThreads         75
        ThreadLimit             64
        ThreadsPerChild         25
        MaxRequestWorkers       800
        ServerLimit             32
        MaxConnectionsPerChild  10000
</IfModule>

The easiest way for configuring MaxRequestWorkers:

ServerLimit x ThreadsPerChild = MaxRequestWorkers

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1