MySQL Memory & max_connections Performance Tuning So, our site runs WordPress and in the past few days we have been getting tons of spam comments etc.  I believe that we are becoming the victims of some kind of bot army that has been crashing our server a lot in the past few days and I really need help.

I have called our tech support and they have recommended decreasing some of the buffer sizes in my.cnf and lowering max_connections.   I ran the mysqltuner script and here are the results.

The immediate problem is that we are reaching our max_connections value.  I don't want to increase it beyond 40 because when I do MySQL uses the full capacity of the server's memory and starts to have memory allocation errors when I'm running terminal commands.  The real issue is what do I need to tweak so that I can increase the max_connections without allowing MySQL to use more memory?  I think the buffer pool size is a big factor but I don't know how to tweak it properly.

Also, mysqltuner says I have a bunch of fragmented tables but I just went through by hand yesterday and ran OPTIMIZE TABLE on all of the tables?? Could that be a result of running mysqlcheck --repair --all-databases ??
After thorough research, we determined that the problem was that WordPress was being attacked and it was causing MySQL to use the maximum amount of memory allotted to it in the configuration files.  Even caching of WordPress pages could not stop this illegitimate traffic from using all of the memory because of the sheer volume of IP addresses the attackers had at their disposal.  We ended up getting CloudFlare and that seems to have resolved the problems by blocking the DDoS at the DNS level. We will also be looking at getting more memory for the server, to prevent this from happening with heavy legitimate traffic in the future.