Persistent database connections to MySQL and Redis servers don’t stay open for more than a couple of minutes before connection is dropped. This issue came up since we switched to node applications in cluster mode that keep around 30 - 50 connections open at any time. Most common error is “MySQL server has gone away” that is usually handled in application logic, but lately errors like “Lost connection to MySQL server during query” and 111 “Connection refused” started coming up, which are not handled cleanly.
Even PHP applications that keep only one non-persistent connection have random connection issues. On top of that even remote SSH to server drops occasionally.
All our servers run in SF1 region. Any ideas what would be causing these connections issues?
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.
Sorry for the late reply. With those persistent connections it’s possible that you are running out of listeners (with all the slots full with persistent connections and the short term php ones as well new clients may be getting denied or dormant connections freed up).
I would recommend reviewing my.cnf (in /etc/mysql) to see what your max_connections
variable is set to. With the persistent connections, check the wait_timeout
value in case MySQL is timing out these connections when they are idle.
Actually there are messages I have missed before. Looks like the mysql server restarts itself once or twice a day. That would definitely contribute to timeouts.
Hi! Are there any errors in MySQL’s error log?