Critical error: Could not connect to database-server (when authenticating) (Too many connections)

Post

Posted
Rating:
#4742 (In Topic #959)

Critical error – bailing out

Hello,
 

Critical error – bailing out

Could not connect to database-server (when authenticating) (Too many connections)

It seems like once a month I get this and the system is down for a few hours. I am waiting for it to come back now, fingers crossed.

Honestly I think it the server I am using and not a problem with Composr.

I am running other composr sites on different servers and this has never happened.

The server this is on is hosted by a friend, he is giving me some space on a server that is also hosting other people so my guess is it is maxed out.

My new goal is to migrate my site to a different server.

Anyone else run into this problem?


php - "Could not connect. Too many connections" Error in MySQLi - Stack Overflow

View



I am going to "... increase the number of connections to your MySQL server..." and see if that helps

 

Post

Posted
Rating:
#4743
update: 
I can't even login via shell so its a server problem for sure

 

Post

Posted
Rating:
#4744
Right, in this kind of situation a server admin needs to look at what is consuming the system resources.

Often some kind of system slow-down will backup web requests, causing limited resources (like the MySQL connection pool) to max out.

It could be bot activity, for example.

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by enelson)
#4745
I wanted to write some more up about this, as over the years I've had to develop expertise in managing servers, and I never really found a good resource summarising how to do it well. I'm not sure it's directly relevant to you, as it's not your own server, but hopefully it will help someone (it's also going in our performance tutorial)…


If you are administrating a server you could come across situations where the server 'grinds to a halt', or spits out depleted resources messages. This isn't a Composr problem, but just like any desktop computer can take on too much work, so can a server.

In these kinds of situations you need to identify what server resource is depleted. Typically it is either:
  1. Disk I/O
  2. Memory
  3. CPU
  4. Network I/O (available bandwidth)

There are are various commands on Linux that are useful during diagnosis…
Command Purpose Hints
uptime Show the CPU load at different points in time If the load level is higher than the number of CPU cores in the server, you have a serious issue.
ps -Af Show all active tasks This will show you if you have a run-away number of processes (e.g. dozens of Apache instances).
top -n1 Show active processes, sorted by CPU usage; also, total CPU usage, memory usage, and I/O wait time This will tell you what processes are using a lot of CPU or memory (press M to sort by memory), as well as giving you good clues to what resource is primarily depleted.
iostat Show CPU and disk load This is useful to find disk I/O load.
iotop Show active processes by I/O load This command usually is not installed by default. It is very useful to find what processes are doing a lot of I/O.
Additionally, the Apache web server has mod_status which can be configured to show what web requests are coming in, and how long they last for. This tells you a lot more than the Apache log will.

There is an 'art' to finding the cause of a performance slow-down. Often just one depleted resource will have a knock-on effect on others. For example, if I/O is saturated, memory may become depleted as Apache processes back up.

A skilled system administrator will:
  1. Stay on top of performance metrics, to know what needs optimising or where to spend more on hardware
  2. Develop experience isolating the cause of slow-downs, pointing to programmers where they need to do profiling and optimisation
  3. Configure a server so that excess activity results in appropriate error messages, rather than a crashed server (for example, by configuring the Apache settings to limit the number of processes and threads to what the server can actually handle)
3 guests and 0 members have recently viewed this.