Today was a hellish day. Late in the afternoon when we’re supposed to be winding down and heading out one of our shared webhosting servers started freaking out. No changes to any software or settings — nothing to suspect — but mysql-proxy kept crashing. We need this utility because we have a lot of old customers with configs from a long time ago when someone thought it was OK to have the database on the webserver.
We’ve never had much luck with mysql-proxy as we’ve seen it crash its fair amount of times or not start properly on boot, but this was unending. Core dumps weren’t giving anything useful; logs were no better. Here’s the MySQL-Proxy alternative that we should have implemented ages ago. Note, we’re running FreeBSD, so adapt to your own OS/Linux distro:
What you need:
# mysql_proxy alternative
log 127.0.0.1 local0
listen mysql :3306
server mysql1 18.104.22.168:3306 check port 3306
Ultimately, HAProxy manages the connections very well and socat fixes any old clients trying to talk over the /tmp/mysql.sock file.