Who is to blame, the server does not pull or scripts have finished?

I have entertainment website https://www.vip-nickname.ru/.
Website on VPS server only (2x2200 Processor, Memory, 2048, OS centos6-x86_64) .

There is some problem with loading it. Mostly works fine page turning is fast, the execution time of php scripts is approximately 0.02 s. But in rush hour Saturday-Sunday online users to about 100 people start braking. It happens that the page is not loaded at all, nor the fact-that for a long time, but in General are not loaded.
The RAM and the CPU on the server is not loaded, according to the statistics of the stock is still decent.
When you open the console and restart the web server reload the page everything starts to fly.

Where to drip do not understand the process like no extra. I would be grateful for any thoughts.
April 7th 20 at 15:56
7 answers
April 7th 20 at 15:58
Che is there to think stupidly to watch the logs and fix the lift
The problem, instead of to read tea leaves as suggested by the author
Thank you! The logs looked before, only now hopefully found the cause

server reached MaxClients setting, consider raising the MaxClients setting - daniella.McLaughl commented on April 7th 20 at 16:01
April 7th 20 at 16:00
I would be grateful for any thoughts.

The idea - and it would be nice for code profiling with timing, you can see which operation typically occurs plugging under load.
Thank you! I'll try. - daniella.McLaughl commented on April 7th 20 at 16:03
April 7th 20 at 16:02
Moving from Apache to nginx. Or, at least, give a statics through nginx (images, styles, js, etc.). Very much will be able to raise the threshold when the server connection goes.
April 7th 20 at 16:04
php-fpm with the configured restart workerb, such as the number of requests - 1000 will be the norm. + The entry in the logs slow requests, too, need to configure is to specify the timeout implementation. Well, heaps of autoscaling workarou to simple was, like, 15 and under load you can and more, for example 50.

For the future,
When you understand that the server is over, you can insert the following, it means just launch another VPS with php-fpm.
If there is upload, then you need to decide how to make them, if the record is not very active, may be suitable for glusterfs or nfs. Both solutions at the ideal uploady pouring in cdn.
And Yes a base to extend between the nodes will need :)
April 7th 20 at 16:06
The main reason was the limitation of the maximum possible concurrent connections to Apache.

"server reached MaxClients setting, consider raising the MaxClients setting"

Increased in 3 times, and other server settings on the same subject corrected.
Immediately after the problem is corrected, the traffic grew about +20% more online

Other proposals will consider, there seem to have more time to spend.

Thank you ALL for your help!
April 7th 20 at 16:08
Where you monitor io?
April 7th 20 at 16:10
1. If your site is running on php-fpm, optimize php-fpm. Note the settings below. For example, the values for the test can be:
emergency_restart_threshold 10
emergency_restart_interval 1m
process_control_timeout 10s

2. If the backend Apache (httpd), we recommend you to take advantage of the server-status from Apache.

Conf file:

Edit configuration file parameters

SetHandler server-status
Order deny,allow
Deny from all
#Allow connection from your network
#Allow from

Test Apache config
httpd-t or apachectl configtest

Perezagruzite Apache
service httpd restart or reload (if the reload didn't work)

At the time of view load status on the following link:

3. At the time of load TOP view on the server.
Analyze the processes.

4. If you use php-FCGI, make the settings
Most often, the configuration file here:

Make the settings in the end of the file and restart Apache.
FcgidProcessLifeTime 14400
FcgidIdleScanInterval 60
FcgidIdleTimeout 60
FcgidMaxProcesses 3000
FcgidMaxProcessesPerClass 500
FcgidMaxRequestsPerProcess 100
FcgidMinProcessesPerClass 0
FcgidMaxRequestLen 200000000
FcgidIOTimeout 300

Test Apache config
httpd-t or apachectl configtest

Restart Apache
service httpd restart or reload (if the reload didn't work)

The above are a few options that can help you.
If you do not help, you need a diagnosis of the problem, to identify solutions.
We wish you good luck in resolving the issue!

Find more questions by tags HostingMySQLPHP