For our application, setup on the Amazon EC2 instances, we are using MySQL databases, installed on 2 EC2 instances, in master-master replication mode. To load balance these DB Servers I am using an HAProxy deployed on another EC2 instance with configuration
listen mysql <public dns of haproxy>:<port>
mode tcp
balance roundrobin
server mysql-db-s1 <elastic ip of db server1>:<port> maxconn 2000
server mysql-db-s2 <elastic ip of db server2>:<port> maxconn 2000
All three instances are assigned elastic ip’s and I use the public dns of haproxy to connect from my application. But at times I get the error
`com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: C
ommunications link failure The last packet successfully received from the server was 58,085 milliseconds ago.
The last packet sent successfully to the server was 0 milliseconds ago.`
Has this anything to do with the configuration I have given here? Is it better to use the elastic ip’s instead of Public DNS ?
This was not essentially an HAProxy issue, as I got the same error after I connected directly to one of the databases. Tuned the database a little and fixed some code in my application, and now I am not getting this atleast for the past 12 hours. Thanks for the suggestions. I would be moving one of the DB to another availability zone.