How to stop server overload, Apache, MySQL and Php config

I have set up a basic 1GB server running Ubuntu and Apache2.4.46, PHP7.4.16 MySQL 8.0.27. I am running one Wordpress installation on it.

I seem to be able to overload and crash the server by repeatedly refreshing pages (holding down command and reload). I made the time that this takes to happen a lot longer by making some changes to configs. Whilst this is an edge case situation, I would like to know if there is a way to make sure my server can not get overloaded from multiple requests.

Are there other settings for Apache, MySQL or PHP (or other) I could change to help with load.

Many thanks in advance.

**PHP set up: PHP Memory Limit 256 MB PHP Post Max Size 256M PHP Time Limit 300 PHP Max Input Vars 5000 Max Upload Size 128 MB

**MySQL key_buffer_size = 128M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 myisam-recover-options = BACKUP max_connections = 20 max_binlog_size = 100M interactive_timeout = 30 wait_timeout = 30 skip-name-resolve I have run mysql tuner and the only recommendation is: innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

**Apache Timeout 30 KeepAlive On MaxKeepAliveRequests 10 KeepAliveTimeout 1

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @RedmansWorld,

What you are describing is not high load or websites going down but your Apache Workers filling up, at least this is how it sounds(might be wrong!).

So first, what are Apache Workers and what are they used for:

Imagine you are in a cinema, and there are 300 chairs inside. Those are the Apache Workers and the movie is your Webiste. If someone wants to watch the movie(your website) they need to sit in the chair (Apache Workers). If all 300 chars are taken, the 301 person needs to wait for someone to leave in order for them to sit and watch the movie. That’s how ApacheWorkers work. Once all ApacheWorkers are taken, a new person that wants to open your website waits for a spot to be open and only after that they can see your website.

Usually, these limits are set by 256 by default but they can be increased.

You can open your Apache configuration file. In there you should see something similar to:

ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000

Increase both the ServerLimit and MaxClients options, restart Apache, and see if this would solve your issue.

It’s possible they do not exist (haven’t been added) and the default values are the ones above. Adding them to the prefork content of apache mods should be fine as well.

Don’t forget to restart Apache afterward.

Regards, KFSys