For any given website there is more than a 50% probability it is running on Apache.
The next step is to check everything is OK with the server itself.
It is, when basic metrics like CPU, memory, disk and swap come into play.
It will add more shades to the picture and give you some guidance on where to dig further.
The most frequent reason for website performance issues is malfunctioning, buggy or un-optimised tool (e.g.
PHP script), and cumbersome DB queries.
Apache normally compiles with mod_status built in but not enabled.
The above configuration will make statistics available at http://127.0.0.1/server-status.
You may also want to make your monitoring system read and store this data.
Lets now examine what kind of statistics are provided by Apache and how these may be useful.
Apache processes and threads architecture
Latest Apache versions implement hybrid multi-threaded and multi-process models to server requests.
This means that you will see multiple Apache processes running and that each process contains multiple threads.
This allows great trade-off between efficiency and stability.
Those workers that are already processing requests are called busy workers.
Depending on the number of idle workers Apache is able to fork or kill processes.
So under normal conditions the number of idle workers should be more or less stable thanks to Apache self-regulation.
The way Apache forks processes and threads is defined by a particular Multi-Processing Module (MPM) implementation.
These modules are also responsible for binding ports, accepting connections, and dispatching it to workers.
There are several of them depending on OS withpreforkandworkerbeing most popular on Unix OS family.
Thuspreforkis less memory efficient but allows more stability in case of non-thread safe applications.
Anything unusual with the traffic?
Another good starting point for troubleshooting website problems is to check whether traffic was/is unusual.
Take a look at Apache logs
Apache, as with any other good software, writes logs.
There are two logs: error.log and access.log.
It will also contain all PHP or other app-level errors encountered by Apache modules.
So the Apache log is definitely worth taking a look at for yourself.
Access.log keeps record of all visitors and all their requests.
A web server should never swap because swapping a process will make request processing latency unacceptable.
you might use this information to anticipate future upgrades of your infrastructure.
use nginx with php-fpm).
Unfortunately there is no silver bullet different recipes are good for different environments and web applications.